> On Nov 19, 2018, at 2:12 PM, Laszlo Ersek <ler...@redhat.com> wrote:
>
> Jordan wrote:
>
>>>> So, is it safe to adjust rbp? Unknown. It may not be if rbp is not
>>>> used as a frame pointer. Is it safe to *not* adjust rbp and
>>>> potentially allow the old temp ram stack to be used? Unknown.
>
> Andrew wrote:
>
>> Looks like OvmfPkg uses SetJump()/LongJump() to change the stack.
>>
>> //
>> // Use SetJump()/LongJump() to switch to a new stack.
>> //
>> if (SetJump (&JumpBuffer) == 0) {
>> #if defined (MDE_CPU_IA32)
>> JumpBuffer.Esp = JumpBuffer.Esp + DebugAgentContext.StackMigrateOffset;
>> JumpBuffer.Ebp = JumpBuffer.Ebp + DebugAgentContext.StackMigrateOffset;
>> #endif
>> #if defined (MDE_CPU_X64)
>> JumpBuffer.Rsp = JumpBuffer.Rsp + DebugAgentContext.StackMigrateOffset;
>> JumpBuffer.Rbp = JumpBuffer.Rbp + DebugAgentContext.StackMigrateOffset;
>> #endif
>> LongJump (&JumpBuffer, (UINTN)-1);
>> }
>>
>> SaveAndSetDebugTimerInterrupt (OldStatus);
>>
>> return EFI_SUCCESS;
>> }
>>
>> But given the above code is C code RBP is going to be restored on return.
>> This would seem to imply that the adjusting of the callers RBP is not
>> required? [...]
>
> The Ebp/Rbp assignments were added in a separate bugfix, namely
>
> https://github.com/tianocore/edk2/commit/89796c69d9fd
>
Laszlo,
This makes sense since as the post-amble when using frame pointers is either:
addq $288, %rsp ## imm = 0x120
popq %rbp
retq
or
> 0x00000000fffcd42f <+403>: c9 leaveq
> 0x00000000fffcd430 <+404>: c3 retq
I've noticed that clang does not seem to be a big fan of the leave function and
it adjusts the stack pointer using math rather than using %rbp.
The stack unwind algorithm implies that the frame point, %rbp in our case, is
valid while the function is running. Even for the clang code gen not switching
the frame point would break the stack unwind.
Thanks,
Andrew Fish
> Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel