[PATCH 2/2] KVM: s390: pci: use asyncronous kvm put

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's possible that the kvm refcount will reach 0 at this point while the
associated device is still in kvm device list - this would result in a
deadlock on the vfio group lock.  Avoid this possibility by using
kvm_put_kvm_async to do the kvm_destroy_vm asynchronously.

Fixes: 09340b2fca00 ("KVM: s390: pci: add routines to start/stop interpretive execution")
Signed-off-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxx>
---
 arch/s390/kvm/pci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index ec51e810e381..d1d528438138 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -509,7 +509,7 @@ static int kvm_s390_pci_register_kvm(void *opaque, struct kvm *kvm)
 		kvm_s390_pci_dev_release(zdev);
 	mutex_unlock(&kvm->lock);
 	mutex_unlock(&zdev->kzdev_lock);
-	kvm_put_kvm(kvm);
+	kvm_put_kvm_async(kvm);
 	return rc;
 }
 
@@ -567,7 +567,11 @@ static void kvm_s390_pci_unregister_kvm(void *opaque)
 	mutex_unlock(&kvm->lock);
 	mutex_unlock(&zdev->kzdev_lock);
 
-	kvm_put_kvm(kvm);
+	/*
+	 * Avoid possible deadlock on any currently-held vfio lock by
+	 * ensuring the potential kvm_destroy_vm call is done asynchronously
+	 */
+	kvm_put_kvm_async(kvm);
 }
 
 void kvm_s390_pci_init_list(struct kvm *kvm)
-- 
2.39.0




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux