kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"vkuznets@redhat.com" <vkuznets@redhat.com>
Subject: Re: [PATCH 11/15] KVM: x86: Add CONFIG_KVM_IOAPIC to allow disabling in-kernel I/O APIC
Date: Thu, 29 May 2025 16:08:07 -0700	[thread overview]
Message-ID: <aDjo16EcJiWx9Nfa@google.com> (raw)
In-Reply-To: <58a580b0f3274f6a7bba8431b2a6e6fef152b237.camel@intel.com>

On Thu, May 29, 2025, Kai Huang wrote:
> On Thu, 2025-05-29 at 07:31 -0700, Sean Christopherson wrote:
> > On Thu, May 29, 2025, Kai Huang wrote:
> > > On Thu, 2025-05-29 at 23:55 +1200, Kai Huang wrote:
> > > > On Mon, 2025-05-19 at 16:28 -0700, Sean Christopherson wrote:
> > > > > Add a Kconfig to allowing building KVM without support for emulating an
> > > > 		   ^
> > > > 		   allow
> > > > 
> > > > > I/O APIC, PIC, and PIT, which is desirable for deployments that effectively
> > > > > don't support a fully in-kernel IRQ chip, i.e. never expect any VMM to
> > > > > create an in-kernel I/O APIC.  
> > > > 
> > > > Do you happen to know what developments don't support a full in-kernel IRQ chip?
> > 
> > Google Cloud, for one.  I suspect/assume many/most CSPs don't utilize an in-kernel
> > I/O APIC.
> > 
> > > > Do they only support userspace IRQ chip, or not support any IRQ chip at all?
> > 
> > The former, only userspace I/O APIC (and associated devices), though some VM
> > shapes, e.g. TDX, don't provide an I/O APIC or PIC.
> 
> Thanks for the info.
> 
> Just wondering what's the benefit of using userspace IRQCHIP instead of
> emulating in the kernel?

