@@ -940,6 +940,11 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
/* This code is always called on the current mm */
bool foreign = false;
+ /*
+ * This OSPKE check is not strictly necessary at runtime.
+ * But, doing it this way allows compiler optimizations
+ * if pkeys are compiled out.
+ */
if (!boot_cpu_has(X86_FEATURE_OSPKE))
return false;
if (error_code & X86_PF_PK)
@@ -955,11 +960,6 @@ static noinline void
bad_area_access_error(struct pt_regs *regs, unsigned long error_code,
unsigned long address, struct vm_area_struct *vma)
{
- /*
- * This OSPKE check is not strictly necessary at runtime.
- * But, doing it this way allows compiler optimizations
- * if pkeys are compiled out.
- */
if (bad_area_access_from_pkeys(error_code, vma))
__bad_area(regs, error_code, address, vma, SEGV_PKUERR);
else