]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: arm64: vgic: Don't hold config_lock while unregistering redistributors
authorMarc Zyngier <maz@kernel.org>
Mon, 19 Aug 2024 12:50:45 +0000 (13:50 +0100)
committerOliver Upton <oliver.upton@linux.dev>
Mon, 19 Aug 2024 17:05:21 +0000 (17:05 +0000)
commitf616506754d34bcfdbfbc7508b562e5c98461e9a
treefa8351befcedb97c02adf9e4c0803652b7fa14cc
parent2240a50e6294214de791729e9dcba6880fa7e44e
KVM: arm64: vgic: Don't hold config_lock while unregistering redistributors

We recently moved the teardown of the vgic part of a vcpu inside
a critical section guarded by the config_lock. This teardown phase
involves calling into kvm_io_bus_unregister_dev(), which takes the
kvm->srcu lock.

However, this violates the established order where kvm->srcu is
taken on a memory fault (such as an MMIO access), possibly
followed by taking the config_lock if the GIC emulation requires
mutual exclusion from the other vcpus.

It therefore results in a bad lockdep splat, as reported by Zenghui.

Fix this by moving the call to kvm_io_bus_unregister_dev() outside
of the config_lock critical section. At this stage, there shouln't
be any need to hold the config_lock.

As an additional bonus, document the ordering between kvm->slots_lock,
kvm->srcu and kvm->arch.config_lock so that I cannot pretend I didn't
know about those anymore.

Fixes: 9eb18136af9f ("KVM: arm64: vgic: Hold config_lock while tearing down a CPU interface")
Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Tested-by: Zenghui Yu <yuzenghui@huawei.com>
Link: https://lore.kernel.org/r/20240819125045.3474845-1-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/vgic/vgic-init.c
arch/arm64/kvm/vgic/vgic.c