linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/7] x86/fpu: Cure supervisor mode (ENQCMD) fallout
@ 2022-03-24 13:47 Thomas Gleixner
  2022-03-24 13:47 ` [patch 1/7] x86/fpu: Remove redundant XCOMP_BV initialization Thomas Gleixner
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Thomas Gleixner @ 2022-03-24 13:47 UTC (permalink / raw)
  To: LKML; +Cc: x86, Chang S. Bae, Paolo Bonzini, Fenghua Yu, Tony Luck

Folks!

The (re)enabling of ENQCMD or the enabling of any supervisor only state
results in a possible inconsistency of the host and guest FPU XSTATE layout
on systems which support that feature.

The reason is that on the host the FPU state has to include supervisor
features while the guest FPU state is strictly user features only.

The problem is restricted to a few places:

  1) The size calculation in the dynamic state permission PRCTL which lacks
     adding the supervisor state size for calculating the kernel buffer
     size.

  2) The offset calculations in the copy to/from UABI functions which
     use precalculated offsets which are only valid for the host.

The cure is to use runtime calculation for the offsets based on the
XCOMP_BV bitmask in the XSTATE header in case of compacted buffers. For
non-compacted format nothing changes.

The following series addresses this and it turns out to be an overall
valuable cleanup and simplification of the code:

 core.c   |    3 
 xstate.c |  211 ++++++++++++++++++---------------------------------------------
 2 files changed, 62 insertions(+), 152 deletions(-)

The result of the consolidation of the buffer size calculation (last patch
in the series) is a significant reduction of cycles spent for initializing
XSTATE due to the avoidance of a gazillion redundant CPUID invocations:

 Before: XSTATE init: 174344 cycles
 After:  XSTATE init:  73890 cycles

It builds, boots on host and guest, but is not yet extensively tested.
Testing with a AMX + PASID enabled machine has not been done at all as I
don't have easy access to such a beast.

The series is based on:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/urgent

and available from git:

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

Thanks,

	tglx



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

end of thread, other threads:[~2022-03-31  9:01 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 13:47 [patch 0/7] x86/fpu: Cure supervisor mode (ENQCMD) fallout Thomas Gleixner
2022-03-24 13:47 ` [patch 1/7] x86/fpu: Remove redundant XCOMP_BV initialization Thomas Gleixner
2022-03-31  9:01   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 2/7] x86/fpu: Remove unused supervisor only offsets Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 3/7] x86/fpu/xsave: Initialize offset/size cache early Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 4/7] x86/fpu: Cache xfeature flags from CPUID Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 5/7] x86/fpu/xsave: Handle compacted offsets correctly with supervisor states Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 6/7] x86/fpu/xstate: Handle supervisor states in XSTATE permissions Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 7/7] x86/fpu/xstate: Consolidate size calculations Thomas Gleixner
2022-03-28 18:43   ` [patch V2 " Thomas Gleixner
2022-03-31  9:00     ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-28 12:39 ` [patch 0/7] x86/fpu: Cure supervisor mode (ENQCMD) fallout Chang S. Bae
2022-03-28 22:30 ` Fenghua Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).