From patchwork Thu Aug 22 15:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13773673 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E01C0C54722 for ; Thu, 22 Aug 2024 15:11:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B16380032; Thu, 22 Aug 2024 11:11:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65F198001E; Thu, 22 Aug 2024 11:11:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B2F780032; Thu, 22 Aug 2024 11:11:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 25F548001E for ; Thu, 22 Aug 2024 11:11:40 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C6E711A0685 for ; Thu, 22 Aug 2024 15:11:39 +0000 (UTC) X-FDA: 82480220718.05.45A5D6D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 05BFB1A0022 for ; Thu, 22 Aug 2024 15:11:37 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724339407; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AN5yxhdKyzfZdHqEo2A34b5U0fOr4xo1lXLMZ11v71Q=; b=7QoZiVQpIRbSmxrbMREh9uIV9ZipHZUxGvOM3GYiLlmL0CgSFr/b68jTjN5bxJ9baEaBcK Xok1UcrdXSSDMdGpRjVEtmMJoT2pu3RPJKaYKrOkVzMNe3vLQQ03By8l38DWTybSQJYxD2 6jKqSbDtOrdXZjETRfsakdXZP3QVonI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724339407; a=rsa-sha256; cv=none; b=72f3+Yjn95oozo9+3n6Aq/Te/2VqhTMwiXVvS8ikhuw6wber54k6vpO6aWXSbkrtXQ3+cy oqRhWG6TyBPoS3lW3kyury0sVTPczSDVB5jGGdUGHU06I2GR2n2pwN0LuljTNS0wzaYDbA FIbvRS3rX8YdDzwzzMU7qTtzvwEtcWc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com 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 6108A1595; Thu, 22 Aug 2024 08:12:03 -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 336263F58B; Thu, 22 Aug 2024 08:11:33 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: nd@arm.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, anshuman.khandual@arm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.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, skhan@linuxfoundation.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: [PATCH v5 03/30] mm: use ARCH_PKEY_BITS to define VM_PKEY_BITN Date: Thu, 22 Aug 2024 16:10:46 +0100 Message-Id: <20240822151113.1479789-4-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240822151113.1479789-1-joey.gouly@arm.com> References: <20240822151113.1479789-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 05BFB1A0022 X-Stat-Signature: 9epo865scq7igcr6dkx53iywuqe5dr8b X-Rspam-User: X-HE-Tag: 1724339497-258551 X-HE-Meta: U2FsdGVkX1+Jithx83lrt/EztyotQNFPLDIFoGAXsT9VMD0kVCx8w+o0P7cfsRCltkWpjU3LPDZ2gHdAke88TNFgoJlWOI8pgeQscOrVbN1UwLIOv3ejVv63scOZUVC9so9EO/b8nJ9s/m6JRaRGuPBDC2r3LDfyvI1wdILJIJnd4xCZs3Nzb2x7FeN6pPFmuZeClaLWiF4J1s1ziy9MHlnRwp6EdjPdv5cNB9iskqXsrGw1yyLjUr9+przEcs0LXjmdwFuMJjxNvBSFA/eA9CnQvu1+X4jLJOHfBAxwyx5iU5WVu1XeBxLCrg0UVZ3oMv0nkFGDRCwrw301oHcR23LJuaJmXQoSOmeua+zCQ2iIVs3j7EYyCRshShElcxd72iHrToiIG+6uXEkhbbcAuD/IBIQzfB3fmNw/dQtqw0RFuNTQw82FZH+iYB28wiYmgg9lrRtGYFt5SOrECaaRZjIVGaTpIDvfig/71KBnXsPiDXynezfUZswarkZaNkGXewEeaeSl5H5mr8BTuoTGSW7eOwANL88xMMm7Gij7aJshItNRZZrAo5qiuzWYihWdAaes29Za/SI15ORgj9HNn5uM+hTyNciy8c7IgUM2CBV41ISLeMBalqyI9zZIOPOeOL/k/5wTiw2M6vm33f6LNdT1GTU5Phlx/7YmH+3LIVc+9x60Av0z9GTZlFq6U8eGAJ2UDPkiRQ4+2bxw+oqibfBmyYbI7LLwiBqUmPv/I1wyf9t/HWyd7HigRf6VzfxAatoasVeq2CLrcq54vOdDAtF1+0VROARVqFmM4e286HFYlhdxLZ+Hub1UsxJzcep4cs1mPCAuHinfRrq/syXf6qfQQArwphC8A07ipmf78iq+cbEy2KeEbMOvhv+edvrO+5VhQY1z+1k+6ACvClZYtjmKFiQKZpqE4zmo05TF71BonVOIHs4qWWlv6QwHNisXjqVlsvSlrlrb2HbZzLN E5MeqA5k 5dvdccJElaWCPJX3GXYrBlCOFmRN7im10vg8C7n4wSR9pJy1vpWGEjc1Lfu8T0MVFi05pmBm5JOixTjAnbff0BwXoLWf7gCvRDQqlM5S5V6YOUZm3ZRmZ03JcSsZqsFapxfLCXD1mNzdkgEfdJ2DW8L/SUdo0ZLl+LlL92OGOr8lEfNvhS4WJrvuUALI+uSsIZMim8DqUJPKZnmqMdMFCbfCOBdqC1vUZYpJ87fg7M1PPqBITlBglnheJnRVvXpyzVrVn3jMfiUNtJG0mEU8bbvWoKCNL2rg1j73WoRxc4mIYRxp/vzQjwTBDEPugqWhD9B6ovUEbEzD6TyNGFHImdfMNEEfsA9FR461yXDdN5ARdbQk76GGS0jgKzPnY/kiSfrC4bfL7WSJaoqfqAxPXrEnYWA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use the new CONFIG_ARCH_PKEY_BITS to simplify setting these bits for different architectures. Signed-off-by: Joey Gouly Cc: Andrew Morton Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Acked-by: Dave Hansen Reviewed-by: Anshuman Khandual --- fs/proc/task_mmu.c | 2 ++ include/linux/mm.h | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git fs/proc/task_mmu.c fs/proc/task_mmu.c index 5f171ad7b436..2c5f4814aef9 100644 --- fs/proc/task_mmu.c +++ fs/proc/task_mmu.c @@ -976,7 +976,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_PKEY_BIT0)] = "", [ilog2(VM_PKEY_BIT1)] = "", [ilog2(VM_PKEY_BIT2)] = "", +#if VM_PKEY_BIT3 [ilog2(VM_PKEY_BIT3)] = "", +#endif #if VM_PKEY_BIT4 [ilog2(VM_PKEY_BIT4)] = "", #endif diff --git include/linux/mm.h include/linux/mm.h index 6549d0979b28..56dc2481cc0f 100644 --- include/linux/mm.h +++ include/linux/mm.h @@ -330,12 +330,16 @@ extern unsigned int kobjsize(const void *objp); #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ #ifdef CONFIG_ARCH_HAS_PKEYS -# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 -# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */ -# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 /* on x86 and 5-bit value on ppc64 */ -# define VM_PKEY_BIT2 VM_HIGH_ARCH_2 -# define VM_PKEY_BIT3 VM_HIGH_ARCH_3 -#ifdef CONFIG_PPC +# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 +# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 +# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 +# define VM_PKEY_BIT2 VM_HIGH_ARCH_2 +#if CONFIG_ARCH_PKEY_BITS > 3 +# define VM_PKEY_BIT3 VM_HIGH_ARCH_3 +#else +# define VM_PKEY_BIT3 0 +#endif +#if CONFIG_ARCH_PKEY_BITS > 4 # define VM_PKEY_BIT4 VM_HIGH_ARCH_4 #else # define VM_PKEY_BIT4 0