28#define IA32_PG_RW BIT1
30#define IA32_PG_WT BIT3
31#define IA32_PG_CD BIT4
34#define IA32_PG_PS BIT7
35#define IA32_PG_PAT_2M BIT12
36#define IA32_PG_PAT_4K IA32_PG_PS
37#define IA32_PG_PMNT BIT62
38#define IA32_PG_NX BIT63
40#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)
41#define PAGE_ATTRIBUTE_BITS_POST_SPLIT (IA32_PG_RW | IA32_PG_P)
47#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P)
49#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)
51#define PAGING_4K_MASK 0xFFF
52#define PAGING_2M_MASK 0x1FFFFF
53#define PAGING_1G_MASK 0x3FFFFFFF
55#define PAGING_PAE_INDEX_MASK 0x1FF
57#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull
58#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull
59#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
61#define MAX_PF_ENTRY_COUNT 10
62#define MAX_DEBUG_MESSAGE_LENGTH 0x100
63#define IA32_PF_EC_ID BIT4
73 PAGE_ATTRIBUTE Attribute;
85 { Page4K, SIZE_4KB, PAGING_4K_ADDRESS_MASK_64 },
86 { Page2M, SIZE_2MB, PAGING_2M_ADDRESS_MASK_64 },
87 { Page1G, SIZE_1GB, PAGING_1G_ADDRESS_MASK_64 },
91BOOLEAN mPageTablePoolLock =
FALSE;
99UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT];
127 if (mSmmBase2 ==
NULL) {
128 gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid,
NULL, (VOID **)&mSmmBase2);
131 if (mSmmBase2 !=
NULL) {
132 mSmmBase2->InSmm (mSmmBase2, &
InSmm);
142 mPagingContext.ContextData.X64.PageTableBase != (UINT64)
AsmReadCr3 ());
161 UINTN *PageTableBase;
167 ZeroMem (&mPagingContext,
sizeof (mPagingContext));
168 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
169 mPagingContext.MachineType = IMAGE_FILE_MACHINE_X64;
171 mPagingContext.MachineType = IMAGE_FILE_MACHINE_I386;
174 GetPagingDetails (&mPagingContext.ContextData, &PageTableBase, &Attributes);
179 if (Cr0.Bits.PG != 0) {
180 *PageTableBase = (
AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64);
185 if (Cr0.Bits.WP != 0) {
186 *Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE;
189 if (Cr4.Bits.PSE != 0) {
190 *Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE;
193 if (Cr4.Bits.PAE != 0) {
194 *Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE;
197 if (Cr4.Bits.LA57 != 0) {
198 *Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL;
205 if (RegEdx.
Bits.
NX != 0) {
210 *Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED;
215 *Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT;
224 CopyMem (PagingContext, &mPagingContext,
sizeof (mPagingContext));
236 IN PAGE_ATTRIBUTE PageAttribute
241 for (Index = 0; Index <
sizeof (mPageAttributeTable)/
sizeof (mPageAttributeTable[0]); Index++) {
242 if (PageAttribute == mPageAttributeTable[Index].Attribute) {
243 return (
UINTN)mPageAttributeTable[Index].Length;
259 IN PAGE_ATTRIBUTE PageAttribute
264 for (Index = 0; Index <
sizeof (mPageAttributeTable)/
sizeof (mPageAttributeTable[0]); Index++) {
265 if (PageAttribute == mPageAttributeTable[Index].Attribute) {
266 return (
UINTN)mPageAttributeTable[Index].AddressMask;
285 IN PHYSICAL_ADDRESS Address,
286 OUT PAGE_ATTRIBUTE *PageAttribute
299 UINT64 AddressEncMask;
301 ASSERT (PagingContext !=
NULL);
303 Index5 = ((
UINTN)
RShiftU64 (Address, 48)) & PAGING_PAE_INDEX_MASK;
304 Index4 = ((
UINTN)
RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK;
305 Index3 = ((
UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK;
306 Index2 = ((
UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK;
307 Index1 = ((
UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK;
311 AddressEncMask =
PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
312 if (AddressEncMask == 0) {
313 AddressEncMask =
PcdGet64 (PcdTdxSharedBitMask) & PAGING_1G_ADDRESS_MASK_64;
316 if (PagingContext->MachineType == IMAGE_FILE_MACHINE_X64) {
317 if ((PagingContext->ContextData.X64.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL) != 0) {
318 L5PageTable = (UINT64 *)(
UINTN)PagingContext->ContextData.X64.PageTableBase;
319 if (L5PageTable[Index5] == 0) {
320 *PageAttribute = PageNone;
324 L4PageTable = (UINT64 *)(
UINTN)(L5PageTable[Index5] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64);
326 L4PageTable = (UINT64 *)(
UINTN)PagingContext->ContextData.X64.PageTableBase;
329 if (L4PageTable[Index4] == 0) {
330 *PageAttribute = PageNone;
334 L3PageTable = (UINT64 *)(
UINTN)(L4PageTable[Index4] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64);
336 ASSERT ((PagingContext->ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) != 0);
337 L3PageTable = (UINT64 *)(
UINTN)PagingContext->ContextData.Ia32.PageTableBase;
340 if (L3PageTable[Index3] == 0) {
341 *PageAttribute = PageNone;
345 if ((L3PageTable[Index3] & IA32_PG_PS) != 0) {
347 *PageAttribute = Page1G;
348 return &L3PageTable[Index3];
351 L2PageTable = (UINT64 *)(
UINTN)(L3PageTable[Index3] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64);
352 if (L2PageTable[Index2] == 0) {
353 *PageAttribute = PageNone;
357 if ((L2PageTable[Index2] & IA32_PG_PS) != 0) {
359 *PageAttribute = Page2M;
360 return &L2PageTable[Index2];
364 L1PageTable = (UINT64 *)(
UINTN)(L2PageTable[Index2] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64);
365 if ((L1PageTable[Index1] == 0) && (Address != 0)) {
366 *PageAttribute = PageNone;
370 *PageAttribute = Page4K;
371 return &L1PageTable[Index1];
390 Attributes |= EFI_MEMORY_RP;
393 if ((*PageEntry & IA32_PG_RW) == 0) {
394 Attributes |= EFI_MEMORY_RO;
397 if ((*PageEntry & IA32_PG_NX) != 0) {
398 Attributes |= EFI_MEMORY_XP;
416 IN UINT64 *PageEntry,
417 IN UINT64 Attributes,
418 IN PAGE_ACTION PageAction,
419 OUT BOOLEAN *IsModified
422 UINT64 CurrentPageEntry;
424 UINT32 *PageAttributes;
426 CurrentPageEntry = *PageEntry;
427 NewPageEntry = CurrentPageEntry;
428 if ((Attributes & EFI_MEMORY_RP) != 0) {
429 switch (PageAction) {
430 case PageActionAssign:
434 case PageActionClear:
439 switch (PageAction) {
440 case PageActionAssign:
444 case PageActionClear:
449 if ((Attributes & EFI_MEMORY_RO) != 0) {
450 switch (PageAction) {
451 case PageActionAssign:
453 NewPageEntry &= ~(UINT64)IA32_PG_RW;
455 case PageActionClear:
456 NewPageEntry |= IA32_PG_RW;
460 switch (PageAction) {
461 case PageActionAssign:
462 NewPageEntry |= IA32_PG_RW;
465 case PageActionClear:
472 if ((*PageAttributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED) != 0) {
473 if ((Attributes & EFI_MEMORY_XP) != 0) {
474 switch (PageAction) {
475 case PageActionAssign:
477 NewPageEntry |= IA32_PG_NX;
479 case PageActionClear:
480 NewPageEntry &= ~IA32_PG_NX;
484 switch (PageAction) {
485 case PageActionAssign:
486 NewPageEntry &= ~IA32_PG_NX;
489 case PageActionClear:
495 *PageEntry = NewPageEntry;
496 if (CurrentPageEntry != NewPageEntry) {
498 DEBUG ((DEBUG_VERBOSE,
"ConvertPageEntryAttribute 0x%lx", CurrentPageEntry));
499 DEBUG ((DEBUG_VERBOSE,
"->0x%lx\n", NewPageEntry));
517 IN PHYSICAL_ADDRESS BaseAddress,
519 IN UINT64 *PageEntry,
520 IN PAGE_ATTRIBUTE PageAttribute
523 UINT64 PageEntryLength;
527 if (((BaseAddress & (PageEntryLength - 1)) == 0) && (Length >= PageEntryLength)) {
531 if (((BaseAddress & PAGING_2M_MASK) != 0) || (Length < SIZE_2MB)) {
552 IN UINT64 *PageEntry,
553 IN PAGE_ATTRIBUTE PageAttribute,
554 IN PAGE_ATTRIBUTE SplitAttribute,
559 UINT64 *NewPageEntry;
561 UINT64 AddressEncMask;
563 ASSERT (PageAttribute == Page2M || PageAttribute == Page1G);
565 ASSERT (AllocatePagesFunc !=
NULL);
569 AddressEncMask =
PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
571 if (PageAttribute == Page2M) {
575 ASSERT (SplitAttribute == Page4K);
576 if (SplitAttribute == Page4K) {
577 NewPageEntry = AllocatePagesFunc (1);
578 DEBUG ((DEBUG_VERBOSE,
"Split - 0x%x\n", NewPageEntry));
579 if (NewPageEntry ==
NULL) {
583 BaseAddress = *PageEntry & ~AddressEncMask & PAGING_2M_ADDRESS_MASK_64;
584 for (Index = 0; Index < SIZE_4KB /
sizeof (UINT64); Index++) {
585 NewPageEntry[Index] = (BaseAddress + SIZE_4KB * Index) | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS);
588 (*PageEntry) = (UINT64)(
UINTN)NewPageEntry | AddressEncMask | PAGE_ATTRIBUTE_BITS_POST_SPLIT;
593 }
else if (PageAttribute == Page1G) {
598 ASSERT (SplitAttribute == Page2M || SplitAttribute == Page4K);
599 if (((SplitAttribute == Page2M) || (SplitAttribute == Page4K))) {
600 NewPageEntry = AllocatePagesFunc (1);
601 DEBUG ((DEBUG_VERBOSE,
"Split - 0x%x\n", NewPageEntry));
602 if (NewPageEntry ==
NULL) {
606 BaseAddress = *PageEntry & ~AddressEncMask & PAGING_1G_ADDRESS_MASK_64;
607 for (Index = 0; Index < SIZE_4KB /
sizeof (UINT64); Index++) {
608 NewPageEntry[Index] = (BaseAddress + SIZE_2MB * Index) | AddressEncMask | IA32_PG_PS | ((*PageEntry) & PAGE_PROGATE_BITS);
611 (*PageEntry) = (UINT64)(
UINTN)NewPageEntry | AddressEncMask | PAGE_ATTRIBUTE_BITS_POST_SPLIT;
641 return (BOOLEAN)(Cr0.Bits.WP != 0);
721 IN PHYSICAL_ADDRESS BaseAddress,
723 IN UINT64 Attributes,
724 IN PAGE_ACTION PageAction,
726 OUT BOOLEAN *IsSplitted OPTIONAL,
727 OUT BOOLEAN *IsModified OPTIONAL
732 PAGE_ATTRIBUTE PageAttribute;
733 UINTN PageEntryLength;
734 PAGE_ATTRIBUTE SplitAttribute;
735 RETURN_STATUS Status;
736 BOOLEAN IsEntryModified;
739 if ((BaseAddress & (SIZE_4KB - 1)) != 0) {
740 DEBUG ((DEBUG_ERROR,
"BaseAddress(0x%lx) is not aligned!\n", BaseAddress));
741 return EFI_UNSUPPORTED;
744 if ((Length & (SIZE_4KB - 1)) != 0) {
745 DEBUG ((DEBUG_ERROR,
"Length(0x%lx) is not aligned!\n", Length));
746 return EFI_UNSUPPORTED;
750 DEBUG ((DEBUG_ERROR,
"Length is 0!\n"));
754 if ((Attributes & ~EFI_MEMORY_ATTRIBUTE_MASK) != 0) {
755 DEBUG ((DEBUG_ERROR,
"Attributes(0x%lx) has unsupported bit\n", Attributes));
756 return EFI_UNSUPPORTED;
759 if (PagingContext ==
NULL) {
762 CopyMem (&CurrentPagingContext, PagingContext,
sizeof (CurrentPagingContext));
765 switch (CurrentPagingContext.MachineType) {
766 case IMAGE_FILE_MACHINE_I386:
767 if (CurrentPagingContext.ContextData.Ia32.PageTableBase == 0) {
768 if (Attributes == 0) {
771 DEBUG ((DEBUG_ERROR,
"PageTable is 0!\n"));
772 return EFI_UNSUPPORTED;
776 if ((CurrentPagingContext.ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) == 0) {
777 DEBUG ((DEBUG_ERROR,
"Non-PAE Paging!\n"));
778 return EFI_UNSUPPORTED;
781 if ((BaseAddress + Length) > BASE_4GB) {
782 DEBUG ((DEBUG_ERROR,
"Beyond 4GB memory in 32-bit mode!\n"));
783 return EFI_UNSUPPORTED;
787 case IMAGE_FILE_MACHINE_X64:
788 ASSERT (CurrentPagingContext.ContextData.X64.PageTableBase != 0);
792 return EFI_UNSUPPORTED;
798 if (IsSplitted !=
NULL) {
802 if (IsModified !=
NULL) {
806 if (AllocatePagesFunc ==
NULL) {
822 while (Length != 0) {
823 PageEntry =
GetPageTableEntry (&CurrentPagingContext, BaseAddress, &PageAttribute);
824 if (PageEntry ==
NULL) {
830 SplitAttribute =
NeedSplitPage (BaseAddress, Length, PageEntry, PageAttribute);
831 if (SplitAttribute == PageNone) {
833 if (IsEntryModified) {
834 if (IsModified !=
NULL) {
842 BaseAddress += PageEntryLength;
843 Length -= PageEntryLength;
845 if (AllocatePagesFunc ==
NULL) {
850 Status =
SplitPage (PageEntry, PageAttribute, SplitAttribute, AllocatePagesFunc);
856 if (IsSplitted !=
NULL) {
860 if (IsModified !=
NULL) {
914 IN PHYSICAL_ADDRESS BaseAddress,
916 IN UINT64 Attributes,
920 RETURN_STATUS Status;
925 Status =
ConvertMemoryPageAttributes (PagingContext, BaseAddress, Length, Attributes, PageActionAssign, AllocatePagesFunc, &IsSplitted, &IsModified);
926 if (!EFI_ERROR (Status)) {
927 if ((PagingContext ==
NULL) && IsModified) {
953 return (MsrEfer.
Bits.
NXE == 1);
965 UINTN NumberOfDescriptors;
968 PAGE_ATTRIBUTE PageAttribute;
971 UINT64 MemorySpaceLength;
974 UINT64 PageStartAddress;
977 UINT64 NewAttributes;
984 Status =
gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
995 Capabilities = EFI_MEMORY_RO | EFI_MEMORY_RP | EFI_MEMORY_XP;
997 Capabilities = EFI_MEMORY_RO | EFI_MEMORY_RP;
1000 for (Index = 0; Index < NumberOfDescriptors; Index++) {
1012 Status =
gDS->SetMemorySpaceCapabilities (
1013 MemorySpaceMap[Index].BaseAddress,
1014 MemorySpaceMap[Index].Length,
1015 MemorySpaceMap[Index].Capabilities | Capabilities
1017 if (EFI_ERROR (Status)) {
1024 "Failed to update capability: [%lu] %016lx - %016lx (%016lx -> %016lx)\r\n",
1026 MemorySpaceMap[Index].BaseAddress,
1027 MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - 1,
1028 MemorySpaceMap[Index].Capabilities,
1029 MemorySpaceMap[Index].Capabilities | Capabilities
1034 if (MemorySpaceMap[Index].BaseAddress >= (BaseAddress + PageLength)) {
1044 PageLength -= (MemorySpaceMap[Index].
BaseAddress - BaseAddress);
1051 MemorySpaceLength = MemorySpaceMap[Index].
Length;
1052 while (MemorySpaceLength > 0) {
1053 if (PageLength == 0) {
1055 if (PageEntry ==
NULL) {
1067 Length =
MIN (PageLength, MemorySpaceLength);
1068 if (Attributes != (MemorySpaceMap[Index].Attributes &
1069 EFI_MEMORY_ATTRIBUTE_MASK))
1071 NewAttributes = (MemorySpaceMap[Index].
Attributes &
1072 ~EFI_MEMORY_ATTRIBUTE_MASK) | Attributes;
1073 Status =
gDS->SetMemorySpaceAttributes (
1081 "Updated memory space attribute: [%lu] %016lx - %016lx (%016lx -> %016lx)\r\n",
1084 BaseAddress + Length - 1,
1085 MemorySpaceMap[Index].Attributes,
1090 PageLength -= Length;
1091 MemorySpaceLength -= Length;
1092 BaseAddress += Length;
1127 if (mPageTablePoolLock) {
1131 mPageTablePoolLock =
TRUE;
1139 PoolPages = ((PoolPages - 1) / PAGE_TABLE_POOL_UNIT_PAGES + 1) *
1140 PAGE_TABLE_POOL_UNIT_PAGES;
1142 if (Buffer ==
NULL) {
1143 DEBUG ((DEBUG_ERROR,
"ERROR: Out of aligned pages\r\n"));
1149 "Paging: added %lu pages to page table pool\r\n",
1156 if (mPageTablePool ==
NULL) {
1157 mPageTablePool = Buffer;
1158 mPageTablePool->NextPool = mPageTablePool;
1161 mPageTablePool->NextPool = Buffer;
1162 mPageTablePool = Buffer;
1168 mPageTablePool->FreePages = PoolPages - 1;
1176 (PHYSICAL_ADDRESS)(
UINTN)Buffer,
1184 ASSERT (IsModified ==
TRUE);
1187 mPageTablePoolLock =
FALSE;
1223 if ((mPageTablePool ==
NULL) ||
1224 (Pages > mPageTablePool->FreePages))
1231 Buffer = (UINT8 *)mPageTablePool + mPageTablePool->Offset;
1234 mPageTablePool->FreePages -= Pages;
1257 BOOLEAN IsWpEnabled;
1269 for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {
1270 if (mLastPFEntryPointer[CpuIndex][PFEntry] !=
NULL) {
1271 *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~(UINT64)
IA32_PG_P;
1282 mPFEntryCount[CpuIndex] = 0;
1292 if (mPagingContext.MachineType == IMAGE_FILE_MACHINE_I386) {
1293 SystemContext.SystemContextIa32->Eflags &= (UINT32) ~BIT8;
1295 SystemContext.SystemContextX64->Rflags &= (UINT64) ~BIT8;
1318 PAGE_ATTRIBUTE PageAttribute;
1324 BOOLEAN NonStopMode;
1327 if (PFAddress < BASE_4KB) {
1328 NonStopMode = NULL_DETECTION_NONSTOP_MODE ?
TRUE :
FALSE;
1330 NonStopMode = HEAP_GUARD_NONSTOP_MODE ?
TRUE :
FALSE;
1342 while (PageNumber > 0) {
1344 ASSERT (PageEntry !=
NULL);
1346 if (PageEntry !=
NULL) {
1348 if ((Attributes & EFI_MEMORY_RP) != 0) {
1349 Attributes &= ~EFI_MEMORY_RP;
1357 if (!EFI_ERROR (Status)) {
1358 Index = mPFEntryCount[CpuIndex];
1364 mLastPFEntryPointer[CpuIndex][Index++] = PageEntry;
1365 mPFEntryCount[CpuIndex] = Index;
1370 PFAddress += EFI_PAGE_SIZE;
1387 if (mPagingContext.MachineType == IMAGE_FILE_MACHINE_I386) {
1388 SystemContext.SystemContextIa32->Eflags |= (UINT32)BIT8;
1390 SystemContext.SystemContextX64->Rflags |= (UINT64)BIT8;
1407 UINTN *PageTableBase;
1411 GetPagingDetails (&CurrentPagingContext.ContextData, &PageTableBase, &Attributes);
1416 if ((*PageTableBase != 0) &&
1417 ((*Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) != 0))
1424 if (HEAP_GUARD_NONSTOP_MODE || NULL_DETECTION_NONSTOP_MODE) {
1426 ASSERT (mPFEntryCount !=
NULL);
1428 mLastPFEntryPointer = (UINT64 *(*)[MAX_PF_ENTRY_COUNT])
1430 ASSERT (mLastPFEntryPointer !=
NULL);
1433 DEBUG ((DEBUG_INFO,
"CurrentPagingContext:\n"));
1434 DEBUG ((DEBUG_INFO,
" MachineType - 0x%x\n", CurrentPagingContext.MachineType));
1435 DEBUG ((DEBUG_INFO,
" PageTableBase - 0x%Lx\n", (UINT64)*PageTableBase));
1436 DEBUG ((DEBUG_INFO,
" Attributes - 0x%x\n", *Attributes));
RETURN_STATUS EFIAPI SerialPortInitialize(VOID)
VOID EFIAPI CpuDeadLoop(VOID)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define MSR_CORE_IA32_EFER
VOID GetPagingDetails(IN PAGE_TABLE_LIB_PAGING_CONTEXT_DATA *PagingContextData, OUT UINTN **PageTableBase OPTIONAL, OUT UINT32 **Attributes OPTIONAL)
VOID *(EFIAPI * PAGE_TABLE_LIB_ALLOCATE_PAGES)(IN UINTN Pages)
VOID EFIAPI CpuFlushTlb(VOID)
VOID *EFIAPI AllocatePageTableMemory(IN UINTN Pages)
VOID GetCurrentPagingContext(IN OUT PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext)
PAGE_ATTRIBUTE NeedSplitPage(IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 *PageEntry, IN PAGE_ATTRIBUTE PageAttribute)
VOID EnableReadOnlyPageWriteProtect(VOID)
RETURN_STATUS ConvertMemoryPageAttributes(IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN PAGE_ACTION PageAction, IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL, OUT BOOLEAN *IsSplitted OPTIONAL, OUT BOOLEAN *IsModified OPTIONAL)
UINT64 GetAttributesFromPageEntry(IN UINT64 *PageEntry)
VOID EFIAPI PageFaultExceptionHandler(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
BOOLEAN IsExecuteDisableEnabled(VOID)
RETURN_STATUS SplitPage(IN UINT64 *PageEntry, IN PAGE_ATTRIBUTE PageAttribute, IN PAGE_ATTRIBUTE SplitAttribute, IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc)
VOID EFIAPI DebugExceptionHandler(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
UINTN PageAttributeToLength(IN PAGE_ATTRIBUTE PageAttribute)
BOOLEAN InitializePageTablePool(IN UINTN PoolPages)
VOID RefreshGcdMemoryAttributesFromPaging(VOID)
VOID InitializePageTableLib(VOID)
RETURN_STATUS EFIAPI AssignMemoryPageAttributes(IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL)
VOID DisableReadOnlyPageWriteProtect(VOID)
UINTN PageAttributeToMask(IN PAGE_ATTRIBUTE PageAttribute)
VOID ConvertPageEntryAttribute(IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext, IN UINT64 *PageEntry, IN UINT64 Attributes, IN PAGE_ACTION PageAction, OUT BOOLEAN *IsModified)
BOOLEAN IsReadOnlyPageWriteProtected(VOID)
VOID * GetPageTableEntry(IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext, IN PHYSICAL_ADDRESS Address, OUT PAGE_ATTRIBUTE *PageAttribute)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI AsmReadCr3(VOID)
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
UINTN EFIAPI AsmReadCr0(VOID)
UINTN EFIAPI AsmWriteCr0(UINTN Cr0)
UINTN EFIAPI AsmReadCr2(VOID)
UINTN EFIAPI AsmReadCr4(VOID)
VOID EFIAPI DumpCpuContext(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
#define RETURN_ERROR(StatusCode)
#define RETURN_UNSUPPORTED
#define RETURN_OUT_OF_RESOURCES
#define RETURN_INVALID_PARAMETER
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define CPUID_EXTENDED_CPU_SIG
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
EFI_STATUS EFIAPI MpInitLibWhoAmI(OUT UINTN *ProcessorNumber)
#define PcdGet64(TokenName)
@ EfiGcdMemoryTypeNonExistent
BOOLEAN EFIAPI InSmm(VOID)
VOID *EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
#define EFI_PAGES_TO_SIZE(Pages)
EFI_PHYSICAL_ADDRESS BaseAddress
struct CPUID_EXTENDED_CPU_SIG_EDX::@750 Bits
struct MSR_CORE_IA32_EFER_REGISTER::@793 Bits
struct MSR_IA32_EFER_REGISTER::@691 Bits