Skip to contentSkip to conversation

hw/pci-host: Add Kconfig selector for IGD PCIe pass-through

RFC Superseded Philippe Mathieu-Daudé 5 participants 6 messages Nov 22, 2019 – Nov 23, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 hw/pci-host: Add Kconfig selector for IGD PCIe pass-through

Introduce a kconfig selector to allow builds without Intel Integrated Graphics Device GPU PCIe passthrough. We keep the default as enabled.

---
RFC because to be able to use the Kconfig-generated "config-devices.h" header we have to move this device out of $common-obj and build i440fx.o on a per-target basis, which is not optimal...

---
 hw/pci-host/i440fx.c      | 9 ++++++++-
 hw/vfio/pci-quirks.c      | 6 ++++++
 hw/pci-host/Kconfig       | 5 +++++
 hw/pci-host/Makefile.objs | 2 +-
 4 files changed, 20 insertions(+), 2 deletions(-)
hw/pci-host/i440fx.c +8 -1
index f27131102d..41e93581f4 100644
@@ -34,6 +34,7 @@
 #include "hw/pci-host/pam.h"
 #include "qapi/visitor.h"
 #include "qemu/error-report.h"
+#include "config-devices.h"
 
 /*
  * I440FX chipset data sheet.
@@ -386,6 +387,8 @@ static const TypeInfo i440fx_info = {
     },
 };
 
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+
 /* IGD Passthrough Host Bridge. */
 typedef struct {
     uint8_t offset;
@@ -470,6 +473,8 @@ static const TypeInfo igd_passthrough_i440fx_info = {
     .class_init    = igd_passthrough_i440fx_class_init,
 };
 
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
+
 static const char *i440fx_pcihost_root_bus_path(PCIHostState *host_bridge,
                                                 PCIBus *rootbus)
 {
@@ -514,8 +519,10 @@ static const TypeInfo i440fx_pcihost_info = {
 static void i440fx_register_types(void)
 {
     type_register_static(&i440fx_info);
-    type_register_static(&igd_passthrough_i440fx_info);
     type_register_static(&i440fx_pcihost_info);
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+    type_register_static(&igd_passthrough_i440fx_info);
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
 }
 
 type_init(i440fx_register_types)
hw/vfio/pci-quirks.c +6 -0
index 136f3a9ad6..858148fa39 100644
@@ -1166,6 +1166,8 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
     trace_vfio_quirk_rtl8168_probe(vdev->vbasedev.name);
 }
 
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+
 /*
  * Intel IGD support
  *
@@ -1811,6 +1813,8 @@ out:
     g_free(lpc);
 }
 
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
+
 /*
  * Common quirk probe entry points.
  */
@@ -1860,7 +1864,9 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
     vfio_probe_nvidia_bar5_quirk(vdev, nr);
     vfio_probe_nvidia_bar0_quirk(vdev, nr);
     vfio_probe_rtl8168_bar2_quirk(vdev, nr);
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
     vfio_probe_igd_bar4_quirk(vdev, nr);
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
 }
 
 void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
hw/pci-host/Kconfig +5 -0
index b0aa8351c4..0b7539765a 100644
@@ -1,6 +1,10 @@
 config PAM
     bool
 
+config INTEL_IGD_PASSTHROUGH
+    default y
+    bool
+
 config PREP_PCI
     bool
     select PCI
@@ -32,6 +36,7 @@ config PCI_I440FX
     bool
     select PCI
     select PAM
+    imply INTEL_IGD_PASSTHROUGH
 
 config PCI_EXPRESS_Q35
     bool
hw/pci-host/Makefile.objs +1 -1
index efd752b766..3c925192dd 100644
@@ -13,7 +13,7 @@ common-obj-$(CONFIG_VERSATILE_PCI) += versatile.o
 
 common-obj-$(CONFIG_PCI_SABRE) += sabre.o
 common-obj-$(CONFIG_FULONG) += bonito.o
-common-obj-$(CONFIG_PCI_I440FX) += i440fx.o
+obj-$(CONFIG_PCI_I440FX) += i440fx.o
 common-obj-$(CONFIG_PCI_EXPRESS_Q35) += q35.o
 common-obj-$(CONFIG_PCI_EXPRESS_GENERIC_BRIDGE) += gpex.o
 common-obj-$(CONFIG_PCI_EXPRESS_XILINX) += xilinx-pcie.o
Signature · 1 line
2.21.0
#1 lore raw
Quoted 48 lines · On Fri, 22 Nov 2019 18:22:01 +0100 Philippe Mathieu-Daudé <[email protected]>…

Introduce a kconfig selector to allow builds without Intel Integrated Graphics Device GPU PCIe passthrough. We keep the default as enabled.

---
RFC because to be able to use the Kconfig-generated "config-devices.h" header we have to move this device out of $common-obj and build i440fx.o on a per-target basis, which is not optimal...

---
 hw/pci-host/i440fx.c      | 9 ++++++++-
 hw/vfio/pci-quirks.c      | 6 ++++++
 hw/pci-host/Kconfig       | 5 +++++
 hw/pci-host/Makefile.objs | 2 +-
 4 files changed, 20 insertions(+), 2 deletions(-)
hw/pci-host/i440fx.c +5 -0
index f27131102d..41e93581f4 100644
@@ -34,6 +34,7 @@
 #include "hw/pci-host/pam.h"
 #include "qapi/visitor.h"
 #include "qemu/error-report.h"
+#include "config-devices.h"
 
 /*
  * I440FX chipset data sheet.
@@ -386,6 +387,8 @@ static const TypeInfo i440fx_info = {
     },
 };
 
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+
 /* IGD Passthrough Host Bridge. */
 typedef struct {
     uint8_t offset;
@@ -470,6 +473,8 @@ static const TypeInfo igd_passthrough_i440fx_info = {
     .class_init    = igd_passthrough_i440fx_class_init,
 };
 
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
+
 static const char *i440fx_pcihost_root_bus_path(PCIHostState *host_bridge,
                                                 PCIBus *rootbus)
 {

hw/pci-host/i440fx.c static const TypeInfo i440fx_pcihost_info = { · line 527

Quoted 10 lines
hw/pci-host/i440fx.c +3 -1
@@ -514,8 +519,10 @@ static const TypeInfo i440fx_pcihost_info = {
 static void i440fx_register_types(void)
 {
     type_register_static(&i440fx_info);
-    type_register_static(&igd_passthrough_i440fx_info);
     type_register_static(&i440fx_pcihost_info);
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+    type_register_static(&igd_passthrough_i440fx_info);
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
 }
 

Note that this IGD thing has nothing to do with the one below in vfio code. AIUI, the one above is specific to Xen and very unfortunately named and placed to seem more generic than it is. vfio IGD *assignment* (not passthrough) has no dependency on this, so please don't link them together. Thanks,

Alex

Quoted 69 lines
hw/pci-host/i440fx.c +0 -0
 type_init(i440fx_register_types)
hw/vfio/pci-quirks.c +6 -0
index 136f3a9ad6..858148fa39 100644
@@ -1166,6 +1166,8 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
     trace_vfio_quirk_rtl8168_probe(vdev->vbasedev.name);
 }
 
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+
 /*
  * Intel IGD support
  *
@@ -1811,6 +1813,8 @@ out:
     g_free(lpc);
 }
 
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
+
 /*
  * Common quirk probe entry points.
  */
@@ -1860,7 +1864,9 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
     vfio_probe_nvidia_bar5_quirk(vdev, nr);
     vfio_probe_nvidia_bar0_quirk(vdev, nr);
     vfio_probe_rtl8168_bar2_quirk(vdev, nr);
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
     vfio_probe_igd_bar4_quirk(vdev, nr);
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
 }
 
 void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
hw/pci-host/Kconfig +5 -0
index b0aa8351c4..0b7539765a 100644
@@ -1,6 +1,10 @@
 config PAM
     bool
 
+config INTEL_IGD_PASSTHROUGH
+    default y
+    bool
+
 config PREP_PCI
     bool
     select PCI
@@ -32,6 +36,7 @@ config PCI_I440FX
     bool
     select PCI
     select PAM
+    imply INTEL_IGD_PASSTHROUGH
 
 config PCI_EXPRESS_Q35
     bool
hw/pci-host/Makefile.objs +1 -1
index efd752b766..3c925192dd 100644
@@ -13,7 +13,7 @@ common-obj-$(CONFIG_VERSATILE_PCI) += versatile.o
 
 common-obj-$(CONFIG_PCI_SABRE) += sabre.o
 common-obj-$(CONFIG_FULONG) += bonito.o
-common-obj-$(CONFIG_PCI_I440FX) += i440fx.o
+obj-$(CONFIG_PCI_I440FX) += i440fx.o
 common-obj-$(CONFIG_PCI_EXPRESS_Q35) += q35.o
 common-obj-$(CONFIG_PCI_EXPRESS_GENERIC_BRIDGE) += gpex.o
 common-obj-$(CONFIG_PCI_EXPRESS_XILINX) += xilinx-pcie.o
#2 lore raw

hw/pci-host/Kconfig line 5

Quoted 2 lines · Alex Williamson
hw/pci-host/Kconfig +2 -0
+config INTEL_IGD_PASSTHROUGH
+    default y

If it's "default y", it need not be "implied". It probably shouldn't be "default y", since it's I440FX-specific.

Paolo

Quoted 11 lines
hw/pci-host/Kconfig +3 -0
+    bool
+
 config PREP_PCI
     bool
     select PCI
@@ -32,6 +36,7 @@ config PCI_I440FX
     bool
     select PCI
     select PAM
+    imply INTEL_IGD_PASSTHROUGH
 
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Introduce a kconfig selector to allow builds without Intel Integrated Graphics Device GPU PCIe passthrough. We keep the default as enabled.

---
RFC because to be able to use the Kconfig-generated "config-devices.h" header we have to move this device out of $common-obj and build i440fx.o on a per-target basis, which is not optimal...

IMHO you should move the code out of i440fx.o and into a separate file if possible. That's hopefully cleaner than #ifdeffing here, and you hopefully only need to move the new code into "obj-" and can keep i440fx.o in common-obj.

Thomas

#4 lore raw
Quoted 12 lines · Thomas Huth
Quoted 10 lines · Philippe Mathieu-Daudé

Introduce a kconfig selector to allow builds without Intel Integrated Graphics Device GPU PCIe passthrough. We keep the default as enabled.

---
RFC because to be able to use the Kconfig-generated "config-devices.h" header we have to move this device out of $common-obj and build i440fx.o on a per-target basis, which is not optimal...

Quoted 4 lines

IMHO you should move the code out of i440fx.o and into a separate file if possible. That's hopefully cleaner than #ifdeffing here, and you hopefully only need to move the new code into "obj-" and can keep i440fx.o in common-obj.

Correct. I wanted to try a surgical patch first ;)

#5 lore raw
In reply to Philippe Mathieu-Daudé
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

LINK aarch64-softmmu/qemu-system-aarch64
hw/vfio/pci.o: In function `vfio_realize':
/tmp/qemu-test/src/hw/vfio/pci.c:2949: undefined reference to `vfio_pci_igd_opregion_init'
collect2: error: ld returned 1 exit status
make[1]: *** [qemu-system-x86_64] Error 1
make: *** [x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
hw/vfio/pci.o: In function `vfio_realize':
/tmp/qemu-test/src/hw/vfio/pci.c:2949: undefined reference to `vfio_pci_igd_opregion_init'
collect2: error: ld returned 1 exit status
make[1]: *** [qemu-system-aarch64] Error 1
make: *** [aarch64-softmmu/all] Error 2
Traceback (most recent call last):
File "./tests/docker/docker.py", line 662, in <module>

    sys.exit(main())

---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=57b8f6e005964f0cb505a02139414e88', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-o78ntsrk/src/docker-src.2019-11-22-15.23.40.28372:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=57b8f6e005964f0cb505a02139414e88
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-o78ntsrk/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 2m36.282s
user 0m7.884s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]