]> git.proxmox.com Git - qemu.git/commit
vfio-pci: Make host MSI-X enable track guest
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 8 Jan 2013 21:09:03 +0000 (14:09 -0700)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 16 Jan 2013 05:05:44 +0000 (23:05 -0600)
commitf042cca009607d4571cbe87323967535fe63daf7
treec858231af6b2dd79e972d69b6e555354b5d5317e
parent1205b8080fb596ce50b2dc0466587c012d9f979d
vfio-pci: Make host MSI-X enable track guest

Guests typically enable MSI-X with all of the vectors in the MSI-X
vector table masked.  Only when the vector is enabled does the vector
get unmasked, resulting in a vector_use callback.  These two points,
enable and unmask, correspond to pci_enable_msix() and request_irq()
for Linux guests.  Some drivers rely on VF/PF or PF/fw communication
channels that expect the physical state of the device to match the
guest visible state of the device.  They don't appreciate lazily
enabling MSI-X on the physical device.

To solve this, enable MSI-X with a single vector when the MSI-X
capability is enabled and immediate disable the vector.  This leaves
the physical device in exactly the same state between host and guest.
Furthermore, the brief gap where we enable vector 0, it fires into
userspace, not KVM, so the guest doesn't get spurious interrupts.
Ideally we could call VFIO_DEVICE_SET_IRQS with the right parameters
to enable MSI-X with zero vectors, but this will currently return an
error as the Linux MSI-X interfaces do not allow it.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-stable@nongnu.org
(cherry picked from commit b0223e29afdc88cc262a764026296414396cd129)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/vfio_pci.c