virt inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9JPHZ CVE: NA
----------------------------------------------------------------------
When the address information of the migrated data is NULL, an exception log is returned and the migration operation exits.
In addition, the status processing during Pre_COPY in DFX is supplemented.
Signed-off-by: Longfang Liu liulongfang@huawei.com Signed-off-by: JangShui Yang yangjiangshui@h-partners.com --- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 23 ++++++++++++++++++- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c index 3304d921bf64..8bfd75865c99 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -336,8 +336,9 @@ static int vf_qm_check_match(struct hisi_acc_vf_core_device *hisi_acc_vdev, if (hisi_acc_vdev->match_done) return 0;
+ /* Transmission not completed yet */ if (migf->total_length < QM_MATCH_SIZE) - return -EINVAL; + return 0;
if (vf_data->acc_magic != ACC_DEV_MAGIC) { dev_err(dev, "failed to match ACC_DEV_MAGIC\n"); @@ -453,6 +454,12 @@ static int vf_qm_load_data(struct hisi_acc_vf_core_device *hisi_acc_vdev, qm->qp_base = vf_data->qp_base; qm->qp_num = vf_data->qp_num;
+ if (!vf_data->eqe_dma || !vf_data->aeqe_dma || + !vf_data->sqc_dma || !vf_data->cqc_dma) { + dev_err(dev, "resume dma addr is NULL!\n"); + return -EINVAL; + } + ret = qm_set_regs(qm, vf_data); if (ret) { dev_err(dev, "set VF regs failed\n"); @@ -1432,6 +1439,12 @@ static int acc_vf_debug_resume(struct hisi_acc_vf_core_device *hisi_acc_vdev) struct device *dev = &hisi_acc_vdev->vf_dev->dev; int ret;
+ ret = vf_qm_get_match_data(hisi_acc_vdev, &migf->vf_data); + if (ret) { + dev_err(dev, "failed to save match data!\n"); + return -EINVAL; + } + ret = vf_qm_state_save(hisi_acc_vdev, migf); if (ret) { dev_err(dev, "failed to save device data!\n"); @@ -1550,6 +1563,14 @@ static ssize_t acc_vf_state_read(struct file *filp, char __user *buffer, len = scnprintf(buf, VFIO_DEV_DBG_LEN, "%s\n", "STOP and COPYING\n"); break; + case VFIO_DEVICE_STATE_PRE_COPY: + len = scnprintf(buf, VFIO_DEV_DBG_LEN, "%s\n", + "Prepare COPYING\n"); + break; + case VFIO_DEVICE_STATE_PRE_COPY_P2P: + len = scnprintf(buf, VFIO_DEV_DBG_LEN, "%s\n", + "Prepare P2P COPYING\n"); + break; case VFIO_DEVICE_STATE_STOP: len = scnprintf(buf, VFIO_DEV_DBG_LEN, "%s\n", "STOP\n"); diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h index e7d2ffc3d598..c1e691b4bfbb 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h @@ -76,6 +76,9 @@ static const char * const vf_dev_state[] = { "Running", "Stop & Copying", "Resuming", + "Running_P2P", + "Pre_Copy", + "Pre_Copy_P2P", };
struct acc_vf_data {