From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85E63AD55; Mon, 8 Jul 2024 17:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720459349; cv=none; b=ubBgDj/Qb/2y3xNQhpYTXZs0/nNOTPa2TD8PBYtHuMjJRNu6Ot54p+2rWTNedN5tThLpVn1z885go44K6/oNQR0+3arBSs/mchz5lLYTh8FfIQ1IGp76hRaA81+Cj3K5zPaPW449Ss6gO5kY4kLy+SJVBO9hxr2DBO4QD4uOz78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720459349; c=relaxed/simple; bh=egCPeI3Ur+czV6GQo2A5wIsjxu5dg2eZAfku3PDOLeE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GwJmCByTkJk7n+BGSMkJ5/6zlxWpaSvp9i7NQWo20BDd+8XafuonWhmAi9OdlK2L7IdHKoccipfqud/tq+MVFY/CbKdXuYZddPVZ7MKPlSRYu7BZThn9gN+cJHuGaV8gW18fCm1aOQ7LM4xPRu6NPFqAYXLrb18QG5gXjvIfyoA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240704124704.GA3548388@e124191.cambridge.arm.com> 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 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 49822C3271E for ; Mon, 8 Jul 2024 17:22:59 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WHrYF6ZJJz3dLN for ; Tue, 9 Jul 2024 03:22:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=cmarinas@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WHrXp6B9Sz30VY for ; Tue, 9 Jul 2024 03:22:34 +1000 (AEST) 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 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: szabolcs.nagy@arm.com, dave.hansen@linux.intel.com, linux-mm@kvack.org, hpa@zytor.com, shuah@kernel.org, Amit Daniel Kachhap , maz@kernel.org, x86@kernel.org, christophe.leroy@csgroup.eu, aneesh.kumar@kernel.org, mingo@redhat.com, naveen.n.rao@linux.ibm.com, will@kernel.org, npiggin@gmail.com, broonie@kernel.org, bp@alien8.de, kvmarm@lists.linux.dev, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, aneesh.kumar@linux.ibm.com, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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