Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 18d053d6828ca308824bd64ddea04de789d97edb
      
https://github.com/tianocore/edk2/commit/18d053d6828ca308824bd64ddea04de789d97edb
  Author: Zhiguang Liu <[email protected]>
  Date:   2025-09-23 (Tue, 23 Sep 2025)

  Changed paths:
    M IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm

  Log Message:
  -----------
  IntelFsp2Pkg/FspSecCore: Reserve 32B when calling C function in 64bit

After bootloader calls FSP API mode, I found the RDI register is
changed in some cases.
Below is the first line of function FspApiCallingCheck in assembly dump
  mov qword ptr [rsp+0x8],rbx
We can see compiler will use rsp+0x8 for some purpose, while rsp+0x8
is used to save RDI by FSP in code before.

According to the x86-64 calling convention, caller is responsible for
allocating 32 bytes of "shadow space" on the stack right before calling
the function (regardless of the actual number of parameters used).
However FSP code doesn't reserve 32 bytes before calling
FspApiCallingCheck C function in 64bit.

The patch fixes it by reserving the 32 bytes before calling C routine.
Also, make sure the stack is 16-byte alignment, sub 0x28 to RSP.

Signed-off-by: Zhiguang Liu <[email protected]>



To unsubscribe from these emails, change your notification settings at 
https://github.com/tianocore/edk2/settings/notifications


_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to