From: Marc Zyngier Date: Wed, 20 May 2026 10:02:00 +0000 (+0100) Subject: KVM: arm64: vgic-v2: Don't init the vgic on in-kernel interrupt injection X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=958023d269e0312d10da85a6a49438d2e107dead;p=thirdparty%2Fkernel%2Flinux.git KVM: arm64: vgic-v2: Don't init the vgic on in-kernel interrupt injection We now have the lazy init on three paths: - on first run of a vcpu - on first injection of an interrupt from userspace and irqfd - on first injection of an interrupt from kernel space as part of the device emulation (timers, PMU, vgic MI) Given that we recompute the state of each in-kernel interrupt every time we are about to enter the guest, we can drop the lazy init from the kernel injection path. This solves a bunch of issues related to vgic_lazy_init() being called in non-preemptible context, such as vcpu reset. Reviewed-by: Oliver Upton Link: https://patch.msgid.link/20260520100200.543845-7-maz@kernel.org Signed-off-by: Marc Zyngier --- diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c index 1e9fe8764584..9e29f03d3463 100644 --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -534,11 +534,9 @@ int kvm_vgic_inject_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, { struct vgic_irq *irq; unsigned long flags; - int ret; - ret = vgic_lazy_init(kvm); - if (ret) - return ret; + if (unlikely(!vgic_initialized(kvm))) + return 0; if (!vcpu && irq_is_private(kvm, intid)) return -EINVAL;