]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: x86: Drop special XSAVE handling from guest_cpuid_has()
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 10 Dec 2019 22:44:15 +0000 (14:44 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 21 Jan 2020 12:58:10 +0000 (13:58 +0100)
Now that KVM prevents setting host-reserved CR4 bits, drop the dedicated
XSAVE check in guest_cpuid_has() in favor of open coding similar checks
in the SVM/VMX XSAVES enabling flows.

Note, checking boot_cpu_has(X86_FEATURE_XSAVE) in the XSAVES flows is
technically redundant with respect to the CR4 reserved bit checks, e.g.
XSAVES #UDs if CR4.OSXSAVE=0 and arch.xsaves_enabled is consumed if and
only if CR4.OXSAVE=1 in guest.  Keep (add?) the explicit boot_cpu_has()
checks to help document KVM's usage of arch.xsaves_enabled.

No functional change intended.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/cpuid.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx/vmx.c

index d78a61408243f20e8369bc5acaa3562d7c34d0aa..b82ae4d3dc71ef59cf050f9cf98de670aba03a6e 100644 (file)
@@ -93,10 +93,6 @@ static __always_inline bool guest_cpuid_has(struct kvm_vcpu *vcpu, unsigned x86_
 {
        int *reg;
 
-       if (x86_feature == X86_FEATURE_XSAVE &&
-                       !static_cpu_has(X86_FEATURE_XSAVE))
-               return false;
-
        reg = guest_cpuid_get_register(vcpu, x86_feature);
        if (!reg)
                return false;
index 9583ae7ae218fcb7f19be3f78ebe544c204e2b97..d399eb7bbff3eb0b22e271042ec7b72ee72e1310 100644 (file)
@@ -5917,6 +5917,7 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
        struct vcpu_svm *svm = to_svm(vcpu);
 
        vcpu->arch.xsaves_enabled = guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
+                                   boot_cpu_has(X86_FEATURE_XSAVE) &&
                                    boot_cpu_has(X86_FEATURE_XSAVES);
 
        /* Update nrips enabled cache */
index 857dd0898e5f1be684d4febbf2a1da928a19b823..3e732d092c401824d75af7f8b73bbc60ee99be1e 100644 (file)
@@ -4049,6 +4049,7 @@ static void vmx_compute_secondary_exec_control(struct vcpu_vmx *vmx)
        if (vmx_xsaves_supported()) {
                /* Exposing XSAVES only when XSAVE is exposed */
                bool xsaves_enabled =
+                       boot_cpu_has(X86_FEATURE_XSAVE) &&
                        guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
                        guest_cpuid_has(vcpu, X86_FEATURE_XSAVES);