37 = GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS;
39 = GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS;
69 StartBit = (
UINTN)GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address);
70 EndBit = (StartBit + BitNumber - 1) % GUARDED_HEAP_MAP_ENTRY_BITS;
72 if ((StartBit + BitNumber) >= GUARDED_HEAP_MAP_ENTRY_BITS) {
73 Msbs = (GUARDED_HEAP_MAP_ENTRY_BITS - StartBit) %
74 GUARDED_HEAP_MAP_ENTRY_BITS;
75 Lsbs = (EndBit + 1) % GUARDED_HEAP_MAP_ENTRY_BITS;
76 Qwords = (BitNumber - Msbs) / GUARDED_HEAP_MAP_ENTRY_BITS;
91 Qwords * GUARDED_HEAP_MAP_ENTRY_BYTES,
125 StartBit = (
UINTN)GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address);
126 EndBit = (StartBit + BitNumber - 1) % GUARDED_HEAP_MAP_ENTRY_BITS;
128 if ((StartBit + BitNumber) >= GUARDED_HEAP_MAP_ENTRY_BITS) {
129 Msbs = (GUARDED_HEAP_MAP_ENTRY_BITS - StartBit) %
130 GUARDED_HEAP_MAP_ENTRY_BITS;
131 Lsbs = (EndBit + 1) % GUARDED_HEAP_MAP_ENTRY_BITS;
132 Qwords = (BitNumber - Msbs) / GUARDED_HEAP_MAP_ENTRY_BITS;
140 *BitMap &= ~LShiftU64 (
LShiftU64 (1, Msbs) - 1, StartBit);
145 SetMem64 ((VOID *)BitMap, Qwords * GUARDED_HEAP_MAP_ENTRY_BYTES, 0);
180 ASSERT (BitNumber <= GUARDED_HEAP_MAP_ENTRY_BITS);
182 StartBit = (
UINTN)GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address);
183 EndBit = (StartBit + BitNumber - 1) % GUARDED_HEAP_MAP_ENTRY_BITS;
185 if ((StartBit + BitNumber) > GUARDED_HEAP_MAP_ENTRY_BITS) {
186 Msbs = GUARDED_HEAP_MAP_ENTRY_BITS - StartBit;
187 Lsbs = (EndBit + 1) % GUARDED_HEAP_MAP_ENTRY_BITS;
193 if ((StartBit == 0) && (BitNumber == GUARDED_HEAP_MAP_ENTRY_BITS)) {
219 IN BOOLEAN AllocMapUnit,
236 while (AllocMapUnit &&
237 mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH &&
240 mLevelShift[GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel - 1]
243 if (mGuardedMemoryMap != 0) {
244 Size = (mLevelMask[GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel - 1] + 1)
245 * GUARDED_HEAP_MAP_ENTRY_BYTES;
254 ASSERT (MapMemory != 0);
258 *(UINT64 *)(
UINTN)MapMemory = mGuardedMemoryMap;
259 mGuardedMemoryMap = MapMemory;
265 GuardMap = &mGuardedMemoryMap;
266 for (Level = GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel;
267 Level < GUARDED_HEAP_MAP_TABLE_DEPTH;
270 if (*GuardMap == 0) {
276 Size = (mLevelMask[Level] + 1) * GUARDED_HEAP_MAP_ENTRY_BYTES;
285 ASSERT (MapMemory != 0);
288 *GuardMap = MapMemory;
292 Index &= mLevelMask[Level];
293 GuardMap = (UINT64 *)(
UINTN)((*GuardMap) + Index *
sizeof (UINT64));
296 BitsToUnitEnd = GUARDED_HEAP_MAP_BITS - GUARDED_HEAP_MAP_BIT_INDEX (Address);
299 return BitsToUnitEnd;
321 while (NumberOfPages > 0) {
323 ASSERT (BitMap !=
NULL);
325 if (NumberOfPages > BitsToUnitEnd) {
327 Bits = BitsToUnitEnd;
329 Bits = NumberOfPages;
332 SetBits (Address, Bits, BitMap);
334 NumberOfPages -= Bits;
358 while (NumberOfPages > 0) {
360 ASSERT (BitMap !=
NULL);
362 if (NumberOfPages > BitsToUnitEnd) {
364 Bits = BitsToUnitEnd;
366 Bits = NumberOfPages;
371 NumberOfPages -= Bits;
396 ASSERT (NumberOfPages <= GUARDED_HEAP_MAP_ENTRY_BITS);
400 while (NumberOfPages > 0) {
403 if (NumberOfPages > BitsToUnitEnd) {
405 Bits = BitsToUnitEnd;
407 Bits = NumberOfPages;
410 if (BitMap !=
NULL) {
415 NumberOfPages -= Bits;
438 if (GuardMap !=
NULL) {
441 GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address)
473 return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
523 Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);
557 Attributes |= EFI_MEMORY_XP;
570 Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);
600 if ((
PcdGet8 (PcdHeapGuardPropertyMask) & PageOrPool) == 0) {
604 if (PageOrPool == GUARD_HEAP_TYPE_POOL) {
605 ConfigBit =
PcdGet64 (PcdHeapGuardPoolType);
606 }
else if (PageOrPool == GUARD_HEAP_TYPE_PAGE) {
607 ConfigBit =
PcdGet64 (PcdHeapGuardPageType);
609 ConfigBit = (UINT64)-1;
612 if ((UINT32)MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {
614 }
else if ((UINT32)MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {
616 }
else if (MemoryType < EfiMaxMemoryType) {
618 }
else if (MemoryType == EfiMaxMemoryType) {
619 TestBit = (UINT64)-1;
624 return ((ConfigBit & TestBit) != 0);
734 if (NumberOfPages == 0) {
752 if ((GuardBitmap & BIT1) == 0) {
756 if ((GuardBitmap & BIT0) == 0) {
785 if ((GuardBitmap & BIT0) == 0) {
789 if ((GuardBitmap & BIT1) == 0) {
828 IN UINT64 SizeRequested
838 if ((
PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0) {
842 Target = Start + Size - SizeRequested;
843 ASSERT (Target >= Start);
854 if (Target < Start) {
859 if (Target == Start) {
868 return Target + SizeRequested - 1;
894 if ((Memory ==
NULL) || (NumberOfPages ==
NULL) || (*NumberOfPages == 0)) {
899 PagesToFree = *NumberOfPages;
915 if ((GuardBitmap & BIT1) == 0) {
919 if ((GuardBitmap & BIT0) == 0) {
950 if ((GuardBitmap & BIT0) == 0) {
954 if ((GuardBitmap & BIT1) == 0) {
961 }
else if (PagesToFree > 0) {
970 *NumberOfPages = PagesToFree;
999 *Memory -= EFI_PAGE_SIZE;
1000 *NumberOfPages += 1;
1022 if ((Memory == 0) || ((
PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) != 0)) {
1026 return (VOID *)(
UINTN)Memory;
1053 if ((Memory == 0) || ((
PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) != 0)) {
1057 return (VOID *)(
UINTN)Memory;
1090 OldPages = NumberOfPages;
1101 if (NumberOfPages == 0) {
1119 UINTN Entries[GUARDED_HEAP_MAP_TABLE_DEPTH];
1120 UINTN Shifts[GUARDED_HEAP_MAP_TABLE_DEPTH];
1121 UINTN Indices[GUARDED_HEAP_MAP_TABLE_DEPTH];
1122 UINT64 Tables[GUARDED_HEAP_MAP_TABLE_DEPTH];
1123 UINT64 Addresses[GUARDED_HEAP_MAP_TABLE_DEPTH];
1131 if ((mGuardedMemoryMap == 0) ||
1133 (mMapLevel > GUARDED_HEAP_MAP_TABLE_DEPTH))
1138 CopyMem (Entries, mLevelMask,
sizeof (Entries));
1139 CopyMem (Shifts, mLevelShift,
sizeof (Shifts));
1141 SetMem (Tables,
sizeof (Tables), 0);
1142 SetMem (Addresses,
sizeof (Addresses), 0);
1143 SetMem (Indices,
sizeof (Indices), 0);
1145 Level = GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel;
1146 Tables[Level] = mGuardedMemoryMap;
1155 if (Indices[Level] > Entries[Level]) {
1159 TableEntry = ((UINT64 *)(
UINTN)(Tables[Level]))[Indices[Level]];
1160 Address = Addresses[Level];
1162 if (TableEntry == 0) {
1164 }
else if (Level < GUARDED_HEAP_MAP_TABLE_DEPTH - 1) {
1166 Tables[Level] = TableEntry;
1167 Addresses[Level] = Address;
1173 while (Index < GUARDED_HEAP_MAP_ENTRY_BITS) {
1174 if ((TableEntry & 1) == 1) {
1178 GuardPage = Address - EFI_PAGE_SIZE;
1184 GuardPage = Address;
1192 if (GuardPage != 0) {
1196 if (TableEntry == 0) {
1201 Address += EFI_PAGE_SIZE;
1207 if (Level < (GUARDED_HEAP_MAP_TABLE_DEPTH - (
INTN)mMapLevel)) {
1211 Indices[Level] += 1;
1212 Address = (Level == 0) ? 0 : Addresses[Level - 1];
1213 Addresses[Level] = Address |
LShiftU64 (Indices[Level], Shifts[Level]);
1235 ASSERT (mMapLevel >= 1);
1238 Map = mGuardedMemoryMap;
1239 for (Level = GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel;
1240 Level < GUARDED_HEAP_MAP_TABLE_DEPTH;
1243 AddressGranularity =
LShiftU64 (1, mLevelShift[Level]);
1248 for (Index = (
INTN)mLevelMask[Level]; Index >= 0; --Index) {
1249 if (((UINT64 *)(
UINTN)Map)[Index] != 0) {
1250 BaseAddress +=
MultU64x32 (AddressGranularity, (UINT32)Index);
1251 Map = ((UINT64 *)(
UINTN)Map)[Index];
1265 *Address = BaseAddress;
1306 if (BaseAddress < BASE_1MB) {
1321 Status = gCpu->SetMemoryAttributes (
1332 if (EFI_ERROR (Status)) {
1333 DEBUG ((DEBUG_WARN,
"Failed to guard freed pages: %p (%lu)\n", BaseAddress, (UINT64)Pages));
1336 mOnGuarding =
FALSE;
1369 UINTN Entries[GUARDED_HEAP_MAP_TABLE_DEPTH];
1370 UINTN Shifts[GUARDED_HEAP_MAP_TABLE_DEPTH];
1371 UINTN Indices[GUARDED_HEAP_MAP_TABLE_DEPTH];
1372 UINT64 Tables[GUARDED_HEAP_MAP_TABLE_DEPTH];
1373 UINT64 Addresses[GUARDED_HEAP_MAP_TABLE_DEPTH];
1379 UINTN GuardPageNumber;
1381 if ((mGuardedMemoryMap == 0) ||
1383 (mMapLevel > GUARDED_HEAP_MAP_TABLE_DEPTH))
1388 CopyMem (Entries, mLevelMask,
sizeof (Entries));
1389 CopyMem (Shifts, mLevelShift,
sizeof (Shifts));
1391 SetMem (Tables,
sizeof (Tables), 0);
1392 SetMem (Addresses,
sizeof (Addresses), 0);
1393 SetMem (Indices,
sizeof (Indices), 0);
1395 Level = GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel;
1396 Tables[Level] = mGuardedMemoryMap;
1398 GuardPage = (UINT64)-1;
1399 GuardPageNumber = 0;
1402 if (Indices[Level] > Entries[Level]) {
1406 TableEntry = ((UINT64 *)(
UINTN)(Tables[Level]))[Indices[Level]];
1407 Address = Addresses[Level];
1409 if (TableEntry == 0) {
1410 GuardPageNumber = 0;
1411 GuardPage = (UINT64)-1;
1413 if (Level < GUARDED_HEAP_MAP_TABLE_DEPTH - 1) {
1415 Tables[Level] = TableEntry;
1416 Addresses[Level] = Address;
1422 while (BitIndex != 0) {
1423 if ((TableEntry & BitIndex) != 0) {
1424 if (GuardPage == (UINT64)-1) {
1425 GuardPage = Address;
1429 }
else if (GuardPageNumber > 0) {
1431 GuardPageNumber = 0;
1432 GuardPage = (UINT64)-1;
1435 if (TableEntry == 0) {
1446 if (Level < (GUARDED_HEAP_MAP_TABLE_DEPTH - (
INTN)mMapLevel)) {
1450 Indices[Level] += 1;
1451 Address = (Level == 0) ? 0 : Addresses[Level - 1];
1452 Addresses[Level] = Address |
LShiftU64 (Indices[Level], Shifts[Level]);
1461 mLastPromotedPage = Address;
1493 Pages -= (
INTN)MemoryMapEntry->NumberOfPages;
1496 EndAddress = MemoryMapEntry->PhysicalStart +
1501 if ((Bitmap & 1) == 0) {
1506 MemoryMapEntry->NumberOfPages++;
1537 UINTN AvailablePages;
1549 Start = mLastPromotedPage;
1551 while (AvailablePages == 0) {
1556 if (Start > mLastPromotedPage) {
1558 ASSERT (Start != 0);
1563 while (Bitmap > 0) {
1564 if ((Bitmap & 1) != 0) {
1566 }
else if (AvailablePages == 0) {
1576 if (AvailablePages != 0) {
1577 DEBUG ((DEBUG_INFO,
"Promoted pages: %lX (%lx)\r\n", Start, (UINT64)AvailablePages));
1586 Status = gCpu->SetMemoryAttributes (gCpu, Start,
EFI_PAGES_TO_SIZE (AvailablePages), 0);
1588 mOnGuarding =
FALSE;
1591 mLastPromotedPage = Start;
1592 *StartAddress = Start;
1608 ASSERT (gCpu !=
NULL);
1613 DEBUG ((DEBUG_ERROR,
"Heap guard and freed memory guard cannot be enabled at the same time.\n"));
1637 OUT CHAR8 *BinString
1642 if (BinString ==
NULL) {
1646 for (Index = 64; Index > 0; --Index) {
1647 BinString[Index - 1] =
'0' + (Value & 1);
1651 BinString[64] =
'\0';
1663 UINTN Entries[GUARDED_HEAP_MAP_TABLE_DEPTH];
1664 UINTN Shifts[GUARDED_HEAP_MAP_TABLE_DEPTH];
1665 UINTN Indices[GUARDED_HEAP_MAP_TABLE_DEPTH];
1666 UINT64 Tables[GUARDED_HEAP_MAP_TABLE_DEPTH];
1667 UINT64 Addresses[GUARDED_HEAP_MAP_TABLE_DEPTH];
1672 CHAR8 String[GUARDED_HEAP_MAP_ENTRY_BITS + 1];
1680 if ((mGuardedMemoryMap == 0) ||
1682 (mMapLevel > GUARDED_HEAP_MAP_TABLE_DEPTH))
1687 Ruler1 =
" 3 2 1 0";
1688 Ruler2 =
"FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210";
1691 HEAP_GUARD_DEBUG_LEVEL,
1692 "============================="
1693 " Guarded Memory Bitmap "
1694 "==============================\r\n"
1696 DEBUG ((HEAP_GUARD_DEBUG_LEVEL,
" %a\r\n", Ruler1));
1697 DEBUG ((HEAP_GUARD_DEBUG_LEVEL,
" %a\r\n", Ruler2));
1699 CopyMem (Entries, mLevelMask,
sizeof (Entries));
1700 CopyMem (Shifts, mLevelShift,
sizeof (Shifts));
1702 SetMem (Indices,
sizeof (Indices), 0);
1703 SetMem (Tables,
sizeof (Tables), 0);
1704 SetMem (Addresses,
sizeof (Addresses), 0);
1706 Level = GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel;
1707 Tables[Level] = mGuardedMemoryMap;
1712 if (Indices[Level] > Entries[Level]) {
1718 HEAP_GUARD_DEBUG_LEVEL,
1719 "========================================="
1720 "=========================================\r\n"
1723 TableEntry = ((UINT64 *)(
UINTN)Tables[Level])[Indices[Level]];
1724 Address = Addresses[Level];
1726 if (TableEntry == 0) {
1727 if (Level == GUARDED_HEAP_MAP_TABLE_DEPTH - 1) {
1728 if (RepeatZero == 0) {
1730 DEBUG ((HEAP_GUARD_DEBUG_LEVEL,
"%016lx: %a\r\n", Address, String));
1731 }
else if (RepeatZero == 1) {
1732 DEBUG ((HEAP_GUARD_DEBUG_LEVEL,
"... : ...\r\n"));
1737 }
else if (Level < GUARDED_HEAP_MAP_TABLE_DEPTH - 1) {
1739 Tables[Level] = TableEntry;
1740 Addresses[Level] = Address;
1748 DEBUG ((HEAP_GUARD_DEBUG_LEVEL,
"%016lx: %a\r\n", Address, String));
1752 if (Level < (GUARDED_HEAP_MAP_TABLE_DEPTH - (
INTN)mMapLevel)) {
1756 Indices[Level] += 1;
1757 Address = (Level == 0) ? 0 : Addresses[Level - 1];
1758 Addresses[Level] = Address |
LShiftU64 (Indices[Level], Shifts[Level]);
VOID EFIAPI CpuDeadLoop(VOID)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI SetMem64(OUT VOID *Buffer, IN UINTN Length, IN UINT64 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID GetLastGuardedFreePageAddress(OUT EFI_PHYSICAL_ADDRESS *Address)
VOID SetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
UINTN EFIAPI GetGuardMapBit(IN EFI_PHYSICAL_ADDRESS Address)
VOID AdjustMemoryF(IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN OUT UINTN *NumberOfPages)
VOID EFIAPI GuardFreedPagesChecked(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINTN Pages)
VOID * AdjustPoolHeadF(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NoPages, IN UINTN Size)
VOID SetAllGuardPages(VOID)
VOID EFIAPI DumpGuardedMemoryBitmap(VOID)
BOOLEAN PromoteGuardedFreePages(OUT EFI_PHYSICAL_ADDRESS *StartAddress, OUT EFI_PHYSICAL_ADDRESS *EndAddress)
STATIC UINT64 GetBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN BitNumber, IN UINT64 *BitMap)
BOOLEAN EFIAPI IsGuardPage(IN EFI_PHYSICAL_ADDRESS Address)
STATIC VOID ClearBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN BitNumber, IN UINT64 *BitMap)
VOID EFIAPI SetGuardPage(IN EFI_PHYSICAL_ADDRESS BaseAddress)
VOID EFIAPI UnsetGuardPage(IN EFI_PHYSICAL_ADDRESS BaseAddress)
VOID Uint64ToBinString(IN UINT64 Value, OUT CHAR8 *BinString)
VOID MergeGuardPages(IN EFI_MEMORY_DESCRIPTOR *MemoryMapEntry, IN EFI_PHYSICAL_ADDRESS MaxAddress)
UINT64 GetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
BOOLEAN IsHeapGuardEnabled(UINT8 GuardType)
VOID GuardAllFreedPages(VOID)
VOID AdjustMemoryA(IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN OUT UINTN *NumberOfPages)
VOID UnsetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
VOID EFIAPI GuardFreedPages(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINTN Pages)
UINT64 AdjustMemoryS(IN UINT64 Start, IN UINT64 Size, IN UINT64 SizeRequested)
VOID MarkFreedPages(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINTN Pages)
STATIC VOID SetBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN BitNumber, IN UINT64 *BitMap)
BOOLEAN IsPoolTypeToGuard(IN EFI_MEMORY_TYPE MemoryType)
VOID EFIAPI ClearGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
BOOLEAN EFIAPI IsMemoryGuarded(IN EFI_PHYSICAL_ADDRESS Address)
VOID EFIAPI SetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
BOOLEAN IsPageTypeToGuard(IN EFI_MEMORY_TYPE MemoryType, IN EFI_ALLOCATE_TYPE AllocateType)
UINTN FindGuardedMemoryMap(IN EFI_PHYSICAL_ADDRESS Address, IN BOOLEAN AllocMapUnit, OUT UINT64 **BitMap)
EFI_STATUS CoreConvertPagesWithGuard(IN UINT64 Start, IN UINTN NumberOfPages, IN EFI_MEMORY_TYPE NewType)
VOID HeapGuardCpuArchProtocolNotify(VOID)
VOID * AdjustPoolHeadA(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NoPages, IN UINTN Size)
BOOLEAN IsMemoryTypeToGuard(IN EFI_MEMORY_TYPE MemoryType, IN EFI_ALLOCATE_TYPE AllocateType, IN UINT8 PageOrPool)
EFI_STATUS CoreConvertPages(IN UINT64 Start, IN UINT64 NumberOfPages, IN EFI_MEMORY_TYPE NewType)
EFI_STATUS EFIAPI CoreInternalAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN BOOLEAN NeedGuard)
#define ALIGN_VALUE(Value, Alignment)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define PcdGet64(TokenName)
#define PcdGet8(TokenName)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)