x86/mm: Clarify hardware vs. software "error_code"
authorDave Hansen <dave.hansen@linux.intel.com>
Fri, 28 Sep 2018 16:02:20 +0000 (09:02 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 9 Oct 2018 14:51:15 +0000 (16:51 +0200)
commit164477c2331be75d9bd57fb76704e676b2bcd1cd
tree8283d32f2a28ecd9cd8271c4fc2eba72be08efd1
parent145f573b89a62bf53cfc0144fa9b1c56b0f70b45
x86/mm: Clarify hardware vs. software "error_code"

We pass around a variable called "error_code" all around the page
fault code.  Sounds simple enough, especially since "error_code" looks
like it exactly matches the values that the hardware gives us on the
stack to report the page fault error code (PFEC in SDM parlance).

But, that's not how it works.

For part of the page fault handler, "error_code" does exactly match
PFEC.  But, during later parts, it diverges and starts to mean
something a bit different.

Give it two names for its two jobs.

The place it diverges is also really screwy.  It's only in a spot
where the hardware tells us we have kernel-mode access that occurred
while we were in usermode accessing user-controlled address space.
Add a warning in there.

Cc: x86@kernel.org
Cc: Jann Horn <jannh@google.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180928160220.4A2272C9@viggo.jf.intel.com
arch/x86/mm/fault.c