Skip to content

Commit 16dc3c6

Browse files
rucodersesantos
andcommitted
pkg/xen-tools: rework QEMU vfio-igd for q35/UEFI iGPU passthrough
Replace the old Revert^2 stolen-memory patch with four targeted patches for QEMU's hw/vfio/igd.c enabling Intel iGPU passthrough on q35/UEFI: Patch 08 — backport upstream igd_gen() with Gen7-Gen12 device ID detection. The old function returned 8 for all unrecognised IDs, making generation-specific checks (BDSM offset, GMS encoding) ineffective on Gen9+ hardware. Patch 09 — restructure vfio_probe_igd_bar4_quirk() for q35/UEFI: - Move GMCH/BDSM emulation and etc/igd-bdsm-size fw_cfg write before the BDF/LPC bridge checks (q35 "Sorry Q35" exits early without it) - Emulate BDSM at 0xC0 (64-bit) for Gen11+, 0x5C (32-bit) for older - Preserve GMS in emulated GMCH (guest driver needs stolen memory size) - Clear stale GTT entries from host POST to prevent IOMMU faults - Fix GMS encoding for Gen9+ Atom SKUs (0xf0-0xff, 4 MB granularity) Patch 10 — add BAR0 BDSM MMIO mirror quirk (backported from upstream). The GPU reads BDSM through BAR0 at offset 0x1080C0 as well as PCI config space; without the mirror the MMIO read returns the host PA while PCI config returns the emulated guest PA, crashing the driver. Patch 11 — temporary diagnostic logging for BDSM/GMCH/GTT/BAR0 mirror. Also ship igd.rom in xen-tools (where QEMU runs on the host rootfs) and update the eve-uefi reference. Co-authored-by: Sergio Santos <sergioliveirasantos@gmail.com> Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
1 parent 3d0b5f8 commit 16dc3c6

6 files changed

+660
-126
lines changed

pkg/xen-tools/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2023-2026 Zededa, Inc.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
FROM lfedge/eve-uefi:b3ef9ca37c99439c776673aeba83c52ea8b84626 AS uefi-build
6+
FROM lfedge/eve-uefi:417cf0c3acf434fb0f775e8a588ae7b6e3523d6d AS uefi-build
77
FROM lfedge/eve-alpine:745ae9066273c73b0fd879c4ba4ff626a8392d04 AS runx-build
88
ENV BUILD_PKGS="mkinitfs gcc musl-dev e2fsprogs chrony agetty"
99
RUN eve-alpine-deploy.sh
@@ -115,7 +115,8 @@ RUN if [ "$(uname -m)" = "x86_64" ]; then rm -f qemu-system-i386 && ln -s "qemu-
115115
COPY --from=uefi-build / /uefi/
116116
RUN mkdir -p /out/usr/lib/xen/boot && cp /uefi/OVMF.fd /out/usr/lib/xen/boot/ovmf.bin && \
117117
cp /uefi/OVMF_PVH.fd /out/usr/lib/xen/boot/ovmf-pvh.bin && \
118-
[ -f /uefi/OVMF_CODE.fd ] && cp /uefi/OVMF_CODE.fd /out/usr/lib/xen/boot/OVMF_CODE.fd || :
118+
[ -f /uefi/OVMF_CODE.fd ] && cp /uefi/OVMF_CODE.fd /out/usr/lib/xen/boot/OVMF_CODE.fd || : && \
119+
[ -f /uefi/igd.rom ] && cp /uefi/igd.rom /out/usr/lib/xen/boot/igd.rom || :
119120

120121
# We need to keep a slim profile, which means removing things we don't need
121122
RUN rm -rf /out/usr/lib/libxen*.a /out/usr/lib/libxl*.a /out/usr/lib/debug /out/usr/lib/python*

pkg/xen-tools/patches-4.19.0/x86_64/08-Revert__Revert__vfio_pci-quirks_c__Disable_stolen_memory_for_igd_VFIO__.patch

