commit 82c66f1853e6fa079be4f7a85f799229bdc1a9ad Author: Eduard Abdullin Date: Wed Aug 12 14:09:30 2026 +0300 Pin the X64 firmware ISA baseline to x86-64-v2 edk2 passes no -march for the X64 toolchains, so the ISA baseline of the shipped firmware is whatever the builder's GCC defaults to, and AlmaLinux 10 builds GCC with --with-arch_64=x86-64-v3. edk2-ovmf is noarch and one build is shared by the x86_64 and the x86_64_v2 repositories, so OVMF ends up carrying BMI1/BMI2 code and no UEFI guest boots on a v2-only CPU: it resets in a loop right after the SEC phase. %{optflags} cannot fix this. edk2.spec exports it as EXTRA_OPTFLAGS, which only reaches the host BaseTools binaries, and edk2-build.py has no way to pass compiler flags to the firmware build, so tools_def is the only place where the baseline can be set. The same patch applies to both edk2 snapshots (a10: 20251114/46548b1adac8, a10s: 20260221/b7a715f7c03c) - the context around the define is identical. https://git.almalinux.org/rpms/edk2/issues/1 diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..fc70582 --- /dev/null +++ b/config.yaml @@ -0,0 +1,20 @@ +actions: + - modify_release: + - suffix: ".alma.1" + enabled: true + + - changelog_entry: + - name: "Eduard Abdullin" + email: "eabdullin@almalinux.org" + line: + - "Pin the X64 firmware ISA baseline to x86-64-v2" + + # edk2 passes no -march for the X64 toolchains, so the shipped firmware + # inherits the builder's GCC default (x86-64-v3 on AlmaLinux 10). The + # edk2-ovmf subpackage is noarch and shared by the x86_64 and x86_64_v2 + # repositories, so it has to be built for the lower baseline. + # https://git.almalinux.org/rpms/edk2/issues/1 + - add_files: + - type: "patch" + name: "0001-BaseTools-pin-the-X64-ISA-baseline-to-x86-64-v2.patch" + number: "Latest" diff --git a/files/0001-BaseTools-pin-the-X64-ISA-baseline-to-x86-64-v2.patch b/files/0001-BaseTools-pin-the-X64-ISA-baseline-to-x86-64-v2.patch new file mode 100644 index 0000000..d9d4f92 --- /dev/null +++ b/files/0001-BaseTools-pin-the-X64-ISA-baseline-to-x86-64-v2.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eduard Abdullin +Date: Wed, 12 Aug 2026 13:58:37 +0300 +Subject: [PATCH] BaseTools: pin the X64 ISA baseline to x86-64-v2 (AlmaLinux + only) + +edk2 does not pass -march for the X64 toolchains, unlike IA32 which is +pinned to -march=i586 right next to it, so the ISA baseline of the +generated firmware is whatever the build host's compiler happens to +default to. RHEL 10 and AlmaLinux 10 build GCC with +--with-arch_64=x86-64-v3, so OVMF ends up carrying BMI1 instructions and +the firmware dies on a x86-64-v2 CPU: the guest resets in a loop right +after the SEC phase, before anything is printed on the console. + +Note that %{optflags} does not help here. edk2.spec exports it as +EXTRA_OPTFLAGS, which only reaches the host BaseTools binaries, and +edk2-build.py has no way to pass compiler flags to the firmware build, +so tools_def is the only place where this can be fixed. + +The edk2-ovmf subpackage is noarch and one build is shared by the x86_64 +and the x86_64_v2 repositories, so the shipped firmware has to be built +for the lower baseline. Pin the X64 CC flags to -march=x86-64-v2: guest +firmware must not inherit the ISA baseline of the machine that built it. +x86-64-v2 code runs unmodified on v3 and v4 CPUs, and firmware is not a +hot path, so there is no practical cost for x86_64 users. + +https://git.almalinux.org/rpms/edk2/issues/1 + +Signed-off-by: Eduard Abdullin +--- + BaseTools/Conf/tools_def.template | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template +--- a/BaseTools/Conf/tools_def.template ++++ b/BaseTools/Conf/tools_def.template +@@ -865,7 +865,7 @@ DEFINE GCC_DEPS_FLAGS = -MMD -MF $@.deps + DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings + DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20 + DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(GCC_IA32_X64_CC_FLAGS) -m32 -march=i586 -malign-double -D EFI32 -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer +-DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(GCC_IA32_X64_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer ++DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(GCC_IA32_X64_CC_FLAGS) -m64 -march=x86-64-v2 "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer + DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable + DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive + DEFINE GCC48_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)