Skip to content

KVM: x86: Fix XSAVE related bugs

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3KVM: x86: Reinstate kvm_vcpu_arch.guest_supported_xcr0arch/x86/include/asm/kvm_host.h arch/x86/kvm/cpuid.c arch/x86/kvm/x86.c+5 -100 replies
2/3KVM: x86: Always enable legacy FP/SSE in allowed user XFEATURESarch/x86/kvm/cpuid.c+7 -10 replies
3/3KVM: x86: Inject #UD on emulated XSETBV if XSAVES isn't enabledarch/x86/kvm/emulate.c arch/x86/kvm/x86.c+4 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] KVM: x86: Fix XSAVE related bugs

Patch 2 (from Dave) is the headliner and fixes a bug where KVM clear the FP+SSE bits in user_xfeatures when XSAVE is hidden from the guest and thus prevent userspace from saving/restoring FP+SSE state on XSAVE host. This most visibily manifests as a failed migration (KVM_GET_XSAVE succeeds on a non-XSAVE host and KVM_SET_XSAVE fails on an XSAVE host), but also causes KVM_GET_SAVE on XSAVE hosts to effectively corrupt guest FP+SSE state.

Patch 1 fixes a mostly theoretical bug, and is also a prerequisite for patch 2.

Patch 3 fixes a bug found by inspection when staring at all of this. KVM fails to check CR4.OSXSAVE when emulating XSETBV (the interception case gets away without the check because the intercept happens after hardware checks CR4).

Dr. David Alan Gilbert (1):
KVM: x86: Always enable legacy FP/SSE in allowed user XFEATURES

Sean Christopherson (2):
KVM: x86: Reinstate kvm_vcpu_arch.guest_supported_xcr0
KVM: x86: Inject #UD on emulated XSETBV if XSAVES isn't enabled

 arch/x86/include/asm/kvm_host.h |  1 +
 arch/x86/kvm/cpuid.c            | 11 ++++++++---
 arch/x86/kvm/emulate.c          |  3 +++
 arch/x86/kvm/x86.c              | 10 +++-------
 4 files changed, 15 insertions(+), 10 deletions(-)

base-commit: 372d07084593dc7a399bf9bee815711b1fb1bcf2

Signature · 1 line
2.37.1.595.g718a3a8f04-goog