Skip to content

Commit 6f2b296

Browse files
sean-jcbonzini
authored andcommitted
KVM: SVM: Inject #GP on guest MSR_TSC_AUX accesses if RDTSCP unsupported
Inject #GP on guest accesses to MSR_TSC_AUX if RDTSCP is unsupported in the guest's CPUID model. Fixes: 46896c7 ("KVM: svm: add support for RDTSCP") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210423223404.3860547-2-seanjc@google.com> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent e23f6d4 commit 6f2b296

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎arch/x86/kvm/svm/svm.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,9 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
26742674
case MSR_TSC_AUX:
26752675
if (!boot_cpu_has(X86_FEATURE_RDTSCP))
26762676
return 1;
2677+
if (!msr_info->host_initiated &&
2678+
!guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
2679+
return 1;
26772680
msr_info->data = svm->tsc_aux;
26782681
break;
26792682
/*
@@ -2892,6 +2895,10 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
28922895
if (!boot_cpu_has(X86_FEATURE_RDTSCP))
28932896
return 1;
28942897

2898+
if (!msr->host_initiated &&
2899+
!guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
2900+
return 1;
2901+
28952902
/*
28962903
* This is rare, so we update the MSR here instead of using
28972904
* direct_access_msrs. Doing that would require a rdmsr in

0 commit comments

Comments
 (0)