]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: arm64: Ensure vgic_ready() is ordered against MMIO registration
authorOliver Upton <oliver.upton@linux.dev>
Thu, 17 Oct 2024 00:19:47 +0000 (00:19 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 17 Oct 2024 08:20:48 +0000 (09:20 +0100)
commit78a00555550042ed77b33ace7423aced228b3b4e
tree8132862d90ddb1bd02c26923f610d15a38e88d90
parent5978d4ec7e82ffc472ac2645601dd10b09e61b0f
KVM: arm64: Ensure vgic_ready() is ordered against MMIO registration

kvm_vgic_map_resources() prematurely marks the distributor as 'ready',
potentially allowing vCPUs to enter the guest before the distributor's
MMIO registration has been made visible.

Plug the race by marking the distributor as ready only after MMIO
registration is completed. Rely on the implied ordering of
synchronize_srcu() to ensure the MMIO registration is visible before
vgic_dist::ready. This also means that writers to vgic_dist::ready are
now serialized by the slots_lock, which was effectively the case already
as all writers held the slots_lock in addition to the config_lock.

Fixes: 59112e9c390b ("KVM: arm64: vgic: Fix a circular locking issue")
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20241017001947.2707312-3-oliver.upton@linux.dev
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-init.c