Commit 2daf298d authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Michael Ellerman

powerpc/book3s64/pkeys: Use pkey_execute_disable_supported

Use pkey_execute_disable_supported to check for execute key support instead
of pkey_disabled.
Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200709032946.881753-16-aneesh.kumar@linux.ibm.com
parent e10cc871
...@@ -126,15 +126,7 @@ static inline int mm_pkey_free(struct mm_struct *mm, int pkey) ...@@ -126,15 +126,7 @@ 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 * Try to dedicate one of the protection keys to be used as an
* execute-only protection key. * execute-only protection key.
*/ */
extern int __execute_only_pkey(struct mm_struct *mm); extern int execute_only_pkey(struct mm_struct *mm);
static inline int execute_only_pkey(struct mm_struct *mm)
{
if (static_branch_likely(&pkey_disabled))
return -1;
return __execute_only_pkey(mm);
}
extern int __arch_override_mprotect_pkey(struct vm_area_struct *vma, extern int __arch_override_mprotect_pkey(struct vm_area_struct *vma,
int prot, int pkey); int prot, int pkey);
static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma, static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma,
......
...@@ -23,7 +23,6 @@ u32 reserved_allocation_mask __ro_after_init; ...@@ -23,7 +23,6 @@ u32 reserved_allocation_mask __ro_after_init;
/* Bits set for the initially allocated keys */ /* Bits set for the initially allocated keys */
static u32 initial_allocation_mask __ro_after_init; static u32 initial_allocation_mask __ro_after_init;
static bool pkey_execute_disable_supported;
/* /*
* Even if we allocate keys with sys_pkey_alloc(), we need to make sure * Even if we allocate keys with sys_pkey_alloc(), we need to make sure
* other thread still find the access denied using the same keys. * other thread still find the access denied using the same keys.
...@@ -38,6 +37,7 @@ static u64 default_uamor = ~0x0UL; ...@@ -38,6 +37,7 @@ static u64 default_uamor = ~0x0UL;
* We pick key 2 because 0 is special key and 1 is reserved as per ISA. * We pick key 2 because 0 is special key and 1 is reserved as per ISA.
*/ */
static int execute_only_key = 2; static int execute_only_key = 2;
static bool pkey_execute_disable_supported;
#define AMR_BITS_PER_PKEY 2 #define AMR_BITS_PER_PKEY 2
...@@ -151,7 +151,7 @@ void __init pkey_early_init_devtree(void) ...@@ -151,7 +151,7 @@ void __init pkey_early_init_devtree(void)
num_pkey = pkeys_total; num_pkey = pkeys_total;
#endif #endif
if (unlikely(num_pkey <= execute_only_key)) { if (unlikely(num_pkey <= execute_only_key) || !pkey_execute_disable_supported) {
/* /*
* Insufficient number of keys to support * Insufficient number of keys to support
* execute only key. Mark it unavailable. * execute only key. Mark it unavailable.
...@@ -359,7 +359,7 @@ void thread_pkey_regs_init(struct thread_struct *thread) ...@@ -359,7 +359,7 @@ void thread_pkey_regs_init(struct thread_struct *thread)
write_uamor(default_uamor); write_uamor(default_uamor);
} }
int __execute_only_pkey(struct mm_struct *mm) int execute_only_pkey(struct mm_struct *mm)
{ {
return mm->context.execute_only_pkey; return mm->context.execute_only_pkey;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment