All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch V3 00/66] x86/fpu: Spring cleaning and PKRU sanitizing
@ 2021-06-18 14:18 Thomas Gleixner
  2021-06-18 14:18 ` [patch V3 01/66] x86/fpu: x86/fpu: Preserve supervisor states in sanitize_restored_user_xstate() Thomas Gleixner
                   ` (70 more replies)
  0 siblings, 71 replies; 133+ messages in thread
From: Thomas Gleixner @ 2021-06-18 14:18 UTC (permalink / raw)
  To: LKML
  Cc: Andy Lutomirski, Dave Hansen, Fenghua Yu, Tony Luck, Yu-cheng Yu,
	Sebastian Andrzej Siewior, Borislav Petkov, Peter Zijlstra,
	Kan Liang

The main parts of this series are:

  - Yet more bug fixes

  - 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 V2 which can be found here:

     https://lore.kernel.org/r/20210614154408.673478623@linutronix.de

Changes vs. V2:

  - Fixed the testing fallout (Dave, Kan)

  - Fixed a few issues found by myself when going through the lot
    with a fine comb, especially MXCSR handling

  - Drop the FNSAVE optimizations

  - Cleanup of signal restore

  - Addressed review comments, mostly comments and a hopefully better
    naming scheme which now just uses the instruction names and
    consolidates everything else on save/restore so it's close to the way
    how the hardware works.

  - A few cleanups and simplifications on the way (mostly regset related).

  - Picked up tags

With the above I'm not intending to do any further surgery on that
code at the moment, though there is still room for improvement which
can and has to be worked on when new bits are added.

Thanks,

	tglx
---
 arch/x86/events/intel/lbr.c          |    6 
 arch/x86/include/asm/fpu/internal.h  |  211 +++-------
 arch/x86/include/asm/fpu/xstate.h    |   70 ++-
 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           |  276 +++++++------
 arch/x86/kernel/fpu/init.c           |   15 
 arch/x86/kernel/fpu/regset.c         |  220 ++++++-----
 arch/x86/kernel/fpu/signal.c         |  423 +++++++++------------
 arch/x86/kernel/fpu/xstate.c         |  693 ++++++++++++++---------------------
 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/mm/extable.c                |    2 
 arch/x86/mm/fault.c                  |    2 
 arch/x86/mm/pkeys.c                  |   22 -
 include/linux/pkeys.h                |    4 
 23 files changed, 1060 insertions(+), 1181 deletions(-)



^ permalink raw reply	[flat|nested] 133+ messages in thread

end of thread, other threads:[~2021-06-24  0:06 UTC | newest]

