In the scenario combining QM_HW_V3 hardware with 64KB large pages, the device functional region and migration registers share the BAR2 physical page, resulting in a lack of isolation that triggers security issues. More critically, since KVM does not support the specific 16-byte read/write instructions used by the guest driver, operating under the KVM emulated device scheme will lead to Guest kernel calltrace issues. To prevent Guest exceptions and avoid security vulnerabilities, the driver directly disables live migration functionality in this scenario. This ensures the system fails cleanly with an error early during startup, while other configuration modes remain unaffected and can still utilize passthrough functionality normally. Fixes: b0eed085903e ("hisi_acc_vfio_pci: Add support for VFIO live migration") Signed-off-by: Longfang Liu --- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c index e95d0ab0f11a..4e845474fa90 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -1208,6 +1208,23 @@ static int hisi_acc_vf_qm_init(struct hisi_acc_vf_core_device *hisi_acc_vdev) else hisi_acc_vdev->drv_mode = HW_ACC_MIG_VF_CTRL; + /* + * On VF_CTRL hardware, BAR2 holds 32KB functional + 32KB + * migration registers. When the host page exceeds 32KB, the + * two share one physical page and cannot be isolated by mmap. + * Reject the open so QEMU fails cleanly at startup. + */ + if (hisi_acc_vdev->drv_mode == HW_ACC_MIG_VF_CTRL) { + resource_size_t func_len = + pci_resource_len(vf_dev, VFIO_PCI_BAR2_REGION_INDEX) >> 1; + + if (func_len < PAGE_SIZE) { + dev_err(&vf_dev->dev, + "migration not supported on 64KB pages with QM_HW_V3\n"); + return -EINVAL; + } + } + if (hisi_acc_vdev->drv_mode == HW_ACC_MIG_PF_CTRL) { /* * On hardware platforms greater than QM_HW_V3, the migration function -- 2.43.0