[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230109201037.33051-3-mjrosato@linux.ibm.com>
Date: Mon, 9 Jan 2023 15:10:37 -0500
From: Matthew Rosato <mjrosato@...ux.ibm.com>
To: alex.williamson@...hat.com, pbonzini@...hat.com
Cc: jgg@...dia.com, cohuck@...hat.com, farman@...ux.ibm.com,
pmorel@...ux.ibm.com, borntraeger@...ux.ibm.com,
frankja@...ux.ibm.com, imbrenda@...ux.ibm.com, david@...hat.com,
akrowiak@...ux.ibm.com, jjherne@...ux.ibm.com, pasic@...ux.ibm.com,
zhenyuw@...ux.intel.com, zhi.a.wang@...el.com,
linux-s390@...r.kernel.org, kvm@...r.kernel.org,
intel-gvt-dev@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] KVM: s390: pci: use asyncronous kvm put
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@...ux.ibm.com>
---
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
Powered by blists - more mailing lists