[PATCH 05/26] KVM: x86: Move MSR_TSC_AUX existence checks into vendor code

From: Sean Christopherson
Date: Wed Jan 29 2020 - 18:48:47 EST


Move the MSR_TSC_AUX existence check into vendor code using the newly
introduced ->has_virtualized_msr() hook to help pave the way toward the
removal of ->rdtscp_supported().

No functional change intended.

Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---
arch/x86/kvm/svm.c | 7 +++++++
arch/x86/kvm/vmx/vmx.c | 7 +++++++
arch/x86/kvm/x86.c | 4 ----
3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1f9323fbad81..4c8427f57b71 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5987,6 +5987,13 @@ static bool svm_cpu_has_accelerated_tpr(void)

static bool svm_has_virtualized_msr(u32 index)
{
+ switch (index) {
+ case MSR_TSC_AUX:
+ return boot_cpu_has(X86_FEATURE_RDTSCP);
+ default:
+ break;
+ }
+
return true;
}

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 3f2c094434e8..9588914e941e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6276,6 +6276,13 @@ static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu,

static bool vmx_has_virtualized_msr(u32 index)
{
+ switch (index) {
+ case MSR_TSC_AUX:
+ return cpu_has_vmx_rdtscp();
+ default:
+ break;
+ }
+
return true;
}

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 94f90fe1c0de..a8619c52ea86 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5241,10 +5241,6 @@ static void kvm_init_msr_list(void)
if (!kvm_mpx_supported())
continue;
break;
- case MSR_TSC_AUX:
- if (!kvm_x86_ops->rdtscp_supported())
- continue;
- break;
case MSR_IA32_RTIT_CTL:
case MSR_IA32_RTIT_STATUS:
if (!kvm_x86_ops->pt_supported())
--
2.24.1