aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/vfio/common.c3
-rw-r--r--hw/vfio/pci.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 3f0d111360..8728d4d5c2 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -783,7 +783,8 @@ static void vfio_register_ram_discard_listener(VFIOContainer *container,
section->mr);
g_assert(vrdl->granularity && is_power_of_2(vrdl->granularity));
- g_assert(vrdl->granularity >= 1 << ctz64(container->pgsizes));
+ g_assert(container->pgsizes &&
+ vrdl->granularity >= 1ULL << ctz64(container->pgsizes));
ram_discard_listener_init(&vrdl->listener,
vfio_ram_discard_notify_populate,
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index ab4077aad2..e1ea1d8a23 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1499,6 +1499,14 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
if (vdev->vendor_id == PCI_VENDOR_ID_CHELSIO &&
(vdev->device_id & 0xff00) == 0x5800) {
msix->pba_offset = 0x1000;
+ /*
+ * BAIDU KUNLUN Virtual Function devices for KUNLUN AI processor
+ * return an incorrect value of 0x460000 for the VF PBA offset while
+ * the BAR itself is only 0x10000. The correct value is 0xb400.
+ */
+ } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
+ PCI_DEVICE_ID_KUNLUN_VF)) {
+ msix->pba_offset = 0xb400;
} else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
error_setg(errp, "hardware reports invalid configuration, "
"MSIX PBA outside of specified BAR");
@@ -3058,14 +3066,14 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
}
}
- if (vdev->vendor_id == PCI_VENDOR_ID_NVIDIA) {
+ if (vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID)) {
ret = vfio_pci_nvidia_v100_ram_init(vdev, errp);
if (ret && ret != -ENODEV) {
error_report("Failed to setup NVIDIA V100 GPU RAM");
}
}
- if (vdev->vendor_id == PCI_VENDOR_ID_IBM) {
+ if (vfio_pci_is(vdev, PCI_VENDOR_ID_IBM, PCI_ANY_ID)) {
ret = vfio_pci_nvlink2_init(vdev, errp);
if (ret && ret != -ENODEV) {
error_report("Failed to setup NVlink2 bridge");