xen/igd: get PCH info from host sysfs
A message that is not in the archive (sent off-list or not yet received): [email protected]
cover xen/igd: fixes for Intel IGD passthrough
This patch series aims to fix long-standing bugs that need to be backported to all currently supported stable versions.
This series fixes three bugs that cause problems ranging from a dark screen in the guest until the guest OS graphics drivers are loaded to an assert failure that prevents the guest from starting.
To test these patches, it is necessary to test with older Intel IGD devices that have support for legacy VGA bios.
The patches have been tested using Xen 4.21 and Seabios 1.17 on Fedora 44 using an Intel NUC7i5BNK with an i5-7260U processor and have been verified to fix the bugs as described in the individual patches.
Chuck Zmudzinski (3):
xen/igd: get PCH info from host sysfs
xen/igd: don't register rom bar twice
xen/igd: fixup device id before registering rom
hw/xen/xen_pt.c | 5 ++- hw/xen/xen_pt_graphics.c | 85 ++++++++++++++++++++++++++++++++++++++-- hw/xen/xen_pt_load_rom.c | 18 ++++++--- include/hw/xen/xen_igd.h | 3 +- 4 files changed, 99 insertions(+), 12 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/3 xen/igd: get PCH info from host sysfs
The igd_combo_id_infos[] data is more than 10 years out of date with many Intel IGD devices missing from igd_combo_id_infos[]. This means that many devices that could be supported will not work with the current implementation.
For newer devices not listed in igd_combo_id_infos[], get infos from the host sysfs to enable support for the newer devices not listed in igd_combo_id_infos[].
Introduce the helper function xen_pt_get_host_pch_info to facilitate getting the necessary information from sysfs.
Also, use errp in xen_igd_passthrough_isa_bridge_create to propagate errors from xen_pt_get_host_pch_info.
--- hw/xen/xen_pt.c | 2 +- hw/xen/xen_pt_graphics.c | 82 ++++++++++++++++++++++++++++++++++++++-- include/hw/xen/xen_igd.h | 3 +- 3 files changed, 82 insertions(+), 5 deletions(-)
hw/xen/xen_pt.c +1 -1
@@ -867,7 +867,7 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) }/* Register ISA bridge for passthrough GFX. */ -xen_igd_passthrough_isa_bridge_create (s, &s->real_device); +xen_igd_passthrough_isa_bridge_create (s, &s->real_device, errp); }/* Handle real device's MMIO/PIO BARs */
hw/xen/xen_pt_graphics.c +79 -3
101 lines not on this page · raw message
include/hw/xen/xen_igd.h +2 -1
@@ -22,7 +22,8 @@ uint32_t igd_read_opregion(XenPCIPassthroughState *s);void xen_igd_reserve_slot (PCIBus *pci_bus);void igd_write_opregion (XenPCIPassthroughState *s,uint32_t val);void xen_igd_passthrough_isa_bridge_create (XenPCIPassthroughState *s, -XenHostPCIDevice *dev); +XenHostPCIDevice *dev, +Error **errp);static inline bool is_igd_vga_passthrough (XenHostPCIDevice *dev) {
Signature · 1 line
2.52.0
PATCH 2/3 xen/igd: don't register rom bar twice
In reply to Chuck ZmudzinskiThis also fixes a failed assertion in pci [1] for Qemu version 10 and higher when passing through an Intel IGD with an option ROM to the guest.
[1] f6fc01c ("hw/pci: Assert a bar is not registered multiple times")
--- hw/xen/xen_pt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/xen/xen_pt.c +2 -1
@@ -495,7 +495,8 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s, uint16_t *cmd) }/* Register expansion ROM address */ -if (d->rom.base_addr && d->rom.size) { +PCIIORegion region = s->dev.io_regions[PCI_ROM_SLOT ]; +if (!region.size && d->rom.base_addr && d->rom.size) {uint32_t bar_data =0 ;/* Re-set BAR reported by OS, otherwise ROM can't be read. */
Signature · 1 line
2.52.0
PATCH 3/3 xen/igd: fixup device id before registering rom
In reply to Chuck ZmudzinskiWith the current implementation, Seabios does not see the fixup of the device id done here and consequently Seabios does not load the VGA bios and the guest screen does not light up until the guest OS graphics driver is loaded. So there is no VGA output from the passed through Intel IGD from either Seabios or the guest bootloader with the current implementation in cases when the device id needs fixing.
Fix this by waiting until after doing fixup of the device id before registering the option ROM. With this patch, Seabios sees the fixup done here and loads the VGA bios, and both Seabios and the guest bootloader light up the guest screen in cases when fixup of the device id is needed.
Also, remove unused header hw/core/loader.h
--- hw/xen/xen_pt_graphics.c | 3 +++ hw/xen/xen_pt_load_rom.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-)
hw/xen/xen_pt_graphics.c +3 -0
@@ -222,6 +222,9 @@ void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev, } } +pci_register_bar (&s->dev,PCI_ROM_SLOT ,0 , &s->dev.rom); + s->dev.has_rom = true; +/* Currently we fixed this address as a primary for legacy BIOS. */ physical_memory_write (0xc0000 , bios, bios_size); }
hw/xen/xen_pt_load_rom.c +12 -6
@@ -4,14 +4,22 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/core/loader.h" #include "hw/pci/pci.h" #include "xen_pt.h" /* -* Scan the assigned devices for the devices that have an option ROM, and then -* load the corresponding ROM data to RAM. If an error occurs while loading an -* option ROM, we just ignore that option ROM and continue with the next one. +* Normally xen_pt_register_regions will handle loading the option ROM, +* but in some cases, such as for the Intel IGD, the option ROM might +* need to be modified. +* +* For such cases, use this function to get a pointer to the option ROM +* from sysfs. Caller has the responsibility to edit the option ROM as +* needed, call pci_register_bar to register the modified option ROM, +* and set has_rom to true for the PCI device. +* +* This function must be called before xen_pt_register_regions is called +* because if xen_pt_register_regions is called first, it will register +* the option ROM and any attempt to register it again will fail. */ void *pci_assign_dev_load_option_rom(PCIDevice *dev, int *size, unsigned int domain,
@@ -76,8 +84,6 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, goto close_rom; } -pci_register_bar (dev,PCI_ROM_SLOT ,0 , &dev->rom); - dev->has_rom = true; *size = st.st_size; close_rom:/* Write "0" to disable ROM */
Signature · 1 line
2.52.0