FROMLIST: KVM: arm64: vgic: Explicitly implement vgic_dist::ready ordering

In preparation to remove synchronize_srcu() from MMIO registration,
remove the distributor's dependency on this implicit barrier by
direct acquire-release synchronization on the flag write and its
lock-free check.

Bug: 395485007
Bug: 357781595
Link: https://lore.kernel.org/all/20250624092256.1105524-3-keirf@google.com/

Change-Id: Id23675e275d78a387d5cb884c4c7da9a5aefe7fe
Signed-off-by: Keir Fraser <keirf@google.com>
This commit is contained in:
Keir Fraser
2025-06-30 09:37:03 +00:00
parent d6045efc66
commit 4be05c6524

View File

@@ -521,7 +521,7 @@ int kvm_vgic_map_resources(struct kvm *kvm)
gpa_t dist_base;
int ret = 0;
if (likely(dist->ready))
if (likely(smp_load_acquire(&dist->ready)))
return 0;
mutex_lock(&kvm->slots_lock);
@@ -552,14 +552,7 @@ int kvm_vgic_map_resources(struct kvm *kvm)
goto out_slots;
}
/*
* kvm_io_bus_register_dev() guarantees all readers see the new MMIO
* registration before returning through synchronize_srcu(), which also
* implies a full memory barrier. As such, marking the distributor as
* 'ready' here is guaranteed to be ordered after all vCPUs having seen
* a completely configured distributor.
*/
dist->ready = true;
smp_store_release(&dist->ready, true);
goto out_slots;
out:
mutex_unlock(&kvm->arch.config_lock);