Skip to content

Commit 02f7450

Browse files
sean-jcgregkh
authored andcommitted
KVM: SVM: Inject #GP on guest MSR_TSC_AUX accesses if RDTSCP unsupported
commit 6f2b296 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1e41cb4 commit 02f7450

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
@@ -2651,6 +2651,9 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
26512651
case MSR_TSC_AUX:
26522652
if (!boot_cpu_has(X86_FEATURE_RDTSCP))
26532653
return 1;
2654+
if (!msr_info->host_initiated &&
2655+
!guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
2656+
return 1;
26542657
msr_info->data = svm->tsc_aux;
26552658
break;
26562659
/*
@@ -2859,6 +2862,10 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
28592862
if (!boot_cpu_has(X86_FEATURE_RDTSCP))
28602863
return 1;
28612864

2865+
if (!msr->host_initiated &&
2866+
!guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
2867+
return 1;
2868+
28622869
/*
28632870
* This is rare, so we update the MSR here instead of using
28642871
* direct_access_msrs. Doing that would require a rdmsr in

0 commit comments

Comments
 (0)