KVM: arm64: Fix circular locking dependency
authorSebastian Ene <sebastianene@google.com>
Wed, 24 Jan 2024 09:10:28 +0000 (09:10 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 30 Jan 2024 21:30:33 +0000 (21:30 +0000)
commit10c02aad111df02088d1a81792a709f6a7eca6cc
tree3e7d7c00ac8cf8304d77a10c5ed51c3ad31c816c
parent6613476e225e090cc9aad49be7fa504e290dd33d
KVM: arm64: Fix circular locking dependency

The rule inside kvm enforces that the vcpu->mutex is taken *inside*
kvm->lock. The rule is violated by the pkvm_create_hyp_vm() which acquires
the kvm->lock while already holding the vcpu->mutex lock from
kvm_vcpu_ioctl(). Avoid the circular locking dependency altogether by
protecting the hyp vm handle with the config_lock, much like we already
do for other forms of VM-scoped data.

Signed-off-by: Sebastian Ene <sebastianene@google.com>
Cc: stable@vger.kernel.org
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20240124091027.1477174-2-sebastianene@google.com
arch/arm64/kvm/pkvm.c