Skip to content

Commit

Permalink
vfio/pci: Clear MSI-X IRQ index always
Browse files Browse the repository at this point in the history
When doing device assignment of a physical device, MSI-X can be
enabled with no vectors enabled and this sets the IRQ index to
VFIO_PCI_MSIX_IRQ_INDEX. However, when MSI-X is disabled, the IRQ
index is left untouched if no vectors are in use. Then, when INTx
is enabled, the IRQ index value is considered incompatible (set to
MSI-X) and VFIO_DEVICE_SET_IRQS fails. QEMU complains with :

qemu-system-x86_64: vfio 0000:08:00.0: Failed to set up TRIGGER eventfd signaling for interrupt INTX-0: VFIO_DEVICE_SET_IRQS failure: Invalid argument

To avoid that, unconditionaly clear the IRQ index when MSI-X is
disabled.

Buglink: https://issues.redhat.com/browse/RHEL-21293
Fixes: 5ebffa4 ("vfio/pci: use an invalid fd to enable MSI-X")
Cc: Jing Liu <jing2.liu@intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
(cherry picked from commit d2b668f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
legoater authored and Michael Tokarev committed Jan 29, 2024
1 parent 106aa13 commit b79a2ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hw/vfio/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,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);
Expand Down

0 comments on commit b79a2ef

Please sign in to comment.