Lines changed: 0 additions & 124 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
From e130d1db4dc882bfbdf7d57c3e80432f5b39838f Mon Sep 17 00:00:00 2001
2+
From: Mikhail Malyshev <mike.malyshev@gmail.com>
3+
Date: Tue, 31 Mar 2026 20:34:07 +0000
4+
Subject: [PATCH 1/2] vfio/igd: backport igd_gen() with Gen7-Gen12 device ID
5+
detection
6+
7+
Backport upstream QEMU's igd_gen() which returns correct generation
8+
numbers for all Intel IGD device families:
9+
10+
Gen 7: Haswell, Valleyview/Bay Trail
11+
Gen 8: Broadwell, Cherryview
12+
Gen 9: Skylake, Kaby Lake, Coffee Lake, Comet Lake, Gemini Lake,
13+
Broxton/Apollo Lake
14+
Gen 11: Ice Lake, Elkhart Lake, Jasper Lake
15+
Gen 12: Tiger Lake, Rocket Lake, Alder Lake, Raptor Lake
16+
17+
The old code only distinguished gen 6, gen 8, and returned 8 for all
18+
unknown device IDs. This made generation-specific checks (e.g. for
19+
BDSM register offset) ineffective on Gen9+ hardware.
20+
21+
Also change the default return from 8 to -1 (unknown), matching
22+
upstream. Callers that check gen < 0 will now correctly reject
23+
unrecognised devices rather than silently treating them as gen 8.
24+
25+
Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
26+
---
27+
hw/vfio/igd.c | 62 ++++++++++++++++++++++++++++++---------------------
28+
1 file changed, 37 insertions(+), 25 deletions(-)
29+
30+
diff --git a/tools/qemu-xen/hw/vfio/igd.c b/tools/qemu-xen/hw/vfio/igd.c
31+
index d320d032a7..c105c9993f 100644
32+
--- a/tools/qemu-xen/hw/vfio/igd.c
33+
+++ b/tools/qemu-xen/hw/vfio/igd.c
34+
@@ -59,38 +59,50 @@
35+
*/
36+
static int igd_gen(VFIOPCIDevice *vdev)
37+
{
38+
- if ((vdev->device_id & 0xfff) == 0xa84) {
39+
- return 8; /* Broxton */
40+
+ /*
41+
+ * Device IDs for Broxton/Apollo Lake are 0x0a84, 0x1a84, 0x1a85, 0x5a84
42+
+ * and 0x5a85, match bit 11:1 here.
43+
+ * Prefix 0x0a is taken by Haswell, this rule should be matched first.
44+
+ */
45+
+ if ((vdev->device_id & 0xffe) == 0xa84) {
46+
+ return 9;
47+
}
48+
49+
switch (vdev->device_id & 0xff00) {
50+
- /* Old, untested, unavailable, unknown */
51+
- case 0x0000:
52+
- case 0x2500:
53+
- case 0x2700:
54+
- case 0x2900:
55+
- case 0x2a00:
56+
- case 0x2e00:
57+
- case 0x3500:
58+
- case 0xa000:
59+
- return -1;
60+
- /* SandyBridge, IvyBridge, ValleyView, Haswell */
61+
- case 0x0100:
62+
- case 0x0400:
63+
- case 0x0a00:
64+
- case 0x0c00:
65+
- case 0x0d00:
66+
- case 0x0f00:
67+
+ case 0x0100: /* SandyBridge, IvyBridge */
68+
return 6;
69+
- /* BroadWell, CherryView, SkyLake, KabyLake */
70+
- case 0x1600:
71+
- case 0x1900:
72+
- case 0x2200:
73+
- case 0x5900:
74+
+ case 0x0400: /* Haswell */
75+
+ case 0x0a00: /* Haswell */
76+
+ case 0x0c00: /* Haswell */
77+
+ case 0x0d00: /* Haswell */
78+
+ case 0x0f00: /* Valleyview/Bay Trail */
79+
+ return 7;
80+
+ case 0x1600: /* Broadwell */
81+
+ case 0x2200: /* Cherryview */
82+
return 8;
83+
+ case 0x1900: /* Skylake */
84+
+ case 0x3100: /* Gemini Lake */
85+
+ case 0x5900: /* Kaby Lake */
86+
+ case 0x3e00: /* Coffee Lake */
87+
+ case 0x9B00: /* Comet Lake */
88+
+ return 9;
89+
+ case 0x8A00: /* Ice Lake */
90+
+ case 0x4500: /* Elkhart Lake */
91+
+ case 0x4E00: /* Jasper Lake */
92+
+ return 11;
93+
+ case 0x9A00: /* Tiger Lake */
94+
+ case 0x4C00: /* Rocket Lake */
95+
+ case 0x4600: /* Alder Lake */
96+
+ case 0xA700: /* Raptor Lake */
97+
+ return 12;
98+
}
99+
100+
- return 8; /* Assume newer is compatible */
101+
+ /*
102+
+ * Unfortunately, Intel changes its specification quite often. This makes
103+
+ * it impossible to use a suitable default value for unknown devices.
104+
+ * Return -1 for not applying any generation-specific quirks.
105+
+ */
106+
+ return -1;
107+
}
108+
109+
typedef struct VFIOIGDQuirk {
110+
--
111+
2.43.0
112+

0 commit comments

Comments
 (0)