diff --git a/0050-Revert-Platform-Loongson-LoongArchQemuPkg-Add-ImageP.patch b/0050-Revert-Platform-Loongson-LoongArchQemuPkg-Add-ImageP.patch new file mode 100644 index 0000000000000000000000000000000000000000..b45d13ed12979d64aa76ea4ab0dcb9e55d7169b5 --- /dev/null +++ b/0050-Revert-Platform-Loongson-LoongArchQemuPkg-Add-ImageP.patch @@ -0,0 +1,26 @@ +From 5f72f1332ec14b1f558cab4f3ec0ce0a97d729d0 Mon Sep 17 00:00:00 2001 +From: Xiaotian Wu +Date: Fri, 13 Sep 2024 10:34:32 +0800 +Subject: [PATCH 1/3] Revert "Platform/Loongson/LoongArchQemuPkg: Add + ImagePropertiesRecordLib Instance" + +This reverts commit 91d9680f50f1922936458bde283030f2e9459f00. +--- + Platform/Loongson/LoongArchQemuPkg/Loongson.dsc | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc +index 7e891ad225..42356f4abc 100644 +--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc ++++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc +@@ -155,7 +155,6 @@ + PciHostBridgeUtilityLib | OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf + MmuLib | Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/MmuBaseLib.inf + FileExplorerLib | MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf +- ImagePropertiesRecordLib | MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf + + !if $(HTTP_BOOT_ENABLE) == TRUE + HttpLib | MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf +-- +2.45.0 + diff --git a/0051-Revert-Platform-Loongson-Fix-compile-error.patch b/0051-Revert-Platform-Loongson-Fix-compile-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..03fea1595db04ee75a5470992707c6f22e203820 --- /dev/null +++ b/0051-Revert-Platform-Loongson-Fix-compile-error.patch @@ -0,0 +1,44 @@ +From 877c5b3473fc02bd043f48c585a58a99d46ae58b Mon Sep 17 00:00:00 2001 +From: Xiaotian Wu +Date: Fri, 13 Sep 2024 10:35:05 +0800 +Subject: [PATCH 2/3] Revert "Platform/Loongson: Fix compile error" + +This reverts commit ef0b6c0cb556957798c3ca5025aced871525dfae. +--- + Platform/Loongson/LoongArchQemuPkg/Loongson.dsc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc +index 42356f4abc..00b28cfa50 100644 +--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc ++++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc +@@ -179,7 +179,7 @@ + # + VirtioLib | OvmfPkg/Library/VirtioLib/VirtioLib.inf + FrameBufferBltLib | MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf +- QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgMmioPeiLib.inf ++ QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf + DebugLib | MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + PeiServicesLib | MdePkg/Library/PeiServicesLib/PeiServicesLib.inf + VariableFlashInfoLib | MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf +@@ -256,7 +256,7 @@ + ReportStatusCodeLib | MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf + UefiScsiLib | MdePkg/Library/UefiScsiLib/UefiScsiLib.inf + ExtractGuidedSectionLib | MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf +- QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgMmioDxeLib.inf ++ QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf + PciPcdProducerLib | OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf + + [LibraryClasses.common.DXE_DRIVER] +@@ -268,7 +268,7 @@ + CpuExceptionHandlerLib | UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf + ExtractGuidedSectionLib | MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf + QemuFwCfgS3Lib | OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf +- QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgMmioDxeLib.inf ++ QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf + PciPcdProducerLib | OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf + PciExpressLib | MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf + AcpiPlatformLib | OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf +-- +2.45.0 + diff --git a/0052-Revert-LoongArchQemuPkg-auto-gen-fix-SEC-ProcessLibr.patch b/0052-Revert-LoongArchQemuPkg-auto-gen-fix-SEC-ProcessLibr.patch new file mode 100644 index 0000000000000000000000000000000000000000..96307864f72a55fd6cec728c87bef9b3aa84f48c --- /dev/null +++ b/0052-Revert-LoongArchQemuPkg-auto-gen-fix-SEC-ProcessLibr.patch @@ -0,0 +1,49 @@ +From 69e129dc2faa09647294aadadca2fc8abe63f3d1 Mon Sep 17 00:00:00 2001 +From: Xiaotian Wu +Date: Fri, 13 Sep 2024 10:35:51 +0800 +Subject: [PATCH 3/3] Revert "LoongArchQemuPkg: auto-gen & fix SEC + ProcessLibraryConstructorList() decl" + +This reverts commit a81b9f2815da1bacb91aa5ece1caa730ac5d80bb. +--- + Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.c | 3 ++- + Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.inf | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.c b/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.c +index 50d898859a..3f1998c48c 100644 +--- a/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.c ++++ b/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.c +@@ -9,6 +9,7 @@ + + #include + ++#include + #include + #include + #include +@@ -377,7 +378,7 @@ SecCoreStartupWithStack ( + + DEBUG ((DEBUG_INFO, "Entering C environment\n")); + +- ProcessLibraryConstructorList (); ++ ProcessLibraryConstructorList (NULL, NULL); + + DEBUG ((DEBUG_INFO, + "SecCoreStartupWithStack (0x%lx, 0x%lx)\n", +diff --git a/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.inf b/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.inf +index bb86c7c774..c0d5439d53 100644 +--- a/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.inf ++++ b/Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.inf +@@ -8,7 +8,7 @@ + ## + + [Defines] +- INF_VERSION = 1.30 ++ INF_VERSION = 0x00010005 + BASE_NAME = SecMain + FILE_GUID = 57d02d4f-5a5d-4bfa-b7d6-ba0a4d2c72ce + MODULE_TYPE = SEC +-- +2.45.0 + diff --git a/0053-relax_edk2_gcc14.patch b/0053-relax_edk2_gcc14.patch new file mode 100644 index 0000000000000000000000000000000000000000..35901ff55b5fddb9518ffc5efbff2f33b84ff703 --- /dev/null +++ b/0053-relax_edk2_gcc14.patch @@ -0,0 +1,44 @@ +diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c +index d53ecb1767..8018d68db1 100644 +--- a/BaseTools/Source/C/GenFw/Elf64Convert.c ++++ b/BaseTools/Source/C/GenFw/Elf64Convert.c +@@ -1778,7 +1778,11 @@ WriteSections64 ( + case R_LARCH_TLS_LD64_HI20: + case R_LARCH_TLS_GD_PC_HI20: + case R_LARCH_TLS_GD64_HI20: ++ case R_LARCH_32_PCREL: + case R_LARCH_RELAX: ++ case R_LARCH_DELETE: ++ case R_LARCH_ALIGN: ++ case R_LARCH_PCREL20_S2: + // + // These types are not used or do not require fixup. + // +@@ -2185,7 +2189,11 @@ WriteRelocations64 ( + case R_LARCH_TLS_LD64_HI20: + case R_LARCH_TLS_GD_PC_HI20: + case R_LARCH_TLS_GD64_HI20: ++ case R_LARCH_32_PCREL: + case R_LARCH_RELAX: ++ case R_LARCH_DELETE: ++ case R_LARCH_ALIGN: ++ case R_LARCH_PCREL20_S2: + // + // These types are not used or do not require fixup in PE format files. + // +diff --git a/BaseTools/Source/C/GenFw/elf_common.h b/BaseTools/Source/C/GenFw/elf_common.h +index ccd32804b0..d3a5303953 100644 +--- a/BaseTools/Source/C/GenFw/elf_common.h ++++ b/BaseTools/Source/C/GenFw/elf_common.h +@@ -1144,5 +1144,10 @@ typedef struct { + #define R_LARCH_TLS_LD64_HI20 96 + #define R_LARCH_TLS_GD_PC_HI20 97 + #define R_LARCH_TLS_GD64_HI20 98 +-#define R_LARCH_RELAX 99 ++#define R_LARCH_32_PCREL 99 ++#define R_LARCH_RELAX 100 ++#define R_LARCH_DELETE 101 ++#define R_LARCH_ALIGN 102 ++#define R_LARCH_PCREL20_S2 103 ++ + #endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/edk2-loongarch64.json b/edk2-loongarch64.json new file mode 100644 index 0000000000000000000000000000000000000000..1108f8f5409029c1299982ca402101c1560679ab --- /dev/null +++ b/edk2-loongarch64.json @@ -0,0 +1,31 @@ +{ + "description": "UEFI firmware for LoongArch64 virtual machines", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "executable": { + "filename": "/usr/share/edk2/loongarch64/QEMU_EFI-silent-pflash.raw", + "format": "raw" + }, + "nvram-template": { + "filename": "/usr/share/edk2/loongarch64/vars-template-pflash.raw", + "format": "raw" + } + }, + "targets": [ + { + "architecture": "loongarch64", + "machines": [ + "virt*" + ] + } + ], + "features": [ + + ], + "tags": [ + + ] +} diff --git a/edk2-platforms-35bca3ca71c0.tar.xz b/edk2-platforms-35bca3ca71c0.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..1fcb69c28fbd37fe29dcd78b64482c52317cc8f2 Binary files /dev/null and b/edk2-platforms-35bca3ca71c0.tar.xz differ diff --git a/edk2.spec b/edk2.spec index 3476891879f93c65523d384a828f3d17c13d822b..de7df6b837a1abd57c94e2f1c88d4aa20d10e2c0 100644 --- a/edk2.spec +++ b/edk2.spec @@ -7,7 +7,7 @@ Name: edk2 Version: %{stable_date} -Release: 10 +Release: 11 Summary: EFI Development Kit II License: BSD-2-Clause-Patent and OpenSSL and MIT URL: https://github.com/tianocore/edk2 @@ -17,6 +17,9 @@ Source2: brotli.%{brotli_commitid}.tar.gz Source3: public-mipi-sys-t.%{public_mipi_sys_t_commitid}.tar.gz Source4: edk2-aarch64-verbose-raw.json Source5: edk2-ovmf-x64-nosb.json +Source6: edk2-loongarch64.json +# git archive from https://github.com/tianocore/edk2-platforms/tree/35bca3ca71c004b7f3d93c6f33724796c6b1bf0b +Source7: edk2-platforms-35bca3ca71c0.tar.xz patch0: 0001-OvmfPkg-VirtioNetDxe-Extend-the-RxBufferSize-to-avoi.patch patch1: 0002-add-Wno-maybe-uninitialized-to-fix-build-error.patch @@ -79,6 +82,14 @@ patch48: 0048-Add-a-test-for-ALPN-and-NPN.patch # Fix CVE-2024-6119 patch49: 0049-Avoid-type-errors-in-EAI-related-name-check-logic.patch +# revert these patches for edk2-platforms to build with edk2-2308 +patch50: 0050-Revert-Platform-Loongson-LoongArchQemuPkg-Add-ImageP.patch +patch51: 0051-Revert-Platform-Loongson-Fix-compile-error.patch +patch52: 0052-Revert-LoongArchQemuPkg-auto-gen-fix-SEC-ProcessLibr.patch + +# Fix edk2 build errror with gcc-14 +patch53: 0053-relax_edk2_gcc14.patch + BuildRequires: acpica-tools gcc gcc-c++ libuuid-devel python3 bc nasm python3-unversioned-command isl %description @@ -134,16 +145,25 @@ BuildArch: noarch EFI Development Kit II Open Virtual Machine Firmware (riscv64) %endif +%ifarch loongarch64 +%package ovmf-loongarch64 +Summary: Open Virtual Machine Firmware +BuildArch: noarch +%description ovmf-loongarch64 +EFI Development Kit II Open Virtual Machine Firmware (loongarch64) +%endif + %prep %setup -n edk2-%{release_tag} tar -xf %{SOURCE1} -C CryptoPkg/Library/OpensslLib/openssl --strip-components=1 tar -xf %{SOURCE2} -C MdeModulePkg/Library/BrotliCustomDecompressLib/brotli --strip-components=1 tar -xf %{SOURCE2} -C BaseTools/Source/C/BrotliCompress/brotli --strip-components=1 tar -xf %{SOURCE3} -C MdePkg/Library/MipiSysTLib/mipisyst --strip-components=1 +tar -xf %{SOURCE7} edk2-platforms/Platform --strip-components=1 %autopatch -p1 -cp -a -- %{SOURCE4} %{SOURCE5} . +cp -a -- %{SOURCE4} %{SOURCE5} %{SOURCE6} . %build NCPUS=`/usr/bin/getconf _NPROCESSORS_ONLN` @@ -176,6 +196,10 @@ BUILD_OPTION="$BUILD_OPTION -D TPM_CONFIG_ENABLE=TRUE" BUILD_OPTION="-t GCC5 -n $NCPUS -b RELEASE -a RISCV64 -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -D SECURE_BOOT_ENABLE=TRUE -D TPM_ENABLE=TRUE -D TPM_CONFIG_ENABLE=TRUE" %endif +%ifarch loongarch64 + BUILD_OPTION="-t GCC5 -n $NCPUS -b RELEASE -a LOONGARCH64 -p Platform/Loongson/LoongArchQemuPkg/Loongson.dsc -D SECURE_BOOT_ENABLE=TRUE -D TPM_ENABLE=TRUE -D TPM_CONFIG_ENABLE=TRUE" +%endif + build $BUILD_OPTION %install @@ -240,6 +264,15 @@ chmod +x %{buildroot}%{_bindir}/Rsa2048Sha256GenerateKeys cp Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd %{buildroot}/usr/share/%{name}/ovmf-riscv64 %endif +%ifarch loongarch64 + mkdir -p %{buildroot}/usr/share/%{name}/loongarch64 + cp Build/LoongArchQemu/RELEASE_*/FV/*.fd %{buildroot}/usr/share/%{name}/loongarch64 + dd of="%{buildroot}/usr/share/%{name}/loongarch64/QEMU_EFI-silent-pflash.raw" if="/dev/zero" bs=1M count=4 + dd of="%{buildroot}/usr/share/%{name}/loongarch64/QEMU_EFI-silent-pflash.raw" if="%{buildroot}/usr/share/%{name}/loongarch64/QEMU_EFI.fd" conv=notrunc + dd of="%{buildroot}/usr/share/%{name}/loongarch64/vars-template-pflash.raw" if="/dev/zero" bs=1M count=16 + install -m 0644 edk2-loongarch64.json %{buildroot}%{_datadir}/qemu/firmware/50-edk2-loongarch64.json +%endif + %files devel %license License.txt %license License-History.txt @@ -316,7 +349,20 @@ chmod +x %{buildroot}%{_bindir}/Rsa2048Sha256GenerateKeys %{_datadir}/%{name}/ovmf-riscv64 %endif +%ifarch loongarch64 +%license OvmfPkg/License.txt +%license LICENSE.openssl +%files ovmf-loongarch64 +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/loongarch64 +%{_datadir}/qemu/firmware/50-edk2-loongarch64.json +%endif + %changelog +* Fri Sep 13 2024 Xiaotian Wu - 202308-11 +- add LoongArch support +- backport edk2-platform to build with edk2-2308 + * Mon Sep 9 2024 shenyage - 202308-10 - fix CVE-2024-6119