Files
lkl_linux/include/linux
Matthew Rosato 2b48f52f2b vfio: fix deadlock between group lock and kvm lock
After 51cdc8bc12, we have another deadlock scenario between the
kvm->lock and the vfio group_lock with two different codepaths acquiring
the locks in different order.  Specifically in vfio_open_device, vfio
holds the vfio group_lock when issuing device->ops->open_device but some
drivers (like vfio-ap) need to acquire kvm->lock during their open_device
routine;  Meanwhile, kvm_vfio_release will acquire the kvm->lock first
before calling vfio_file_set_kvm which will acquire the vfio group_lock.

To resolve this, let's remove the need for the vfio group_lock from the
kvm_vfio_release codepath.  This is done by introducing a new spinlock to
protect modifications to the vfio group kvm pointer, and acquiring a kvm
ref from within vfio while holding this spinlock, with the reference held
until the last close for the device in question.

Fixes: 51cdc8bc12 ("kvm/vfio: Fix potential deadlock on vfio group_lock")
Reported-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Tested-by: Tony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20230203215027.151988-2-mjrosato@linux.ibm.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2023-02-09 11:41:25 -07:00
..
2022-10-27 13:23:43 +02:00
2022-11-04 12:59:25 +02:00
2022-12-11 21:25:58 +01:00
2023-01-04 14:43:27 -07:00
2022-12-07 09:43:12 -07:00
2022-12-02 18:12:40 +08:00
2022-11-18 09:14:10 +01:00
2022-12-11 18:12:17 -08:00
2022-10-20 10:13:30 +02:00
2022-10-24 12:30:26 +03:00
2022-11-11 18:18:05 -08:00
2022-11-29 09:09:17 +11:00
2022-11-15 00:42:02 -08:00
2022-12-11 19:30:20 -08:00
2022-11-09 19:28:49 -08:00
2022-10-16 17:58:54 -05:00
2023-01-04 14:44:13 -07:00
2022-10-20 10:13:30 +02:00
2022-12-20 03:13:45 +01:00
2022-10-23 18:06:54 -04:00
2022-10-21 10:11:00 -07:00
2022-12-09 19:47:41 -08:00
2022-11-29 15:00:06 -08:00
2022-12-11 18:12:19 -08:00
2022-12-10 13:36:05 -05:00
2022-10-24 12:12:32 -07:00