]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.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)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 8 Jan 2013 21:09:03 +0000 (14:09 -0700)
commitb0223e29afdc88cc262a764026296414396cd129
treea46b52c27406ad7192e8dba21727cb749b4f6a6a
parent560c30b1db1d40fe45c5104185367c4de43399d3
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
hw/vfio_pci.c