REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3865 Ensure bit3:0 of NewStack is aligned with bit3:0 of OldStack for X64 before switching stack. Otherwise, RSP may not be aligned to a 16-byte boundary after returning from SecTemporaryRamSupport.
Cc: Chasel Chiu <[email protected]> Cc: Nate DeSimone <[email protected]> Cc: Star Zeng <[email protected]> Cc: Ashraf Ali S <[email protected]> Signed-off-by: Ted Kuo <[email protected]> --- IntelFsp2Pkg/FspSecCore/SecMain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c b/IntelFsp2Pkg/FspSecCore/SecMain.c index d376fb8361..f93e2d2ff7 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.c +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c @@ -258,6 +258,14 @@ SecTemporaryRamSupport ( NewStack = (VOID *)(UINTN)PermanentMemoryBase; } + // + // Ensure bit3:0 of NewStack is aligned with bit3:0 of OldStack for X64 before switching stack. + // Otherwise, RSP may not be aligned to a 16-byte boundary after returning from SecTemporaryRamSupport. + // + if ((sizeof (UINTN) == sizeof (UINT64)) && (((UINTN)NewStack & 0x0F) != ((UINTN)OldStack & 0x0F))) { + NewStack = (VOID *)((UINTN)NewStack - 8); + } + // // Migrate Heap // -- 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87793): https://edk2.groups.io/g/devel/message/87793 Mute This Topic: https://groups.io/mt/89926608/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
