Re: [PATCH 14/15] KVM: x86: Tie Intel and AMD behavior for MSR_TSC_AUX to guest CPU model
From: Sean Christopherson
Date: Mon May 10 2021 - 12:50:40 EST
On Mon, May 10, 2021, Maxim Levitsky wrote:
> On Tue, 2021-05-04 at 10:17 -0700, Sean Christopherson wrote:
> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> > index de921935e8de..6c7c6a303cc5 100644
> > --- a/arch/x86/kvm/svm/svm.c
> > +++ b/arch/x86/kvm/svm/svm.c
> > @@ -2663,12 +2663,6 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> > msr_info->data |= (u64)svm->sysenter_esp_hi << 32;
> > break;
> > case MSR_TSC_AUX:
> > - if (tsc_aux_uret_slot < 0)
> > - return 1;
> > - if (!msr_info->host_initiated &&
> Not related to this patch, but I do wonder why do we need
> to always allow writing this msr if done by the host,
> since if neither RDTSPC nor RDPID are supported, the guest
> won't be able to read this msr at all.
It's an ordering thing and not specific to MSR_TSC_AUX. Exempting host userspace
from guest CPUID checks allows userspace to set MSR state, e.g. during migration,
before setting the guest CPUID model.
> > - !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP) &&
> > - !guest_cpuid_has(vcpu, X86_FEATURE_RDPID))
> > - return 1;
> > msr_info->data = svm->tsc_aux;
> > break;
> > /*