[PATCH] KVM: arm64: vgic: Don't hold config_lock while unregistering redistributors
Zenghui Yu
yuzenghui at huawei.com
Mon Aug 19 08:20:37 PDT 2024
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 at huawei.com>
> Signed-off-by: Marc Zyngier <maz at kernel.org>
Reviewed-by: Zenghui Yu <yuzenghui at huawei.com>
Tested-by: Zenghui Yu <yuzenghui at huawei.com>
Thanks,
Zenghui
More information about the linux-arm-kernel
mailing list