Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Khushit Shah <khushit.shah@nutanix.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	 "kai.huang@intel.com" <kai.huang@intel.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	 "x86@kernel.org" <x86@kernel.org>, "bp@alien8.de" <bp@alien8.de>,
	"hpa@zytor.com" <hpa@zytor.com>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	 "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	 Jon Kohler <jon@nutanix.com>,
	Shaju Abraham <shaju.abraham@nutanix.com>,
	 "stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v3] KVM: x86: Add x2APIC "features" to control EOI broadcast suppression
Date: Tue, 2 Dec 2025 14:26:36 -0800	[thread overview]
Message-ID: <aS9ng741Osi91O_v@google.com> (raw)
In-Reply-To: <fac971fe6625456f3c9ad69d859008117e35826a.camel@infradead.org>

On Tue, Dec 02, 2025, David Woodhouse wrote:
> On Tue, 2025-12-02 at 08:36 -0800, Sean Christopherson wrote:
> > 
> > Hmm, I suppose that could work for uAPI.  Having both an ENABLE and a DISABLE
> > is obviously a bit odd, but slowing down the reader might actually be a good
> > thing in this case.  And the documentation should be easy enough to write.
> > 
> > I was worried that having ENABLE and DISABLE controls would lead to confusing code
> > internally, but there's no reason KVM's internal tracking needs to match uAPI.
> > 
> > How about this?
> > 
> > ---
> >  arch/x86/include/asm/kvm_host.h |  7 +++++++
> >  arch/x86/include/uapi/asm/kvm.h |  6 ++++--
> >  arch/x86/kvm/lapic.c            | 16 +++++++++++++++-
> >  arch/x86/kvm/x86.c              | 15 ++++++++++++---
> >  4 files changed, 38 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index 5a3bfa293e8b..b4c41255f01d 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -1226,6 +1226,12 @@ enum kvm_irqchip_mode {
> >  	KVM_IRQCHIP_SPLIT,        /* created with KVM_CAP_SPLIT_IRQCHIP */
> >  };
> >  
> > +enum kvm_suppress_eoi_broadcast_mode {
> > +	KVM_SUPPRESS_EOI_QUIRKED,
> > +	KVM_SUPPRESS_EOI_ENABLED,
> > +	KVM_SUPPRESS_EOI_DISABLED,
> > +};
> > +
> 
> Looks good. I'd probably call it KVM_SUPPRESS_EOI_LEGACY though?

Why legacy?  "Quirk" has specific meaning in KVM: technically broken behavior
that is retained as the default for backwards compatibility.  "Legacy" does not,
outside of a few outliers like HPET crud.

> And just for clarity I wouldn't embed the explicit checks against e.g
> arch.suppress_eoi_broadcast != KVM_SUPPRESS_EOI_LEGACY. I'd make static
> inline functions like

Ya, definitely no objection,
 
> static inline bool kvm_lapic_advertise_directed_eoi(kvm)

s/directed_eoi/suppress_eoi_broadcast.  I want to provide as clear of split as
possible between the local APIC feature and the I/O APIC feature.

> {
> 	/* Legacy behaviour was to advertise this feature but it
> didn't 
> 	 * actually work. */
> 	return kvm->arch.suppress_eoi_broadcast != KVM_SUPPRESS_EOI_DISABLED;
> }
> 
> static inline bool kvm_lapic_suppress_directed_eoi(kvm)

Too close to "suppress EOI broadcast", e.g. it would be easy to read this as
"suppress EOIs" and invert the polarity.  It's wordy, but I think
kvm_lapic_ignore_suppress_eoi_broadcast() is the least awful name.

> {
> 	/* Legacy behaviour advertised this feature but didn't
> actually
> 	 * suppress the EOI. */
> 	return kvm->arch.suppress_eoi_broadcast == KVM_SUPPRESS_EOI_ENABLED;
> }
> 
> Because it keeps the batshittery in one place and clearly documented?
> 
> I note your version did actually suppress the broadcast even in the
> DISABLED case if the guest had managed to set that bit in SPIV, but I
> don't think it *can* so that difference doesn't matter anyway, right?

Right.  If we want to be paranoid, we could WARN_ON_ONCE() in whatever the "ignore
broadcast" accessor is called, because it should only be used if the bit is enabled
in the local APIC.

  reply	other threads:[~2025-12-02 22:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25 18:05 [PATCH v3] KVM: x86: Add x2APIC "features" to control EOI broadcast suppression Khushit Shah
2025-11-25 21:16 ` Huang, Kai
2025-12-02  9:13 ` David Woodhouse
2025-12-02 12:58   ` Khushit Shah
2025-12-02 13:31     ` David Woodhouse
2025-12-02 15:42       ` Sean Christopherson
2025-12-02 15:51         ` David Woodhouse
2025-12-02 16:36           ` Sean Christopherson
2025-12-02 17:10             ` David Woodhouse
2025-12-02 22:26               ` Sean Christopherson [this message]
2025-12-02 22:35                 ` David Woodhouse
2025-12-03  0:50             ` Huang, Kai
2025-12-03  1:14               ` David Woodhouse
2025-12-03 12:25               ` David Woodhouse
2025-12-03 13:10                 ` Paolo Bonzini
2025-12-03 13:32                   ` David Woodhouse
2025-12-03 13:36                     ` Paolo Bonzini
2025-12-03 13:55                       ` David Woodhouse
2025-12-03  7:45             ` Khushit Shah
2025-12-02 16:04         ` David Woodhouse

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=aS9ng741Osi91O_v@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jon@nutanix.com \
    --cc=kai.huang@intel.com \
    --cc=khushit.shah@nutanix.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=shaju.abraham@nutanix.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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