]> git.baikalelectronics.ru Git - kernel.git/commit
x86/fpu/xsave: Handle compacted offsets correctly with supervisor states
authorThomas Gleixner <tglx@linutronix.de>
Thu, 24 Mar 2022 13:47:13 +0000 (14:47 +0100)
committerBorislav Petkov <bp@suse.de>
Wed, 30 Mar 2022 09:20:36 +0000 (11:20 +0200)
commit4498601d1a038eb5457c928eeaa4c6d0481d91c7
tree9eccf1ad56132fdf3808af0514650a2bedf31712
parent1c2d2cefd62de2e03286b4cfb112bf9a8e6e80a4
x86/fpu/xsave: Handle compacted offsets correctly with supervisor states

So far the cached fixed compacted offsets worked, but with (re-)enabling
of ENQCMD this does no longer work with KVM fpstate.

KVM does not have supervisor features enabled for the guest FPU, which
means that KVM has then a different XSAVE area layout than the host FPU
state. This in turn breaks the copy from/to UABI functions when invoked for
a guest state.

Remove the pre-calculated compacted offsets and calculate the offset
of each component at runtime based on the XCOMP_BV field in the XSAVE
header.

The runtime overhead is not interesting because these copy from/to UABI
functions are not used in critical fast paths. KVM uses them to save and
restore FPU state during migration. The host uses them for ptrace and for
the slow path of 32bit signal handling.

Fixes: 2b1207b0e600 ("x86/cpufeatures: Re-enable ENQCMD")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220324134623.627636809@linutronix.de
arch/x86/kernel/fpu/xstate.c