Reduced kernel attack surface (this was especially true years ago, before KVM's
I/O APIC emulation was well-tested) and more flexibility (e.g. shipping userspace
changes is typically easier than shipping new kernels.  I'm pretty sure there's
one more big one that I'm blanking on at the moment.

> I thought one should either use in-kernel IRQCHIP or doesn't use any.
> 
> > 
> > > Forgot to ask:
> > > 
> > > Since this new Kconfig option is not only for IOAPIC but also includes PIC and
> > > PIT, is CONFIG_KVM_IRQCHIP a better name?
> > 
> > I much prefer IOAPIC, because IRQCHIP is far too ambiguous and confusing, e.g.
> > just look at KVM's internal APIs, where these:
> > 
> >   irqchip_in_kernel()
> >   irqchip_kernel()
> > 
> > are not equivalent.  In practice, no modern guest kernel is going to utilize the
> > PIC, and the PIT isn't an IRQ chip, i.e. isn't strictly covered by IRQCHIP either.
> 
> Right.
> 
> Maybe it is worth to further have dedicated Kconfig for PIC, PIT and IOAPIC?

Nah.  PIC and I/O APIC can't be split (without new uAPI and non-trivial complexity),
and I highly doubt there is any use case that would want an in-kernel I/O APIC
with a userspace PIT.  I.e. in practice, the threealmost always come as a group;
either a setup wants all, or a setup wants none.

> But hmm, I am not sure whether emulating IOAPIC has more value than PIC.

AIUI, it's not really an either or, since most software expects both an I/O APIC
and PIC.  Any remotely modern kernel will definitely prefer the I/O APIC, but I
don't think it's something that can be guaranteed.

> For modern guests all emulated/assigned devices should just use MSI/MSI-X?

Not all emulated devices, since some legacy hang off the I/O APIC, i.e. aren't
capable of generating MISs.

> > So I think/hope the vast majority of users/readers will be able to intuit that
> > CONFIG_KVM_IOAPIC also covers the PIC and PIT.
> 
> Sure.
> 
> Btw, I also find irqchip_in_kernel() and irqchip_kernel() confusing.  I am not
> sure the value of having irqchip_in_kernel() in fact.  The guest should always
> have an in-kernel APIC for modern guests.  I am wondering whether we can get rid
> of it completely (the logic will be it is always be true), or we can have a
> Kconfig to only build it when user truly wants it.

For better or worse, an in-kernel local APIC is still optional.  I do hope/want
to make it mandatory, but that's not a small ABI change.

  reply	other threads:[~2025-05-29 23:08 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-19 23:27 [PATCH 00/15] KVM: x86: Add I/O APIC kconfig, delete irq_comm.c Sean Christopherson
2025-05-19 23:27 ` [PATCH 01/15] KVM: x86: Trigger I/O APIC route rescan in kvm_arch_irq_routing_update() Sean Christopherson
2025-05-19 23:27 ` [PATCH 02/15] KVM: x86: Drop superfluous kvm_set_pic_irq() => kvm_pic_set_irq() wrapper Sean Christopherson
2025-05-19 23:27 ` [PATCH 03/15] KVM: x86: Drop superfluous kvm_set_ioapic_irq() => kvm_ioapic_set_irq() wrapper Sean Christopherson
2025-05-19 23:27 ` [PATCH 04/15] KVM: x86: Drop superfluous kvm_hv_set_sint() => kvm_hv_synic_set_irq() wrapper Sean Christopherson
2025-05-20  9:57   ` Vitaly Kuznetsov
2025-05-29 11:37   ` Huang, Kai
2025-05-29 14:39     ` Sean Christopherson
2025-05-29 22:34       ` Huang, Kai
2025-05-19 23:27 ` [PATCH 05/15] KVM: x86: Fold kvm_setup_default_irq_routing() into kvm_ioapic_init() Sean Christopherson
2025-06-04 16:43   ` Paolo Bonzini
2025-05-19 23:27 ` [PATCH 06/15] KVM: x86: Move kvm_{request,free}_irq_source_id() to i8254.c (PIT) Sean Christopherson
2025-05-19 23:28 ` [PATCH 07/15] KVM: x86: Hardcode the PIT IRQ source ID to '2' Sean Christopherson
2025-05-19 23:28 ` [PATCH 08/15] KVM: x86: Don't clear PIT's IRQ line status when destroying PIT Sean Christopherson
2025-05-29 11:41   ` Huang, Kai
2025-05-19 23:28 ` [PATCH 09/15] KVM: x86: Explicitly check for in-kernel PIC when getting ExtINT Sean Christopherson
2025-05-19 23:28 ` [PATCH 10/15] KVM: Move x86-only tracepoints to x86's trace.h Sean Christopherson
2025-05-19 23:28 ` [PATCH 11/15] KVM: x86: Add CONFIG_KVM_IOAPIC to allow disabling in-kernel I/O APIC Sean Christopherson
2025-05-29 11:55   ` Huang, Kai
2025-05-29 11:57     ` Huang, Kai
2025-05-29 14:31       ` Sean Christopherson
2025-05-29 22:51         ` Huang, Kai
2025-05-29 23:08           ` Sean Christopherson [this message]
2025-05-29 23:55             ` Huang, Kai
2025-06-04 16:54             ` Paolo Bonzini
2025-06-19 10:05               ` Naveen N Rao
2025-05-19 23:28 ` [PATCH 12/15] KVM: Squash two CONFIG_HAVE_KVM_IRQCHIP #ifdefs into one Sean Christopherson
2025-05-19 23:28 ` [PATCH 13/15] KVM: selftests: Fall back to split IRQ chip if full in-kernel chip is unsupported Sean Christopherson
2025-05-19 23:28 ` [PATCH 14/15] KVM: x86: Move IRQ mask notifier infrastructure to I/O APIC emulation Sean Christopherson
2025-05-19 23:28 ` [PATCH 15/15] KVM: x86: Fold irq_comm.c into irq.c Sean Christopherson
2025-05-29 11:58 ` [PATCH 00/15] KVM: x86: Add I/O APIC kconfig, delete irq_comm.c Huang, Kai
2025-06-04 16:56 ` Paolo Bonzini

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=aDjo16EcJiWx9Nfa@google.com \
    --to=seanjc@google.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).