Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: vgic-v5: Hold config_lock while finalizing GICv5 PPIs

Finalizing the PPI state is done without holding any lock, which
means that two vcpus can race against each other and have one zeroing
the state while another one is setting it, or even maybe using it.

Fixing this is done by:

- holding the config lock while performing the initialisation

- checking if SW_PPI has already been advertised, meaning that
we have already completed the initialisation once

Reviewed-by: Sascha Bischoff <sascha.bischoff@arm.com>
Fixes: 8f1fbe2fd2792 ("KVM: arm64: gic-v5: Finalize GICv5 PPIs and generate mask")
Link: https://sashiko.dev/#/patchset/20260319154937.3619520-1-sascha.bischoff%40arm.com
Link: https://patch.msgid.link/20260401103611.357092-7-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>

+10
+10
arch/arm64/kvm/vgic/vgic-v5.c
··· 172 172 if (!vgic_is_v5(kvm)) 173 173 return 0; 174 174 175 + guard(mutex)(&kvm->arch.config_lock); 176 + 177 + /* 178 + * If SW_PPI has been advertised, then we know we already 179 + * initialised the whole thing, and we can return early. Yes, 180 + * this is pretty hackish as far as state tracking goes... 181 + */ 182 + if (test_bit(GICV5_ARCH_PPI_SW_PPI, kvm->arch.vgic.gicv5_vm.vgic_ppi_mask)) 183 + return 0; 184 + 175 185 /* The PPI state for all VCPUs should be the same. Pick the first. */ 176 186 vcpu0 = kvm_get_vcpu(kvm, 0); 177 187