GetWakeupBuffer() tries to find a below-1M free memory, it checks
whether the memory is allocated already in
CheckOverlapWithAllocatedBuffer(). When there is a memory allocation
hob (base = 0xff_00000000, size = 0x10000000),
CheckOverlapWithAllocateBuffer() truncates the base to 0 which causes
it always returns TRUE so GetWakeupBuffer() fails to find a below-1MB
memory.
The patch fixes this issue by using UINT64 type.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
/** @file\r
MP initialize support functions for PEI phase.\r
\r
/** @file\r
MP initialize support functions for PEI phase.\r
\r
- Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
**/\r
BOOLEAN\r
CheckOverlapWithAllocatedBuffer (\r
**/\r
BOOLEAN\r
CheckOverlapWithAllocatedBuffer (\r
- IN UINTN WakeupBufferStart,\r
- IN UINTN WakeupBufferEnd\r
+ IN UINT64 WakeupBufferStart,\r
+ IN UINT64 WakeupBufferEnd\r
)\r
{\r
EFI_PEI_HOB_POINTERS Hob;\r
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r
BOOLEAN Overlapped;\r
)\r
{\r
EFI_PEI_HOB_POINTERS Hob;\r
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r
BOOLEAN Overlapped;\r
- UINTN MemoryStart;\r
- UINTN MemoryEnd;\r
+ UINT64 MemoryStart;\r
+ UINT64 MemoryEnd;\r
\r
Overlapped = FALSE;\r
//\r
\r
Overlapped = FALSE;\r
//\r
while (!END_OF_HOB_LIST (Hob)) {\r
if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
MemoryHob = Hob.MemoryAllocation;\r
while (!END_OF_HOB_LIST (Hob)) {\r
if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
MemoryHob = Hob.MemoryAllocation;\r
- MemoryStart = (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
- MemoryEnd = (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddress +\r
- MemoryHob->AllocDescriptor.MemoryLength);\r
+ MemoryStart = MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
+ MemoryEnd = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;\r
if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) {\r
Overlapped = TRUE;\r
break;\r
if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) {\r
Overlapped = TRUE;\r
break;\r
)\r
{\r
EFI_PEI_HOB_POINTERS Hob;\r
)\r
{\r
EFI_PEI_HOB_POINTERS Hob;\r
- UINTN WakeupBufferStart;\r
- UINTN WakeupBufferEnd;\r
+ UINT64 WakeupBufferStart;\r
+ UINT64 WakeupBufferEnd;\r
\r
WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1);\r
\r
\r
WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1);\r
\r
//\r
// Need memory under 1MB to be collected here\r
//\r
//\r
// Need memory under 1MB to be collected here\r
//\r
- WakeupBufferEnd = (UINTN) (Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength);\r
+ WakeupBufferEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength;\r
if (WakeupBufferEnd > BASE_1MB) {\r
//\r
// Wakeup buffer should be under 1MB\r
if (WakeupBufferEnd > BASE_1MB) {\r
//\r
// Wakeup buffer should be under 1MB\r
}\r
DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r
WakeupBufferStart, WakeupBufferSize));\r
}\r
DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r
WakeupBufferStart, WakeupBufferSize));\r
- return WakeupBufferStart;\r
+ return (UINTN)WakeupBufferStart;\r