[patch V4 00/65] x86/fpu: Spring cleaning and PKRU sanitizing

From: Thomas Gleixner
Date: Wed Jun 23 2021 - 08:23:38 EST


The main parts of this series are:

- Simplification and removal/replacement of redundant and/or
overengineered code.

- Name space cleanup as the existing names were just a permanent source
of confusion.

- Clear seperation of user ABI and kernel internal state handling.

- Removal of PKRU from being XSTATE managed in the kernel because PKRU
has to be eagerly restored on context switch and keeping it in sync
in the xstate buffer is just pointless overhead and fragile.

The kernel still XSAVEs PKRU on context switch but the value in the
buffer is not longer used and never restored from the buffer.

This still needs to be cleaned up, but the series is already 40+
patches large and the cleanup of this is not a functional problem.

The functional issues of PKRU management are fully addressed with the
series as is.

- Cleanup of fpu signal restore

- Make the fast path self contained. Handle #PF directly and skip
the slow path on any other exception as that will just end up
with the same result that the frame is invalid. This allows
the compiler to optimize the slow path out for 64bit kernels
w/o ia32 emulation.

- Reduce code duplication and unnecessary operations

It applies on top of

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master

and is also available via git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu

This is a follow up to V3 which can be found here:

https://lore.kernel.org/r/20210618141823.161158090@xxxxxxxxxxxxx

Changes vs. V3:

- Dropped the two bugfixes which are applied already and rebased on top

- Addressed review comments (Andy, Boris)

Patches: 13, 35, 36, 37, 46, 58, 62, 63

- Fixed the math-emu fallout which I had stashed safely on the 32bit
testbox (Boris)

Patch: 28

- Picked up tags

Thanks to everyone for review, feedback and testing (various teams
@Intel).

Note: I've not picked up any tested-by tags. It would be nice to have
them on this hopefully final version.

Thanks,

tglx
---
arch/x86/events/intel/lbr.c | 6
arch/x86/include/asm/fpu/internal.h | 202 ++++------
arch/x86/include/asm/fpu/xstate.h | 78 +++-
arch/x86/include/asm/pgtable.h | 57 ---
arch/x86/include/asm/pkeys.h | 9
arch/x86/include/asm/pkru.h | 62 +++
arch/x86/include/asm/processor.h | 9
arch/x86/include/asm/special_insns.h | 14
arch/x86/kernel/cpu/common.c | 34 -
arch/x86/kernel/fpu/core.c | 282 +++++++--------
arch/x86/kernel/fpu/init.c | 15
arch/x86/kernel/fpu/regset.c | 223 ++++++------
arch/x86/kernel/fpu/signal.c | 419 ++++++++++------------
arch/x86/kernel/fpu/xstate.c | 645 +++++++++++++----------------------
arch/x86/kernel/process.c | 22 +
arch/x86/kernel/process_64.c | 28 +
arch/x86/kernel/traps.c | 5
arch/x86/kvm/svm/sev.c | 1
arch/x86/kvm/x86.c | 56 +--
arch/x86/math-emu/fpu_proto.h | 2
arch/x86/math-emu/load_store.c | 2
arch/x86/math-emu/reg_ld_str.c | 2
arch/x86/mm/extable.c | 2
arch/x86/mm/fault.c | 2
arch/x86/mm/pkeys.c | 22 -
include/linux/pkeys.h | 4
26 files changed, 1037 insertions(+), 1166 deletions(-)