From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E364CC31D97 for ; Thu, 4 Jul 2024 12:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3VRfPuhN/AytwzoBKdx33khObrsA46bve2QJNOSAYns=; b=12gKMv4UQys2T8TfUrCgdmX8FF fNtX2NSz6n/tEtmfU5fducGY7xOtricC72HI3K9g0JyZBLZJAF8pn6MOrQ63Y3+RWzf1c1eN7BYo0 eRPSouzmmU6BaA6dH7svgIBDQheTKvwdkljrz4HRpB2kIp61W+SItn3sQOS+YmQndIXQt2JzS8bLB cizWijTmWkEjDFJ3KzrHydAbCBuPiunvho51V1LI22I0zwy8aFWbmJjOtBwQitL/9t7ROd2NgLyPs Clyn1FzjL8bJ50rzH8lUcZB4lZXdPzh/TvCLZa8fI3HTEByJ1QGf0ibK2nUVo0MG8D/3TLRGiSOS4 NxtOWv5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPLs1-0000000DAcb-3oA7; Thu, 04 Jul 2024 12:47:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPLro-0000000DAYe-37Yq for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2024 12:47:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3AE77367; Thu, 4 Jul 2024 05:47:38 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A177D3F762; Thu, 4 Jul 2024 05:47:09 -0700 (PDT) Date: Thu, 4 Jul 2024 13:47:04 +0100 From: Joey Gouly To: Catalin Marinas Cc: Amit Daniel Kachhap , linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v4 13/29] arm64: convert protection key into vm_flags and pgprot values Message-ID: <20240704124704.GA3548388@e124191.cambridge.arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> <20240503130147.1154804-14-joey.gouly@arm.com> <4f7d8691-fe19-4e8a-95e5-9f7680c82021@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240704_054716_844358_1EC2D4A7 X-CRM114-Status: GOOD ( 18.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Wed, Jun 19, 2024 at 05:45:29PM +0100, Catalin Marinas wrote: > On Tue, May 28, 2024 at 12:24:57PM +0530, Amit Daniel Kachhap wrote: > > On 5/3/24 18:31, Joey Gouly wrote: > > > diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h > > > index 5966ee4a6154..ecb2d18dc4d7 100644 > > > --- a/arch/arm64/include/asm/mman.h > > > +++ b/arch/arm64/include/asm/mman.h > > > @@ -7,7 +7,7 @@ > > > #include > > > static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, > > > - unsigned long pkey __always_unused) > > > + unsigned long pkey) > > > { > > > unsigned long ret = 0; > > > @@ -17,6 +17,12 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, > > > if (system_supports_mte() && (prot & PROT_MTE)) > > > ret |= VM_MTE; > > > +#if defined(CONFIG_ARCH_HAS_PKEYS) > > > > Should there be system_supports_poe() check like above? > > I think it should, otherwise we end up with these bits in the pte even > when POE is not supported. I think it can't get here due to the flow of the code, but I will add it to be defensive (since it's just an alternative that gets patched). I still need the defined(CONFIG_ARCH_HAS_PKEYS) check, since the VM_PKEY_BIT* are only defined then. > > > > + ret |= pkey & 0x1 ? VM_PKEY_BIT0 : 0; > > > + ret |= pkey & 0x2 ? VM_PKEY_BIT1 : 0; > > > + ret |= pkey & 0x4 ? VM_PKEY_BIT2 : 0; > > > +#endif > > > + > > > return ret; > > > } > > > #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) Thanks, Joey