From 4426d1da870f493606542004d3d9249f7d822763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 31 Mar 2025 19:11:43 +0200 Subject: [PATCH 1/2] Apply fix for devices without legacy IRQ Apply PV version of a patch for devices without legacy IRQ. The new version of the patch handles just PVH dom0 and requires also pciback update. https://forum.qubes-os.org/t/usb-controller-touchscreen-not-working/33178/7 --- 0655-libxl-Skip-missing-legacy-IRQ.patch | 33 ++++++++++++++++++++++++ xen.spec.in | 1 + 2 files changed, 34 insertions(+) create mode 100644 0655-libxl-Skip-missing-legacy-IRQ.patch diff --git a/0655-libxl-Skip-missing-legacy-IRQ.patch b/0655-libxl-Skip-missing-legacy-IRQ.patch new file mode 100644 index 00000000..54cb51a9 --- /dev/null +++ b/0655-libxl-Skip-missing-legacy-IRQ.patch @@ -0,0 +1,33 @@ +From 3eb2c24f633d41c4a4ec7b94feab23d235c235dc Mon Sep 17 00:00:00 2001 +From: Jason Andryuk +Date: Mon, 31 Mar 2025 19:08:07 +0200 +Subject: [PATCH] libxl: Skip missing legacy IRQ + +A PCI device's irq field is an 8-bit number. A value of 0xff indicates +that the device is not connected. Additionally, the Linux ACPI code can +convert these 0xff values to IRQ_NOTCONNECTED(0x80000000) because +"0x80000000 is guaranteed to be outside the available range of +interrupts and easy to distinguish from other possible incorrect +values." When the hypercall to assign that IRQ fails, device +passthrough as a whole fails. + +--- + tools/libs/light/libxl_pci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c +index 68d4d50cad9e..a3bb946c2de8 100644 +--- a/tools/libs/light/libxl_pci.c ++++ b/tools/libs/light/libxl_pci.c +@@ -1486,7 +1486,7 @@ static void pci_add_dm_done(libxl__egc *egc, + LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path); + goto out_no_irq; + } +- if ((fscanf(f, "%u", &irq) == 1) && irq) { ++ if ((fscanf(f, "%u", &irq) == 1) && irq > 0 && irq < 0xff) { + r = xc_physdev_map_pirq(ctx->xch, domid, irq, &irq); + if (r < 0) { + LOGED(ERROR, domainid, "xc_physdev_map_pirq irq=%d (error=%d)", +-- +2.48.1 + diff --git a/xen.spec.in b/xen.spec.in index dacc9397..0485df33 100644 --- a/xen.spec.in +++ b/xen.spec.in @@ -142,6 +142,7 @@ Patch0630: 0630-tools-xg-increase-LZMA_BLOCK_SIZE-for-uncompressing-.patch Patch0653: 0653-python-avoid-conflicting-_FORTIFY_SOURCE-values.patch Patch0654: 0654-libxl-extend-IGD-check.patch +Patch0655: 0655-libxl-Skip-missing-legacy-IRQ.patch # Qubes specific patches Patch1000: 1000-Do-not-access-network-during-the-build.patch From 97776b22e297b47e8db44658f66e7d3eccce759a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 6 Apr 2025 12:46:46 +0200 Subject: [PATCH 2/2] libxl: do not consider IGD VF a VGA passthru This option is not needed for VF, and in fact it's harmful because QEMU is looking for function-0 device which isn't present in the stubdomain: [2025-04-05 23:53:23] pci 0000:00:00.1: [8086:a788] type 00 class 0x030000 ... [2025-04-05 23:53:23] qemu: Failed to open: /sys/bus/pci/devices/0000:00:00.0/config: No such file or directory Fixes QubesOS/qubes-issues#9853 --- ...o-not-consider-IGD-VF-a-VGA-passthru.patch | 35 +++++++++++++++++++ xen.spec.in | 1 + 2 files changed, 36 insertions(+) create mode 100644 0656-libxl-do-not-consider-IGD-VF-a-VGA-passthru.patch diff --git a/0656-libxl-do-not-consider-IGD-VF-a-VGA-passthru.patch b/0656-libxl-do-not-consider-IGD-VF-a-VGA-passthru.patch new file mode 100644 index 00000000..482f6691 --- /dev/null +++ b/0656-libxl-do-not-consider-IGD-VF-a-VGA-passthru.patch @@ -0,0 +1,35 @@ +From 6eac9adf45857e6c9787ad843061136f41883ecb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= + +Date: Sun, 6 Apr 2025 12:30:51 +0200 +Subject: [PATCH] libxl: do not consider IGD VF a VGA passthru +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The special QEMU treatment is needed only for non-SR-IOV passthrough. Do +not set the passthru option automatically for VF. If one really wants, +the option can still be set manually. + +Signed-off-by: Marek Marczykowski-Górecki +--- + tools/libs/light/libxl_pci.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c +index 35e3e1360423..cd9acb21efa6 100644 +--- a/tools/libs/light/libxl_pci.c ++++ b/tools/libs/light/libxl_pci.c +@@ -633,6 +633,9 @@ bool libxl__is_igd_vga_passthru(libxl__gc *gc, + pt_vendor != 0x8086) + continue; + ++ /* Skip VF, those don't need QEMU hack */ ++ if (pci->func) ++ continue; + if (sysfs_dev_get_class(gc, pci, &class)) + continue; + if (class == 0x030000 || class == 0x038000) +-- +2.48.1 + diff --git a/xen.spec.in b/xen.spec.in index 0485df33..9e7f9cce 100644 --- a/xen.spec.in +++ b/xen.spec.in @@ -143,6 +143,7 @@ Patch0630: 0630-tools-xg-increase-LZMA_BLOCK_SIZE-for-uncompressing-.patch Patch0653: 0653-python-avoid-conflicting-_FORTIFY_SOURCE-values.patch Patch0654: 0654-libxl-extend-IGD-check.patch Patch0655: 0655-libxl-Skip-missing-legacy-IRQ.patch +Patch0656: 0656-libxl-do-not-consider-IGD-VF-a-VGA-passthru.patch # Qubes specific patches Patch1000: 1000-Do-not-access-network-during-the-build.patch