]> git.hungrycats.org Git - linux/commit
vfio/virtio: Convert list_lock from spinlock to mutex
authorAlex Williamson <alex.williamson@nvidia.com>
Tue, 14 Apr 2026 20:06:19 +0000 (14:06 -0600)
committerAlex Williamson <alex@shazbot.org>
Tue, 21 Apr 2026 18:01:20 +0000 (12:01 -0600)
commit903570835f12b7436ca0edb0a9ed351c0349121e
tree40ef53dd539f05fd702a0f1788cc2c8d51b83506
parentd97708701434ce72968e771976aaf9d3438fcafd
vfio/virtio: Convert list_lock from spinlock to mutex

The list_lock spinlock with IRQ disabling was copied from the mlx5
vfio-pci variant driver, where it is justified by a hardirq async
command completion callback that accesses the protected lists.  The
virtio driver has no such interrupt context usage; all list_lock
acquisitions occur in process context via file read/write operations
or state transitions under state_mutex.

Convert list_lock to a mutex to be consistent with peer vfio-pci
variant drivers (hisilicon, pds, qat, xe) which all use mutexes for
equivalent migration data protection.  This also fixes a mismatched
spin_lock()/spin_unlock_irq() pair in virtiovf_read_device_context_chunk()
that could incorrectly enable interrupts.

Reported-by: Jinhui Guo <guojinhui.liam@bytedance.com>
Closes: https://lore.kernel.org/all/20260413073603.30538-1-guojinhui.liam@bytedance.com
Fixes: 0bbc82e4ec79 ("vfio/virtio: Add support for the basic live migration functionality")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Alex Williamson <alex.williamson@nvidia.com>
Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/20260414200625.3601509-2-alex.williamson@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
drivers/vfio/pci/virtio/common.h
drivers/vfio/pci/virtio/migrate.c