]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Drop superfluous host XSAVE check when adjusting guest XSAVES caps
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 01:34:18 +0000 (17:34 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:20:17 +0000 (14:20 -0800)
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>
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c

index 734b3ca403119b7ecd676541e3b3667dcc92b3b5..07911ddf1efefe619fe1ebd12a9ebff2196a3cf9 100644 (file)
@@ -4402,7 +4402,6 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
         * the guest read/write access to the host's XSS.
         */
        guest_cpu_cap_change(vcpu, X86_FEATURE_XSAVES,
-                            boot_cpu_has(X86_FEATURE_XSAVE) &&
                             boot_cpu_has(X86_FEATURE_XSAVES) &&
                             guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE));
 
index 6e5edaa2ba3acf28ac77e12910afba4fab9784ee..cf872d8691b5019e345de09c7fbe9c9941f941e7 100644 (file)
@@ -7825,8 +7825,7 @@ void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
         * to the guest.  XSAVES depends on CR4.OSXSAVE, and CR4.OSXSAVE can be
         * set if and only if XSAVE is supported.
         */
-       if (!boot_cpu_has(X86_FEATURE_XSAVE) ||
-           !guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE))
+       if (!guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE))
                guest_cpu_cap_clear(vcpu, X86_FEATURE_XSAVES);
 
        vmx_setup_uret_msrs(vmx);