hw/vfio: Move the IGD quirk code to a separate file
PATCH 1/1 hw/vfio: Move the IGD quirk code to a separate file
The IGD quirk code defines a separate device, the so-called "vfio-pci-igd-lpc-bridge" which shows up as a user-creatable device in all QEMU binaries that include the vfio code. This is a little bit unfortunate for two reasons: First, this device is completely useless in binaries like qemu-system-s390x. Second we also would like to disable it in downstream RHEL which currently requires some extra patches there since the device does not have a proper Kconfig-style switch yet.
So it would be good if the device could be disabled more easily, thus let's move the code to a separate file instead and introduce a proper Kconfig switch for it which gets only enabled by default if we also have CONFIG_PC_PCI enabled.
--- hw/vfio/Kconfig | 5 + hw/vfio/Makefile.objs | 1 + hw/vfio/igd.c | 616 ++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 614 +---------------------------------------- hw/vfio/pci.h | 17 ++ 5 files changed, 642 insertions(+), 611 deletions(-) create mode 100644 hw/vfio/igd.c
hw/vfio/Kconfig +5 -0
@@ -36,3 +36,8 @@ config VFIO_AP default y select VFIO depends on LINUX && S390_CCW_VIRTIO + +config VFIO_IGD + bool + default y if PC_PCI + depends on VFIO_PCI
hw/vfio/Makefile.objs +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_VFIO_PLATFORM) += platform.o obj-$(CONFIG_VFIO_XGMAC) += calxeda-xgmac.o obj-$(CONFIG_VFIO_AMD_XGBE) += amd-xgbe.o obj-$(CONFIG_VFIO_AP) += ap.o +obj-$(CONFIG_VFIO_IGD) += igd.o
hw/vfio/igd.c new file +616 -0
616 lines not on this page · raw message
hw/vfio/pci-quirks.c +3 -611
645 lines not on this page · raw message
hw/vfio/pci.h +17 -0
@@ -172,6 +172,21 @@ typedef struct VFIOPCIDevice {Notifier irqchip_change_notifier; } VFIOPCIDevice; +/* Use uin32_t for vendor & device so PCI_ANY_ID expands and cannot match hw */ +static inline bool vfio_pci_is (VFIOPCIDevice *vdev,uint32_t vendor,uint32_t device) +{ +return (vendor ==PCI_ANY_ID || vendor == vdev->vendor_id) && + (device ==PCI_ANY_ID || device == vdev->device_id); +} + +static inline bool vfio_is_vga (VFIOPCIDevice *vdev) +{ +PCIDevice *pdev = &vdev->pdev; +uint16_t class =pci_get_word (pdev->config +PCI_CLASS_DEVICE ); + +return class ==PCI_CLASS_DISPLAY_VGA ; +} +uint32_t vfio_pci_read_config (PCIDevice *pdev,uint32_t addr,int len);void vfio_pci_write_config (PCIDevice *pdev,uint32_t addr,uint32_t val,int len);
@@ -189,6 +204,8 @@ 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);void vfio_quirk_reset (VFIOPCIDevice *vdev); +VFIOQuirk *vfio_quirk_alloc (int nr_mem); +void vfio_probe_igd_bar4_quirk (VFIOPCIDevice *vdev,int nr);extern const PropertyInfo qdev_prop_nv_gpudirect_clique;
Signature · 1 line
2.18.1
Quoted 29 lines · Thomas Huth
The IGD quirk code defines a separate device, the so-called "vfio-pci-igd-lpc-bridge" which shows up as a user-creatable device in all QEMU binaries that include the vfio code. This is a little bit unfortunate for two reasons: First, this device is completely useless in binaries like qemu-system-s390x. Second we also would like to disable it in downstream RHEL which currently requires some extra patches there since the device does not have a proper Kconfig-style switch yet.
So it would be good if the device could be disabled more easily, thus let's move the code to a separate file instead and introduce a proper
Kconfigswitch for it which gets only enabled by default if we also haveCONFIG_PC_PCIenabled.Signed-off-by Thomas Huth <[email protected]>--- hw/vfio/Kconfig | 5 + hw/vfio/Makefile.objs | 1 + hw/vfio/igd.c | 616 ++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 614 +---------------------------------------- hw/vfio/pci.h | 17 ++ 5 files changed, 642 insertions(+), 611 deletions(-)create mode 100644
hw/vfio/igd.chw/vfio/Kconfig +0
-0
hw/vfio/Kconfig config VFIO_AP · line 42
Quoted 7 lines
hw/vfio/Kconfig +4
-0@@ -36,3 +36,8 @@ config VFIO_AP default y select VFIO depends on LINUX && S390_CCW_VIRTIO + +config VFIO_IGD + bool + default y if PC_PCI
With the details from Alex here:
https://www.mail-archive.com/[email protected]/msg663667.html
I'm tempted to use:
default y if XEN
depends on PC_PCI
Watch out the Xen Kconfig seems fragile, yesterday using --enable-xen --disable-tcg I hit this build error:
LINK i386-softmmu/qemu-system-i386/usr/bin/ld: hw/xen/xen_pt.o: in function `xen_igd_passthrough_isa_bridge_create':/home/phil/source/qemu/hw/xen/xen_pt.c:701: undefined reference to `igd_passthrough_isa_bridge_create'
Quoted 10 lines
hw/vfio/Kconfig +1
-0+ depends on VFIO_PCIhw/vfio/Makefile.objs +1
-0@@ -5,3 +5,4 @@ obj-$(CONFIG_VFIO_PLATFORM) += platform.o obj-$(CONFIG_VFIO_XGMAC) += calxeda-xgmac.o obj-$(CONFIG_VFIO_AMD_XGBE) += amd-xgbe.o obj-$(CONFIG_VFIO_AP) += ap.o +obj-$(CONFIG_VFIO_IGD) += igd.o
Quoted 41 lines · On Tue, 14 Jan 2020 18:10:26 +0100 Philippe Mathieu-Daudé <[email protected]>…
Quoted 29 lines · Thomas Huth
The IGD quirk code defines a separate device, the so-called "vfio-pci-igd-lpc-bridge" which shows up as a user-creatable device in all QEMU binaries that include the vfio code. This is a little bit unfortunate for two reasons: First, this device is completely useless in binaries like qemu-system-s390x. Second we also would like to disable it in downstream RHEL which currently requires some extra patches there since the device does not have a proper Kconfig-style switch yet.
So it would be good if the device could be disabled more easily, thus let's move the code to a separate file instead and introduce a proper
Kconfigswitch for it which gets only enabled by default if we also haveCONFIG_PC_PCIenabled.Signed-off-by Thomas Huth <[email protected]>--- hw/vfio/Kconfig | 5 + hw/vfio/Makefile.objs | 1 + hw/vfio/igd.c | 616 ++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 614 +---------------------------------------- hw/vfio/pci.h | 17 ++ 5 files changed, 642 insertions(+), 611 deletions(-)create mode 100644
hw/vfio/igd.chw/vfio/Kconfig +0
-0hw/vfio/Kconfig config VFIO_AP · line 42
Quoted 7 lines
hw/vfio/Kconfig +4
-0@@ -36,3 +36,8 @@ config VFIO_AP default y select VFIO depends on LINUX && S390_CCW_VIRTIO + +config VFIO_IGD + bool + default y if PC_PCIWith the details from Alex here:
https://www.mail-archive.com/[email protected]/msg663667.html
Quoted 4 lines
I'm tempted to use:
default y if XEN
depends onPC_PCI
I think you might be confused, there are two separate LPC bridges in QEMU for IGD support, one specifically for Xen and this one specifically for VFIO. This one is never used in a Xen environment. Thanks,
Alex
Quoted 20 lines
Watch out the Xen
Kconfigseems fragile, yesterday using --enable-xen --disable-tcg I hit this build error:LINK i386-softmmu/qemu-system-i386
/usr/bin/ld:hw/xen/xen_pt.o: in function `xen_igd_passthrough_isa_bridge_create':/home/phil/source/qemu/hw/xen/xen_pt.c:701: undefined reference to `igd_passthrough_isa_bridge_create'Quoted 10 lines
hw/vfio/Kconfig +1
-0+ depends on VFIO_PCIhw/vfio/Makefile.objs +1
-0@@ -5,3 +5,4 @@ obj-$(CONFIG_VFIO_PLATFORM) += platform.o obj-$(CONFIG_VFIO_XGMAC) += calxeda-xgmac.o obj-$(CONFIG_VFIO_AMD_XGBE) += amd-xgbe.o obj-$(CONFIG_VFIO_AP) += ap.o +obj-$(CONFIG_VFIO_IGD) += igd.o
Quoted 44 lines · Alex Williamson
Quoted 41 lines · On Tue, 14 Jan 2020 18:10:26 +0100 Philippe Mathieu-Daudé <[email protected]>…
Quoted 29 lines · Thomas Huth
The IGD quirk code defines a separate device, the so-called "vfio-pci-igd-lpc-bridge" which shows up as a user-creatable device in all QEMU binaries that include the vfio code. This is a little bit unfortunate for two reasons: First, this device is completely useless in binaries like qemu-system-s390x. Second we also would like to disable it in downstream RHEL which currently requires some extra patches there since the device does not have a proper Kconfig-style switch yet.
So it would be good if the device could be disabled more easily, thus let's move the code to a separate file instead and introduce a proper
Kconfigswitch for it which gets only enabled by default if we also haveCONFIG_PC_PCIenabled.Signed-off-by Thomas Huth <[email protected]>--- hw/vfio/Kconfig | 5 + hw/vfio/Makefile.objs | 1 + hw/vfio/igd.c | 616 ++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 614 +---------------------------------------- hw/vfio/pci.h | 17 ++ 5 files changed, 642 insertions(+), 611 deletions(-)create mode 100644
hw/vfio/igd.chw/vfio/Kconfig +0
-0hw/vfio/Kconfig config VFIO_AP · line 42
Quoted 7 lines
hw/vfio/Kconfig +4
-0@@ -36,3 +36,8 @@ config VFIO_AP default y select VFIO depends on LINUX && S390_CCW_VIRTIO + +config VFIO_IGD + bool + default y if PC_PCIWith the details from Alex here:
https://www.mail-archive.com/[email protected]/msg663667.html
Quoted 8 lines
Quoted 4 lines
I'm tempted to use:
default y if XEN
depends onPC_PCII think you might be confused, there are two separate LPC bridges in QEMU for IGD support, one specifically for Xen and this one specifically for VFIO. This one is never used in a Xen environment.
Argh I see, OK!
Quoted 21 lines
Quoted 20 lines
Watch out the Xen
Kconfigseems fragile, yesterday using --enable-xen --disable-tcg I hit this build error:LINK i386-softmmu/qemu-system-i386
/usr/bin/ld:hw/xen/xen_pt.o: in function `xen_igd_passthrough_isa_bridge_create':/home/phil/source/qemu/hw/xen/xen_pt.c:701: undefined reference to `igd_passthrough_isa_bridge_create'Quoted 10 lines
hw/vfio/Kconfig +1
-0+ depends on VFIO_PCIhw/vfio/Makefile.objs +1
-0@@ -5,3 +5,4 @@ obj-$(CONFIG_VFIO_PLATFORM) += platform.o obj-$(CONFIG_VFIO_XGMAC) += calxeda-xgmac.o obj-$(CONFIG_VFIO_AMD_XGBE) += amd-xgbe.o obj-$(CONFIG_VFIO_AP) += ap.o +obj-$(CONFIG_VFIO_IGD) += igd.o