From: Khushit Shah <khushit.shah@nutanix.com>
To: Sean Christopherson <seanjc@google.com>,
David Woodhouse <dwmw2@infradead.org>
Cc: "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 v4] KVM: x86: Add x2APIC "features" to control EOI broadcast suppression
Date: Wed, 17 Dec 2025 12:06:43 +0000 [thread overview]
Message-ID: <9B3CAB86-B3E6-475E-8849-85CE63BD7E36@nutanix.com> (raw)
In-Reply-To: <B45DB519-3B04-46F7-894E-42A44DF2FC8E@nutanix.com>
> On 12 Dec 2025, at 12:38 PM, Khushit Shah <khushit.shah@nutanix.com> wrote:
>
> @@ -1515,6 +1552,17 @@ static void kvm_ioapic_send_eoi(struct kvm_lapic *apic, int vector)
> if (apic->vcpu->arch.highest_stale_pending_ioapic_eoi == vector)
> kvm_make_request(KVM_REQ_SCAN_IOAPIC, apic->vcpu);
>
> + /*
> + * Don't send the EOI to the I/O APIC 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). Ignore the suppression if the guest has not
> + * explicitly enabled Suppress EOI broadcast.
> + */
> + if ((kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) &&
> + !kvm_lapic_ignore_suppress_eoi_broadcast(apic->vcpu->kvm))
> + return;
> +
> /* Request a KVM exit to inform the userspace IOAPIC. */
> if (irqchip_split(apic->vcpu->kvm)) {
> apic->vcpu->arch.pending_ioapic_eoi = vector;
>
>
> I am not entirely sure if returning from kvm_ioapic_send_eoi() early is correct
> for kernel IOAPIC. The original code (which is now redundant) does this very
> late in kvm_ioapic_update_eoi_one().
Am I correct in assuming we still need a call to rtc_irq_eoi() even if the guest
has enabled SEOIB?
We will call kvm_ioapic_update_eoi_one() on I/O APIC EOIR write. But, the
following condition in kvm_ioapic_update_eoi_one() blocks EOI processing:
if (trigger_mode != IOAPIC_LEVEL_TRIG ||
kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)
return;
So, the condition needs to moved from kvm_ioapic_update_eoi_one(). It makes
sense to keep it in kvm_ioapic_send_eoi() even for kernel IRQCHIP. But if a call
to rtc_irq_eoi() is required (likely), then we need something similar to following:
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 2c2783296aed..76e511a36699 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -560,8 +560,7 @@ static void kvm_ioapic_update_eoi_one(struct kvm_vcpu *vcpu,
kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, pin);
spin_lock(&ioapic->lock);
- if (trigger_mode != IOAPIC_LEVEL_TRIG ||
- kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)
+ if (trigger_mode != IOAPIC_LEVEL_TRIG)
return;
ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
@@ -595,6 +594,11 @@ void kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, int vector, int trigger_mode)
spin_lock(&ioapic->lock);
rtc_irq_eoi(ioapic, vcpu, vector);
+
+ if((kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) &&
+ kvm_lapic_respect_suppress_eoi_broadcast(ioapic->kvm))
+ goto out;
+
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[i];
@@ -602,6 +606,8 @@ void kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, int vector, int trigger_mode)
continue;
kvm_ioapic_update_eoi_one(vcpu, ioapic, trigger_mode, i);
}
+
+out:
spin_unlock(&ioapic->lock);
}
---
Finally, just to double-check, it is safe to not call kvm_notify_acked_irq()
on LAPIC EOI when guest has enabled Suppress EOI Broadcast, right? As it will
anyway be called on Direct EOI.
Thanks,
Khushit
prev parent reply other threads:[~2025-12-17 12:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 10:59 Khushit Shah
2025-12-11 18:59 ` Sean Christopherson
2025-12-12 5:44 ` Khushit Shah
2025-12-11 21:05 ` Huang, Kai
2025-12-12 0:01 ` David Woodhouse
2025-12-12 0:10 ` Sean Christopherson
2025-12-12 1:11 ` David Woodhouse
2025-12-12 7:08 ` Khushit Shah
2025-12-12 7:31 ` David Woodhouse
2025-12-12 8:16 ` Khushit Shah
2025-12-12 8:19 ` David Woodhouse
2025-12-12 8:27 ` Khushit Shah
2025-12-12 8:30 ` David Woodhouse
2025-12-17 12:06 ` Khushit Shah [this message]
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=9B3CAB86-B3E6-475E-8849-85CE63BD7E36@nutanix.com \
--to=khushit.shah@nutanix.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=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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
all inboxes | Powered by JetHome®