All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Khushit Shah <khushit.shah@nutanix.com>
Cc: pbonzini@redhat.com, kai.huang@intel.com, dwmw2@infradead.org,
	 mingo@redhat.com, x86@kernel.org, bp@alien8.de, hpa@zytor.com,
	 linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	 dave.hansen@linux.intel.com, tglx@linutronix.de,
	jon@nutanix.com,  shaju.abraham@nutanix.com
Subject: Re: [PATCH v5 1/3] KVM: x86: Refactor suppress EOI broadcast logic
Date: Tue, 13 Jan 2026 15:11:01 -0800	[thread overview]
Message-ID: <aWbRBd85eeb0awfF@google.com> (raw)
In-Reply-To: <20251229111708.59402-2-khushit.shah@nutanix.com>

On Mon, Dec 29, 2025, Khushit Shah wrote:
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 0ae7f913d782..2c24fd8d815f 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -105,6 +105,39 @@ bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector)
>  		apic_test_vector(vector, apic->regs + APIC_IRR);
>  }
>  
> +bool kvm_lapic_advertise_suppress_eoi_broadcast(struct kvm *kvm)

This can be static, its only caller is kvm_apic_set_version().

> +{
> +	/*
> +	 * The default in-kernel I/O APIC emulates the 82093AA and does not
> +	 * implement an EOI register. Some guests (e.g. Windows with the
> +	 * Hyper-V role enabled) disable LAPIC EOI broadcast without checking
> +	 * the I/O APIC version, which can cause level-triggered interrupts to
> +	 * never be EOI'd.
> +	 *
> +	 * To avoid this, KVM must not advertise Suppress EOI Broadcast support
> +	 * when using the default in-kernel I/O APIC.
> +	 *
> +	 * Historically, in split IRQCHIP mode, KVM always advertised Suppress
> +	 * EOI Broadcast support but did not actually suppress EOIs, resulting
> +	 * in quirky behavior.
> +	 */
> +	return !ioapic_in_kernel(kvm);
> +}
> +
> +bool kvm_lapic_respect_suppress_eoi_broadcast(struct kvm *kvm)

I don't see any point in forcing every caller to check SPIV *and* this helper.
Just do:

bool kvm_lapic_suppress_eoi_broadcast(struct kvm_lapic *apic)
{
	struct kvm *kvm = apic->vcpu->kvm;

	if (!(kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI))
		return false;

	switch (kvm->arch.suppress_eoi_broadcast_mode) {

	...
	}
}

And then callers are much more readable, e.g. (spoiler alert if you haven't read
my other mail, which I haven't sent yet):

	if (trigger_mode != IOAPIC_LEVEL_TRIG ||
	    kvm_lapic_suppress_eoi_broadcast(apic))
		return;

and

	/* Request a KVM exit to inform the userspace IOAPIC. */
	if (irqchip_split(apic->vcpu->kvm)) {
		/*
		 * Don't exit to userspace if the guest has enabled Directed
		 * EOI, a.k.a. Suppress EOI Broadcasts, in which case the local
		 * APIC doesn't broadcast EOIs (the guest must EOI the target
		 * I/O APIC(s) directly).
		 */
		if (kvm_lapic_suppress_eoi_broadcast(apic))
			return;

		apic->vcpu->arch.pending_ioapic_eoi = vector;
		kvm_make_request(KVM_REQ_IOAPIC_EOI_EXIT, apic->vcpu);
		return;
	}

  parent reply	other threads:[~2026-01-13 23:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-29 11:17 [PATCH v5 0/3] KVM: x86: Add userspace control for Suppress EOI Broadcast Khushit Shah
2025-12-29 11:17 ` [PATCH v5 1/3] KVM: x86: Refactor suppress EOI broadcast logic Khushit Shah
2026-01-02 16:23   ` David Woodhouse
2026-01-12  4:15     ` Khushit Shah
2026-01-13 23:40       ` David Woodhouse
2026-01-14  0:10       ` Sean Christopherson
2026-01-16  4:41         ` Khushit Shah
2026-01-16  9:01         ` David Woodhouse
2026-01-16 10:02           ` Khushit Shah
2026-01-16 17:34             ` Sean Christopherson
2026-01-23 13:04               ` Khushit Shah
2026-01-13 23:11   ` Sean Christopherson [this message]
2025-12-29 11:17 ` [PATCH v5 2/3] KVM: x86/ioapic: Implement support for I/O APIC version 0x20 with EOIR Khushit Shah
2025-12-29 11:39   ` David Woodhouse
2025-12-29 12:21     ` Khushit Shah
2025-12-29 13:01       ` David Woodhouse
2025-12-29 15:16         ` Khushit Shah
2025-12-29 15:36           ` David Woodhouse
2025-12-29 15:57             ` Khushit Shah
2026-01-02 16:17               ` David Woodhouse
2026-01-12  3:22                 ` Khushit Shah
2025-12-29 11:17 ` [PATCH v5 3/3] KVM: x86: Add x2APIC "features" to control EOI broadcast suppression Khushit Shah
2026-01-02 16:41   ` David Woodhouse
2026-01-12  3:27     ` Khushit Shah
2026-01-29  4:49 ` [PATCH v5 4/3] KVM: selftests: Add test cases for EOI suppression modes David Woodhouse
2026-01-29 15:19   ` Sean Christopherson
2026-01-29 15:58     ` David Woodhouse
2026-02-04  0:00       ` Sean Christopherson

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=aWbRBd85eeb0awfF@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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.