Alexander Graf 76995b
From: Nikita Leshenko <nikita.leshchenko@oracle.com>
Alexander Graf 76995b
Date: Sun, 5 Nov 2017 15:52:30 +0200
Alexander Graf 76995b
Subject: KVM: x86: ioapic: Don't fire level irq when Remote IRR set
Alexander Graf 76995b
MIME-Version: 1.0
Alexander Graf 76995b
Content-Type: text/plain; charset=UTF-8
Alexander Graf 76995b
Content-Transfer-Encoding: 8bit
Alexander Graf 76995b
Patch-mainline: v4.15-rc2
Alexander Graf 76995b
Git-commit: da3fe7bdfada217bf02ecd0477fcdb55da50944c
Alexander Graf 76995b
References: bsc#1077761
Alexander Graf 76995b
Alexander Graf 76995b
Avoid firing a level-triggered interrupt that has the Remote IRR bit set,
Alexander Graf 76995b
because that means that some CPU is already processing it. The Remote
Alexander Graf 76995b
IRR bit will be cleared after an EOI and the interrupt will refire
Alexander Graf 76995b
if the irq line is still asserted.
Alexander Graf 76995b
Alexander Graf 76995b
This behavior is aligned with QEMU's IOAPIC implementation that was
Alexander Graf 76995b
introduced by commit f99b86b94987
Alexander Graf 76995b
("x86: ioapic: ignore level irq during processing") in QEMU.
Alexander Graf 76995b
Alexander Graf 76995b
Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Alexander Graf 76995b
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Alexander Graf 76995b
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Alexander Graf 76995b
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
Alexander Graf 76995b
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Alexander Graf 76995b
Acked-by: Alexander Graf <agraf@suse.de>
Alexander Graf 76995b
---
Alexander Graf 76995b
 arch/x86/kvm/ioapic.c |    4 +++-
Alexander Graf 76995b
 1 file changed, 3 insertions(+), 1 deletion(-)
Alexander Graf 76995b
Alexander Graf 76995b
--- a/arch/x86/kvm/ioapic.c
Alexander Graf 76995b
+++ b/arch/x86/kvm/ioapic.c
Alexander Graf 76995b
@@ -323,7 +323,9 @@
Alexander Graf 76995b
 	struct kvm_lapic_irq irqe;
Alexander Graf 76995b
 	int ret;
Alexander Graf 76995b
 
Alexander Graf 76995b
-	if (entry->fields.mask)
Alexander Graf 76995b
+	if (entry->fields.mask ||
Alexander Graf 76995b
+	    (entry->fields.trig_mode == IOAPIC_LEVEL_TRIG &&
Alexander Graf 76995b
+	    entry->fields.remote_irr))
Alexander Graf 76995b
 		return -1;
Alexander Graf 76995b
 
Alexander Graf 76995b
 	ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "