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 CA770C3DA41 for ; Mon, 8 Jul 2024 17:22:59 +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=VPc2tLV7VFqqvakpQC7xlgW47cbbpJmS4MsPvBZTcWE=; b=hjCT2MR4h5XJIjcN35ZYo14ToW ESJ06vZxPd4GuG0nQ/oxKjLW5boJs+RGs/Ciz14ZC0SDdor0QOOAxVrpsLFIXrIC5hahtdx/I7ssy G4zhwzxgiapWCyXZHBQOs1LrOVKoAfFwAtGIkVl7tZxYQVarHntiSWWOPmvEZMS7T/SE9Jwr1XryS ctgcfEEGAqbp01FDy8xdpKpz6ekbRwSuDJ+vAeK5FutsP+wr0t3xjC/savpckteS7AiU+S22JQs6U q6LTvo6zM9UaHZQasv80otdKUrghEq2VjhDED0lwa+uPDMFDGHbR8NTr/scUncX2mruPVA6SMzXNH IKn8ZxGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQs4d-00000004a9A-2AAc; Mon, 08 Jul 2024 17:22:47 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQs4O-00000004a6H-02yx for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2024 17:22:33 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C4898CE069F; Mon, 8 Jul 2024 17:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6469C116B1; Mon, 8 Jul 2024 17:22:24 +0000 (UTC) Date: Mon, 8 Jul 2024 18:22:22 +0100 From: Catalin Marinas To: Joey Gouly 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: References: <20240503130147.1154804-1-joey.gouly@arm.com> <20240503130147.1154804-14-joey.gouly@arm.com> <4f7d8691-fe19-4e8a-95e5-9f7680c82021@arm.com> <20240704124704.GA3548388@e124191.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240704124704.GA3548388@e124191.cambridge.arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_102232_248247_6C2C45F2 X-CRM114-Status: GOOD ( 21.01 ) 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 On Thu, Jul 04, 2024 at 01:47:04PM +0100, Joey Gouly wrote: > 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). You are probably right, the mprotect_pkey() will reject the call if we don't support POE. So you could add a comment instead (but a system_supports_poe() check seems safer). > I still need the defined(CONFIG_ARCH_HAS_PKEYS) check, since the VM_PKEY_BIT* > are only defined then. Yes, the ifdef will stay. -- Catalin