All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: Fix oneshot interrupts forwarding
@ 2022-07-15 15:59 Dmytro Maluka
  2022-07-15 15:59 ` [PATCH 1/3] KVM: x86: Move kvm_(un)register_irq_mask_notifier() to generic KVM Dmytro Maluka
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Dmytro Maluka @ 2022-07-15 15:59 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, kvm
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-kernel, Eric Auger, Alex Williamson,
	Rong L Liu, Zhenyu Wang, Tomasz Nowicki, Grzegorz Jaszczyk,
	Dmitry Torokhov, Dmytro Maluka

The existing KVM mechanism for forwarding of level-triggered interrupts
using resample eventfd doesn't work quite correctly in the case of
interrupts that are handled in a Linux guest as oneshot interrupts
(IRQF_ONESHOT). Such an interrupt is acked to the device in its
threaded irq handler, i.e. later than it is acked to the interrupt
controller (EOI at the end of hardirq), not earlier. The existing KVM
code doesn't take that into account, which results in erroneous extra
interrupts in the guest caused by premature re-assert of an
unacknowledged IRQ by the host.

This patch series fixes this issue (for now on x86 only) by checking if
the interrupt is unmasked when we receive irq ack (EOI) and, in case if
it's masked, postponing resamplefd notify until the guest unmasks it.

Patches 1 and 2 implement the prerequisites needed for KVM irqfd to
know the interrupt mask state. Patch 3 implements the actual fix:
postponing resamplefd notify in KVM irqfd until the irq is unmasked.

Please see individual patches for more details.

Dmytro Maluka (3):
  KVM: x86: Move kvm_(un)register_irq_mask_notifier() to generic KVM
  KVM: x86: Add kvm_irq_is_masked()
  KVM: irqfd: Postpone resamplefd notify for oneshot interrupts

 arch/x86/include/asm/kvm_host.h | 11 +-----
 arch/x86/kvm/i8259.c            | 11 ++++++
 arch/x86/kvm/ioapic.c           | 11 ++++++
 arch/x86/kvm/ioapic.h           |  1 +
 arch/x86/kvm/irq_comm.c         | 34 +++++++++---------
 include/linux/kvm_host.h        | 13 +++++++
 include/linux/kvm_irqfd.h       | 14 ++++++++
 virt/kvm/eventfd.c              | 63 +++++++++++++++++++++++++++++++++
 virt/kvm/irqchip.c              | 34 ++++++++++++++++++
 9 files changed, 164 insertions(+), 28 deletions(-)

-- 
2.37.0.170.g444d1eabd0-goog


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

end of thread, other threads:[~2022-08-13 14:33 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 15:59 [PATCH 0/3] KVM: Fix oneshot interrupts forwarding Dmytro Maluka
2022-07-15 15:59 ` [PATCH 1/3] KVM: x86: Move kvm_(un)register_irq_mask_notifier() to generic KVM Dmytro Maluka
2022-07-28 18:46   ` Sean Christopherson
2022-07-29 11:09     ` Dmytro Maluka
2022-08-02 21:43       ` Sean Christopherson
2022-07-15 15:59 ` [PATCH 2/3] KVM: x86: Add kvm_irq_is_masked() Dmytro Maluka
2022-08-04 17:14   ` Eric Auger
2022-08-04 19:31     ` Dmytro Maluka
2022-07-15 15:59 ` [PATCH 3/3] KVM: irqfd: Postpone resamplefd notify for oneshot interrupts Dmytro Maluka
2022-07-25 23:44   ` Liu, Rong L
2022-07-26 14:07     ` Dmytro Maluka
2022-07-29 20:48       ` Liu, Rong L
2022-07-30 14:34         ` Dmytro Maluka
2022-08-09 22:02           ` Liu, Rong L
2022-08-10  0:56             ` Dmytro Maluka
2022-08-11 16:12               ` Liu, Rong L
2022-08-13 14:33                 ` Dmytro Maluka
2022-08-10 17:34             ` Liu, Rong L
2022-07-28 18:55   ` Sean Christopherson
2022-07-29 11:19     ` Dmytro Maluka
2022-07-29 21:21   ` Liu, Rong L
2022-07-30 15:30     ` Dmytro Maluka
2022-08-02 18:47   ` Dmytro Maluka

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.