Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	 Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org,  "H. Peter Anvin" <hpa@zytor.com>,
	Shuah Khan <shuah@kernel.org>,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	 Clayton Pence <ctpence@google.com>
Subject: Re: [PATCH v2 2/3] KVM: x86: Virtualize AMD CPUID faulting
Date: Tue, 12 May 2026 17:04:40 -0700	[thread overview]
Message-ID: <agPAGOxjALgvPwAY@google.com> (raw)
In-Reply-To: <CALMp9eRKcNpLxVBEg8RF6tSqndRFpLW_Q-rcXazPR9HYFJcdag@mail.gmail.com>

On Tue, May 12, 2026, Jim Mattson wrote:
> On Tue, May 12, 2026 at 2:33 PM Sean Christopherson <seanjc@google.com> wrote:
> > From: Sean Christopherson <seanjc@google.com>
> > Date: Tue, 12 May 2026 14:20:47 -0700
> > Subject: [PATCH 1/3] KVM: x86: Consolidate CPUID fault handling for emulator
> >  and interception logic
> >
> > Extract the logic for emulating CPUID faulting (where CPUID #GPs at CPL>0
> > outside of SMM) into a dedicated helper and use the helper for both the
> > full emulator and the intercepted-CPUID paths.
> >
> > Opportunistically drop kvm_require_cpl(), as kvm_require_cpl() was the one
> > and only user.
> >
> > No functional change intended.
> >
> > Signed-off-by: Sean Christopherson <seanjc@google.com>
> > ---
> >  arch/x86/include/asm/kvm_host.h |  1 -
> >  arch/x86/kvm/cpuid.c            |  5 +++--
> >  arch/x86/kvm/cpuid.h            |  8 ++++++++
> >  arch/x86/kvm/emulate.c          |  6 +-----
> >  arch/x86/kvm/kvm_emulate.h      |  1 +
> >  arch/x86/kvm/x86.c              | 18 ++++++------------
> >  6 files changed, 19 insertions(+), 20 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index c470e40a00aa..a9005c61619b 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -2285,7 +2285,6 @@ void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned int nr,
> >  void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault);
> >  void kvm_inject_emulated_page_fault(struct kvm_vcpu *vcpu,
> >                                     struct x86_exception *fault);
> > -bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl);
> >  bool kvm_require_dr(struct kvm_vcpu *vcpu, int dr);
> >
> >  static inline int __kvm_irq_line_state(unsigned long *irq_state,
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index e69156b54cff..1c95d1fa3ead 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -2161,9 +2161,10 @@ int kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
> >  {
> >         u32 eax, ebx, ecx, edx;
> >
> > -       if (!is_smm(vcpu) && cpuid_fault_enabled(vcpu) &&
> > -           !kvm_require_cpl(vcpu, 0))
> > +       if (!kvm_is_cpuid_allowed(vcpu)) {
> > +               kvm_queue_exception_e(vcpu, GP_VECTOR, 0);
> >                 return 1;
> > +       }
> 
> That's so much better!
> 
> Will you drop this in when applying, or should I send a V3?

Go ahead and send a v3.  It slots in easy enough, but I'm trying not to get into
the habit of applying pseudo-posted patches.

  reply	other threads:[~2026-05-13  0:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 17:07 [PATCH v2 0/3] KVM: x86: Virtualize AMD CPUID faulting Jim Mattson
2026-05-08 17:07 ` [PATCH v2 1/3] KVM: x86: Remove supports_cpuid_fault() helper Jim Mattson
2026-05-08 17:07 ` [PATCH v2 2/3] KVM: x86: Virtualize AMD CPUID faulting Jim Mattson
2026-05-12 21:33   ` Sean Christopherson
2026-05-13  0:01     ` Jim Mattson
2026-05-13  0:04       ` Sean Christopherson [this message]
2026-05-08 17:07 ` [PATCH v2 3/3] KVM: selftests: Update hwcr_msr_test for CPUID faulting bit Jim Mattson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=agPAGOxjALgvPwAY@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=ctpence@google.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox