]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vfio/pci: Add virtual capabilities quirk infrastructure
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 29 Aug 2017 22:05:39 +0000 (16:05 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 3 Oct 2017 18:57:36 +0000 (12:57 -0600)
If the hypervisor needs to add purely virtual capabilties, give us a
hook through quirks to do that.  Note that we determine the maximum
size for a capability based on the physical device, if we insert a
virtual capability, that can change.  Therefore if maximum size is
smaller after added virt capabilities, use that.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/pci-quirks.c
hw/vfio/pci.c
hw/vfio/pci.h

index 349085ea12bc3c9591c666acea1b41e19c73e9d0..40aaae76feb9e6f895766e30dc6d825d44c300a9 100644 (file)
@@ -1850,3 +1850,7 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev)
         break;
     }
 }
+int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp)
+{
+    return 0;
+}
index 916d365dfab3fc776b34081a9ba9c60b5d6d1c2c..bfeaaef22d00d4737c9d9db695e81b87f902ae30 100644 (file)
@@ -1833,8 +1833,16 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp)
         pdev->config[PCI_CAPABILITY_LIST] = 0;
         vdev->emulated_config_bits[PCI_CAPABILITY_LIST] = 0xff;
         vdev->emulated_config_bits[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
+
+        ret = vfio_add_virt_caps(vdev, errp);
+        if (ret) {
+            return ret;
+        }
     }
 
+    /* Scale down size, esp in case virt caps were added above */
+    size = MIN(size, vfio_std_cap_max_size(pdev, pos));
+
     /* Use emulated next pointer to allow dropping caps */
     pci_set_byte(vdev->emulated_config_bits + pos + PCI_CAP_LIST_NEXT, 0xff);
 
index a8366bb2a74a888f9743a4f4c0294bbf47bd9afe..958cee058b3b60a2f817ceff2227a66c8fc5d4c4 100644 (file)
@@ -160,6 +160,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr);
 void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr);
 void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr);
 void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
+int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp);
 
 int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp);