Skip to content

Commit 2777a40

Browse files
Longfang Liuawilliam
authored andcommitted
hisi_acc_vfio_pci: bugfix live migration function without VF device driver
If the VF device driver is not loaded in the Guest OS and we attempt to perform device data migration, the address of the migrated data will be NULL. The live migration recovery operation on the destination side will access a null address value, which will cause access errors. Therefore, live migration of VMs without added VF device drivers does not require device data migration. In addition, when the queue address data obtained by the destination is empty, device queue recovery processing will not be performed. Fixes: b0eed08 ("hisi_acc_vfio_pci: Add support for VFIO live migration") Signed-off-by: Longfang Liu <liulongfang@huawei.com> Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Link: https://lore.kernel.org/r/20250510081155.55840-6-liulongfang@huawei.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent db6525a commit 2777a40

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,6 @@ static int vf_qm_check_match(struct hisi_acc_vf_core_device *hisi_acc_vdev,
426426
return -EINVAL;
427427
}
428428

429-
ret = qm_write_regs(vf_qm, QM_VF_STATE, &vf_data->vf_qm_state, 1);
430-
if (ret) {
431-
dev_err(dev, "failed to write QM_VF_STATE\n");
432-
return ret;
433-
}
434-
435-
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
436429
hisi_acc_vdev->match_done = true;
437430
return 0;
438431
}
@@ -498,6 +491,20 @@ static int vf_qm_load_data(struct hisi_acc_vf_core_device *hisi_acc_vdev,
498491
if (migf->total_length < sizeof(struct acc_vf_data))
499492
return -EINVAL;
500493

494+
if (!vf_data->eqe_dma || !vf_data->aeqe_dma ||
495+
!vf_data->sqc_dma || !vf_data->cqc_dma) {
496+
dev_info(dev, "resume dma addr is NULL!\n");
497+
hisi_acc_vdev->vf_qm_state = QM_NOT_READY;
498+
return 0;
499+
}
500+
501+
ret = qm_write_regs(qm, QM_VF_STATE, &vf_data->vf_qm_state, 1);
502+
if (ret) {
503+
dev_err(dev, "failed to write QM_VF_STATE\n");
504+
return -EINVAL;
505+
}
506+
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
507+
501508
qm->eqe_dma = vf_data->eqe_dma;
502509
qm->aeqe_dma = vf_data->aeqe_dma;
503510
qm->sqc_dma = vf_data->sqc_dma;
@@ -1531,6 +1538,7 @@ static int hisi_acc_vfio_pci_migrn_init_dev(struct vfio_device *core_vdev)
15311538
hisi_acc_vdev->vf_id = pci_iov_vf_id(pdev) + 1;
15321539
hisi_acc_vdev->pf_qm = pf_qm;
15331540
hisi_acc_vdev->vf_dev = pdev;
1541+
hisi_acc_vdev->vf_qm_state = QM_NOT_READY;
15341542
mutex_init(&hisi_acc_vdev->state_mutex);
15351543
mutex_init(&hisi_acc_vdev->open_mutex);
15361544

0 commit comments

Comments
 (0)