[PATCH v3 0/3] LoongArch: KVM: Harden interrupt injection

From: Bibo Mao

Date: Sun Jun 28 2026 - 22:33:06 EST


API kvm_vcpu_ioctl_interrupt() is mainly to used to deliver interrupt
from user mode, and internal APIs kvm_queue_irq() and kvm_dequeue_irq()
are used in kernel mode, also moves IPI interrupt handling within lock
protection.

Also this patch replaces kvm_err() with WARN_ONCE() to avoid noise
kernel log.

---
v2 ... v3:
1. Split the patches into three smaller ones, the first patch removes
old default case and kvm_err() since it is impossible to happen.
And the second patch replaces kvm_err() with WARN_ONCE().

v1 ... v2:
1. Add border check with ipnum in eiointc_set_sw_coreisr() and
eiointc_update_irq(), so that injected interrupt vector is valid.

2. Move IPI inject and ack within lock to avoid contention in
ipi_set() and ipi_clear().

3. Add kvm_arch_irqchip_in_kernel() check in user mode irq injection
in function kvm_vcpu_ioctl_interrupt(), contention of user mode irq
injection is assured from user mode VMM.
---
Bibo Mao (3):
LoongArch: KVM: Set default MAILBOX access size with 8
LoongArch: KVM: Replace kvm_err() with WARN_ONCE()
LoongArch: KVM: Use internal API to deliver interrupt in kernel mode

arch/loongarch/kvm/exit.c | 15 ++++-----
arch/loongarch/kvm/intc/dmsintc.c | 15 +++++----
arch/loongarch/kvm/intc/eiointc.c | 32 ++++++++++--------
arch/loongarch/kvm/intc/ipi.c | 55 ++++++++++++++-----------------
arch/loongarch/kvm/intc/pch_pic.c | 12 +++----
arch/loongarch/kvm/vcpu.c | 5 ++-
6 files changed, 67 insertions(+), 67 deletions(-)


base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
--
2.39.3