Loading arch/powerpc/include/asm/mman.h +6 −1 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ #include <asm/cputable.h> #include <linux/mm.h> #include <linux/pkeys.h> #include <asm/cpu_has_feature.h> /* Loading @@ -22,7 +23,11 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, unsigned long pkey) { return (prot & PROT_SAO) ? VM_SAO : 0; #ifdef CONFIG_PPC_MEM_KEYS return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey)); #else return ((prot & PROT_SAO) ? VM_SAO : 0); #endif } #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) Loading arch/powerpc/include/asm/pkeys.h +11 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,17 @@ extern u32 initial_allocation_mask; /* bits set for reserved keys */ #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \ VM_PKEY_BIT3 | VM_PKEY_BIT4) /* Override any generic PKEY permission defines */ #define PKEY_DISABLE_EXECUTE 0x4 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS | \ PKEY_DISABLE_WRITE | \ PKEY_DISABLE_EXECUTE) static inline u64 pkey_to_vmflag_bits(u16 pkey) { return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS); } #define arch_max_pkey() pkeys_total #define pkey_alloc_mask(pkey) (0x1 << pkey) Loading arch/powerpc/mm/pkeys.c +8 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,14 @@ int pkey_initialize(void) BUILD_BUG_ON(PKEY_DISABLE_EXECUTE & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); /* * pkey_to_vmflag_bits() assumes that the pkey bits are contiguous * in the vmaflag. Make sure that is really the case. */ BUILD_BUG_ON(__builtin_clzl(ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT) + __builtin_popcountl(ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT) != (sizeof(u64) * BITS_PER_BYTE)); /* * Disable the pkey system till everything is in place. A subsequent * patch will enable it. Loading Loading
arch/powerpc/include/asm/mman.h +6 −1 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ #include <asm/cputable.h> #include <linux/mm.h> #include <linux/pkeys.h> #include <asm/cpu_has_feature.h> /* Loading @@ -22,7 +23,11 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, unsigned long pkey) { return (prot & PROT_SAO) ? VM_SAO : 0; #ifdef CONFIG_PPC_MEM_KEYS return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey)); #else return ((prot & PROT_SAO) ? VM_SAO : 0); #endif } #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) Loading
arch/powerpc/include/asm/pkeys.h +11 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,17 @@ extern u32 initial_allocation_mask; /* bits set for reserved keys */ #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \ VM_PKEY_BIT3 | VM_PKEY_BIT4) /* Override any generic PKEY permission defines */ #define PKEY_DISABLE_EXECUTE 0x4 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS | \ PKEY_DISABLE_WRITE | \ PKEY_DISABLE_EXECUTE) static inline u64 pkey_to_vmflag_bits(u16 pkey) { return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS); } #define arch_max_pkey() pkeys_total #define pkey_alloc_mask(pkey) (0x1 << pkey) Loading
arch/powerpc/mm/pkeys.c +8 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,14 @@ int pkey_initialize(void) BUILD_BUG_ON(PKEY_DISABLE_EXECUTE & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); /* * pkey_to_vmflag_bits() assumes that the pkey bits are contiguous * in the vmaflag. Make sure that is really the case. */ BUILD_BUG_ON(__builtin_clzl(ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT) + __builtin_popcountl(ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT) != (sizeof(u64) * BITS_PER_BYTE)); /* * Disable the pkey system till everything is in place. A subsequent * patch will enable it. Loading