Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2200990imm; Thu, 20 Sep 2018 09:14:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaIG3JIQpj1Tlu/Hv1MlsaQ1lUM9yYjVS+VOx0JSjU9fqXx6925ocBGRwCN8qvlUxocsjGN X-Received: by 2002:a63:4e11:: with SMTP id c17-v6mr8996854pgb.6.1537460064371; Thu, 20 Sep 2018 09:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537460064; cv=none; d=google.com; s=arc-20160816; b=B/MMXge5rj53VU4gXXnGvjr5EvK85UIsPKq6zm0b0+O/TXtFpWKoSN+jc1s+Ez9aFA FRzgECHVkRYiSNngQnJ9meCxNXWEC3DFtNIiV7la5RnMImdA2sGe/QqUTncwDX5nTFtr t0tZRb0RiGVNmO9BtkzwVf9ArMq2TQqFT+8e6H9nV+I09KffpsYwhzgSx9f/6WxfmS2d fmPsoffskAcbcjsGuDxGxE/GVJLGwd5/WmVkAdEnaPE7nS3CUsT4xfX9ZqJWc0Cbq/Xs cW1bUVTCD/fPANdm++aUP85ByalwOuRudhR7pd5E9JGcq0gdllIE4PdP9jykAigJBdH0 b9GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:message-id:user-agent:in-reply-to :mime-version:references:reply-to:subject:cc:to:from:date; bh=GC1yWD7Qvql4/J7CPDpkFFwbjqLaQl6U/ORUinaMhsE=; b=nV5tc8fV57v9/1tN3JFZ46rkToimpsj3obH6TEXu0MUXeRLvA9sGd6qqkWMsejyFSE l6gCXN+rQexFtn0OLvTKsefIxamszjSUDCcXQX37uaKJtbUNwr5vECyOtz46HQrkUFvr h9FTlj7Epvr52qL/rs0ABJ2lGA/kteRStedlf1TYeEhixzr7yXlhPGjB99rGD30TY9Ih tsgw9VCtC0s2a8lQZoTMg8JI3ooC5PZaxz2JUO4ZfoRQRmesN0t6S10w0PGGaua/wGMD KX317LLmEExapemnE+UbhUej2u4Adehst9GJGIvjavpzI4qLf8HGE/3ypo5mTMHsljOZ vbUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si23927141pgh.310.2018.09.20.09.13.59; Thu, 20 Sep 2018 09:14:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732350AbeITV4M (ORCPT + 99 others); Thu, 20 Sep 2018 17:56:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54806 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727229AbeITV4L (ORCPT ); Thu, 20 Sep 2018 17:56:11 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8KG2Hua141266 for ; Thu, 20 Sep 2018 12:11:59 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mmcrgxfm3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Sep 2018 12:11:58 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Sep 2018 17:11:56 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 20 Sep 2018 17:11:53 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8KGBqi859506778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 20 Sep 2018 16:11:52 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 130D552054; Thu, 20 Sep 2018 19:11:37 +0100 (BST) Received: from ram.oc3035372033.ibm.com (unknown [9.85.157.177]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id C4AEE5205F; Thu, 20 Sep 2018 19:11:35 +0100 (BST) Date: Thu, 20 Sep 2018 09:11:47 -0700 From: Ram Pai To: Thiago Jung Bauermann Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman Subject: Re: [PATCH] powerpc/pkeys: Fix reading of ibm,processor-storage-keys property Reply-To: Ram Pai References: <20180920043858.28773-1-bauerman@linux.ibm.com> MIME-Version: 1.0 In-Reply-To: <20180920043858.28773-1-bauerman@linux.ibm.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18092016-0016-0000-0000-000002082F95 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18092016-0017-0000-0000-0000325F324B Message-Id: <20180920161147.GE5809@ram.oc3035372033.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-20_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809200157 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 20, 2018 at 01:38:58AM -0300, Thiago Jung Bauermann wrote: > scan_pkey_feature() uses of_property_read_u32_array() to read the > ibm,processor-storage-keys property and calls be32_to_cpu() on the > value it gets. The problem is that of_property_read_u32_array() already > returns the value converted to the CPU byte order. > > The value of pkeys_total ends up more or less sane because there's a min() > call in pkey_initialize() which reduces pkeys_total to 32. So in practice > the kernel ignores the fact that the hypervisor reserved one key for > itself (the device tree advertises 31 keys in my test VM). > > This is wrong, but the effect in practice is that when a process tries to > allocate the 32nd key, it gets an -EINVAL error instead of -ENOSPC which > would indicate that there aren't any keys available Thanks for the fix. Reviewed-by: Ram Pai > > Fixes: cf43d3b26452 ("powerpc: Enable pkey subsystem") > Signed-off-by: Thiago Jung Bauermann > --- > arch/powerpc/mm/pkeys.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c > index 333b1f80c435..b271b283c785 100644 > --- a/arch/powerpc/mm/pkeys.c > +++ b/arch/powerpc/mm/pkeys.c > @@ -45,7 +45,7 @@ static void scan_pkey_feature(void) > * Since any pkey can be used for data or execute, we will just treat > * all keys as equal and track them as one entity. > */ > - pkeys_total = be32_to_cpu(vals[0]); > + pkeys_total = vals[0]; > pkeys_devtree_defined = true; > } -- Ram Pai