diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2022-06-08 18:09:36 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-06-08 11:48:07 +0000 |
commit | ff36b2550f94dc5fac838cf298ae5a23cfddf204 (patch) | |
tree | 26b0adb6df4706c9222a58efd6c83fcded9c6da1 /OvmfPkg/Sec | |
parent | a81a650da1dc40ec2b2825d1878cdf2778b4be14 (diff) | |
download | edk2-ff36b2550f94dc5fac838cf298ae5a23cfddf204.tar.gz edk2-ff36b2550f94dc5fac838cf298ae5a23cfddf204.tar.bz2 edk2-ff36b2550f94dc5fac838cf298ae5a23cfddf204.zip |
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 <jirislaby@kernel.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'OvmfPkg/Sec')
-rw-r--r-- | OvmfPkg/Sec/SecMain.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 1167d22a68..3ca0dcdfd3 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -1052,12 +1052,16 @@ 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);
}
|