]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: vgic-v5: Atomically assign bits to PPI DVI bitmap
authorSascha Bischoff <sascha.bischoff@arm.com>
Wed, 20 May 2026 09:19:42 +0000 (10:19 +0100)
committerMarc Zyngier <maz@kernel.org>
Sat, 23 May 2026 14:07:41 +0000 (15:07 +0100)
For GICv5 guests we make use of the DVI mechanism for PPIs where
possible.  When mapping a virtual irq to a physical one for a GICv5
guest, the corresponding bit in the DVI bitmap is set. When unmapping,
said bit is cleared again. The key user of this mechanism is the arch
timer.

The existing code used the non-atomic __assign_bit() rather than doing
the update atomically. This could technically result in losing state
if a second PPI's DVI bit were being manipulated concurrently. Each
individual bit within the DVI bitmap is guarded using
vgic_irq->irq_lock, but there's no locking for the overall
bitmap. Therefore, switch to using the atomic assign_bit() function
instead.

Fixes: 5a98d0e17e59 ("KVM: arm64: gic-v5: Implement direct injection of PPIs")
Link: https://sashiko.dev/#/patchset/20260319154937.3619520-1-sascha.bischoff%40arm.com
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
Link: https://lore.kernel.org/r/20260520091949.542365-12-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-v5.c

index 7916bd8d564ef62628ff2fe376fc6b8a69a0e321..d4789ff3e74026419fab82a78546d57621a0a18d 100644 (file)
@@ -272,7 +272,7 @@ void vgic_v5_set_ppi_dvi(struct kvm_vcpu *vcpu, struct vgic_irq *irq, bool dvi)
        lockdep_assert_held(&irq->irq_lock);
 
        ppi = vgic_v5_get_hwirq_id(irq->intid);
-       __assign_bit(ppi, cpu_if->vgic_ppi_dvir, dvi);
+       assign_bit(ppi, cpu_if->vgic_ppi_dvir, dvi);
 }
 
 static const struct irq_ops vgic_v5_ppi_irq_ops = {