[PATCH 00/11] x86/fault: Cleanups and robustifications

From: Andy Lutomirski
Date: Sun Jan 31 2021 - 15:01:41 EST


The BPF team reported a warning in the x86 page fault code. This caused me
to read said code, and it was quite tangled. This series attempts to
mostly disentangle it and fixes a whole bunch of corner cases. In my
opinion, the control flow and the semantics of the various page fault
functions are much clearer with this series applied, and it also fixes
warts in the SMEP, SMAP, and WRUSS corners of the page fault handler.

Fortunately we don't have any WRUSS instructions in the kernel yet, but I
can dream that some day we'll get real instructions for explicit access to
normal user memory, in which case they will also benefit from these fixes.

The first patch is a genuine regression fix, but the rest is potentially
subtle enough that I would like it to have a good long soak in -next before
landing.

As a nice side bonus, the first patch should give a decent speedup to page
fault signal delivery on CPUs that are not affected by AMD erratum #91.

Andy Lutomirski (11):
x86/fault: Fix AMD erratum #91 errata fixup for user code
x86/fault: Fold mm_fault_error() into do_user_addr_fault()
x86/fault/32: Move is_f00f_bug() do do_kern_addr_fault()
x86/fault: Document the locking in the fault_signal_pending() path
x86/fault: Correct a few user vs kernel checks wrt WRUSS
x86/fault: Improve kernel-executing-user-memory handling
x86/fault: Split the OOPS code out from no_context()
x86/fault: Bypass no_context() for implicit kernel faults from
usermode
x86/fault: Rename no_context() to kernelmode_fixup_or_oops()
x86/fault: Don't run fixups for SMAP violations
x86/fault: Don't look for extable entries for SMEP violations

arch/x86/mm/fault.c | 355 ++++++++++++++++++++++++--------------------
1 file changed, 197 insertions(+), 158 deletions(-)

--
2.29.2