• Thomas Gleixner's avatar
    x86/fpu/xsave: Handle compacted offsets correctly with supervisor states · 7aa5128b
    Thomas Gleixner authored
    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: 7c1ef591 ("x86/cpufeatures: Re-enable ENQCMD")
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/20220324134623.627636809@linutronix.de
    7aa5128b
xstate.c 49 KB