diff --git a/QEMU_EFI.fd b/QEMU_EFI.fd new file mode 100644 index 0000000000000000000000000000000000000000..69b4abaae816589b39748da3b6cc5dce5fc39dc3 Binary files /dev/null and b/QEMU_EFI.fd differ diff --git a/QEMU_VARS.fd b/QEMU_VARS.fd new file mode 100644 index 0000000000000000000000000000000000000000..fca24ccc73bd6462fbc098d4be07eacfe01674f3 Binary files /dev/null and b/QEMU_VARS.fd differ 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-5374f6cd4af3.tar.gz b/edk2-platforms-5374f6cd4af3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..f13f75aa8fdd79b56580490f1ddef2fdcc11cf7c Binary files /dev/null and b/edk2-platforms-5374f6cd4af3.tar.gz differ diff --git a/edk2.spec b/edk2.spec index 6a4b577e73d820e28184db5edaac2ac705448621..e8b7487af16b7674fa566e22c15c2b075191cb61 100644 --- a/edk2.spec +++ b/edk2.spec @@ -7,7 +7,7 @@ Name: edk2 Version: %{stable_date} -Release: 7 +Release: 8 Summary: EFI Development Kit II License: BSD-2-Clause-Patent and OpenSSL and MIT URL: https://github.com/tianocore/edk2 @@ -17,6 +17,10 @@ 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 +Source7: edk2-platforms-5374f6cd4af3.tar.gz +Source8: QEMU_EFI.fd +Source9: QEMU_VARS.fd patch0: 0001-OvmfPkg-VirtioNetDxe-Extend-the-RxBufferSize-to-avoi.patch patch1: 0002-add-Wno-maybe-uninitialized-to-fix-build-error.patch @@ -68,6 +72,7 @@ patch42: 0042-Fix-unconstrained-session-cache-growth-in-TLSv1.3.patch patch43: 0043-Hardening-around-not_resumable-sessions.patch patch44: 0044-Add-a-test-for-session-cache-overflow.patch patch45: 0045-Limit-the-execution-time-of-RSA-public-key-check.patch +patch46: relax_edk2_gcc14.diff BuildRequires: acpica-tools gcc gcc-c++ libuuid-devel python3 bc nasm python3-unversioned-command isl @@ -124,16 +129,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` @@ -166,7 +180,11 @@ 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 -build $BUILD_OPTION +#%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 cp CryptoPkg/Library/OpensslLib/openssl/LICENSE.txt LICENSE.openssl @@ -230,6 +248,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 %{SOURCE8} %{SOURCE9} %{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 @@ -306,7 +333,19 @@ 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 May 31 2024 Xiaotian Wu - 202308-8 +- add LoongArch support + * Wed Apr 17 2024 jiangdongxu - 202308-7 - make EFI_LOADER_DATA executable again. diff --git a/relax_edk2_gcc14.diff b/relax_edk2_gcc14.diff new file mode 100644 index 0000000000000000000000000000000000000000..35901ff55b5fddb9518ffc5efbff2f33b84ff703 --- /dev/null +++ b/relax_edk2_gcc14.diff @@ -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_ */