powerpc: introduce execute-only pkey
RFC v7 10/25 powerpc: introduce execute-only pkey
This patch provides the implementation of execute-only pkey. The architecture-independent expects the ability to create and manage a special key which has execute-only permission.
Signed-off-by Ram Pai <[email protected]>
--- arch/powerpc/include/asm/book3s/64/mmu.h | 1 + arch/powerpc/include/asm/pkeys.h | 8 ++++- arch/powerpc/mm/pkeys.c | 57 ++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +1 -0
@@ -116,6 +116,7 @@ struct patb_entry {* bit unset -> key available for allocation */ u32 pkey_allocation_map; +s16 execute_only_pkey;/* key holding execute-only protection */ #endif } mm_context_t;
arch/powerpc/include/asm/pkeys.h +7 -1
@@ -126,11 +126,15 @@ static inline int mm_pkey_free(struct mm_struct *mm, int pkey)* Try to dedicate one of the protection keys to be used as an * execute-only protection key. */ +extern int __execute_only_pkey (struct mm_struct *mm);static inline int execute_only_pkey (struct mm_struct *mm) { -return 0 ; +if (!pkey_inited) +return -1 ; +return __execute_only_pkey (mm); } +static inline int arch_override_mprotect_pkey (struct vm_area_struct *vma,int prot,int pkey) {
@@ -157,6 +161,8 @@ static inline void pkey_mm_init(struct mm_struct *mm)if (!pkey_inited)return ;mm_pkey_allocation_map (mm) = initial_allocation_mask; +/* -1 means unallocated or invalid */ + mm->context.execute_only_pkey =-1 ; }static inline void pkey_initialize (void )
arch/powerpc/mm/pkeys.c +57 -0
60 lines not on this page · raw message
Signature · 1 line
1.7.1