]> git.proxmox.com Git - qemu.git/commitdiff
vfio-pci: Fix multifunction=on
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 12 Nov 2013 18:53:24 +0000 (11:53 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 21 Nov 2013 16:39:04 +0000 (17:39 +0100)
When an assigned device is initialized it copies the device config
space into the emulated config space.  Unfortunately multifunction is
setup prior to the device initfn and gets clobbered.  We need to
restore it just like pci-assign does.

Cc: qemu-stable@nongnu.org
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/misc/vfio.c

index fe95e03d1d7d4ad906371370236025f6d2d354d0..f7f8a19ee8b0127b758d03ada9499e564aa091f5 100644 (file)
@@ -3568,6 +3568,13 @@ static int vfio_initfn(PCIDevice *pdev)
     vdev->emulated_config_bits[PCI_HEADER_TYPE] =
                                               PCI_HEADER_TYPE_MULTI_FUNCTION;
 
+    /* Restore or clear multifunction, this is always controlled by QEMU */
+    if (vdev->pdev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
+        vdev->pdev.config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;
+    } else {
+        vdev->pdev.config[PCI_HEADER_TYPE] &= ~PCI_HEADER_TYPE_MULTI_FUNCTION;
+    }
+
     /*
      * Clear host resource mapping info.  If we choose not to register a
      * BAR, such as might be the case with the option ROM, we can get