KVM: VMX: Check guest support for RDTSCP before processing MSR_TSC_AUX
authorSean Christopherson <sean.j.christopherson@intel.com>
Wed, 23 Sep 2020 18:04:03 +0000 (11:04 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 28 Sep 2020 11:57:59 +0000 (07:57 -0400)
Check for RDTSCP support prior to checking if MSR_TSC_AUX is in the uret
MSRs array so that the array lookup and manipulation are back-to-back.
This paves the way toward adding a helper to wrap the lookup and
manipulation.

No functional change intended.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200923180409.32255-10-sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c

index ae3c01cde79d238035d049d15efc51afbd37d5b9..068783a13ac8df8f87e885ed6fa1b15f4d67b221 100644 (file)
@@ -1651,9 +1651,11 @@ static void setup_msrs(struct vcpu_vmx *vmx)
        index = __vmx_find_uret_msr(vmx, MSR_EFER);
        if (index >= 0 && update_transition_efer(vmx, index))
                move_msr_up(vmx, index, nr_active_uret_msrs++);
-       index = __vmx_find_uret_msr(vmx, MSR_TSC_AUX);
-       if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP))
-               move_msr_up(vmx, index, nr_active_uret_msrs++);
+       if (guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP)) {
+               index = __vmx_find_uret_msr(vmx, MSR_TSC_AUX);
+               if (index >= 0)
+                       move_msr_up(vmx, index, nr_active_uret_msrs++);
+       }
        index = __vmx_find_uret_msr(vmx, MSR_IA32_TSX_CTRL);
        if (index >= 0)
                move_msr_up(vmx, index, nr_active_uret_msrs++);