lkml.org 
[lkml]   [2023]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] KVM: s390: pci: use asyncronous kvm put
Date
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@linux.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
\
 
 \ /
  Last update: 2023-03-26 23:33    [W:0.062 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site