Thread overview: 133+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 14:18 [patch V3 00/66] x86/fpu: Spring cleaning and PKRU sanitizing Thomas Gleixner
2021-06-18 14:18 ` [patch V3 01/66] x86/fpu: x86/fpu: Preserve supervisor states in sanitize_restored_user_xstate() Thomas Gleixner
2021-06-19  8:34   ` Borislav Petkov
2021-06-22 11:45   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2021-06-18 14:18 ` [patch V3 02/66] x86/fpu: Make init_fpstate correct with optimized XSAVE Thomas Gleixner
2021-06-18 20:41   ` Thomas Gleixner
2021-06-18 20:44     ` Borislav Petkov
2021-06-22 11:45   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2021-06-18 14:18 ` [patch V3 03/66] x86/fpu: Fix copy_xstate_to_kernel() gap handling Thomas Gleixner
2021-06-19  9:41   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 04/66] x86/pkeys: Revert a5eff7259790 ("x86/pkeys: Add PKRU value to init_fpstate") Thomas Gleixner
2021-06-18 14:18 ` [patch V3 05/66] x86/fpu: Mark various FPU states __ro_after_init Thomas Gleixner
2021-06-18 14:18 ` [patch V3 06/66] x86/fpu: Make xfeatures_mask_all __ro_after_init Thomas Gleixner
2021-06-20  8:44   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 07/66] x86/fpu: Get rid of fpu__get_supported_xfeatures_mask() Thomas Gleixner
2021-06-20  9:02   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 08/66] x86/fpu: Remove unused get_xsave_field_ptr() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 09/66] x86/fpu: Move inlines where they belong Thomas Gleixner
2021-06-18 14:18 ` [patch V3 10/66] x86/fpu: Limit xstate copy size in xstateregs_set() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 11/66] x86/fpu: Sanitize xstateregs_set() Thomas Gleixner
2021-06-20 21:30   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 12/66] x86/fpu: Reject invalid MXCSR values in copy_kernel_to_xstate() Thomas Gleixner
2021-06-21 10:00   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 13/66] x86/fpu: Simplify PTRACE_GETREGS code Thomas Gleixner
2021-06-18 14:18 ` [patch V3 14/66] x86/fpu: Rewrite xfpregs_set() Thomas Gleixner
2021-06-21 10:20   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 15/66] x86/fpu: Fail ptrace() requests that try to set invalid MXCSR values Thomas Gleixner
2021-06-21 10:17   ` Thomas Gleixner
2021-06-18 14:18 ` [patch V3 16/66] x86/fpu: Clean up fpregs_set() Thomas Gleixner
2021-06-21 12:05   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 17/66] x86/fpu: Make copy_xstate_to_kernel() usable for [x]fpregs_get() Thomas Gleixner
2021-06-21 12:32   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 18/66] x86/fpu: Use copy_xstate_to_uabi_buf() in xfpregs_get() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 19/66] x86/fpu: Use copy_xstate_to_uabi_buf() in fpregs_get() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 20/66] x86/fpu: Remove fpstate_sanitize_xstate() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 21/66] x86/fpu/regset: Move fpu__read_begin() into regset Thomas Gleixner
2021-06-21 13:26   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 22/66] x86/fpu: Move fpu__write_begin() to regset Thomas Gleixner
2021-06-21 15:30   ` Borislav Petkov
2021-06-21 20:15     ` Thomas Gleixner
2021-06-18 14:18 ` [patch V3 23/66] x86/fpu: Get rid of using_compacted_format() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 24/66] x86/kvm: Avoid looking up PKRU in XSAVE buffer Thomas Gleixner
2021-06-18 14:18 ` [patch V3 25/66] x86/fpu: Cleanup arch_set_user_pkey_access() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 26/66] x86/fpu: Get rid of copy_supervisor_to_kernel() Thomas Gleixner
2021-06-18 14:18 ` [patch V3 27/66] x86/fpu: Rename copy_xregs_to_kernel() and copy_kernel_to_xregs() Thomas Gleixner
2021-06-21 18:00   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 28/66] x86/fpu: Rename copy_user_to_xregs() and copy_xregs_to_user() Thomas Gleixner
2021-06-21 19:44   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 29/66] x86/fpu: Rename fxregs related copy functions Thomas Gleixner
2021-06-21 23:00   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 30/66] x86/fpu: Rename fregs " Thomas Gleixner
2021-06-22  9:31   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 31/66] x86/fpu: Rename xstate copy functions which are related to UABI Thomas Gleixner
2021-06-22  9:38   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 32/66] x86/fpu: Deduplicate copy_uabi_from_user/kernel_to_xstate() Thomas Gleixner
2021-06-22 10:09   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 33/66] x86/fpu: Rename copy_fpregs_to_fpstate() to save_fpregs_to_fpstate() Thomas Gleixner
2021-06-22 10:16   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 34/66] x86/fpu: Get rid of the FNSAVE optimization Thomas Gleixner
2021-06-22 10:36   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 35/66] x86/fpu: Rename copy_kernel_to_fpregs() to restore_fpregs_from_kernel() Thomas Gleixner
2021-06-22 10:46   ` Borislav Petkov
2021-06-18 14:18 ` [patch V3 36/66] x86/fpu: Rename initstate copy functions Thomas Gleixner
2021-06-22 10:48   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 37/66] x86/fpu: Rename "dynamic" XSTATEs to "independent" Thomas Gleixner
2021-06-22 11:05   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 38/66] x86/fpu/xstate: Sanitize handling of independent features Thomas Gleixner
2021-06-21 20:42   ` Liang, Kan
2021-06-22 11:32   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 39/66] x86/pkeys: Move read_pkru() and write_pkru() Thomas Gleixner
2021-06-18 14:19 ` [patch V3 40/66] x86/fpu: Rename and sanitize fpu__save/copy() Thomas Gleixner
2021-06-22 13:51   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 41/66] x86/cpu: Sanitize X86_FEATURE_OSPKE Thomas Gleixner
2021-06-22 14:15   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 42/66] x86/pkru: Provide pkru_get_init_value() Thomas Gleixner
2021-06-18 14:19 ` [patch V3 43/66] x86/pkru: Provide pkru_write_default() Thomas Gleixner
2021-06-22 14:30   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 44/66] x86/cpu: Write the default PKRU value when enabling PKE Thomas Gleixner
2021-06-18 14:19 ` [patch V3 45/66] x86/fpu: Use pkru_write_default() in copy_init_fpstate_to_fpregs() Thomas Gleixner
2021-06-18 14:19 ` [patch V3 46/66] x86/fpu: Rename fpu__clear_all() to fpu_flush_thread() Thomas Gleixner
2021-06-22 14:40   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 47/66] x86/fpu: Clean up the fpu__clear() variants Thomas Gleixner
2021-06-22 15:38   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 48/66] x86/fpu: Rename __fpregs_load_activate() to fpregs_restore_userregs() Thomas Gleixner
2021-06-22 15:40   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 49/66] x86/fpu: Move FXSAVE_LEAK quirk info __copy_kernel_to_fpregs() Thomas Gleixner
2021-06-22 15:58   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 50/66] x86/fpu: Rename xfeatures_mask_user() to xfeatures_mask_uabi() Thomas Gleixner
2021-06-22 16:02   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 51/66] x86/fpu: Dont restore PKRU in fpregs_restore_userspace() Thomas Gleixner
2021-06-22 16:08   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 52/66] x86/fpu: Add PKRU storage outside of task XSAVE buffer Thomas Gleixner
2021-06-22 16:55   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 53/66] x86/fpu: Hook up PKRU into ptrace() Thomas Gleixner
2021-06-22 17:01   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 54/66] x86/fpu: Mask PKRU from kernel XRSTOR[S] operations Thomas Gleixner
2021-06-22 17:07   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 55/66] x86/fpu: Remove PKRU handling from switch_fpu_finish() Thomas Gleixner
2021-06-22 17:08   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 56/66] x86/fpu: Dont store PKRU in xstate in fpu_reset_fpstate() Thomas Gleixner
2021-06-22 17:10   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 57/66] x86/pkru: Remove xstate fiddling from write_pkru() Thomas Gleixner
2021-06-22 17:15   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 58/66] x86/fpu: Mark init_fpstate __ro_after_init Thomas Gleixner
2021-06-18 14:19 ` [patch V3 59/66] x86/fpu/signal: Move initial checks into fpu__sig_restore() Thomas Gleixner
2021-06-22 17:35   ` Borislav Petkov
2021-06-22 18:38     ` Thomas Gleixner
2021-06-22 18:43       ` Thomas Gleixner
2021-06-18 14:19 ` [patch V3 60/66] x86/fpu/signal: Remove the legacy alignment check Thomas Gleixner
2021-06-22 17:40   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 61/66] x86/fpu/signal: Sanitize the xstate check on sigframe Thomas Gleixner
2021-06-18 21:02   ` Andrew Cooper
2021-06-18 23:49     ` Thomas Gleixner
2021-06-22 19:10   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 62/66] x86/fpu/signal: Sanitize copy_user_to_fpregs_zeroing() Thomas Gleixner
2021-06-23  7:51   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 63/66] x86/fpu/signal: Split out the direct restore code Thomas Gleixner
2021-06-23  8:10   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 64/66] x86/fpu: Return proper error codes from user access functions Thomas Gleixner
2021-06-23  8:30   ` Borislav Petkov
2021-06-23 10:56     ` Thomas Gleixner
2021-06-18 14:19 ` [patch V3 65/66] x86/fpu/signal: Handle #PF in the direct restore path Thomas Gleixner
2021-06-23  8:45   ` Borislav Petkov
2021-06-18 14:19 ` [patch V3 66/66] x86/fpu/signal: Let xrstor handle the features to init Thomas Gleixner
2021-06-23  8:56   ` Borislav Petkov
2021-06-21 16:15 ` [patch V3 00/66] x86/fpu: Spring cleaning and PKRU sanitizing Yu, Yu-cheng
2021-06-21 21:53 ` Fenghua Yu
2021-06-21 22:22 ` Bae, Chang Seok
2021-06-22 20:02   ` Bae, Chang Seok
2021-06-24  0:06     ` Bae, Chang Seok
2021-06-22  1:59 ` Oliver Sang
2021-06-22  9:08   ` Thomas Gleixner
2021-06-22 18:56 ` Dey, Megha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.