Skip to content

Commit cbdeea0

Browse files
committed
KVM: x86: Drop superfluous host XSAVE check when adjusting guest XSAVES caps
Drop the manual boot_cpu_has() checks on XSAVE when adjusting the guest's XSAVES capabilities now that guest cpu_caps incorporates KVM's support. The guest's cpu_caps are initialized from kvm_cpu_caps, which are in turn initialized from boot_cpu_data, i.e. checking guest_cpu_cap_has() also checks host/KVM capabilities (which is the entire point of cpu_caps). Cc: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Link: https://lore.kernel.org/r/20241128013424.4096668-52-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 8f2a277 commit cbdeea0

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4402,7 +4402,6 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
44024402
* the guest read/write access to the host's XSS.
44034403
*/
44044404
guest_cpu_cap_change(vcpu, X86_FEATURE_XSAVES,
4405-
boot_cpu_has(X86_FEATURE_XSAVE) &&
44064405
boot_cpu_has(X86_FEATURE_XSAVES) &&
44074406
guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE));
44084407

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7825,8 +7825,7 @@ void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
78257825
* to the guest. XSAVES depends on CR4.OSXSAVE, and CR4.OSXSAVE can be
78267826
* set if and only if XSAVE is supported.
78277827
*/
7828-
if (!boot_cpu_has(X86_FEATURE_XSAVE) ||
7829-
!guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE))
7828+
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE))
78307829
guest_cpu_cap_clear(vcpu, X86_FEATURE_XSAVES);
78317830

78327831
vmx_setup_uret_msrs(vmx);

0 commit comments

Comments
 (0)