From 729059caf64af03ef20f38f833f69eed14b4b42a Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 8 Jun 2022 17:17:19 +0200 Subject: [PATCH] - fix PcdResizeXterm patch. - minor specfile cleanup. - add 0021-OvmfPkg-Sec-fix-stack-switch.patch - Resolves rhbz#2093745 --- ...ResizeXterm-from-the-QEMU-command-li.patch | 4 +- ...take-PcdResizeXterm-from-the-QEMU-co.patch | 25 ------- ...tools_def-to-support-cross-compiling.patch | 0 0021-OvmfPkg-Sec-fix-stack-switch.patch | 66 +++++++++++++++++++ edk2.spec | 16 +++-- 5 files changed, 77 insertions(+), 34 deletions(-) delete mode 100644 0020-OvmfPkg-Microvm-take-PcdResizeXterm-from-the-QEMU-co.patch rename 0021-Tweak-the-tools_def-to-support-cross-compiling.patch => 0020-Tweak-the-tools_def-to-support-cross-compiling.patch (100%) create mode 100644 0021-OvmfPkg-Sec-fix-stack-switch.patch diff --git a/0006-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch b/0006-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch index 3565a4a..e76d135 100644 --- a/0006-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch +++ b/0006-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch @@ -1,4 +1,4 @@ -From b969a329b7a7df0f8f25c8497eaa3c0987b69265 Mon Sep 17 00:00:00 2001 +From e2aa9521a02cacb0ec147667d7bd87ccde2508db Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 14 Oct 2015 15:59:06 +0200 Subject: [PATCH 06/21] OvmfPkg: take PcdResizeXterm from the QEMU command line @@ -215,5 +215,5 @@ index f006755d5fdb..b8f56902512c 100644 InstallClearCacheCallback (); -- -2.35.3 +2.36.1 diff --git a/0020-OvmfPkg-Microvm-take-PcdResizeXterm-from-the-QEMU-co.patch b/0020-OvmfPkg-Microvm-take-PcdResizeXterm-from-the-QEMU-co.patch deleted file mode 100644 index 3526dcf..0000000 --- a/0020-OvmfPkg-Microvm-take-PcdResizeXterm-from-the-QEMU-co.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 74b3fd529e1b49dbe1ede576d23771d4f071d338 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Thu, 2 Dec 2021 14:06:18 +0100 -Subject: [PATCH 20/21] OvmfPkg/Microvm: take PcdResizeXterm from the QEMU - command line (RH only) - ---- - OvmfPkg/Microvm/MicrovmX64.dsc | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc -index 4e5ab89c8f0d..e1a7e6cb77a9 100644 ---- a/OvmfPkg/Microvm/MicrovmX64.dsc -+++ b/OvmfPkg/Microvm/MicrovmX64.dsc -@@ -556,6 +556,7 @@ [PcdsDynamicDefault] - # only set when - # ($(SMM_REQUIRE) == FALSE) - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE - - gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 --- -2.35.3 - diff --git a/0021-Tweak-the-tools_def-to-support-cross-compiling.patch b/0020-Tweak-the-tools_def-to-support-cross-compiling.patch similarity index 100% rename from 0021-Tweak-the-tools_def-to-support-cross-compiling.patch rename to 0020-Tweak-the-tools_def-to-support-cross-compiling.patch diff --git a/0021-OvmfPkg-Sec-fix-stack-switch.patch b/0021-OvmfPkg-Sec-fix-stack-switch.patch new file mode 100644 index 0000000..806c126 --- /dev/null +++ b/0021-OvmfPkg-Sec-fix-stack-switch.patch @@ -0,0 +1,66 @@ +From 16974ba9c90984e667f057e13630cea6c27d0ae9 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Tue, 7 Jun 2022 14:24:59 +0200 +Subject: [PATCH 21/21] OvmfPkg/Sec: fix stack switch + +The ebp/rbp register can either be used for the frame pointer or +as general purpose register. With gcc (and clang) this depends +on the -f(no-)omit-frame-pointer switch. + +This patch updates tools_def.template to explicitly set the compiler +option and also add a define to allow conditionally compile code. + +The new define is used to fix stack switching in TemporaryRamMigration. +The ebp/rbp must not be touched when the compiler can use it as general +purpose register. With version 12 gcc starts actually using the +register, so changing it leads to firmware crashes in some +configurations. + +Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3934 +Reported-by: Jiri Slaby +Signed-off-by: Gerd Hoffmann +--- + OvmfPkg/Sec/SecMain.c | 4 ++++ + BaseTools/Conf/tools_def.template | 6 +++--- + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c +index 1167d22a68cc..3ca0dcdfd3dd 100644 +--- a/OvmfPkg/Sec/SecMain.c ++++ b/OvmfPkg/Sec/SecMain.c +@@ -1052,11 +1052,15 @@ TemporaryRamMigration ( + if (SetJump (&JumpBuffer) == 0) { + #if defined (MDE_CPU_IA32) + JumpBuffer.Esp = JumpBuffer.Esp + DebugAgentContext.StackMigrateOffset; ++ #ifndef OMIT_FRAME_POINTER + JumpBuffer.Ebp = JumpBuffer.Ebp + DebugAgentContext.StackMigrateOffset; + #endif ++ #endif + #if defined (MDE_CPU_X64) + JumpBuffer.Rsp = JumpBuffer.Rsp + DebugAgentContext.StackMigrateOffset; ++ #ifndef OMIT_FRAME_POINTER + JumpBuffer.Rbp = JumpBuffer.Rbp + DebugAgentContext.StackMigrateOffset; ++ #endif + #endif + LongJump (&JumpBuffer, (UINTN)-1); + } +diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template +index 5901d9eecb5d..3b5f1f915c96 100755 +--- a/BaseTools/Conf/tools_def.template ++++ b/BaseTools/Conf/tools_def.template +@@ -1849,9 +1849,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N + *_*_*_DTC_PATH = DEF(DTC_BIN) + + DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common +-DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe +-DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe +-DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie ++DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe -fno-omit-frame-pointer ++DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe -fomit-frame-pointer -DOMIT_FRAME_POINTER=1 ++DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -DOMIT_FRAME_POINTER=1 -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie + DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access + DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18 + DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only +-- +2.36.1 + diff --git a/edk2.spec b/edk2.spec index 0b86f04..b44d97e 100644 --- a/edk2.spec +++ b/edk2.spec @@ -35,7 +35,7 @@ ExclusiveArch: x86_64 aarch64 Name: edk2 Version: %{GITDATE}git%{GITCOMMIT} -Release: 1%{?dist} +Release: 2%{?dist} Summary: UEFI firmware for 64-bit virtual machines License: BSD-2-Clause-Patent and OpenSSL and MIT URL: http://www.tianocore.org @@ -84,12 +84,8 @@ Patch0016: 0016-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch Patch0017: 0017-CryptoPkg-OpensslLib-list-RHEL8-specific-OpenSSL-fil.patch Patch0018: 0018-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch Patch0019: 0019-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch -Patch0020: 0020-OvmfPkg-Microvm-take-PcdResizeXterm-from-the-QEMU-co.patch -Patch0021: 0021-Tweak-the-tools_def-to-support-cross-compiling.patch - -#Patch0030: 0030-BaseTools-fix-gcc12-warning.patch -#Patch0031: 0031-BaseTools-fix-gcc12-warning.patch -#Patch0032: 0032-Basetools-turn-off-gcc12-warning.patch +Patch0020: 0020-Tweak-the-tools_def-to-support-cross-compiling.patch +Patch0021: 0021-OvmfPkg-Sec-fix-stack-switch.patch # python3-devel and libuuid-devel are required for building tools. # python3-devel is also needed for varstore template generation and @@ -711,6 +707,12 @@ virt-fw-vars --input Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_VARS.secboot.fd \ %changelog +* Wed Jun 08 2022 Gerd Hoffmann - 20220526git16779ede2d36-2 +- fix PcdResizeXterm patch. +- minor specfile cleanup. +- add 0021-OvmfPkg-Sec-fix-stack-switch.patch +- Resolves rhbz#2093745 + * Tue May 31 2022 Gerd Hoffmann - 20220526git16779ede2d36-1 - update to new edk2 stable tag (2022-05), refresh patches. - add amdsev and inteltdx builds