Skip to content

Commit 5c57533

Browse files
committed
KVM: arm64: vgic-v4: Fall back to software irqbypass if LPI not found
Continuing with the theme of broken VMMs and guests, irqbypass registration can fail if the virtual ITS lacks a translation for the MSI. Either the guest hasn't mapped it or userspace may have forgotten to restore the ITS. Exit silently and allow irqbypass configuration to succeed. As a reward for ingenuity, LPIs are demoted to software injection. Tested-by: Sudheer Dantuluri <dantuluris@google.com> Fixes: 196b136 ("KVM: arm/arm64: GICv4: Wire mapping/unmapping of VLPIs in VFIO irq bypass") Acked-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250226183124.82094-4-oliver.upton@linux.dev Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent d0b7956 commit 5c57533

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

arch/arm64/kvm/vgic/vgic-v4.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
415415
struct vgic_irq *irq;
416416
struct its_vlpi_map map;
417417
unsigned long flags;
418-
int ret;
418+
int ret = 0;
419419

420420
if (!vgic_supports_direct_msis(kvm))
421421
return 0;
@@ -430,10 +430,15 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
430430

431431
mutex_lock(&its->its_lock);
432432

433-
/* Perform the actual DevID/EventID -> LPI translation. */
434-
ret = vgic_its_resolve_lpi(kvm, its, irq_entry->msi.devid,
435-
irq_entry->msi.data, &irq);
436-
if (ret)
433+
/*
434+
* Perform the actual DevID/EventID -> LPI translation.
435+
*
436+
* Silently exit if translation fails as the guest (or userspace!) has
437+
* managed to do something stupid. Emulated LPI injection will still
438+
* work if the guest figures itself out at a later time.
439+
*/
440+
if (vgic_its_resolve_lpi(kvm, its, irq_entry->msi.devid,
441+
irq_entry->msi.data, &irq))
437442
goto out;
438443

439444
/* Silently exit if the vLPI is already mapped */

0 commit comments

Comments
 (0)