summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2008-01-31 08:41:14 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2008-01-31 08:41:14 +0000
commit1eabd8e747453dbe583d31c88a691d14d419352e (patch)
tree1691d402d1f8921c26defbc22a311ec799ec4609 /MdeModulePkg
parent6be065d4be09485125128631fb3de8be12c4a85b (diff)
downloadedk2-platforms-1eabd8e747453dbe583d31c88a691d14d419352e.tar.xz
Make sure the base address of stack base and base address of hob start is in page alignment in InstallPeiMemory() interface.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4646 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Pei/Memory/MemoryServices.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
index e2b2ccc30f..3be63fb105 100644
--- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -115,16 +115,23 @@ Returns:
UINT64 EfiFreeMemorySize;
EFI_PHYSICAL_ADDRESS PhysicalAddressOfOldHob;
+ if (MemoryLength > (MAX_ADDRESS - MemoryBegin + 1))
+ return EFI_INVALID_PARAMETER;
+
+
DEBUG ((EFI_D_INFO, "PeiInstallPeiMemory MemoryBegin 0x%LX, MemoryLength 0x%LX\n", MemoryBegin, MemoryLength));
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
PrivateData->SwitchStackSignal = TRUE;
PrivateData->PeiMemoryInstalled = TRUE;
-
- PrivateData->StackBase = MemoryBegin;
- PeiStackSize = RShiftU64 (MemoryLength, 1);
+ //
+ // Ensure the stack base is in page alignment
+ //
+ PrivateData->StackBase = ((UINTN)MemoryBegin + (EFI_PAGE_SIZE - 1)) & EFI_PAGE_SIZE;
+
+ PeiStackSize = (RShiftU64 (MemoryLength, 1) + (EFI_PAGE_SIZE - 1)) & EFI_PAGE_SIZE;
if (PEI_STACK_SIZE > PeiStackSize) {
PrivateData->StackSize = PeiStackSize;
} else {
@@ -133,7 +140,7 @@ Returns:
OldHandOffHob = PrivateData->HobList.HandoffInformationTable;
- PrivateData->HobList.Raw = (VOID *)((UINTN)(MemoryBegin + PrivateData->StackSize));
+ PrivateData->HobList.Raw = (VOID *)((UINTN)(PrivateData->StackBase + PrivateData->StackSize));
NewHandOffHob = PrivateData->HobList.HandoffInformationTable;
PhysicalAddressOfOldHob = (EFI_PHYSICAL_ADDRESS) (UINTN) OldHandOffHob;