diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 4aa86f563c..059bfdc07a 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1118,7 +1118,7 @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, { uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + sizeof(struct vfio_device_feature_dma_logging_report), - sizeof(__u64))] = {}; + sizeof(uint64_t))] = {}; struct vfio_device_feature *feature = (struct vfio_device_feature *)buf; struct vfio_device_feature_dma_logging_report *report = (struct vfio_device_feature_dma_logging_report *)feature->data; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index d7fe06715c..4fa387f043 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -826,9 +826,11 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev) } } - if (vdev->nr_vectors) { - vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); - } + /* + * Always clear MSI-X IRQ index. A PF device could have enabled + * MSI-X with no vectors. See vfio_msix_enable(). + */ + vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); vfio_msi_disable_common(vdev); vfio_intx_enable(vdev, &err);