Loading arch/powerpc/include/uapi/asm/mman.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -30,4 +30,10 @@ #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ /* Override any generic PKEY permission defines */ #define PKEY_DISABLE_EXECUTE 0x4 #undef PKEY_ACCESS_MASK #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ PKEY_DISABLE_WRITE |\ PKEY_DISABLE_EXECUTE) #endif /* _UAPI_ASM_POWERPC_MMAN_H */ #endif /* _UAPI_ASM_POWERPC_MMAN_H */ arch/powerpc/mm/pkeys.c +16 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,14 @@ int pkey_initialize(void) { { int os_reserved, i; int os_reserved, i; /* * We define PKEY_DISABLE_EXECUTE in addition to the arch-neutral * generic defines for PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE. * Ensure that the bits a distinct. */ BUILD_BUG_ON(PKEY_DISABLE_EXECUTE & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); /* /* * Disable the pkey system till everything is in place. A subsequent * Disable the pkey system till everything is in place. A subsequent * patch will enable it. * patch will enable it. Loading Loading @@ -177,10 +185,18 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val) unsigned long init_val) { { u64 new_amr_bits = 0x0ul; u64 new_amr_bits = 0x0ul; u64 new_iamr_bits = 0x0ul; if (!is_pkey_enabled(pkey)) if (!is_pkey_enabled(pkey)) return -EINVAL; return -EINVAL; if (init_val & PKEY_DISABLE_EXECUTE) { if (!pkey_execute_disable_supported) return -EINVAL; new_iamr_bits |= IAMR_EX_BIT; } init_iamr(pkey, new_iamr_bits); /* Set the bits we need in AMR: */ /* Set the bits we need in AMR: */ if (init_val & PKEY_DISABLE_ACCESS) if (init_val & PKEY_DISABLE_ACCESS) new_amr_bits |= AMR_RD_BIT | AMR_WR_BIT; new_amr_bits |= AMR_RD_BIT | AMR_WR_BIT; Loading Loading
arch/powerpc/include/uapi/asm/mman.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -30,4 +30,10 @@ #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ /* Override any generic PKEY permission defines */ #define PKEY_DISABLE_EXECUTE 0x4 #undef PKEY_ACCESS_MASK #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ PKEY_DISABLE_WRITE |\ PKEY_DISABLE_EXECUTE) #endif /* _UAPI_ASM_POWERPC_MMAN_H */ #endif /* _UAPI_ASM_POWERPC_MMAN_H */
arch/powerpc/mm/pkeys.c +16 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,14 @@ int pkey_initialize(void) { { int os_reserved, i; int os_reserved, i; /* * We define PKEY_DISABLE_EXECUTE in addition to the arch-neutral * generic defines for PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE. * Ensure that the bits a distinct. */ BUILD_BUG_ON(PKEY_DISABLE_EXECUTE & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); /* /* * Disable the pkey system till everything is in place. A subsequent * Disable the pkey system till everything is in place. A subsequent * patch will enable it. * patch will enable it. Loading Loading @@ -177,10 +185,18 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val) unsigned long init_val) { { u64 new_amr_bits = 0x0ul; u64 new_amr_bits = 0x0ul; u64 new_iamr_bits = 0x0ul; if (!is_pkey_enabled(pkey)) if (!is_pkey_enabled(pkey)) return -EINVAL; return -EINVAL; if (init_val & PKEY_DISABLE_EXECUTE) { if (!pkey_execute_disable_supported) return -EINVAL; new_iamr_bits |= IAMR_EX_BIT; } init_iamr(pkey, new_iamr_bits); /* Set the bits we need in AMR: */ /* Set the bits we need in AMR: */ if (init_val & PKEY_DISABLE_ACCESS) if (init_val & PKEY_DISABLE_ACCESS) new_amr_bits |= AMR_RD_BIT | AMR_WR_BIT; new_amr_bits |= AMR_RD_BIT | AMR_WR_BIT; Loading