summaryrefslogtreecommitdiff
path: root/EdkModulePkg
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2006-11-28 02:42:44 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2006-11-28 02:42:44 +0000
commit62332e5da35ad775d514a5ffad708d49bd1dbbae (patch)
tree8a7175af1ae06694717a1b545125b18d9f49d01f /EdkModulePkg
parent4a3286201898cd85ac9f5fa4cceadd09d59d8965 (diff)
downloadedk2-platforms-62332e5da35ad775d514a5ffad708d49bd1dbbae.tar.xz
Align the top of the stack correctly when the PEI Core calls SwitchStack()
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2022 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg')
-rw-r--r--EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index b0de859073..ccd840d376 100644
--- a/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -63,6 +63,7 @@ Returns:
BOOLEAN NextFvFound;
EFI_FIRMWARE_VOLUME_HEADER *NextFvAddress;
EFI_FIRMWARE_VOLUME_HEADER *DefaultFvAddress;
+ VOID *TopOfStack;
//
// Debug data for uninstalled Peim list
//
@@ -204,15 +205,16 @@ Returns:
PrivateDataInMem = (UINTN) TransferOldDataToNewDataRange (PrivateData);
ASSERT (PrivateDataInMem != 0);
//
- //Subtract 0x10 from the 4th parameter indicating the new stack base,
- //in order to provide buffer protection against possible illegal stack
- //access that might corrupt the stack.
+ // Adjust the top of stack to be aligned at CPU_STACK_ALIGNMENT
//
+ TopOfStack = (VOID *)((UINTN)PrivateData->StackBase + (UINTN)PrivateData->StackSize - CPU_STACK_ALIGNMENT);
+ TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
+
PeiSwitchStacks (
(SWITCH_STACK_ENTRY_POINT)(UINTN)TempPtr.Raw,
PeiStartupDescriptor,
(VOID*)PrivateDataInMem,
- (VOID*)((UINTN)PrivateData->StackBase + (UINTN)PrivateData->StackSize),
+ TopOfStack,
(VOID*)(UINTN)PrivateData->StackBase
);
}