powerpc: ability to create execute-disabled pkeys
RFC v7 8/25 powerpc: ability to create execute-disabled pkeys
powerpc has hardware support to disable execute on a pkey. This patch enables the ability to create execute-disabled keys.
Signed-off-by Ram Pai <[email protected]>
--- arch/powerpc/include/asm/pkeys.h | 12 ++++++++++++ arch/powerpc/mm/pkeys.c | 5 +++++ 2 files changed, 17 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/pkeys.h +12 -0
@@ -22,6 +22,18 @@#define VM_PKEY_BIT4 VM_HIGH_ARCH_4#endif +/* override any generic PKEY Permission defines */ +#undef PKEY_DISABLE_ACCESS +#define PKEY_DISABLE_ACCESS 0x1 +#undef PKEY_DISABLE_WRITE +#define PKEY_DISABLE_WRITE 0x2 +#undef PKEY_DISABLE_EXECUTE +#define PKEY_DISABLE_EXECUTE 0x4 +#undef PKEY_ACCESS_MASK +#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ + PKEY_DISABLE_WRITE |\ + PKEY_DISABLE_EXECUTE) +#define arch_max_pkey () pkeys_total#define AMR_RD_BIT 0x1UL#define AMR_WR_BIT 0x2UL
arch/powerpc/mm/pkeys.c +5 -0
@@ -78,6 +78,7 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val) {u64 new_amr_bits =0x0ul ; +u64 new_iamr_bits =0x0ul ;if (!is_pkey_enabled (pkey))return -EINVAL ;
@@ -90,5 +91,9 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,init_amr (pkey, new_amr_bits); +if ((init_val &PKEY_DISABLE_EXECUTE )) + new_iamr_bits |=IAMR_EX_BIT ; + +init_iamr (pkey, new_iamr_bits);return 0 ; }
Signature · 1 line
1.7.1