From 98ba57a9ba4dd9910fdb08d4c7b6937946d0b08d Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Mon, 14 Oct 2024 14:27:54 +0300 Subject: [PATCH 1/6] pkg/uefi: remove unused Intel IDG driver Remove Intel IDG driver and rom. Signed-off-by: Shahriyar Jalayeri --- pkg/uefi/Dockerfile | 3 --- pkg/uefi/build.sh | 2 -- pkg/xen-tools/Dockerfile | 1 - 3 files changed, 6 deletions(-) diff --git a/pkg/uefi/Dockerfile b/pkg/uefi/Dockerfile index 402883c04e..ba0a303047 100644 --- a/pkg/uefi/Dockerfile +++ b/pkg/uefi/Dockerfile @@ -67,9 +67,6 @@ RUN rm -rf /out && mkdir /out && cp /edk2/OVMF*.fd /out # some architecture specific cases. There probably is a cleaner dockerfile-native way to do this. RUN case $(uname -m) in \ - x86_64) \ - cp /edk2/*.rom /out/ \ - ;; \ aarch64) \ cp -r /rpi /out/ \ ;; \ diff --git a/pkg/uefi/build.sh b/pkg/uefi/build.sh index 9593208263..634bbd916c 100755 --- a/pkg/uefi/build.sh +++ b/pkg/uefi/build.sh @@ -26,8 +26,6 @@ case $(uname -m) in x86_64) build -b ${TARGET} -t GCC5 -a X64 -p OvmfPkg/OvmfPkgX64.dsc -D TPM_ENABLE=TRUE -D TPM_CONFIG_ENABLE=TRUE cp Build/OvmfX64/${TARGET}_*/FV/OVMF*.fd . build -b ${TARGET} -t GCC5 -a X64 -p OvmfPkg/OvmfXen.dsc - BaseTools/Source/C/bin/EfiRom -f 0x1F96 -i 0x0778 -e Build/OvmfX64/${TARGET}_*/X64/IgdAssignmentDxe.efi - cp Build/OvmfX64/${TARGET}_*/X64/IgdAssignmentDxe.rom IgdAssignmentDxe.rom cp Build/OvmfXen/${TARGET}_*/FV/OVMF.fd OVMF_PVH.fd ;; *) echo "Unsupported architecture $(uname). Bailing." diff --git a/pkg/xen-tools/Dockerfile b/pkg/xen-tools/Dockerfile index 2b14a3617e..b4fe052c3e 100644 --- a/pkg/xen-tools/Dockerfile +++ b/pkg/xen-tools/Dockerfile @@ -113,7 +113,6 @@ COPY --from=uefi-build / /uefi/ RUN mkdir -p /out/usr/lib/xen/boot && cp /uefi/OVMF.fd /out/usr/lib/xen/boot/ovmf.bin && \ cp /uefi/OVMF_PVH.fd /out/usr/lib/xen/boot/ovmf-pvh.bin && \ [ -f /uefi/OVMF_CODE.fd ] && cp /uefi/OVMF_CODE.fd /out/usr/lib/xen/boot/OVMF_CODE.fd || : -RUN if [ "$(uname -m)" = "x86_64" ]; then cp /uefi/*.rom /out/usr/lib/xen/boot/;fi FROM scratch COPY --from=build /out/ / From 83ce7e9c65e185a9df9e8312b830926cb6074eb9 Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Mon, 14 Oct 2024 14:33:58 +0300 Subject: [PATCH 2/6] pkg/uefi: update to edk2-stable202408 and enable secure boot Update the UEFI firmware from edk2-stable202005 to edk2-stable202408 and enable secure boot as it is required to boot Windows VMs. Signed-off-by: Shahriyar Jalayeri --- pkg/uefi/Dockerfile | 4 ++-- pkg/uefi/build.sh | 8 +++++++- pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch | 0 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch diff --git a/pkg/uefi/Dockerfile b/pkg/uefi/Dockerfile index ba0a303047..6805b76ce9 100644 --- a/pkg/uefi/Dockerfile +++ b/pkg/uefi/Dockerfile @@ -29,8 +29,8 @@ COPY rpi /rpi FROM build AS build-amd64-versions -ENV EDK_VERSION edk2-stable202005 -ENV EDK_COMMIT ca407c7246bf405da6d9b1b9d93e5e7f17b4b1f9 +ENV EDK_VERSION edk2-stable202408 +ENV EDK_COMMIT b158dad150bf02879668f72ce306445250838201 FROM build-${TARGETARCH}-versions AS build-edk2 diff --git a/pkg/uefi/build.sh b/pkg/uefi/build.sh index 634bbd916c..d7a60d05f8 100755 --- a/pkg/uefi/build.sh +++ b/pkg/uefi/build.sh @@ -3,12 +3,18 @@ TARGET=RELEASE make -C BaseTools +OVMF_COMMON_FLAGS="-DNETWORK_TLS_ENABLE" +OVMF_COMMON_FLAGS+=" -DSECURE_BOOT_ENABLE=TRUE" +OVMF_COMMON_FLAGS+=" -DTPM2_CONFIG_ENABLE=TRUE" +OVMF_COMMON_FLAGS+=" -DTPM2_ENABLE=TRUE" +OVMF_COMMON_FLAGS+=" -DFD_SIZE_4MB" # shellcheck disable=SC1091 . edksetup.sh set -e +# shellcheck disable=SC2086 case $(uname -m) in riscv64) make -C /opensbi -j "$(nproc)" PLATFORM=generic cp /opensbi/build/platform/generic/firmware/fw_payload.elf OVMF_CODE.fd @@ -23,7 +29,7 @@ case $(uname -m) in build -b ${TARGET} -t GCC5 -a AARCH64 -p ArmVirtPkg/ArmVirtXen.dsc cp Build/ArmVirtXen-AARCH64/${TARGET}_*/FV/XEN_EFI.fd OVMF_PVH.fd ;; - x86_64) build -b ${TARGET} -t GCC5 -a X64 -p OvmfPkg/OvmfPkgX64.dsc -D TPM_ENABLE=TRUE -D TPM_CONFIG_ENABLE=TRUE + x86_64) build -b ${TARGET} -t GCC5 -a X64 -p OvmfPkg/OvmfPkgX64.dsc ${OVMF_COMMON_FLAGS} cp Build/OvmfX64/${TARGET}_*/FV/OVMF*.fd . build -b ${TARGET} -t GCC5 -a X64 -p OvmfPkg/OvmfXen.dsc cp Build/OvmfXen/${TARGET}_*/FV/OVMF.fd OVMF_PVH.fd diff --git a/pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch b/pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch new file mode 100644 index 0000000000..e69de29bb2 From b4f7e4073d93cb6ed9fb32a12fcd63699f327277 Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Mon, 14 Oct 2024 16:32:59 +0300 Subject: [PATCH 3/6] pkg/uefi : add Xen spoofing patch Nvidia GPUs drivers detect it being running inside a VM and refuse to work. Spoofin Xen hypervisor signatures is a workaround for this issue. more info: https://lists.xenproject.org/archives/html/xen-devel/2016-07/msg01713.html Signed-off-by: Shahriyar Jalayeri --- .../edk2-stable202408/0-empty.patch | 0 ...0-Add-Xen-spoofing-in-XenPlatformPei.patch | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+) delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch create mode 100644 pkg/uefi/edk2-patches/edk2-stable202408/0000-Add-Xen-spoofing-in-XenPlatformPei.patch diff --git a/pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch b/pkg/uefi/edk2-patches/edk2-stable202408/0-empty.patch deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pkg/uefi/edk2-patches/edk2-stable202408/0000-Add-Xen-spoofing-in-XenPlatformPei.patch b/pkg/uefi/edk2-patches/edk2-stable202408/0000-Add-Xen-spoofing-in-XenPlatformPei.patch new file mode 100644 index 0000000000..0df5c0fe73 --- /dev/null +++ b/pkg/uefi/edk2-patches/edk2-stable202408/0000-Add-Xen-spoofing-in-XenPlatformPei.patch @@ -0,0 +1,27 @@ +From 40f36e7c4c78caf19a8367995f615139190dfbd2 Mon Sep 17 00:00:00 2001 +From: Shahriyar Jalayeri +Date: Mon, 14 Oct 2024 16:22:11 +0300 +Subject: [PATCH] Add Xen spoofing in XenPlatformPei + +Signed-off-by: Shahriyar Jalayeri +--- + OvmfPkg/XenPlatformPei/Xen.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/OvmfPkg/XenPlatformPei/Xen.c b/OvmfPkg/XenPlatformPei/Xen.c +index 7f00eef11e..6b51154f39 100644 +--- a/OvmfPkg/XenPlatformPei/Xen.c ++++ b/OvmfPkg/XenPlatformPei/Xen.c +@@ -261,6 +261,9 @@ XenDetect ( + if (!AsciiStrCmp ((CHAR8 *)Signature, "XenVMMXenVMM")) { + return TRUE; + } ++ if (!AsciiStrCmp ((CHAR8 *)Signature, "ZenZenZenZen")) { ++ return TRUE; ++ } + } + + mXenLeaf = 0; +-- +2.34.1 + From fef5845e518ebd208d0e6f38a50a1816ecdb3867 Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Mon, 14 Oct 2024 16:39:28 +0300 Subject: [PATCH 4/6] pkg/uefi : remove edk2-stable202005 patches The following Intel Graphics GOP driver patches have been dropped after discussion with @rucoder (Michael Malyshev) : 0001-OvmfPkg-Add-OpRegion-and-VBT-header-definition.patch 0002-OvmfPkg-add-IgdAssignmentDxe.patch 0003-OvmfPkg-add-Platform-GOP-Policy.patch 0004-OvmfPkg-PlatformGopPolicy-Add-OpRegion-2.1-support.patch 0005-OvmfPkg-PlatformPei-Reserve-IGD-Stolen-in-E820.patch The following patches have been dropped because they're part of the mainline : 0006-disable-werror.patch 0007-build-Fix-python3.10-threading-DeprecationWarnings.patch 0008-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch 0009-BaseTools-Work-around-array.array.tostring-removal-i.patch 0010-OvmfPkg-PlatformBootManagerLib-use-utf8-for-the-seri.patch Signed-off-by: Shahriyar Jalayeri --- .../0000-patch-xen-PlatformPei.patch | 27 - ...d-OpRegion-and-VBT-header-definition.patch | 262 ------- .../0002-OvmfPkg-add-IgdAssignmentDxe.patch | 711 ------------------ ...0003-OvmfPkg-add-Platform-GOP-Policy.patch | 407 ---------- ...rmGopPolicy-Add-OpRegion-2.1-support.patch | 87 --- ...atformPei-Reserve-IGD-Stolen-in-E820.patch | 79 -- .../0006-disable-werror.patch | 26 - ...on3.10-threading-DeprecationWarnings.patch | 171 ----- ...Tools-fix-ucs-2-lookup-on-python-3.9.patch | 50 -- ...round-array.array.tostring-removal-i.patch | 50 -- ...BootManagerLib-use-utf8-for-the-seri.patch | 72 -- 11 files changed, 1942 deletions(-) delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0000-patch-xen-PlatformPei.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0001-OvmfPkg-Add-OpRegion-and-VBT-header-definition.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0002-OvmfPkg-add-IgdAssignmentDxe.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0003-OvmfPkg-add-Platform-GOP-Policy.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0004-OvmfPkg-PlatformGopPolicy-Add-OpRegion-2.1-support.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0005-OvmfPkg-PlatformPei-Reserve-IGD-Stolen-in-E820.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0006-disable-werror.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0007-build-Fix-python3.10-threading-DeprecationWarnings.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0008-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0009-BaseTools-Work-around-array.array.tostring-removal-i.patch delete mode 100644 pkg/uefi/edk2-patches/edk2-stable202005/0010-OvmfPkg-PlatformBootManagerLib-use-utf8-for-the-seri.patch diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0000-patch-xen-PlatformPei.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0000-patch-xen-PlatformPei.patch deleted file mode 100644 index 19d0503994..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0000-patch-xen-PlatformPei.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 25d4d8ca06e121f44a769f29e176ab75ae07f6d4 Mon Sep 17 00:00:00 2001 -From: Petr Fedchenkov -Date: Thu, 15 Jul 2021 22:15:03 +0300 -Subject: [PATCH] patch xen PlatformPei - ---- - OvmfPkg/PlatformPei/Xen.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c -index 104922c..f1eae10 100644 ---- a/OvmfPkg/PlatformPei/Xen.c -+++ b/OvmfPkg/PlatformPei/Xen.c -@@ -137,6 +137,10 @@ XenDetect ( - mXen = TRUE; - return TRUE; - } -+ if (!AsciiStrCmp ((CHAR8 *) Signature, "ZenZenZenZen")) { -+ mXen = TRUE; -+ return TRUE; -+ } - } - - mXenLeaf = 0; --- -2.30.2 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0001-OvmfPkg-Add-OpRegion-and-VBT-header-definition.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0001-OvmfPkg-Add-OpRegion-and-VBT-header-definition.patch deleted file mode 100644 index 9ad94bb820..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0001-OvmfPkg-Add-OpRegion-and-VBT-header-definition.patch +++ /dev/null @@ -1,262 +0,0 @@ -From b64249a66fa21851737348eadbf06d1f8336c825 Mon Sep 17 00:00:00 2001 -From: Colin Xu -Date: Sun, 25 Apr 2021 16:46:52 +0800 -Subject: [PATCH] OvmfPkg: Add OpRegion and VBT header definition - -IgdAssignmentDxe and PlatformGOPPolicy will parse OpRegion and VBT. - -Signed-off-by: Colin Xu ---- - .../Include/IndustryStandard/AssignedIgd.h | 51 +++++ - .../Include/IndustryStandard/IgdOpRegion.h | 181 ++++++++++++++++++ - 2 files changed, 232 insertions(+) - create mode 100644 OvmfPkg/Include/IndustryStandard/AssignedIgd.h - create mode 100644 OvmfPkg/Include/IndustryStandard/IgdOpRegion.h - -diff --git a/OvmfPkg/Include/IndustryStandard/AssignedIgd.h b/OvmfPkg/Include/IndustryStandard/AssignedIgd.h -new file mode 100644 -index 000000000000..1543e20b08d0 ---- /dev/null -+++ b/OvmfPkg/Include/IndustryStandard/AssignedIgd.h -@@ -0,0 +1,51 @@ -+/** @file -+ Macros corresponding to QEMU's "Intel Graphics Device (IGD) assignment with -+ vfio-pci" specification, located at "docs/igd-assign.txt" in the QEMU source -+ tree. -+ -+ Copyright (C) 2018, Red Hat, Inc. -+ -+ This program and the accompanying materials are licensed and made available -+ under the terms and conditions of the BSD License which accompanies this -+ distribution. The full text of the license may be found at -+ http://opensource.org/licenses/bsd-license.php -+ -+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+**/ -+ -+#ifndef _ASSIGNED_IGD_H_ -+#define _ASSIGNED_IGD_H_ -+ -+#include -+ -+// -+// names of fw_cfg files -+// -+#define ASSIGNED_IGD_FW_CFG_OPREGION "etc/igd-opregion" -+#define ASSIGNED_IGD_FW_CFG_BDSM_SIZE "etc/igd-bdsm-size" -+ -+// -+// Alignment constants. UEFI page allocation automatically satisfies the -+// requirements for the OpRegion, thus we only need to define an alignment -+// constant for IGD stolen memory. -+// -+#define ASSIGNED_IGD_BDSM_ALIGN SIZE_1MB -+ -+// -+// PCI config space registers. The naming follows the PCI_*_OFFSET pattern seen -+// in MdePkg/Include/IndustryStandard/Pci*.h. -+// -+#define ASSIGNED_IGD_PCI_GSM_SIZE_OFFSET 0x51 -+#define ASSIGNED_IGD_PCI_BDSM_OFFSET 0x5C -+#define ASSIGNED_IGD_PCI_ASLS_OFFSET 0xFC -+ -+// -+// PCI location and vendor -+// -+#define ASSIGNED_IGD_PCI_BUS 0x00 -+#define ASSIGNED_IGD_PCI_DEVICE 0x02 -+#define ASSIGNED_IGD_PCI_FUNCTION 0x0 -+#define ASSIGNED_IGD_PCI_VENDOR_ID 0x8086 -+ -+#endif // _ASSIGNED_IGD_H_ -diff --git a/OvmfPkg/Include/IndustryStandard/IgdOpRegion.h b/OvmfPkg/Include/IndustryStandard/IgdOpRegion.h -new file mode 100644 -index 000000000000..4e9180c86b09 ---- /dev/null -+++ b/OvmfPkg/Include/IndustryStandard/IgdOpRegion.h -@@ -0,0 +1,181 @@ -+/** @file -+ IGD OpRegion definition from Intel Integrated Graphics Device OpRegion -+ Specification. -+ -+ https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf -+ -+ @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to 0x46(70) -+ -+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
-+ This program and the accompanying materials -+ are licensed and made available under the terms and conditions of the BSD License -+ which accompanies this distribution. The full text of the license may be found at -+ http://opensource.org/licenses/bsd-license.php -+ -+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+ -+**/ -+#ifndef _IGD_OPREGION_H_ -+#define _IGD_OPREGION_H_ -+ -+#define IGD_OPREGION_HEADER_SIGN "IntelGraphicsMem" -+#define IGD_OPREGION_HEADER_MBOX1 BIT0 -+#define IGD_OPREGION_HEADER_MBOX2 BIT1 -+#define IGD_OPREGION_HEADER_MBOX3 BIT2 -+#define IGD_OPREGION_HEADER_MBOX4 BIT3 -+#define IGD_OPREGION_HEADER_MBOX5 BIT4 -+ -+#define IGD_OPREGION_VBT_SIZE_6K (6 * SIZE_1KB) -+ -+/** -+ OpRegion structures: -+ Sub-structures define the different parts of the OpRegion followed by the -+ main structure representing the entire OpRegion. -+ -+ @note These structures are packed to 1 byte offsets because the exact -+ data location is required by the supporting design specification due to -+ the fact that the data is used by ASL and Graphics driver code compiled -+ separately. -+**/ -+#pragma pack(1) -+/// -+/// OpRegion Mailbox 0 Header structure. The OpRegion Header is used to -+/// identify a block of memory as the graphics driver OpRegion. -+/// Offset 0x0, Size 0x100 -+/// -+typedef struct { -+ CHAR8 SIGN[0x10]; ///< Offset 0x00 OpRegion Signature -+ UINT32 SIZE; ///< Offset 0x10 OpRegion Size -+ UINT32 OVER; ///< Offset 0x14 OpRegion Structure Version -+ UINT8 SVER[0x20]; ///< Offset 0x18 System BIOS Build Version -+ UINT8 VVER[0x10]; ///< Offset 0x38 Video BIOS Build Version -+ UINT8 GVER[0x10]; ///< Offset 0x48 Graphic Driver Build Version -+ UINT32 MBOX; ///< Offset 0x58 Supported Mailboxes -+ UINT32 DMOD; ///< Offset 0x5C Driver Model -+ UINT32 PCON; ///< Offset 0x60 Platform Configuration -+ CHAR16 DVER[0x10]; ///< Offset 0x64 GOP Version -+ UINT8 RM01[0x7C]; ///< Offset 0x84 Reserved Must be zero -+} IGD_OPREGION_HEADER; -+ -+/// -+/// OpRegion Mailbox 1 - Public ACPI Methods -+/// Offset 0x100, Size 0x100 -+/// -+typedef struct { -+ UINT32 DRDY; ///< Offset 0x100 Driver Readiness -+ UINT32 CSTS; ///< Offset 0x104 Status -+ UINT32 CEVT; ///< Offset 0x108 Current Event -+ UINT8 RM11[0x14]; ///< Offset 0x10C Reserved Must be Zero -+ UINT32 DIDL[8]; ///< Offset 0x120 Supported Display Devices ID List -+ UINT32 CPDL[8]; ///< Offset 0x140 Currently Attached Display Devices List -+ UINT32 CADL[8]; ///< Offset 0x160 Currently Active Display Devices List -+ UINT32 NADL[8]; ///< Offset 0x180 Next Active Devices List -+ UINT32 ASLP; ///< Offset 0x1A0 ASL Sleep Time Out -+ UINT32 TIDX; ///< Offset 0x1A4 Toggle Table Index -+ UINT32 CHPD; ///< Offset 0x1A8 Current Hotplug Enable Indicator -+ UINT32 CLID; ///< Offset 0x1AC Current Lid State Indicator -+ UINT32 CDCK; ///< Offset 0x1B0 Current Docking State Indicator -+ UINT32 SXSW; ///< Offset 0x1B4 Display Switch Notification on Sx State Resume -+ UINT32 EVTS; ///< Offset 0x1B8 Events supported by ASL -+ UINT32 CNOT; ///< Offset 0x1BC Current OS Notification -+ UINT32 NRDY; ///< Offset 0x1C0 Driver Status -+ UINT8 DID2[0x1C]; ///< Offset 0x1C4 Extended Supported Devices ID List (DOD) -+ UINT8 CPD2[0x1C]; ///< Offset 0x1E0 Extended Attached Display Devices List -+ UINT8 RM12[4]; ///< Offset 0x1FC - 0x1FF Reserved Must be zero -+} IGD_OPREGION_MBOX1; -+ -+/// -+/// OpRegion Mailbox 2 - Software SCI Interface -+/// Offset 0x200, Size 0x100 -+/// -+typedef struct { -+ UINT32 SCIC; ///< Offset 0x200 Software SCI Command / Status / Data -+ UINT32 PARM; ///< Offset 0x204 Software SCI Parameters -+ UINT32 DSLP; ///< Offset 0x208 Driver Sleep Time Out -+ UINT8 RM21[0xF4]; ///< Offset 0x20C - 0x2FF Reserved Must be zero -+} IGD_OPREGION_MBOX2; -+ -+/// -+/// OpRegion Mailbox 3 - BIOS/Driver Notification - ASLE Support -+/// Offset 0x300, Size 0x100 -+/// -+typedef struct { -+ UINT32 ARDY; ///< Offset 0x300 Driver Readiness -+ UINT32 ASLC; ///< Offset 0x304 ASLE Interrupt Command / Status -+ UINT32 TCHE; ///< Offset 0x308 Technology Enabled Indicator -+ UINT32 ALSI; ///< Offset 0x30C Current ALS Luminance Reading -+ UINT32 BCLP; ///< Offset 0x310 Requested Backlight Brightness -+ UINT32 PFIT; ///< Offset 0x314 Panel Fitting State or Request -+ UINT32 CBLV; ///< Offset 0x318 Current Brightness Level -+ UINT16 BCLM[0x14]; ///< Offset 0x31C Backlight Brightness Levels Duty Cycle Mapping Table -+ UINT32 CPFM; ///< Offset 0x344 Current Panel Fitting Mode -+ UINT32 EPFM; ///< Offset 0x348 Enabled Panel Fitting Modes -+ UINT8 PLUT[0x4A]; ///< Offset 0x34C Panel Look Up Table & Identifier -+ UINT32 PFMB; ///< Offset 0x396 PWM Frequency and Minimum Brightness -+ UINT32 CCDV; ///< Offset 0x39A Color Correction Default Values -+ UINT32 PCFT; ///< Offset 0x39E Power Conservation Features -+ UINT32 SROT; ///< Offset 0x3A2 Supported Rotation Angles -+ UINT32 IUER; ///< Offset 0x3A6 Intel Ultrabook(TM) Event Register -+ UINT64 FDSS; ///< Offset 0x3AA DSS Buffer address allocated for IFFS feature -+ UINT32 FDSP; ///< Offset 0x3B2 Size of DSS buffer -+ UINT32 STAT; ///< Offset 0x3B6 State Indicator -+ UINT64 RVDA; ///< Offset 0x3BA Absolute/Relative Address of Raw VBT Data from OpRegion Base -+ UINT32 RVDS; ///< Offset 0x3C2 Raw VBT Data Size -+ UINT8 RSVD3[0x3A]; ///< Offset 0x3C6 - 0x3FF Reserved Must be zero. Bug in spec 0x45(69) -+} IGD_OPREGION_MBOX3; -+ -+/// -+/// OpRegion Mailbox 4 - VBT Video BIOS Table -+/// Offset 0x400, Size 0x1800 -+/// -+typedef struct { -+ UINT8 RVBT[IGD_OPREGION_VBT_SIZE_6K]; ///< Offset 0x400 - 0x1BFF Raw VBT Data -+} IGD_OPREGION_MBOX4; -+ -+/// -+/// OpRegion Mailbox 5 - BIOS/Driver Notification - Data storage BIOS to Driver data sync -+/// Offset 0x1C00, Size 0x400 -+/// -+typedef struct { -+ UINT32 PHED; ///< Offset 0x1C00 Panel Header -+ UINT8 BDDC[0x100]; ///< Offset 0x1C04 Panel EDID (DDC data) -+ UINT8 RM51[0x2FC]; ///< Offset 0x1D04 - 0x1FFF Reserved Must be zero -+} IGD_OPREGION_MBOX5; -+ -+/// -+/// IGD OpRegion Structure -+/// -+typedef struct { -+ IGD_OPREGION_HEADER Header; ///< OpRegion header (Offset 0x0, Size 0x100) -+ IGD_OPREGION_MBOX1 MBox1; ///< Mailbox 1: Public ACPI Methods (Offset 0x100, Size 0x100) -+ IGD_OPREGION_MBOX2 MBox2; ///< Mailbox 2: Software SCI Interface (Offset 0x200, Size 0x100) -+ IGD_OPREGION_MBOX3 MBox3; ///< Mailbox 3: BIOS to Driver Notification (Offset 0x300, Size 0x100) -+ IGD_OPREGION_MBOX4 MBox4; ///< Mailbox 4: Video BIOS Table (VBT) (Offset 0x400, Size 0x1800) -+ IGD_OPREGION_MBOX5 MBox5; ///< Mailbox 5: BIOS to Driver Notification Extension (Offset 0x1C00, Size 0x400) -+} IGD_OPREGION_STRUCTURE; -+ -+/// -+/// VBT Header Structure -+/// -+typedef struct { -+ UINT8 Product_String[20]; -+ UINT16 Version; -+ UINT16 Header_Size; -+ UINT16 Table_Size; -+ UINT8 Checksum; -+ UINT8 Reserved1; -+ UINT32 Bios_Data_Offset; -+ UINT32 Aim_Data_Offset[4]; -+} VBT_HEADER; -+ -+typedef struct { -+ UINT8 BDB_Signature[16]; -+ UINT16 BDB_Version; -+ UINT16 BDB_Header_Size; -+ UINT16 BDB_Size; -+} VBT_BIOS_DATA_HEADER; -+ -+#pragma pack() -+ -+#endif --- -2.31.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0002-OvmfPkg-add-IgdAssignmentDxe.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0002-OvmfPkg-add-IgdAssignmentDxe.patch deleted file mode 100644 index 73b55b93e0..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0002-OvmfPkg-add-IgdAssignmentDxe.patch +++ /dev/null @@ -1,711 +0,0 @@ -From 4144c27b6922fa284a32ae104a29e9d508ae1af4 Mon Sep 17 00:00:00 2001 -From: Colin Xu -Date: Sun, 25 Apr 2021 12:45:06 -0600 -Subject: [PATCH] OvmfPkg: add IgdAssignmentDxe - -Add a DXE_DRIVER that enables Intel Graphics Device (IGD) assignment with -vfio-pci according to QEMU's "docs/igd-assign.txt" specification. - -Note that the driver is not a UEFI_DRIVER; it doesn't try to bind the -device or to install a Graphics Output Protocol instance. - -V2: -Seperate AssignedIgd.h to previous patch. -Show current OpRegion version. - -V3: -Don't define GetPciName() if MDEPKG_NDEBUG. - -Cc: Alex Williamson -Cc: Ard Biesheuvel -Cc: Jack Coulter -Cc: Jordan Justen -Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=935 -Contributed-under: TianoCore Contribution Agreement 1.1 -Signed-off-by: Laszlo Ersek -Signed-off-by: Colin Xu ---- - OvmfPkg/IgdAssignmentDxe/IgdAssignment.c | 594 +++++++++++++++++++++ - OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf | 43 ++ - OvmfPkg/OvmfPkgX64.dsc | 1 + - OvmfPkg/OvmfPkgX64.fdf | 1 + - 4 files changed, 639 insertions(+) - create mode 100644 OvmfPkg/IgdAssignmentDxe/IgdAssignment.c - create mode 100644 OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf - -diff --git a/OvmfPkg/IgdAssignmentDxe/IgdAssignment.c b/OvmfPkg/IgdAssignmentDxe/IgdAssignment.c -new file mode 100644 -index 000000000000..67f4fc8cd9ec ---- /dev/null -+++ b/OvmfPkg/IgdAssignmentDxe/IgdAssignment.c -@@ -0,0 +1,594 @@ -+/** @file -+ This driver enables Intel Graphics Device (IGD) assignment with vfio-pci -+ according to QEMU's "docs/igd-assign.txt" specification. -+ -+ Copyright (C) 2018, Red Hat, Inc. -+ -+ This program and the accompanying materials are licensed and made available -+ under the terms and conditions of the BSD License which accompanies this -+ distribution. The full text of the license may be found at -+ http://opensource.org/licenses/bsd-license.php -+ -+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+// -+// structure that collects information from PCI config space that is needed to -+// evaluate whether IGD assignment applies to the device -+// -+typedef struct { -+ UINT16 VendorId; -+ UINT8 ClassCode[3]; -+ UINTN Segment; -+ UINTN Bus; -+ UINTN Device; -+ UINTN Function; -+ CHAR8 Name[sizeof "0000:00:02.0"]; -+} CANDIDATE_PCI_INFO; -+ -+// -+// selector and size of ASSIGNED_IGD_FW_CFG_OPREGION -+// -+STATIC FIRMWARE_CONFIG_ITEM mOpRegionItem; -+STATIC UINTN mOpRegionSize; -+// -+// value read from ASSIGNED_IGD_FW_CFG_BDSM_SIZE, converted to UINTN -+// -+STATIC UINTN mBdsmSize; -+// -+// gBS->LocateProtocol() helper for finding the next unhandled PciIo instance -+// -+STATIC VOID *mPciIoTracker; -+ -+ -+/** -+ Populate the CANDIDATE_PCI_INFO structure for a PciIo protocol instance. -+ -+ @param[in] PciIo EFI_PCI_IO_PROTOCOL instance to interrogate. -+ -+ @param[out] PciInfo CANDIDATE_PCI_INFO structure to fill. -+ -+ @retval EFI_SUCCESS PciInfo has been filled in. PciInfo->Name has been set -+ to the empty string. -+ -+ @return Error codes from PciIo->Pci.Read() and -+ PciIo->GetLocation(). The contents of PciInfo are -+ indeterminate. -+**/ -+STATIC -+EFI_STATUS -+InitPciInfo ( -+ IN EFI_PCI_IO_PROTOCOL *PciIo, -+ OUT CANDIDATE_PCI_INFO *PciInfo -+ ) -+{ -+ EFI_STATUS Status; -+ -+ Status = PciIo->Pci.Read ( -+ PciIo, -+ EfiPciIoWidthUint16, -+ PCI_VENDOR_ID_OFFSET, -+ 1, // Count -+ &PciInfo->VendorId -+ ); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ Status = PciIo->Pci.Read ( -+ PciIo, -+ EfiPciIoWidthUint8, -+ PCI_CLASSCODE_OFFSET, -+ sizeof PciInfo->ClassCode, -+ PciInfo->ClassCode -+ ); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ Status = PciIo->GetLocation ( -+ PciIo, -+ &PciInfo->Segment, -+ &PciInfo->Bus, -+ &PciInfo->Device, -+ &PciInfo->Function -+ ); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ PciInfo->Name[0] = '\0'; -+ return EFI_SUCCESS; -+} -+ -+ -+/** -+ Format and get the debug name of a CANDIDATE_PCI_INFO structure. -+ -+ param[in,out] PciInfo If the PciInfo->Name member is an empty string, format -+ the PCI bus address of PciInfo into PciInfo->Name. -+ Otherwise, don't modify PciInfo. -+ -+ @return PciInfo->Name -+**/ -+#if !defined(MDEPKG_NDEBUG) -+STATIC -+CONST CHAR8 * -+GetPciName ( -+ IN OUT CANDIDATE_PCI_INFO *PciInfo -+ ) -+{ -+ if (PciInfo->Name[0] == '\0') { -+ AsciiSPrint ( -+ PciInfo->Name, -+ sizeof PciInfo->Name, -+ "%04x:%02x:%02x.%x", -+ (UINT16)PciInfo->Segment, -+ (UINT8)PciInfo->Bus, -+ (UINT8)PciInfo->Device, -+ (UINT32)PciInfo->Function & 0xf -+ ); -+ } -+ return PciInfo->Name; -+} -+#endif -+ -+/** -+ Allocate memory in the 32-bit address space, with the requested UEFI memory -+ type and the requested alignment. -+ -+ @param[in] MemoryType Assign MemoryType to the allocated pages as -+ memory type. -+ -+ @param[in] NumberOfPages The number of pages to allocate. -+ -+ @param[in] AlignmentInPages On output, Address will be a whole multiple of -+ EFI_PAGES_TO_SIZE (AlignmentInPages). -+ AlignmentInPages must be a power of two. -+ -+ @param[out] Address Base address of the allocated area. -+ -+ @retval EFI_SUCCESS Allocation successful. -+ -+ @retval EFI_INVALID_PARAMETER AlignmentInPages is not a power of two (a -+ special case of which is when AlignmentInPages -+ is zero). -+ -+ @retval EFI_OUT_OF_RESOURCES Integer overflow detected. -+ -+ @return Error codes from gBS->AllocatePages(). -+**/ -+STATIC -+EFI_STATUS -+Allocate32BitAlignedPagesWithType ( -+ IN EFI_MEMORY_TYPE MemoryType, -+ IN UINTN NumberOfPages, -+ IN UINTN AlignmentInPages, -+ OUT EFI_PHYSICAL_ADDRESS *Address -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_PHYSICAL_ADDRESS PageAlignedAddress; -+ EFI_PHYSICAL_ADDRESS FullyAlignedAddress; -+ UINTN BottomPages; -+ UINTN TopPages; -+ -+ // -+ // AlignmentInPages must be a power of two. -+ // -+ if (AlignmentInPages == 0 || -+ (AlignmentInPages & (AlignmentInPages - 1)) != 0) { -+ return EFI_INVALID_PARAMETER; -+ } -+ // -+ // (NumberOfPages + (AlignmentInPages - 1)) must not overflow UINTN. -+ // -+ if (AlignmentInPages - 1 > MAX_UINTN - NumberOfPages) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ // -+ // EFI_PAGES_TO_SIZE (AlignmentInPages) must not overflow UINTN. -+ // -+ if (AlignmentInPages > (MAX_UINTN >> EFI_PAGE_SHIFT)) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ // -+ // Allocate with sufficient padding for alignment. -+ // -+ PageAlignedAddress = BASE_4GB - 1; -+ Status = gBS->AllocatePages ( -+ AllocateMaxAddress, -+ MemoryType, -+ NumberOfPages + (AlignmentInPages - 1), -+ &PageAlignedAddress -+ ); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ FullyAlignedAddress = ALIGN_VALUE ( -+ PageAlignedAddress, -+ (UINT64)EFI_PAGES_TO_SIZE (AlignmentInPages) -+ ); -+ -+ // -+ // Release bottom and/or top padding. -+ // -+ BottomPages = EFI_SIZE_TO_PAGES ( -+ (UINTN)(FullyAlignedAddress - PageAlignedAddress) -+ ); -+ TopPages = (AlignmentInPages - 1) - BottomPages; -+ if (BottomPages > 0) { -+ Status = gBS->FreePages (PageAlignedAddress, BottomPages); -+ ASSERT_EFI_ERROR (Status); -+ } -+ if (TopPages > 0) { -+ Status = gBS->FreePages ( -+ FullyAlignedAddress + EFI_PAGES_TO_SIZE (NumberOfPages), -+ TopPages -+ ); -+ ASSERT_EFI_ERROR (Status); -+ } -+ -+ *Address = FullyAlignedAddress; -+ return EFI_SUCCESS; -+} -+ -+ -+/** -+ Set up the OpRegion for the device identified by PciIo. -+ -+ @param[in] PciIo The device to set up the OpRegion for. -+ -+ @param[in,out] PciInfo On input, PciInfo must have been initialized from -+ PciIo with InitPciInfo(). SetupOpRegion() may call -+ GetPciName() on PciInfo, possibly modifying it. -+ -+ @retval EFI_SUCCESS OpRegion setup successful. -+ -+ @retval EFI_INVALID_PARAMETER mOpRegionSize is zero. -+ -+ @return Error codes propagated from underlying -+ functions. -+**/ -+STATIC -+EFI_STATUS -+SetupOpRegion ( -+ IN EFI_PCI_IO_PROTOCOL *PciIo, -+ IN OUT CANDIDATE_PCI_INFO *PciInfo -+ ) -+{ -+ UINTN OpRegionPages; -+ UINTN OpRegionResidual; -+ EFI_STATUS Status; -+ EFI_PHYSICAL_ADDRESS Address; -+ UINT8 *BytePointer; -+ -+ if (mOpRegionSize == 0) { -+ return EFI_INVALID_PARAMETER; -+ } -+ OpRegionPages = EFI_SIZE_TO_PAGES (mOpRegionSize); -+ OpRegionResidual = EFI_PAGES_TO_SIZE (OpRegionPages) - mOpRegionSize; -+ -+ // -+ // While QEMU's "docs/igd-assign.txt" specifies reserved memory, Intel's IGD -+ // OpRegion spec refers to ACPI NVS. -+ // -+ Status = Allocate32BitAlignedPagesWithType ( -+ EfiACPIMemoryNVS, -+ OpRegionPages, -+ 1, // AlignmentInPages -+ &Address -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: failed to allocate OpRegion: %r\n", -+ __FUNCTION__, GetPciName (PciInfo), Status)); -+ return Status; -+ } -+ -+ // -+ // Download OpRegion contents from fw_cfg, zero out trailing portion. -+ // -+ BytePointer = (UINT8 *)(UINTN)Address; -+ QemuFwCfgSelectItem (mOpRegionItem); -+ QemuFwCfgReadBytes (mOpRegionSize, BytePointer); -+ ZeroMem (BytePointer + mOpRegionSize, OpRegionResidual); -+ -+ // -+ // Write address of OpRegion to PCI config space. -+ // -+ Status = PciIo->Pci.Write ( -+ PciIo, -+ EfiPciIoWidthUint32, -+ ASSIGNED_IGD_PCI_ASLS_OFFSET, -+ 1, // Count -+ &Address -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: failed to write OpRegion address: %r\n", -+ __FUNCTION__, GetPciName (PciInfo), Status)); -+ goto FreeOpRegion; -+ } -+ -+ DEBUG ((DEBUG_INFO, "%a: %a: OpRegion @ 0x%Lx size 0x%Lx version %d.%d.%d\n", -+ __FUNCTION__, -+ GetPciName (PciInfo), Address, (UINT64)mOpRegionSize, -+ ((IGD_OPREGION_HEADER*)BytePointer)->OVER >> 24, -+ ((IGD_OPREGION_HEADER*)BytePointer)->OVER >> 16 & 0xff, -+ ((IGD_OPREGION_HEADER*)BytePointer)->OVER >> 8 & 0xff)); -+ return EFI_SUCCESS; -+ -+FreeOpRegion: -+ gBS->FreePages (Address, OpRegionPages); -+ return Status; -+} -+ -+ -+/** -+ Set up stolen memory for the device identified by PciIo. -+ -+ @param[in] PciIo The device to set up stolen memory for. -+ -+ @param[in,out] PciInfo On input, PciInfo must have been initialized from -+ PciIo with InitPciInfo(). SetupStolenMemory() may -+ call GetPciName() on PciInfo, possibly modifying it. -+ -+ @retval EFI_SUCCESS Stolen memory setup successful. -+ -+ @retval EFI_INVALID_PARAMETER mBdsmSize is zero. -+ -+ @return Error codes propagated from underlying -+ functions. -+**/ -+STATIC -+EFI_STATUS -+SetupStolenMemory ( -+ IN EFI_PCI_IO_PROTOCOL *PciIo, -+ IN OUT CANDIDATE_PCI_INFO *PciInfo -+ ) -+{ -+ UINTN BdsmPages; -+ EFI_STATUS Status; -+ EFI_PHYSICAL_ADDRESS Address; -+ -+ if (mBdsmSize == 0) { -+ return EFI_INVALID_PARAMETER; -+ } -+ BdsmPages = EFI_SIZE_TO_PAGES (mBdsmSize); -+ -+ Status = Allocate32BitAlignedPagesWithType ( -+ EfiReservedMemoryType, -+ BdsmPages, -+ EFI_SIZE_TO_PAGES ((UINTN)ASSIGNED_IGD_BDSM_ALIGN), -+ &Address -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: failed to allocate stolen memory: %r\n", -+ __FUNCTION__, GetPciName (PciInfo), Status)); -+ return Status; -+ } -+ -+ // -+ // Zero out stolen memory. -+ // -+ ZeroMem ((VOID *)(UINTN)Address, EFI_PAGES_TO_SIZE (BdsmPages)); -+ -+ // -+ // Write address of stolen memory to PCI config space. -+ // -+ Status = PciIo->Pci.Write ( -+ PciIo, -+ EfiPciIoWidthUint32, -+ ASSIGNED_IGD_PCI_BDSM_OFFSET, -+ 1, // Count -+ &Address -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: failed to write stolen memory address: %r\n", -+ __FUNCTION__, GetPciName (PciInfo), Status)); -+ goto FreeStolenMemory; -+ } -+ -+ DEBUG ((DEBUG_INFO, "%a: %a: stolen memory @ 0x%Lx size 0x%Lx\n", -+ __FUNCTION__, GetPciName (PciInfo), Address, (UINT64)mBdsmSize)); -+ return EFI_SUCCESS; -+ -+FreeStolenMemory: -+ gBS->FreePages (Address, BdsmPages); -+ return Status; -+} -+ -+ -+/** -+ Process any PciIo protocol instances that may have been installed since the -+ last invocation. -+ -+ @param[in] Event Event whose notification function is being invoked. -+ -+ @param[in] Context The pointer to the notification function's context. -+**/ -+STATIC -+VOID -+EFIAPI -+PciIoNotify ( -+ IN EFI_EVENT Event, -+ IN VOID *Context -+ ) -+{ -+ EFI_PCI_IO_PROTOCOL *PciIo; -+ -+ while (!EFI_ERROR (gBS->LocateProtocol ( -+ &gEfiPciIoProtocolGuid, -+ mPciIoTracker, -+ (VOID **)&PciIo -+ ))) { -+ EFI_STATUS Status; -+ CANDIDATE_PCI_INFO PciInfo; -+ -+ Status = InitPciInfo (PciIo, &PciInfo); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: InitPciInfo (PciIo@%p): %r\n", __FUNCTION__, -+ (VOID *)PciIo, Status)); -+ continue; -+ } -+ -+ // -+ // Check VendorId and ClassCode. These checks are necessary for both -+ // OpRegion and stolen memory setup. -+ // -+ if (PciInfo.VendorId != ASSIGNED_IGD_PCI_VENDOR_ID || -+ PciInfo.ClassCode[2] != PCI_CLASS_DISPLAY || -+ PciInfo.ClassCode[1] != PCI_CLASS_DISPLAY_VGA || -+ PciInfo.ClassCode[0] != PCI_IF_VGA_VGA) { -+ continue; -+ } -+ -+ if (mOpRegionSize > 0) { -+ SetupOpRegion (PciIo, &PciInfo); -+ } -+ -+ // -+ // Check Bus:Device.Function (Segment is ignored). This is necessary before -+ // stolen memory setup. -+ // -+ if (PciInfo.Bus != ASSIGNED_IGD_PCI_BUS || -+ PciInfo.Device != ASSIGNED_IGD_PCI_DEVICE || -+ PciInfo.Function != ASSIGNED_IGD_PCI_FUNCTION) { -+ continue; -+ } -+ -+ if (mBdsmSize > 0) { -+ SetupStolenMemory (PciIo, &PciInfo); -+ } -+ } -+} -+ -+ -+/** -+ Entry point for this driver. -+ -+ @param[in] ImageHandle Image handle of this driver. -+ -+ @param[in] SystemTable Pointer to SystemTable. -+ -+ @retval EFI_SUCESS Driver has loaded successfully. -+ -+ @retval EFI_UNSUPPORTED No IGD assigned. -+ -+ @retval EFI_PROTOCOL_ERROR Invalid fw_cfg contents. -+ -+ @return Error codes propagated from underlying functions. -+**/ -+EFI_STATUS -+EFIAPI -+IgdAssignmentEntry ( -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable -+ ) -+{ -+ EFI_STATUS OpRegionStatus; -+ EFI_STATUS BdsmStatus; -+ FIRMWARE_CONFIG_ITEM BdsmItem; -+ UINTN BdsmItemSize; -+ EFI_STATUS Status; -+ EFI_EVENT PciIoEvent; -+ -+ OpRegionStatus = QemuFwCfgFindFile ( -+ ASSIGNED_IGD_FW_CFG_OPREGION, -+ &mOpRegionItem, -+ &mOpRegionSize -+ ); -+ BdsmStatus = QemuFwCfgFindFile ( -+ ASSIGNED_IGD_FW_CFG_BDSM_SIZE, -+ &BdsmItem, -+ &BdsmItemSize -+ ); -+ // -+ // If neither fw_cfg file is available, assume no IGD is assigned. -+ // -+ if (EFI_ERROR (OpRegionStatus) && EFI_ERROR (BdsmStatus)) { -+ return EFI_UNSUPPORTED; -+ } -+ -+ // -+ // Require all fw_cfg files that are present to be well-formed. -+ // -+ if (!EFI_ERROR (OpRegionStatus) && mOpRegionSize == 0) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: zero size\n", __FUNCTION__, -+ ASSIGNED_IGD_FW_CFG_OPREGION)); -+ return EFI_PROTOCOL_ERROR; -+ } -+ -+ if (!EFI_ERROR (BdsmStatus)) { -+ UINT64 BdsmSize; -+ -+ if (BdsmItemSize != sizeof BdsmSize) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: invalid fw_cfg size: %Lu\n", __FUNCTION__, -+ ASSIGNED_IGD_FW_CFG_BDSM_SIZE, (UINT64)BdsmItemSize)); -+ return EFI_PROTOCOL_ERROR; -+ } -+ QemuFwCfgSelectItem (BdsmItem); -+ QemuFwCfgReadBytes (BdsmItemSize, &BdsmSize); -+ -+ if (BdsmSize == 0 || BdsmSize > MAX_UINTN) { -+ DEBUG ((DEBUG_ERROR, "%a: %a: invalid value: %Lu\n", __FUNCTION__, -+ ASSIGNED_IGD_FW_CFG_BDSM_SIZE, BdsmSize)); -+ return EFI_PROTOCOL_ERROR; -+ } -+ mBdsmSize = (UINTN)BdsmSize; -+ } -+ -+ // -+ // At least one valid fw_cfg file has been found. -+ // -+ ASSERT (mOpRegionSize > 0 || mBdsmSize > 0); -+ -+ // -+ // Register PciIo protocol installation callback. -+ // -+ Status = gBS->CreateEvent ( -+ EVT_NOTIFY_SIGNAL, -+ TPL_CALLBACK, -+ PciIoNotify, -+ NULL, // Context -+ &PciIoEvent -+ ); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ Status = gBS->RegisterProtocolNotify ( -+ &gEfiPciIoProtocolGuid, -+ PciIoEvent, -+ &mPciIoTracker -+ ); -+ if (EFI_ERROR (Status)) { -+ goto ClosePciIoEvent; -+ } -+ -+ // -+ // Kick the event for any existent PciIo protocol instances. -+ // -+ Status = gBS->SignalEvent (PciIoEvent); -+ if (EFI_ERROR (Status)) { -+ goto ClosePciIoEvent; -+ } -+ -+ return EFI_SUCCESS; -+ -+ClosePciIoEvent: -+ gBS->CloseEvent (PciIoEvent); -+ -+ return Status; -+} -diff --git a/OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf b/OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf -new file mode 100644 -index 000000000000..241c57b6e257 ---- /dev/null -+++ b/OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf -@@ -0,0 +1,43 @@ -+## @file -+# This driver enables Intel Graphics Device (IGD) assignment with vfio-pci -+# according to QEMU's "docs/igd-assign.txt" specification. -+# -+# Copyright (C) 2018, Red Hat, Inc. -+# -+# This program and the accompanying materials are licensed and made available -+# under the terms and conditions of the BSD License which accompanies this -+# distribution. The full text of the license may be found at -+# http://opensource.org/licenses/bsd-license.php -+# -+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+## -+ -+[Defines] -+ INF_VERSION = 1.27 -+ BASE_NAME = IgdAssignmentDxe -+ FILE_GUID = FDD95992-8F3B-4ADD-8DEC-989EA84E9DF1 -+ MODULE_TYPE = DXE_DRIVER -+ VERSION_STRING = 1.0 -+ ENTRY_POINT = IgdAssignmentEntry -+ -+[Sources] -+ IgdAssignment.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ OvmfPkg/OvmfPkg.dec -+ -+[LibraryClasses] -+ BaseMemoryLib -+ DebugLib -+ PrintLib -+ QemuFwCfgLib -+ UefiBootServicesTableLib -+ UefiDriverEntryPoint -+ -+[Protocols] -+ gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES ## NOTIFY -+ -+[Depex] -+ TRUE -diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index b80710fbdca4..565e0573b24d 100644 ---- a/OvmfPkg/OvmfPkgX64.dsc -+++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -783,6 +783,7 @@ - OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf - OvmfPkg/XenBusDxe/XenBusDxe.inf - OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf -+ OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf -index 8da59037e5f0..00098b18d911 100644 ---- a/OvmfPkg/OvmfPkgX64.fdf -+++ b/OvmfPkg/OvmfPkgX64.fdf -@@ -240,6 +240,7 @@ INF OvmfPkg/VirtioRngDxe/VirtioRng.inf - INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf - INF OvmfPkg/XenBusDxe/XenBusDxe.inf - INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf -+INF OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf - !if $(PVSCSI_ENABLE) == TRUE - INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif --- -2.31.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0003-OvmfPkg-add-Platform-GOP-Policy.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0003-OvmfPkg-add-Platform-GOP-Policy.patch deleted file mode 100644 index d258f4eb00..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0003-OvmfPkg-add-Platform-GOP-Policy.patch +++ /dev/null @@ -1,407 +0,0 @@ -From f21e0f89e27d34c16e1d1c706e007a5735afb6b5 Mon Sep 17 00:00:00 2001 -From: Colin Xu -Date: Sun, 25 Apr 2021 12:50:17 -0600 -Subject: [PATCH] OvmfPkg: add Platform GOP Policy - -GOP driver has dependency on PlatformGopPolicy protocol, especially -the GetVbtData() interface, here we return the vbt from host opregion. - -V2: -Fix VBT checksum so that the pass-through IGD can always use the correct -VBT matching the actual. - -Signed-off-by: Xiong Zhang -Signed-off-by: Colin Xu ---- - OvmfPkg/Include/Protocol/PlatformGopPolicy.h | 68 ++++++ - OvmfPkg/OvmfPkg.dec | 1 + - OvmfPkg/OvmfPkgX64.dsc | 1 + - OvmfPkg/OvmfPkgX64.fdf | 1 + - OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c | 206 ++++++++++++++++++ - .../PlatformGopPolicy/PlatformGopPolicy.inf | 50 +++++ - 6 files changed, 327 insertions(+) - create mode 100644 OvmfPkg/Include/Protocol/PlatformGopPolicy.h - create mode 100644 OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c - create mode 100644 OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.inf - -diff --git a/OvmfPkg/Include/Protocol/PlatformGopPolicy.h b/OvmfPkg/Include/Protocol/PlatformGopPolicy.h -new file mode 100644 -index 000000000000..e29c8690fd7c ---- /dev/null -+++ b/OvmfPkg/Include/Protocol/PlatformGopPolicy.h -@@ -0,0 +1,68 @@ -+/*++ -+ -+Copyright (c) 1999 - 2019, Intel Corporation. All rights reserved -+ -+ This program and the accompanying materials are licensed and made available under -+ the terms and conditions of the BSD License that accompanies this distribution. -+ The full text of the license may be found at -+ http://opensource.org/licenses/bsd-license.php. -+ -+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+ -+ -+--*/ -+ -+/** @file -+**/ -+ -+#ifndef _PLATFORM_GOP_POLICY_PROTOCOL_H_ -+#define _PLATFORM_GOP_POLICY_PROTOCOL_H_ -+ -+#define EFI_PLATFORM_GOP_POLICY_PROTOCOL_GUID \ -+ { 0xec2e931b, 0x3281, 0x48a5, 0x81, 0x7, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } -+ -+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01 0x01 -+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_02 x0222 -+ -+#pragma pack(1) -+ -+typedef enum { -+ LidClosed, -+ LidOpen, -+ LidStatusMax -+} LID_STATUS; -+ -+typedef enum { -+ Docked, -+ UnDocked, -+ DockStatusMax -+} DOCK_STATUS; -+ -+typedef -+EFI_STATUS -+(EFIAPI *GET_PLATFORM_LID_STATUS) ( -+ OUT LID_STATUS *CurrentLidStatus -+); -+ -+typedef -+EFI_STATUS -+(EFIAPI *GET_VBT_DATA) ( -+ OUT EFI_PHYSICAL_ADDRESS *VbtAddress, -+ OUT UINT32 *VbtSize -+); -+ -+#pragma pack() -+ -+typedef struct _PLATFORM_GOP_POLICY_PROTOCOL { -+ UINT32 Revision; -+ GET_PLATFORM_LID_STATUS GetPlatformLidStatus; -+ GET_VBT_DATA GetVbtData; -+} PLATFORM_GOP_POLICY_PROTOCOL; -+ -+// -+// Extern the GUID for protocol users. -+// -+extern EFI_GUID gPlatformGOPPolicyGuid; -+ -+#endif -diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec -index 6abde4fd9351..b46b5778e28e 100644 ---- a/OvmfPkg/OvmfPkg.dec -+++ b/OvmfPkg/OvmfPkg.dec -@@ -136,6 +136,7 @@ - gEfiLegacyInterruptProtocolGuid = {0x31ce593d, 0x108a, 0x485d, {0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe}} - gEfiVgaMiniPortProtocolGuid = {0xc7735a2f, 0x88f5, 0x4882, {0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3}} - gOvmfLoadedX86LinuxKernelProtocolGuid = {0xa3edc05d, 0xb618, 0x4ff6, {0x95, 0x52, 0x76, 0xd7, 0x88, 0x63, 0x43, 0xc8}} -+ gPlatformGOPPolicyGuid = {0xec2e931b, 0x3281, 0x48a5, {0x81, 0x07, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d}} - - [PcdsFixedAtBuild] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|0x0|UINT32|0 -diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index 565e0573b24d..f3a27f33f518 100644 ---- a/OvmfPkg/OvmfPkgX64.dsc -+++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -784,6 +784,7 @@ - OvmfPkg/XenBusDxe/XenBusDxe.inf - OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf -+ OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf -index 00098b18d911..a782f86ffec8 100644 ---- a/OvmfPkg/OvmfPkgX64.fdf -+++ b/OvmfPkg/OvmfPkgX64.fdf -@@ -241,6 +241,7 @@ INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf - INF OvmfPkg/XenBusDxe/XenBusDxe.inf - INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - INF OvmfPkg/IgdAssignmentDxe/IgdAssignment.inf -+INF OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.inf - !if $(PVSCSI_ENABLE) == TRUE - INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -diff --git a/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c b/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c -new file mode 100644 -index 000000000000..d94f154c0279 ---- /dev/null -+++ b/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c -@@ -0,0 +1,206 @@ -+/*++ -+ -+Copyright (c) 1999 - 2019, Intel Corporation. All rights reserved -+ -+ This program and the accompanying materials are licensed and made available under -+ the terms and conditions of the BSD License that accompanies this distribution. -+ The full text of the license may be found at -+ http://opensource.org/licenses/bsd-license.php. -+ -+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+ -+ -+--*/ -+ -+/** @file -+**/ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+#include -+#include -+ -+PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy; -+EFI_PHYSICAL_ADDRESS mVbt; -+ -+// -+// Function implementations -+// -+ -+/** -+ The function will execute with as the platform policy, and gives -+ the Platform Lid Status. IBV/OEM can customize this code for their specific -+ policy action. -+ -+ @param CurrentLidStatus Gives the current LID Status -+ -+ @retval EFI_SUCCESS. -+ -+**/ -+EFI_STATUS -+EFIAPI -+GetPlatformLidStatus ( -+ OUT LID_STATUS *CurrentLidStatus -+) -+{ -+ return EFI_UNSUPPORTED; -+} -+ -+/** -+ The function will execute and gives the Video Bios Table Size and Address. -+ -+ @param VbtAddress Gives the Physical Address of Video BIOS Table -+ -+ @param VbtSize Gives the Size of Video BIOS Table -+ -+ @retval EFI_STATUS. -+ -+**/ -+ -+EFI_STATUS -+EFIAPI -+GetVbtData ( -+ OUT EFI_PHYSICAL_ADDRESS *VbtAddress, -+ OUT UINT32 *VbtSize -+) -+{ -+ IGD_OPREGION_STRUCTURE *OpRegion; -+ EFI_STATUS Status = EFI_INVALID_PARAMETER; -+ UINT16 VerMajor, VerMinor = 0; -+ UINT32 VbtSizeMax = 0; -+ -+ OpRegion = (IGD_OPREGION_STRUCTURE*)(UINTN)PciRead32 ( -+ PCI_LIB_ADDRESS ( -+ ASSIGNED_IGD_PCI_BUS, -+ ASSIGNED_IGD_PCI_DEVICE, -+ ASSIGNED_IGD_PCI_FUNCTION, -+ ASSIGNED_IGD_PCI_ASLS_OFFSET)); -+ -+ /* Validate IGD OpRegion signature and version */ -+ if (OpRegion) { -+ if (CompareMem (OpRegion->Header.SIGN, IGD_OPREGION_HEADER_SIGN, sizeof(OpRegion->Header.SIGN)) != 0) { -+ DEBUG ((EFI_D_ERROR, "%a: Invalid OpRegion signature, expect %s\n", -+ __FUNCTION__, IGD_OPREGION_HEADER_SIGN)); -+ return EFI_INVALID_PARAMETER; -+ } else { -+ VerMajor = OpRegion->Header.OVER >> 24; -+ VerMinor = OpRegion->Header.OVER >> 16 & 0xff; -+ if (VerMajor < 2 || OpRegion->MBox3.RVDA == 0) { -+ VbtSizeMax = IGD_OPREGION_VBT_SIZE_6K; -+ if (((VBT_HEADER*)&OpRegion->MBox4)->Table_Size > IGD_OPREGION_VBT_SIZE_6K) { -+ DEBUG ((EFI_D_ERROR, "%a: VBT Header reports larger size (0x%x) than OpRegion VBT Mailbox (0x%x)\n", -+ __FUNCTION__, -+ ((VBT_HEADER*)&OpRegion->MBox4)->Table_Size, IGD_OPREGION_VBT_SIZE_6K)); -+ VbtSizeMax = 0; -+ return EFI_INVALID_PARAMETER; -+ } -+ } else { -+ DEBUG ((EFI_D_ERROR, "%a: Unsupported OpRegion version %d.%d\n", -+ __FUNCTION__, VerMajor, VerMinor)); -+ return EFI_UNSUPPORTED; -+ } -+ } -+ } -+ -+ if (mVbt) { -+ Status = gBS->FreePages ( -+ mVbt, -+ EFI_SIZE_TO_PAGES (VbtSizeMax) -+ ); -+ } -+ -+ if (VbtSizeMax == IGD_OPREGION_VBT_SIZE_6K) { -+ mVbt = SIZE_4GB - 1; -+ } -+ -+ /* Only operates VBT on support OpRegion */ -+ if (VbtSizeMax) { -+ Status = gBS->AllocatePages ( -+ AllocateMaxAddress, -+ EfiReservedMemoryType, -+ EFI_SIZE_TO_PAGES (VbtSizeMax), -+ &mVbt -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((EFI_D_ERROR, "%a: AllocatePages failed for VBT size 0x%x status %d\n", -+ __FUNCTION__, VbtSizeMax, Status)); -+ return EFI_OUT_OF_RESOURCES; -+ } else { -+ UINT8 CheckSum = 0; -+ -+ /* Zero-out first*/ -+ ZeroMem ((VOID*)mVbt, VbtSizeMax); -+ /* Only copy with size as specified in VBT table */ -+ CopyMem((VOID*)mVbt, (VOID*)OpRegion->MBox4.RVBT, ((VBT_HEADER*)&OpRegion->MBox4)->Table_Size); -+ -+ /* Fix the checksum */ -+ for (UINT32 i = 0; i < ((VBT_HEADER*)mVbt)->Table_Size; i++) { -+ CheckSum = (CheckSum + ((UINT8*)mVbt)[i]) & 0xFF; -+ } -+ ((VBT_HEADER*)mVbt)->Checksum += (0x100 - CheckSum); -+ -+ *VbtAddress = mVbt; -+ *VbtSize = ((VBT_HEADER*)mVbt)->Table_Size; -+ DEBUG ((DEBUG_INFO, "%a: VBT Version %d size 0x%x\n", __FUNCTION__, -+ ((VBT_BIOS_DATA_HEADER*)(mVbt + ((VBT_HEADER*)mVbt)->Bios_Data_Offset))->BDB_Version, -+ ((VBT_HEADER*)mVbt)->Table_Size)); -+ return EFI_SUCCESS; -+ } -+ } -+ -+ return EFI_UNSUPPORTED; -+} -+ -+/** -+ Entry point for the Platform GOP Policy Driver. -+ -+ @param ImageHandle Image handle of this driver. -+ @param SystemTable Global system service table. -+ -+ @retval EFI_SUCCESS Initialization complete. -+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver. -+ -+**/ -+ -+EFI_STATUS -+EFIAPI -+PlatformGOPPolicyEntryPoint ( -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable -+ ) -+ -+{ -+ EFI_STATUS Status = EFI_SUCCESS; -+ -+ gBS = SystemTable->BootServices; -+ -+ gBS->SetMem ( -+ &mPlatformGOPPolicy, -+ sizeof (PLATFORM_GOP_POLICY_PROTOCOL), -+ 0 -+ ); -+ -+ mPlatformGOPPolicy.Revision = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01; -+ mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus; -+ mPlatformGOPPolicy.GetVbtData = GetVbtData; -+ -+ // -+ // Install protocol to allow access to this Policy. -+ // -+ Status = gBS->InstallMultipleProtocolInterfaces ( -+ &ImageHandle, -+ &gPlatformGOPPolicyGuid, -+ &mPlatformGOPPolicy, -+ NULL -+ ); -+ -+ return Status; -+} -diff --git a/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.inf b/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.inf -new file mode 100644 -index 000000000000..705b4960b8cd ---- /dev/null -+++ b/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.inf -@@ -0,0 +1,50 @@ -+# -+# -+# Copyright (c) 1999 - 2019, Intel Corporation. All rights reserved -+# -+# This program and the accompanying materials are licensed and made available under -+# the terms and conditions of the BSD License that accompanies this distribution. -+# The full text of the license may be found at -+# http://opensource.org/licenses/bsd-license.php. -+# -+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -+# -+# -+# -+## -+ -+ -+[Defines] -+ INF_VERSION = 0x00010005 -+ BASE_NAME = PlatformGOPPolicy -+ FILE_GUID = 9737D7CA-D869-45e5-A5EF-75D9438688DE -+ MODULE_TYPE = DXE_DRIVER -+ VERSION_STRING = 1.0 -+ ENTRY_POINT = PlatformGOPPolicyEntryPoint -+ -+# -+# The following information is for reference only and not required by the build tools. -+# -+# VALID_ARCHITECTURES = IA32 -+# -+ -+[Sources.common] -+ PlatformGopPolicy.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ OvmfPkg/OvmfPkg.dec -+ -+[LibraryClasses] -+ BaseLib -+ DebugLib -+ UefiDriverEntryPoint -+ UefiRuntimeServicesTableLib -+ PciLib -+ -+[Protocols] -+ gPlatformGOPPolicyGuid -+ -+[Depex] -+ TRUE --- -2.31.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0004-OvmfPkg-PlatformGopPolicy-Add-OpRegion-2.1-support.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0004-OvmfPkg-PlatformGopPolicy-Add-OpRegion-2.1-support.patch deleted file mode 100644 index 05151f8fb1..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0004-OvmfPkg-PlatformGopPolicy-Add-OpRegion-2.1-support.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 4247fe457ea18f2d4c7467d431dc048b3451cb04 Mon Sep 17 00:00:00 2001 -From: Colin Xu -Date: Thu, 27 May 2021 09:08:25 +0800 -Subject: [PATCH] OvmfPkg/PlatformGopPolicy: Add OpRegion 2.1 support. - -Signed-off-by: Colin Xu ---- - OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c | 39 ++++++++++++++----- - 1 file changed, 30 insertions(+), 9 deletions(-) - -diff --git a/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c b/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c -index d94f154c0279..2df8def8e20d 100644 ---- a/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c -+++ b/OvmfPkg/PlatformGopPolicy/PlatformGopPolicy.c -@@ -93,7 +93,21 @@ GetVbtData ( - } else { - VerMajor = OpRegion->Header.OVER >> 24; - VerMinor = OpRegion->Header.OVER >> 16 & 0xff; -- if (VerMajor < 2 || OpRegion->MBox3.RVDA == 0) { -+ /* -+ * OpRegion version and VBT size: -+ * Before 2.0: VBT is stored in OpRegion Mailbox 4 and the size won't exceed 6K. -+ * For 2.0 and 2.0+: -+ * If VBT raw data size doesn't exceeds 6K, VBT is stored in Mailbox 4. -+ * If exceeds 6K, VBT is stored in extended VBT region, the address and -+ * size are stored in OpRegion head RVDA and RVDS. -+ * - 2.0, RVDA holds the absolute physical address. -+ * - 2.0+, RVDA holds the relative address OpRegion base, >= OpRegion size -+ * vfio-pci allocates a contigious memory to hold both OpRegion and VBT for -+ * OpRegion 2.0 with >6K VBT and fake it to 2.1. So from OVMF perspective, -+ * it shouldn't see OpRegion 2.0 with valid RVDA/RVDS. Otherwise the -+ * vfio-pci driver needs updated. -+ */ -+ if (VerMajor < 2) { - VbtSizeMax = IGD_OPREGION_VBT_SIZE_6K; - if (((VBT_HEADER*)&OpRegion->MBox4)->Table_Size > IGD_OPREGION_VBT_SIZE_6K) { - DEBUG ((EFI_D_ERROR, "%a: VBT Header reports larger size (0x%x) than OpRegion VBT Mailbox (0x%x)\n", -@@ -102,10 +116,16 @@ GetVbtData ( - VbtSizeMax = 0; - return EFI_INVALID_PARAMETER; - } -- } else { -- DEBUG ((EFI_D_ERROR, "%a: Unsupported OpRegion version %d.%d\n", -- __FUNCTION__, VerMajor, VerMinor)); -+ } else if (VerMajor == 2 && VerMinor == 0 && OpRegion->MBox3.RVDA && OpRegion->MBox3.RVDS){ -+ DEBUG ((EFI_D_ERROR, "%a: Unsupported OpRegion version %d.%d with VBT larger than 0x%x\n", -+ __FUNCTION__, VerMajor, VerMinor, IGD_OPREGION_VBT_SIZE_6K)); -+ VbtSizeMax = 0; - return EFI_UNSUPPORTED; -+ } else { -+ VbtSizeMax = IGD_OPREGION_VBT_SIZE_6K; -+ if (OpRegion->MBox3.RVDA && OpRegion->MBox3.RVDS) { -+ VbtSizeMax = OpRegion->MBox3.RVDS; -+ } - } - } - } -@@ -117,12 +137,9 @@ GetVbtData ( - ); - } - -- if (VbtSizeMax == IGD_OPREGION_VBT_SIZE_6K) { -- mVbt = SIZE_4GB - 1; -- } -- - /* Only operates VBT on support OpRegion */ - if (VbtSizeMax) { -+ mVbt = SIZE_4GB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, -@@ -139,7 +156,11 @@ GetVbtData ( - /* Zero-out first*/ - ZeroMem ((VOID*)mVbt, VbtSizeMax); - /* Only copy with size as specified in VBT table */ -- CopyMem((VOID*)mVbt, (VOID*)OpRegion->MBox4.RVBT, ((VBT_HEADER*)&OpRegion->MBox4)->Table_Size); -+ if (VerMajor < 2 || !OpRegion->MBox3.RVDA || !OpRegion->MBox3.RVDS) { -+ CopyMem((VOID*)mVbt, (VOID*)OpRegion->MBox4.RVBT, ((VBT_HEADER*)&OpRegion->MBox4)->Table_Size); -+ } else { -+ CopyMem((VOID*)mVbt, (VOID*)OpRegion + OpRegion->MBox3.RVDA, OpRegion->MBox3.RVDS); -+ } - - /* Fix the checksum */ - for (UINT32 i = 0; i < ((VBT_HEADER*)mVbt)->Table_Size; i++) { --- -2.31.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0005-OvmfPkg-PlatformPei-Reserve-IGD-Stolen-in-E820.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0005-OvmfPkg-PlatformPei-Reserve-IGD-Stolen-in-E820.patch deleted file mode 100644 index 83dc746ce6..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0005-OvmfPkg-PlatformPei-Reserve-IGD-Stolen-in-E820.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 4b38f8f132b10c038de87b52ee6d97c84656293c Mon Sep 17 00:00:00 2001 -From: Colin Xu -Date: Thu, 27 May 2021 16:36:37 +0800 -Subject: [PATCH] OvmfPkg/PlatformPei: Reserve IGD Stolen in E820. - -Read DSM info from QemuFwCfg and reserve in E820. - -Signed-off-by: Colin Xu ---- - OvmfPkg/PlatformPei/Platform.c | 46 ++++++++++++++++++++++++++++++++++ - 1 file changed, 46 insertions(+) - -diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c -index 96468701e3b8..4a883e965b17 100644 ---- a/OvmfPkg/PlatformPei/Platform.c -+++ b/OvmfPkg/PlatformPei/Platform.c -@@ -457,6 +457,50 @@ ReserveEmuVariableNvStore ( - ASSERT_RETURN_ERROR (PcdStatus); - } - -+#define INTEL_PCI_VENDOR_ID 0x8086 -+#define PCI_BUS_NUM_IGD 0 -+#define PCI_DEV_NUM_IGD 2 -+#define PCI_FUNC_NUM_IGD 0 -+ -+VOID -+ReserveIgdStolen ( -+ ) -+{ -+ UINT16 VendorId = PciRead16 (PCI_LIB_ADDRESS (PCI_BUS_NUM_IGD, PCI_DEV_NUM_IGD, PCI_FUNC_NUM_IGD, PCI_VENDOR_ID_OFFSET)); -+ UINT8 Class = PciRead8 (PCI_LIB_ADDRESS (PCI_BUS_NUM_IGD, PCI_DEV_NUM_IGD, PCI_FUNC_NUM_IGD, PCI_CLASSCODE_OFFSET + 2)); -+ -+ if (VendorId == INTEL_PCI_VENDOR_ID && Class == PCI_CLASS_DISPLAY) { -+ EFI_STATUS FwCfgStatus = 0; -+ FIRMWARE_CONFIG_ITEM FwCfgItem; -+ UINTN FwCfgItemSize; -+ UINT64 StolenBase = 0; -+ UINT64 StolenSize = 0; -+ -+ FwCfgStatus = QemuFwCfgFindFile ("etc/igd-dsm-base", &FwCfgItem, &FwCfgItemSize); -+ if (EFI_ERROR (FwCfgStatus) || FwCfgItemSize != sizeof(StolenBase)) { -+ return; -+ } -+ QemuFwCfgSelectItem (FwCfgItem); -+ QemuFwCfgReadBytes (FwCfgItemSize, &StolenBase); -+ -+ FwCfgStatus = QemuFwCfgFindFile ("etc/igd-dsm-size", &FwCfgItem, &FwCfgItemSize); -+ if (EFI_ERROR (FwCfgStatus) || FwCfgItemSize != sizeof(StolenSize)) { -+ return; -+ } -+ QemuFwCfgSelectItem (FwCfgItem); -+ QemuFwCfgReadBytes (FwCfgItemSize, &StolenSize); -+ -+ if (StolenBase && StolenSize) { -+ BuildMemoryAllocationHob ( -+ StolenBase, -+ StolenSize, -+ EfiReservedMemoryType -+ ); -+ -+ DEBUG ((DEBUG_INFO, "IGD stolen memory at %llx, size %x\n", StolenBase, StolenSize)); -+ } -+ } -+} - - VOID - DebugDumpCmos ( -@@ -705,6 +749,8 @@ InitializePlatform ( - - XenDetect (); - -+ ReserveIgdStolen (); -+ - if (QemuFwCfgS3Enabled ()) { - DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n")); - mS3Supported = TRUE; --- -2.31.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0006-disable-werror.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0006-disable-werror.patch deleted file mode 100644 index 952b2ee6fe..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0006-disable-werror.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 70b02770f1969f003de3956632db429b26c83160 Mon Sep 17 00:00:00 2001 -From: Petr Fedchenkov -Date: Tue, 16 Aug 2022 14:33:13 +0300 -Subject: [PATCH] build: Fix building under gcc 11.2 - -Signed-off-by: Petr Fedchenkov ---- - BaseTools/Source/C/Makefiles/header.makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile -index 4e9b36d98b..af2f631683 100644 ---- a/BaseTools/Source/C/Makefiles/header.makefile -+++ b/BaseTools/Source/C/Makefiles/header.makefile -@@ -73,7 +73,7 @@ BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \ - -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g - else - BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ ---fno-delete-null-pointer-checks -Wall -Werror \ -+-fno-delete-null-pointer-checks -Wall \ - -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \ - -Wno-unused-result -nostdlib -g - endif --- -2.34.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0007-build-Fix-python3.10-threading-DeprecationWarnings.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0007-build-Fix-python3.10-threading-DeprecationWarnings.patch deleted file mode 100644 index 11de4723b2..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0007-build-Fix-python3.10-threading-DeprecationWarnings.patch +++ /dev/null @@ -1,171 +0,0 @@ -From 975031b82b0c55686143ffe70a487dc2afe2051d Mon Sep 17 00:00:00 2001 -From: Petr Fedchenkov -Date: Tue, 16 Aug 2022 14:30:26 +0300 -Subject: [PATCH] build: Fix python3.10 threading DeprecationWarnings - -threading camelCase functions have preferred alternatives since -python2.6. python3.10 has started emitting DeprecationWarnings -for them - -Signed-off-by: Petr Fedchenkov ---- - BaseTools/Source/Python/build/build.py | 48 +++++++++++++------------- - 1 file changed, 24 insertions(+), 24 deletions(-) - -diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py -index ed3a3b978d..6de500c4a3 100755 ---- a/BaseTools/Source/Python/build/build.py -+++ b/BaseTools/Source/Python/build/build.py -@@ -196,7 +196,7 @@ def ReadMessage(From, To, ExitFlag,MemTo=None): - To(LineStr) - else: - break -- if ExitFlag.isSet(): -+ if ExitFlag.is_set(): - break - - class MakeSubProc(Popen): -@@ -240,8 +240,8 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto = None): - EndOfProcedure.clear() - if Proc.stdout: - StdOutThread = Thread(target=ReadMessage, args=(Proc.stdout, EdkLogger.info, EndOfProcedure,Proc.ProcOut)) -- StdOutThread.setName("STDOUT-Redirector") -- StdOutThread.setDaemon(False) -+ StdOutThread.name = "STDOUT-Redirector" -+ StdOutThread.daemon = False - StdOutThread.start() - - -@@ -432,8 +432,8 @@ class BuildTask: - @staticmethod - def StartScheduler(MaxThreadNumber, ExitFlag): - SchedulerThread = Thread(target=BuildTask.Scheduler, args=(MaxThreadNumber, ExitFlag)) -- SchedulerThread.setName("Build-Task-Scheduler") -- SchedulerThread.setDaemon(False) -+ SchedulerThread.name = "Build-Task-Scheduler" -+ SchedulerThread.daemon = False - SchedulerThread.start() - # wait for the scheduler to be started, especially useful in Linux - while not BuildTask.IsOnGoing(): -@@ -455,7 +455,7 @@ class BuildTask: - # indicated to do so, or there's error in running thread - # - while (len(BuildTask._PendingQueue) > 0 or len(BuildTask._ReadyQueue) > 0 \ -- or not ExitFlag.isSet()) and not BuildTask._ErrorFlag.isSet(): -+ or not ExitFlag.is_set()) and not BuildTask._ErrorFlag.is_set(): - EdkLogger.debug(EdkLogger.DEBUG_8, "Pending Queue (%d), Ready Queue (%d)" - % (len(BuildTask._PendingQueue), len(BuildTask._ReadyQueue))) - -@@ -473,7 +473,7 @@ class BuildTask: - BuildTask._PendingQueueLock.release() - - # launch build thread until the maximum number of threads is reached -- while not BuildTask._ErrorFlag.isSet(): -+ while not BuildTask._ErrorFlag.is_set(): - # empty ready queue, do nothing further - if len(BuildTask._ReadyQueue) == 0: - break -@@ -497,12 +497,12 @@ class BuildTask: - time.sleep(0.01) - - # wait for all running threads exit -- if BuildTask._ErrorFlag.isSet(): -+ if BuildTask._ErrorFlag.is_set(): - EdkLogger.quiet("\nWaiting for all build threads exit...") -- # while not BuildTask._ErrorFlag.isSet() and \ -+ # while not BuildTask._ErrorFlag.is_set() and \ - while len(BuildTask._RunningQueue) > 0: - EdkLogger.verbose("Waiting for thread ending...(%d)" % len(BuildTask._RunningQueue)) -- EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate())) -+ EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.name for Th in threading.enumerate())) - # avoid tense loop - time.sleep(0.1) - except BaseException as X: -@@ -530,7 +530,7 @@ class BuildTask: - # - @staticmethod - def IsOnGoing(): -- return not BuildTask._SchedulerStopped.isSet() -+ return not BuildTask._SchedulerStopped.is_set() - - ## Abort the build - @staticmethod -@@ -546,7 +546,7 @@ class BuildTask: - # - @staticmethod - def HasError(): -- return BuildTask._ErrorFlag.isSet() -+ return BuildTask._ErrorFlag.is_set() - - ## Get error message in running thread - # -@@ -643,7 +643,7 @@ class BuildTask: - # TRICK: hide the output of threads left running, so that the user can - # catch the error message easily - # -- if not BuildTask._ErrorFlag.isSet(): -+ if not BuildTask._ErrorFlag.is_set(): - GlobalData.gBuildingModule = "%s [%s, %s, %s]" % (str(self.BuildItem.BuildObject), - self.BuildItem.BuildObject.Arch, - self.BuildItem.BuildObject.ToolChain, -@@ -652,7 +652,7 @@ class BuildTask: - EdkLogger.SetLevel(EdkLogger.ERROR) - BuildTask._ErrorFlag.set() - BuildTask._ErrorMessage = "%s broken\n %s [%s]" % \ -- (threading.currentThread().getName(), Command, WorkingDir) -+ (threading.current_thread().name, Command, WorkingDir) - - # indicate there's a thread is available for another build task - BuildTask._RunningQueueLock.acquire() -@@ -666,8 +666,8 @@ class BuildTask: - EdkLogger.quiet("Building ... %s" % repr(self.BuildItem)) - Command = self.BuildItem.BuildCommand + [self.BuildItem.Target] - self.BuildTread = Thread(target=self._CommandThread, args=(Command, self.BuildItem.WorkingDir)) -- self.BuildTread.setName("build thread") -- self.BuildTread.setDaemon(False) -+ self.BuildTread.name = "build thread" -+ self.BuildTread.daemon = False - self.BuildTread.start() - - ## The class contains the information related to EFI image -@@ -1127,14 +1127,14 @@ class Build(): - EndOfProcedure.clear() - if Process.stdout: - StdOutThread = Thread(target=ReadMessage, args=(Process.stdout, EdkLogger.info, EndOfProcedure)) -- StdOutThread.setName("STDOUT-Redirector") -- StdOutThread.setDaemon(False) -+ StdOutThread.name = "STDOUT-Redirector" -+ StdOutThread.daemon = False - StdOutThread.start() - - if Process.stderr: - StdErrThread = Thread(target=ReadMessage, args=(Process.stderr, EdkLogger.quiet, EndOfProcedure)) -- StdErrThread.setName("STDERR-Redirector") -- StdErrThread.setDaemon(False) -+ StdErrThread.name = "STDERR-Redirector" -+ StdErrThread.daemon = False - StdErrThread.start() - # waiting for program exit - Process.wait() -@@ -1167,14 +1167,14 @@ class Build(): - EndOfProcedure.clear() - if Process.stdout: - StdOutThread = Thread(target=ReadMessage, args=(Process.stdout, EdkLogger.info, EndOfProcedure)) -- StdOutThread.setName("STDOUT-Redirector") -- StdOutThread.setDaemon(False) -+ StdOutThread.name = "STDOUT-Redirector" -+ StdOutThread.daemon = False - StdOutThread.start() - - if Process.stderr: - StdErrThread = Thread(target=ReadMessage, args=(Process.stderr, EdkLogger.quiet, EndOfProcedure)) -- StdErrThread.setName("STDERR-Redirector") -- StdErrThread.setDaemon(False) -+ StdErrThread.name = "STDERR-Redirector" -+ StdErrThread.daemon = False - StdErrThread.start() - # waiting for program exit - Process.wait() --- -2.34.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0008-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0008-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch deleted file mode 100644 index fb3514f4d1..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0008-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 5d8648345cd9ad729837118c731063c59edea192 Mon Sep 17 00:00:00 2001 -From: Cole Robinson -Date: Wed, 12 Aug 2020 01:28:17 +0800 -Subject: [PATCH] BaseTools: fix ucs-2 lookup on python 3.9 - -python3.9 changed/fixed codec.register behavior to always replace -hyphen with underscore for passed in codec names: - - https://bugs.python.org/issue37751 - -So the custom Ucs2Search needs to be adapted to handle 'ucs_2' in -addition to existing 'ucs-2' for back compat. - -This fixes test failures on python3.9, example: - -====================================================================== -FAIL: testUtf16InUniFile (CheckUnicodeSourceFiles.Tests) ----------------------------------------------------------------------- -Traceback (most recent call last): - File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 375, in PreProcess - FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path)) - File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 303, in OpenUniFile - UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding) - File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 312, in VerifyUcs2Data - Ucs2Info = codecs.lookup('ucs-2') -LookupError: unknown encoding: ucs-2 - -Signed-off-by: Cole Robinson -Reviewed-by: Yuwei Chen -Reviewed-by: Bob Feng ---- - BaseTools/Source/Python/AutoGen/UniClassObject.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py -index b2895f7e5c..883c2356e0 100644 ---- a/BaseTools/Source/Python/AutoGen/UniClassObject.py -+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py -@@ -152,7 +152,7 @@ class Ucs2Codec(codecs.Codec): - - TheUcs2Codec = Ucs2Codec() - def Ucs2Search(name): -- if name == 'ucs-2': -+ if name in ['ucs-2', 'ucs_2']: - return codecs.CodecInfo( - name=name, - encode=TheUcs2Codec.encode, --- -2.34.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0009-BaseTools-Work-around-array.array.tostring-removal-i.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0009-BaseTools-Work-around-array.array.tostring-removal-i.patch deleted file mode 100644 index 8b92b659ef..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0009-BaseTools-Work-around-array.array.tostring-removal-i.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 43bec9ea3d56f3662ede78023baa2a791b66acac Mon Sep 17 00:00:00 2001 -From: Cole Robinson -Date: Wed, 12 Aug 2020 01:28:18 +0800 -Subject: [PATCH] BaseTools: Work around array.array.tostring() removal in - python 3.9 - -In python3, array.array.tostring() was a compat alias for tobytes(). -tostring() was removed in python 3.9. - -Convert this to use tolist() which should be valid for all python -versions. - -This fixes this build error on python3.9: - -(Python 3.9.0b5 on linux) Traceback (most recent call last): - File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 593, in Main - GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile) - File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 449, in GenerateVfrBinSec - VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrNameList) - File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 88, in GetVariableOffset - return _parseForGCC(lines, efifilepath, varnames) - File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 151, in _parseForGCC - efisecs = PeImageClass(efifilepath).SectionHeaderList - File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 1638, in __init__ - if ByteArray.tostring() != b'PE\0\0': -AttributeError: 'array.array' object has no attribute 'tostring' - -Signed-off-by: Cole Robinson -Reviewed-by: Yuwei Chen -Reviewed-by: Bob Feng ---- - BaseTools/Source/Python/Common/Misc.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py -index ad55671080..4be7957138 100755 ---- a/BaseTools/Source/Python/Common/Misc.py -+++ b/BaseTools/Source/Python/Common/Misc.py -@@ -1635,7 +1635,7 @@ class PeImageClass(): - ByteArray = array.array('B') - ByteArray.fromfile(PeObject, 4) - # PE signature should be 'PE\0\0' -- if ByteArray.tostring() != b'PE\0\0': -+ if ByteArray.tolist() != [ord('P'), ord('E'), 0, 0]: - self.ErrorInfo = self.FileName + ' has no valid PE signature PE00' - return - --- -2.34.1 - diff --git a/pkg/uefi/edk2-patches/edk2-stable202005/0010-OvmfPkg-PlatformBootManagerLib-use-utf8-for-the-seri.patch b/pkg/uefi/edk2-patches/edk2-stable202005/0010-OvmfPkg-PlatformBootManagerLib-use-utf8-for-the-seri.patch deleted file mode 100644 index 188a4a0cf4..0000000000 --- a/pkg/uefi/edk2-patches/edk2-stable202005/0010-OvmfPkg-PlatformBootManagerLib-use-utf8-for-the-seri.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 14b7aa716de91c06e6bd8c85f1fabf8f1b013e07 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Fri, 17 Mar 2023 13:19:21 +0100 -Subject: [PATCH] OvmfPkg/PlatformBootManagerLib: use utf8 for the serial - console. - -Time to leave behind relics from the last century and arrive in the -modern world. Drop PC-ANSI Terminal Type for the serial console, use -UTF-8 instead. - -Signed-off-by: Gerd Hoffmann ---- - OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h | 4 ++-- - OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c | 6 +++--- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h -index 153e215101..8a581fa1f0 100644 ---- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h -+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h -@@ -127,7 +127,7 @@ extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode; - 1 \ - } - --#define gPcAnsiTerminal \ -+#define gVtUtf8Terminal \ - { \ - { \ - MESSAGING_DEVICE_PATH, \ -@@ -137,7 +137,7 @@ extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode; - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \ - } \ - }, \ -- DEVICE_PATH_MESSAGING_PC_ANSI \ -+ DEVICE_PATH_MESSAGING_VT_UTF8 \ - } - - #define gEndEntire \ -diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c -index 2858c3dfd5..7183d1dcef 100644 ---- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c -+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c -@@ -47,7 +47,7 @@ typedef struct { - ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard; - ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort; - UART_DEVICE_PATH gUartDeviceNode = gUart; --VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal; -+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gVtUtf8Terminal; - - // - // Platform specific keyboard device path -@@ -84,7 +84,7 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = { - 0, // Parity - Default - 0, // StopBits - Default - }, -- gPcAnsiTerminal, -+ gVtUtf8Terminal, - gEndEntire - }; - -@@ -169,7 +169,7 @@ STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = { - FixedPcdGet8 (PcdUartDefaultParity), - FixedPcdGet8 (PcdUartDefaultStopBits), - }, -- gPcAnsiTerminal, -+ gVtUtf8Terminal, - gEndEntire - }; - --- -2.30.2 - From f1016ce714a975f565cf8417f390bc86fac74457 Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Wed, 16 Oct 2024 16:58:04 +0300 Subject: [PATCH 5/6] pkg/pillar : update eve-uefi hash to the latest version Update the eve-uefi package to the latest version. Signed-off-by: Shahriyar Jalayeri --- pkg/pillar/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/pillar/Dockerfile b/pkg/pillar/Dockerfile index 318bf85120..e4ce896b0e 100644 --- a/pkg/pillar/Dockerfile +++ b/pkg/pillar/Dockerfile @@ -10,7 +10,7 @@ ARG BUILD_PKGS_BASE="git gcc linux-headers libc-dev make linux-pam-dev m4 findut # we use the same image in several places ARG EVE_ALPINE_IMAGE=lfedge/eve-alpine:591df01e581889c3027514c8a91feaca1c8ad49f -FROM lfedge/eve-uefi:d821658883d6748d8bbf0d6640c62288e3ce8c6f as uefi-build +FROM lfedge/eve-uefi:1f971167cc8866c306ffc7f4157665a1a2e6d95d as uefi-build FROM lfedge/eve-dom0-ztools:09f378d92d6c8ada04fb8e9cf5d45fc8fdf934f9 as zfs RUN mkdir /out # copy zfs-related files from dom0-ztools using prepared list of files From 2c5efce28021391a58a06f60ef341d97e588f9be Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Wed, 16 Oct 2024 16:58:34 +0300 Subject: [PATCH 6/6] pkg/xen-tools : update eve-uefi hash to the latest version Update the eve-uefi package to the latest version. Signed-off-by: Shahriyar Jalayeri --- pkg/xen-tools/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/xen-tools/Dockerfile b/pkg/xen-tools/Dockerfile index b4fe052c3e..b9ee7201d4 100644 --- a/pkg/xen-tools/Dockerfile +++ b/pkg/xen-tools/Dockerfile @@ -3,8 +3,7 @@ # Copyright (c) 2023 Zededa, Inc. # SPDX-License-Identifier: Apache-2.0 -FROM lfedge/eve-uefi:d821658883d6748d8bbf0d6640c62288e3ce8c6f AS uefi-build - +FROM lfedge/eve-uefi:1f971167cc8866c306ffc7f4157665a1a2e6d95d as uefi-build FROM lfedge/eve-alpine:591df01e581889c3027514c8a91feaca1c8ad49f AS runx-build ENV BUILD_PKGS mkinitfs gcc musl-dev e2fsprogs chrony agetty RUN eve-alpine-deploy.sh