Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 196b136498b3 ("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>

+10 -5
+10 -5
arch/arm64/kvm/vgic/vgic-v4.c
··· 415 415 struct vgic_irq *irq; 416 416 struct its_vlpi_map map; 417 417 unsigned long flags; 418 - int ret; 418 + int ret = 0; 419 419 420 420 if (!vgic_supports_direct_msis(kvm)) 421 421 return 0; ··· 430 430 431 431 mutex_lock(&its->its_lock); 432 432 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)) 437 442 goto out; 438 443 439 444 /* Silently exit if the vLPI is already mapped */