mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 01:08:13 -04:00
KVM: s390: vsie: Avoid potential deadlock with real spaces
The natural lock ordering is mmu_lock -> children_lock, but in
gmap_create_shadow() the reverse order is used when handling shadowing
of real address spaces.
Convert the inner locking of kvm->mmu_lock to a trylock; return -EAGAIN
if the lock is busy, and let the caller try again.
This path is not expected to happen in real-life scenarios, so its
performance is not important.
Fixes: a2c17f9270 ("KVM: s390: New gmap code")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
This commit is contained in:
committed by
Christian Borntraeger
parent
7b69729046
commit
866d03de6d
@@ -1374,8 +1374,13 @@ struct gmap *gmap_create_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *pare
|
||||
/* Only allow one real-space gmap shadow. */
|
||||
list_for_each_entry(sg, &parent->children, list) {
|
||||
if (sg->guest_asce.r) {
|
||||
scoped_guard(write_lock, &parent->kvm->mmu_lock)
|
||||
if (write_trylock(&parent->kvm->mmu_lock)) {
|
||||
gmap_unshadow(sg);
|
||||
write_unlock(&parent->kvm->mmu_lock);
|
||||
} else {
|
||||
gmap_put(new);
|
||||
return ERR_PTR(-EAGAIN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user