Skip to content

Commit 9f82f15

Browse files
jgoulywilldeacon
authored andcommitted
mm: use ARCH_PKEY_BITS to define VM_PKEY_BITN
Use the new CONFIG_ARCH_PKEY_BITS to simplify setting these bits for different architectures. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Link: https://lore.kernel.org/r/20240822151113.1479789-4-joey.gouly@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 5626f8d commit 9f82f15

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

fs/proc/task_mmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
976976
[ilog2(VM_PKEY_BIT0)] = "",
977977
[ilog2(VM_PKEY_BIT1)] = "",
978978
[ilog2(VM_PKEY_BIT2)] = "",
979+
#if VM_PKEY_BIT3
979980
[ilog2(VM_PKEY_BIT3)] = "",
981+
#endif
980982
#if VM_PKEY_BIT4
981983
[ilog2(VM_PKEY_BIT4)] = "",
982984
#endif

include/linux/mm.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,16 @@ extern unsigned int kobjsize(const void *objp);
330330
#endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
331331

332332
#ifdef CONFIG_ARCH_HAS_PKEYS
333-
# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
334-
# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */
335-
# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 /* on x86 and 5-bit value on ppc64 */
336-
# define VM_PKEY_BIT2 VM_HIGH_ARCH_2
337-
# define VM_PKEY_BIT3 VM_HIGH_ARCH_3
338-
#ifdef CONFIG_PPC
333+
# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
334+
# define VM_PKEY_BIT0 VM_HIGH_ARCH_0
335+
# define VM_PKEY_BIT1 VM_HIGH_ARCH_1
336+
# define VM_PKEY_BIT2 VM_HIGH_ARCH_2
337+
#if CONFIG_ARCH_PKEY_BITS > 3
338+
# define VM_PKEY_BIT3 VM_HIGH_ARCH_3
339+
#else
340+
# define VM_PKEY_BIT3 0
341+
#endif
342+
#if CONFIG_ARCH_PKEY_BITS > 4
339343
# define VM_PKEY_BIT4 VM_HIGH_ARCH_4
340344
#else
341345
# define VM_PKEY_BIT4 0

0 commit comments

Comments
 (0)