[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zo2I3FChU58bX7qH@google.com>
Date: Tue, 9 Jul 2024 12:00:44 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Maxim Levitsky <mlevitsk@...hat.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Hou Wenlong <houwenlong.hwl@...group.com>,
Kechen Lu <kechenl@...dia.com>, Oliver Upton <oliver.upton@...ux.dev>,
Binbin Wu <binbin.wu@...ux.intel.com>, Yang Weijiang <weijiang.yang@...el.com>,
Robert Hoo <robert.hoo.linux@...il.com>
Subject: Re: [PATCH v2 29/49] KVM: x86: Remove unnecessary caching of KVM's PV
CPUID base
On Thu, Jul 04, 2024, Maxim Levitsky wrote:
> On Fri, 2024-05-17 at 10:39 -0700, Sean Christopherson wrote:
> > Now that KVM only searches for KVM's PV CPUID base when userspace sets
> > guest CPUID, drop the cache and simply do the search every time.
> >
> > Practically speaking, this is a nop except for situations where userspace
> > sets CPUID _after_ running the vCPU, which is anything but a hot path,
> > e.g. QEMU does so only when hotplugging a vCPU. And on the flip side,
> > caching guest CPUID information, especially information that is used to
> > query/modify _other_ CPUID state, is inherently dangerous as it's all too
> > easy to use stale information, i.e. KVM should only cache CPUID state when
> > the performance and/or programming benefits justify it.
> >
> > Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> > ---
...
> > @@ -491,13 +479,6 @@ static int kvm_set_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *e2,
> > * whether the supplied CPUID data is equal to what's already set.
> > */
> > if (kvm_vcpu_has_run(vcpu)) {
> > - /*
> > - * Note, runtime CPUID updates may consume other CPUID-driven
> > - * vCPU state, e.g. KVM or Xen CPUID bases. Updating runtime
> > - * state before full CPUID processing is functionally correct
> > - * only because any change in CPUID is disallowed, i.e. using
> > - * stale data is ok because KVM will reject the change.
> > - */
> Hi,
>
> Any reason why this comment was removed?
Because after this patch, runtime CPUID updates no longer consume other vCPU
state that is derived from guest CPUID.
> As I said earlier in the review. It might make sense to replace this comment
> with a comment reflecting on why we need to call kvm_update_cpuid_runtime,
> that is solely to allow old == new compare to succeed.
Ya, I'll figure out a location and patch to document why KVM applies runtime
and quirks to the CPUID before checking.
>
> > kvm_update_cpuid_runtime(vcpu);
> > kvm_apply_cpuid_pv_features_quirk(vcpu);
Powered by blists - more mailing lists