Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: x86: ioapic: Set remote_irr only after successful delivery
@ 2026-08-06 13:39 Hao Zhang
  2026-08-06 13:46 ` [PATCH 2/2] KVM: selftests: Verify IOAPIC doesn't set remote_irr on failed delivery Hao Zhang
  2026-08-07  7:41 ` [PATCH 1/2] KVM: x86: ioapic: Set remote_irr only after successful delivery Huang, Kai
  0 siblings, 2 replies; 3+ messages in thread
From: Hao Zhang @ 2026-08-06 13:39 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: Paolo Bonzini, kvm

From: Hao Zhang <zhanghao1@kylinos.cn>

The I/O APIC sets remote_irr for level-triggered interrupts to track that
the interrupt has been accepted by a local APIC and that the I/O APIC must
wait for the corresponding EOI before delivering the interrupt again.

But ioapic_service() currently sets remote_irr for any non-zero return
from kvm_irq_delivery_to_apic(). The delivery helper can return -1 when
no destination is found. Treating -1 as success causes KVM to set
remote_irr even though no interrupt was delivered and no EOI will ever
be generated, leaving the pin blocked.

Set remote_irr only when the delivery result is positive, i.e. when at
least one local APIC accepted the interrupt.

Fixes: 4925663a079c ("KVM: Report IRQ injection status to userspace.")
Signed-off-by: Hao Zhang <zhanghao1@kylinos.cn>
---
 arch/x86/kvm/ioapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 757667fb2bfa..24a7cc3b8b7e 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -491,7 +491,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
 	} else
 		ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe);
 
-	if (ret && irqe.trig_mode == IOAPIC_LEVEL_TRIG)
+	if (ret > 0 && irqe.trig_mode == IOAPIC_LEVEL_TRIG)
 		entry->fields.remote_irr = 1;
 
 	return ret;

base-commit: c21bb4193868a8de71fc4693fa741e195fdf5d86
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-07  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 13:39 [PATCH 1/2] KVM: x86: ioapic: Set remote_irr only after successful delivery Hao Zhang
2026-08-06 13:46 ` [PATCH 2/2] KVM: selftests: Verify IOAPIC doesn't set remote_irr on failed delivery Hao Zhang
2026-08-07  7:41 ` [PATCH 1/2] KVM: x86: ioapic: Set remote_irr only after successful delivery Huang, Kai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox