public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] vfio/virtio: Fix list_lock type and modernize locking
@ 2026-04-14 20:06 Alex Williamson
  2026-04-14 20:06 ` [PATCH 1/4] vfio/virtio: Convert list_lock from spinlock to mutex Alex Williamson
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Alex Williamson @ 2026-04-14 20:06 UTC (permalink / raw)
  To: alex
  Cc: Alex Williamson, yishaih, kvm, guojinhui.liam, linux-kernel,
	virtualization

Jinhui Guo reported a mismatched spin_lock()/spin_unlock_irq() pair
in virtiovf_read_device_context_chunk() where spin_unlock_irq() would
unconditionally enable interrupts despite spin_lock() never having
disabled them.  On closer inspection, the list_lock spinlock with IRQ
disabling was copied from the mlx5 variant driver where a hardirq
completion callback justifies it, but the virtio driver has no
interrupt context usage of list_lock.  Patch 1 converts list_lock to
a mutex, fixing the mismatch and aligning with peer vfio-pci variant
drivers.                                                                                                                                                    
Patch 2 converts the list_lock acquisitions to guard()/scoped_guard()
where the lock scope aligns naturally with function or block scope.

Patches 3 and 4 extend the same guard() conversion to the remaining
two mutexes in the driver (migf->lock and bar_mutex).  These are
relatively independent of the list_lock fix but complete the
conversion across the driver.  Thanks,

Alex

Alex Williamson (4):
  vfio/virtio: Convert list_lock from spinlock to mutex
  vfio/virtio: Use guard() for list_lock where applicable
  vfio/virtio: Use guard() for migf->lock where applicable
  vfio/virtio: Use guard() for bar_mutex in legacy I/O

 drivers/vfio/pci/virtio/common.h    |  2 +-
 drivers/vfio/pci/virtio/legacy_io.c | 17 +++---
 drivers/vfio/pci/virtio/migrate.c   | 90 ++++++++++++-----------------
 3 files changed, 46 insertions(+), 63 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-15 17:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 20:06 [PATCH 0/4] vfio/virtio: Fix list_lock type and modernize locking Alex Williamson
2026-04-14 20:06 ` [PATCH 1/4] vfio/virtio: Convert list_lock from spinlock to mutex Alex Williamson
2026-04-14 20:06 ` [PATCH 2/4] vfio/virtio: Use guard() for list_lock where applicable Alex Williamson
2026-04-14 20:06 ` [PATCH 3/4] vfio/virtio: Use guard() for migf->lock " Alex Williamson
2026-04-14 20:06 ` [PATCH 4/4] vfio/virtio: Use guard() for bar_mutex in legacy I/O Alex Williamson
2026-04-15 15:12 ` [PATCH 0/4] vfio/virtio: Fix list_lock type and modernize locking Yishai Hadas
2026-04-15 15:39   ` Alex Williamson
2026-04-15 17:23     ` Yishai Hadas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox