Fix bug in latest check-in of "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@4666 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2008-02-03 07:41:10 +00:00
parent ff8ff1391d
commit 39d262c4ce
1 changed files with 11 additions and 4 deletions

View File

@ -115,6 +115,10 @@ 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);
@ -122,9 +126,12 @@ Returns:
PrivateData->SwitchStackSignal = TRUE;
PrivateData->PeiMemoryInstalled = TRUE;
PrivateData->StackBase = MemoryBegin;
//
// Ensure the stack base is in page alignment
//
PrivateData->StackBase = ((UINTN)MemoryBegin + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
PeiStackSize = (RShiftU64 (MemoryLength, 1) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
PeiStackSize = RShiftU64 (MemoryLength, 1);
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;