@@ -1141,11 +1141,15 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
unsigned long address)
{
/*
- * Protection keys exceptions only happen on user pages. We
- * have no user pages in the kernel portion of the address
- * space, so do not expect them here.
+ * X86_PF_PK (Protection key exceptions) may occur on kernel addresses
+ * when PKS (PKeys Supervisor) are enabled.
+ *
+ * If PKS is not enabled an exception should only happen on user pages.
+ * Because, we have no user pages in the kernel portion of the address
+ * space something must have gone very wrong and we should WARN.
*/
- WARN_ON_ONCE(hw_error_code & X86_PF_PK);
+ WARN_ON_ONCE(!cpu_feature_enabled(X86_FEATURE_PKS) &&
+ (hw_error_code & X86_PF_PK));
#ifdef CONFIG_X86_32
/*