Skip to content

Commit 0497d2a

Browse files
committed
KVM: VMX: Check KVM CPU caps, not just VMX MSR support, for XSAVE enabling
Check KVM CPU capabilities instead of raw VMX support for XSAVES when determining whether or not XSAVER can/should be exposed to the guest. Practically speaking, it's nonsensical/impossible for a CPU to support "enable XSAVES" without XSAVES being supported natively. The real motivation for checking kvm_cpu_cap_has() is to allow using the governed feature's standard check-and-set logic. Reviewed-by: Yuan Yao <yuan.yao@intel.com> Link: https://lore.kernel.org/r/20230815203653.519297-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 1143c0b commit 0497d2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7743,7 +7743,7 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
77437743
* to the guest. XSAVES depends on CR4.OSXSAVE, and CR4.OSXSAVE can be
77447744
* set if and only if XSAVE is supported.
77457745
*/
7746-
vcpu->arch.xsaves_enabled = cpu_has_vmx_xsaves() &&
7746+
vcpu->arch.xsaves_enabled = kvm_cpu_cap_has(X86_FEATURE_XSAVES) &&
77477747
boot_cpu_has(X86_FEATURE_XSAVE) &&
77487748
guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
77497749
guest_cpuid_has(vcpu, X86_FEATURE_XSAVES);

0 commit comments

Comments
 (0)