[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALMp9eSzy6gEvZe2s-MGe3cM047iKNoGidHDkm63=01sfgSyjg@mail.gmail.com>
Date: Mon, 10 May 2021 10:11:07 -0700
From: Jim Mattson <jmattson@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Maxim Levitsky <mlevitsk@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Joerg Roedel <joro@...tes.org>, kvm list <kvm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Xiaoyao Li <xiaoyao.li@...el.com>,
Reiji Watanabe <reijiw@...gle.com>
Subject: Re: [PATCH 14/15] KVM: x86: Tie Intel and AMD behavior for
MSR_TSC_AUX to guest CPU model
On Mon, May 10, 2021 at 9:50 AM Sean Christopherson <seanjc@...gle.com> 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.
> > > - !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP) &&
> > > - !guest_cpuid_has(vcpu, X86_FEATURE_RDPID))
> > > - return 1;
> > > msr_info->data = svm->tsc_aux;
> > > break;
> > > /*
Powered by blists - more mailing lists