KVM: arm64: GICv2: Don't WARN on out-of-range GICV_DIR INTID
Subsystems (3)
PATCH v2 1/1 KVM: arm64: GICv2: Don't WARN on out-of-range GICV_DIR INTID
vgic_v2_deactivate() passes the INTID a guest wrote to GICV_DIR straight to vgic_get_vcpu_irq(), and treats a failed lookup as a "can't happen" condition with WARN_ON_ONCE().
The guest can make it happen at will, though: for any INTID outside of the implemented SGI, PPI and SPI ranges the lookup returns NULL, since GICv2 has no LPIs. A guest running with EOImode==1 writing such an INTID to GICV_DIR triggers the WARN, and panics hosts running with panic_on_warn.
Drop the WARN and ignore failed lookups.
---
v2:
- Drop the WARN_ON_ONCE() instead of bounding the INTID before the lookup, which duplicated the range check vgic_get_irq() already performs (Marc)
- Retitled; was "KVM: arm64: GICv2: Bound the INTID in vgic_v2_deactivate()"
Link to v1: https://lore.kernel.org/r/[email protected]
arch/arm64/kvm/vgic/vgic-v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kvm/vgic/vgic-v2.c +2 -1
@@ -170,8 +170,9 @@ void vgic_v2_deactivate(struct kvm_vcpu *vcpu, u32 val)/* Make sure we're in the same context as LR handling */ local_irq_save (flags); +/* Guest-supplied INTID: out of range yields no irq, so ignore it */ irq =vgic_get_vcpu_irq (vcpu, val); -if (WARN_ON_ONCE (!irq)) +if (!irq) goto out;/* See the corresponding v3 code for the rationale */
Signature · 1 line
2.51.0
Quoted 11 lines · Karl Mehltretter
vgic_v2_deactivate()passes the INTID a guest wrote toGICV_DIRstraight tovgic_get_vcpu_irq(), and treats a failed lookup as a "can't happen" condition withWARN_ON_ONCE().The guest can make it happen at will, though: for any INTID outside of the implemented SGI, PPI and SPI ranges the lookup returns NULL, since GICv2 has no LPIs. A guest running with EOImode==1 writing such an INTID to
GICV_DIRtriggers the WARN, and panics hosts running withpanic_on_warn.[...]
Applied to next, thanks!
[1/1] KVM: arm64: GICv2: Don't WARN on out-of-range GICV_DIR INTID
https://git.kernel.org/kvmarm/kvmarm/c/c6d9c8ac6521
--
Best,
Oliver