On 2024/8/19 20:50, Marc Zyngier wrote: > 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@xxxxxxxxxx> > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> Reviewed-by: Zenghui Yu <yuzenghui@xxxxxxxxxx> Tested-by: Zenghui Yu <yuzenghui@xxxxxxxxxx> Thanks, Zenghui