If vgic_v4_load() is called to schedule GICv4 on a vCPU at the same time that kvm_vgic_enable_vcpu_vlpi() is called to enable vLPI direct injection on the vCPU, vgic_v4_load() will attempt to map the vCPU's doorbell IRQ to the physical processor while kvm_vgic_enable_vcpu_vlpi() is still creating the doorbell IRQ.
This race will cause vgic_v4_load()'s mapping operation to fail, triggering a WARN_ON in vgic_v3_load().
Fix by checking for the presence of a doorbell IRQ before attempting to load GICv4. Remove WARN_ON to remove verbosity of GICv4 load failures resulting from this race; failure to load GICv4 is not breaking behavior.
Signed-off-by: Maximilian Dittgen mdittgen@amazon.com --- arch/arm64/kvm/vgic/vgic-v3.c | 2 +- arch/arm64/kvm/vgic/vgic-v4.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 842a3a50f3a2..ffaf692399fd 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -995,7 +995,7 @@ void vgic_v3_load(struct kvm_vcpu *vcpu) if (has_vhe()) __vgic_v3_activate_traps(cpu_if);
- WARN_ON(vgic_v4_load(vcpu)); + vgic_v4_load(vcpu); }
void vgic_v3_put(struct kvm_vcpu *vcpu) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index efb9ac9188e3..0affcfca17f0 100644 --- a/arch/arm64/kvm/vgic/vgic-v4.c +++ b/arch/arm64/kvm/vgic/vgic-v4.c @@ -454,6 +454,7 @@ int vgic_v4_load(struct kvm_vcpu *vcpu)
if (!vgic_supports_direct_irqs(vcpu->kvm) || !vpe->its_vm || + !vpe->irq || /* check if irq has been allocated yet */ vpe->resident) return 0;