Hi,
In a recent discussion [1], an unsafe locking pattern was discovered.
Initially, it was believed that the locking issue is related to calling
copy_from_user()/copy_to_user() under state_mutex [2], but it turns out
that it's a generic issue that has impact on all drivers that are not
implementing a "deferred reset".
This is a first attempt to simplify the migration device state locking,
following a suggestion from Jason to try and solve the issue on core
side rather than duplicating deferred reset in all of the drivers.
Introduce a dedicated .migration_reset_state() callback called outside
vdev->memory_lock to break the locking dependency chain and convert all
of the drivers to use it.
[1] https://lore.kernel.org/intel-xe/7dtl5qum4mfgjosj2mkfqu5u5tu7p2roi2et3env4lhrccmiqi@asemffaeeflr/
[2] https://lore.kernel.org/kvm/20240220132459.GM13330@nvidia.com/
Michał Winiarski (6):
vfio: Introduce .migration_reset_state() callback
hisi_acc_vfio_pci: Use .migration_reset_state() callback
vfio/pds: Use .migration_reset_state() callback
vfio/qat: Use .migration_reset_state() callback
vfio/mlx5: Use .migration_reset_state() callback
vfio/virtio: Use .migration_reset_state() callback
.../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 7 +-
drivers/vfio/pci/mlx5/cmd.c | 15 ++--
drivers/vfio/pci/mlx5/cmd.h | 3 -
drivers/vfio/pci/mlx5/main.c | 59 ++++-----------
drivers/vfio/pci/pds/pci_drv.c | 10 ---
drivers/vfio/pci/pds/vfio_dev.c | 12 ++++
drivers/vfio/pci/qat/main.c | 36 +++++-----
drivers/vfio/pci/vfio_pci_core.c | 25 ++++++-
drivers/vfio/pci/virtio/common.h | 3 -
drivers/vfio/pci/virtio/main.c | 1 -
drivers/vfio/pci/virtio/migrate.c | 71 ++++++-------------
include/linux/vfio.h | 4 ++
12 files changed, 101 insertions(+), 145 deletions(-)
--
2.51.2