On Mon, 2021-05-10 at 10:11 -0700, Jim Mattson wrote: > On Mon, May 10, 2021 at 9:50 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > > 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. > > I thought the rule was that if an MSR was enumerated by > KVM_GET_MSR_INDEX_LIST, then KVM had to accept legal writes from the > host. The only "ordering thing" is that KVM_GET_MSR_INDEX_LIST is a > device ioctl, so it can't take guest CPUID information into account. This makes sense. Thanks! Best regards, Maxim Levitsky > > > > > - !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP) && > > > > - !guest_cpuid_has(vcpu, X86_FEATURE_RDPID)) > > > > - return 1; > > > > msr_info->data = svm->tsc_aux; > > > > break; > > > > /*