]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: vgic-v2: Don't init the vgic on in-kernel interrupt injection
authorMarc Zyngier <maz@kernel.org>
Wed, 20 May 2026 10:02:00 +0000 (11:02 +0100)
committerMarc Zyngier <maz@kernel.org>
Thu, 21 May 2026 07:09:22 +0000 (08:09 +0100)
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 <oupton@kernel.org>
Link: https://patch.msgid.link/20260520100200.543845-7-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic.c

index 1e9fe8764584de17c295f8b4fbca01617f8a4716..9e29f03d3463c06e43224db17af91a7aa9546676 100644 (file)
@@ -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;