|
Gerd Hoffmann |
729059 |
From 16974ba9c90984e667f057e13630cea6c27d0ae9 Mon Sep 17 00:00:00 2001
|
|
Gerd Hoffmann |
729059 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Gerd Hoffmann |
729059 |
Date: Tue, 7 Jun 2022 14:24:59 +0200
|
|
Gerd Hoffmann |
729059 |
Subject: [PATCH 21/21] OvmfPkg/Sec: fix stack switch
|
|
Gerd Hoffmann |
729059 |
|
|
Gerd Hoffmann |
729059 |
The ebp/rbp register can either be used for the frame pointer or
|
|
Gerd Hoffmann |
729059 |
as general purpose register. With gcc (and clang) this depends
|
|
Gerd Hoffmann |
729059 |
on the -f(no-)omit-frame-pointer switch.
|
|
Gerd Hoffmann |
729059 |
|
|
Gerd Hoffmann |
729059 |
This patch updates tools_def.template to explicitly set the compiler
|
|
Gerd Hoffmann |
729059 |
option and also add a define to allow conditionally compile code.
|
|
Gerd Hoffmann |
729059 |
|
|
Gerd Hoffmann |
729059 |
The new define is used to fix stack switching in TemporaryRamMigration.
|
|
Gerd Hoffmann |
729059 |
The ebp/rbp must not be touched when the compiler can use it as general
|
|
Gerd Hoffmann |
729059 |
purpose register. With version 12 gcc starts actually using the
|
|
Gerd Hoffmann |
729059 |
register, so changing it leads to firmware crashes in some
|
|
Gerd Hoffmann |
729059 |
configurations.
|
|
Gerd Hoffmann |
729059 |
|
|
Gerd Hoffmann |
729059 |
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3934
|
|
Gerd Hoffmann |
729059 |
Reported-by: Jiri Slaby <jirislaby@kernel.org>
|
|
Gerd Hoffmann |
729059 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Gerd Hoffmann |
729059 |
---
|
|
Gerd Hoffmann |
729059 |
OvmfPkg/Sec/SecMain.c | 4 ++++
|
|
Gerd Hoffmann |
729059 |
BaseTools/Conf/tools_def.template | 6 +++---
|
|
Gerd Hoffmann |
729059 |
2 files changed, 7 insertions(+), 3 deletions(-)
|
|
Gerd Hoffmann |
729059 |
|
|
Gerd Hoffmann |
729059 |
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
|
|
Gerd Hoffmann |
729059 |
index 1167d22a68cc..3ca0dcdfd3dd 100644
|
|
Gerd Hoffmann |
729059 |
--- a/OvmfPkg/Sec/SecMain.c
|
|
Gerd Hoffmann |
729059 |
+++ b/OvmfPkg/Sec/SecMain.c
|
|
Gerd Hoffmann |
729059 |
@@ -1052,11 +1052,15 @@ TemporaryRamMigration (
|
|
Gerd Hoffmann |
729059 |
if (SetJump (&JumpBuffer) == 0) {
|
|
Gerd Hoffmann |
729059 |
#if defined (MDE_CPU_IA32)
|
|
Gerd Hoffmann |
729059 |
JumpBuffer.Esp = JumpBuffer.Esp + DebugAgentContext.StackMigrateOffset;
|
|
Gerd Hoffmann |
729059 |
+ #ifndef OMIT_FRAME_POINTER
|
|
Gerd Hoffmann |
729059 |
JumpBuffer.Ebp = JumpBuffer.Ebp + DebugAgentContext.StackMigrateOffset;
|
|
Gerd Hoffmann |
729059 |
#endif
|
|
Gerd Hoffmann |
729059 |
+ #endif
|
|
Gerd Hoffmann |
729059 |
#if defined (MDE_CPU_X64)
|
|
Gerd Hoffmann |
729059 |
JumpBuffer.Rsp = JumpBuffer.Rsp + DebugAgentContext.StackMigrateOffset;
|
|
Gerd Hoffmann |
729059 |
+ #ifndef OMIT_FRAME_POINTER
|
|
Gerd Hoffmann |
729059 |
JumpBuffer.Rbp = JumpBuffer.Rbp + DebugAgentContext.StackMigrateOffset;
|
|
Gerd Hoffmann |
729059 |
+ #endif
|
|
Gerd Hoffmann |
729059 |
#endif
|
|
Gerd Hoffmann |
729059 |
LongJump (&JumpBuffer, (UINTN)-1);
|
|
Gerd Hoffmann |
729059 |
}
|
|
Gerd Hoffmann |
729059 |
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
|
|
Gerd Hoffmann |
729059 |
index 5901d9eecb5d..3b5f1f915c96 100755
|
|
Gerd Hoffmann |
729059 |
--- a/BaseTools/Conf/tools_def.template
|
|
Gerd Hoffmann |
729059 |
+++ b/BaseTools/Conf/tools_def.template
|
|
Gerd Hoffmann |
729059 |
@@ -1849,9 +1849,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
|
|
Gerd Hoffmann |
729059 |
*_*_*_DTC_PATH = DEF(DTC_BIN)
|
|
Gerd Hoffmann |
729059 |
|
|
Gerd Hoffmann |
729059 |
DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common
|
|
Gerd Hoffmann |
729059 |
-DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
|
|
Gerd Hoffmann |
729059 |
-DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe
|
|
Gerd Hoffmann |
729059 |
-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
|
|
Gerd Hoffmann |
729059 |
+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
|
|
Gerd Hoffmann |
729059 |
+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
|
|
Gerd Hoffmann |
729059 |
+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
|
|
Gerd Hoffmann |
729059 |
DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
|
|
Gerd Hoffmann |
729059 |
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
|
|
Gerd Hoffmann |
729059 |
DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
|
|
Gerd Hoffmann |
729059 |
--
|
|
Gerd Hoffmann |
729059 |
2.36.1
|
|
Gerd Hoffmann |
729059 |
|