From 715968d236133773ec1880c5c053fa87a561ed84 Mon Sep 17 00:00:00 2001 From: Neowutran Date: Thu, 30 Nov 2023 20:07:37 +0100 Subject: [PATCH 1/2] fix https://github.com/QubesOS/qubes-issues/issues/4321 --- ...der-pci-do-not-allow-memory-relocate.patch | 30 +++++++++++++++++++ xen.spec.in | 1 + 2 files changed, 31 insertions(+) create mode 100644 1021-hvmloader-pci-do-not-allow-memory-relocate.patch diff --git a/1021-hvmloader-pci-do-not-allow-memory-relocate.patch b/1021-hvmloader-pci-do-not-allow-memory-relocate.patch new file mode 100644 index 0000000..a29e7b5 --- /dev/null +++ b/1021-hvmloader-pci-do-not-allow-memory-relocate.patch @@ -0,0 +1,30 @@ +From bc81cb8b47b2c489fbc6068dff46898167cd760b Mon Sep 17 00:00:00 2001 +Message-ID: +From: Neowutran +Date: Wed, 29 Nov 2023 20:35:02 +0100 +Subject: [PATCH] fix hvmloader relocating memory and overwritting some part of guest memory + +--- + tools/firmware/hvmloader/pci.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c +index 257a6feb..03b464da 100644 +--- a/tools/firmware/hvmloader/pci.c ++++ b/tools/firmware/hvmloader/pci.c +@@ -118,7 +118,12 @@ void pci_setup(void) + * Since xend can only use qemu-traditional, I think this is the + * option that will have the least impact. + */ +- bool allow_memory_relocate = 1; ++ /* ++ * For QubesOS we default to 0. qemu-traditional is not used. ++ * Settings this parameter to 1 can result in memory corruption ++ * in the guest when passingthrough big pci device like GPU. ++ */ ++ bool allow_memory_relocate = 0; + + BUILD_BUG_ON((typeof(*pci_devfn_decode_type))PCI_COMMAND_IO != + PCI_COMMAND_IO); +-- +2.43.0 diff --git a/xen.spec.in b/xen.spec.in index f2066ee..e8eea72 100644 --- a/xen.spec.in +++ b/xen.spec.in @@ -187,6 +187,7 @@ Patch1016: 1016-gnttab-disable-grant-tables-v2-by-default.patch Patch1017: 1017-Disable-TSX-by-default.patch Patch1018: 1018-Fix-IGD-passthrough-with-linux-stubdomain.patch Patch1019: 1019-Use-Linux-s-PAT.patch +Patch1020: 1021-hvmloader-pci-do-not-allow-memory-relocate.patch # Reproducible builds Patch1100: 1100-Define-build-dates-time-based-on-SOURCE_DATE_EPOCH.patch From 861dddf1cecc4f10175ce15fa1508162c674c244 Mon Sep 17 00:00:00 2001 From: Neowutran Date: Thu, 30 Nov 2023 20:10:08 +0100 Subject: [PATCH 2/2] fix typo --- xen.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen.spec.in b/xen.spec.in index e8eea72..656a035 100644 --- a/xen.spec.in +++ b/xen.spec.in @@ -187,7 +187,7 @@ Patch1016: 1016-gnttab-disable-grant-tables-v2-by-default.patch Patch1017: 1017-Disable-TSX-by-default.patch Patch1018: 1018-Fix-IGD-passthrough-with-linux-stubdomain.patch Patch1019: 1019-Use-Linux-s-PAT.patch -Patch1020: 1021-hvmloader-pci-do-not-allow-memory-relocate.patch +Patch1021: 1021-hvmloader-pci-do-not-allow-memory-relocate.patch # Reproducible builds Patch1100: 1100-Define-build-dates-time-based-on-SOURCE_DATE_EPOCH.patch