10BOOLEAN mIsShadowStack =
FALSE;
11BOOLEAN m5LevelPagingNeeded =
FALSE;
12PAGING_MODE mPagingMode = PagingModeMax;
22BOOLEAN mIsReadOnlyPageTable =
FALSE;
32 OUT BOOLEAN *WriteProtect
38 *WriteProtect = (Cr0.Bits.WP != 0);
53 IN BOOLEAN WriteProtect
96 PoolPages = ((PoolPages - 1) / PAGE_TABLE_POOL_UNIT_PAGES + 1) *
97 PAGE_TABLE_POOL_UNIT_PAGES;
100 DEBUG ((DEBUG_ERROR,
"ERROR: Out of aligned pages\r\n"));
107 if (mPageTablePool ==
NULL) {
108 mPageTablePool = Buffer;
109 mPageTablePool->NextPool = mPageTablePool;
112 mPageTablePool->NextPool = Buffer;
113 mPageTablePool = Buffer;
119 mPageTablePool->FreePages = PoolPages - 1;
125 if (mIsReadOnlyPageTable) {
130 WRITE_PROTECT_RO_PAGES (WriteProtect, CetEnabled);
165 if ((mPageTablePool ==
NULL) ||
166 (Pages > mPageTablePool->FreePages))
173 Buffer = (UINT8 *)mPageTablePool + mPageTablePool->Offset;
176 mPageTablePool->FreePages -= Pages;
194 IN BOOLEAN Enable5LevelPaging,
195 IN PHYSICAL_ADDRESS Address,
196 OUT PAGE_ATTRIBUTE *PageAttribute
210 Index5 = ((
UINTN)
RShiftU64 (Address, 48)) & PAGING_PAE_INDEX_MASK;
211 Index4 = ((
UINTN)
RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK;
212 Index3 = ((
UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK;
213 Index2 = ((
UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK;
214 Index1 = ((
UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK;
216 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
217 if (Enable5LevelPaging) {
218 L5PageTable = (UINT64 *)PageTableBase;
219 if (L5PageTable[Index5] == 0) {
220 *PageAttribute = PageNone;
224 L4PageTable = (UINT64 *)(
UINTN)(L5PageTable[Index5] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64);
226 L4PageTable = (UINT64 *)PageTableBase;
229 if (L4PageTable[Index4] == 0) {
230 *PageAttribute = PageNone;
234 L3PageTable = (UINT64 *)(
UINTN)(L4PageTable[Index4] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64);
236 L3PageTable = (UINT64 *)PageTableBase;
239 if (L3PageTable[Index3] == 0) {
240 *PageAttribute = PageNone;
244 if ((L3PageTable[Index3] & IA32_PG_PS) != 0) {
246 *PageAttribute = Page1G;
247 return &L3PageTable[Index3];
250 L2PageTable = (UINT64 *)(
UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64);
251 if (L2PageTable[Index2] == 0) {
252 *PageAttribute = PageNone;
256 if ((L2PageTable[Index2] & IA32_PG_PS) != 0) {
258 *PageAttribute = Page2M;
259 return &L2PageTable[Index2];
263 L1PageTable = (UINT64 *)(
UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64);
264 if ((L1PageTable[Index1] == 0) && (Address != 0)) {
265 *PageAttribute = PageNone;
269 *PageAttribute = Page4K;
270 return &L1PageTable[Index1];
288 if ((*PageEntry & IA32_PG_P) == 0) {
289 Attributes |= EFI_MEMORY_RP;
292 if ((*PageEntry & IA32_PG_RW) == 0) {
293 Attributes |= EFI_MEMORY_RO;
296 if ((*PageEntry & IA32_PG_NX) != 0) {
297 Attributes |= EFI_MEMORY_XP;
333 IN PAGING_MODE PagingMode,
334 IN PHYSICAL_ADDRESS BaseAddress,
336 IN UINT64 Attributes,
338 OUT BOOLEAN *IsModified OPTIONAL
341 RETURN_STATUS Status;
344 UINTN PageTableBufferSize;
345 VOID *PageTableBuffer;
350 UINT64 OverlappedRangeBase;
351 UINT64 OverlappedRangeLimit;
353 ASSERT (Attributes != 0);
354 ASSERT ((Attributes & ~EFI_MEMORY_ATTRIBUTE_MASK) == 0);
356 ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0);
357 ASSERT ((Length & (SIZE_4KB - 1)) == 0);
358 ASSERT (PageTableBase != 0);
365 if (BaseAddress > MaximumSupportMemAddress) {
369 if (Length > MaximumSupportMemAddress) {
373 if ((Length != 0) && (BaseAddress > MaximumSupportMemAddress - (Length - 1))) {
377 if (IsModified !=
NULL) {
381 PagingAttribute.Uint64 = 0;
382 PagingAttribute.Uint64 = mAddressEncMask | BaseAddress;
383 PagingAttrMask.Uint64 = 0;
385 if ((Attributes & EFI_MEMORY_RO) != 0) {
386 PagingAttrMask.Bits.ReadWrite = 1;
388 PagingAttribute.Bits.ReadWrite = 0;
389 PagingAttrMask.Bits.Dirty = 1;
390 if (mIsShadowStack) {
393 PagingAttribute.Bits.Dirty = 1;
395 PagingAttribute.Bits.UserSupervisor = 0;
396 PagingAttrMask.Bits.UserSupervisor = 1;
400 PagingAttribute.Bits.Dirty = 0;
403 PagingAttribute.Bits.ReadWrite = 1;
407 if ((Attributes & EFI_MEMORY_XP) != 0) {
409 PagingAttribute.Bits.Nx = IsSet ? 1 : 0;
410 PagingAttrMask.Bits.Nx = 1;
414 if ((Attributes & EFI_MEMORY_RP) != 0) {
416 PagingAttribute.Bits.Present = 0;
420 PagingAttrMask.Uint64 = 0;
421 PagingAttrMask.Bits.Present = 1;
426 PagingAttribute.Bits.Present = 1;
427 PagingAttrMask.Uint64 = MAX_UINT64;
432 PagingAttribute.Bits.UserSupervisor = 1;
435 if (((Attributes & EFI_MEMORY_RO) == 0) || (((Attributes & EFI_MEMORY_XP) == 0) && (mXdSupported))) {
451 ASSERT (Map !=
NULL);
452 Status =
PageTableParse (PageTableBase, mPagingMode, Map, &Count);
456 for (Index = 0; Index < Count; Index++) {
457 if (Map[Index].LinearAddress >= BaseAddress + Length) {
461 if ((BaseAddress < Map[Index].LinearAddress + Map[Index].Length) && (BaseAddress + Length > Map[Index].LinearAddress)) {
462 OverlappedRangeBase =
MAX (BaseAddress, Map[Index].LinearAddress);
463 OverlappedRangeLimit =
MIN (BaseAddress + Length, Map[Index].LinearAddress + Map[Index].Length);
465 if (((Attributes & EFI_MEMORY_RO) == 0) && (Map[Index].Attribute.Bits.ReadWrite == 1)) {
466 DEBUG ((DEBUG_ERROR,
"SMM ConvertMemoryPageAttributes: [0x%lx, 0x%lx] is set from ReadWrite to ReadOnly\n", OverlappedRangeBase, OverlappedRangeLimit));
469 if (((Attributes & EFI_MEMORY_XP) == 0) && (mXdSupported) && (Map[Index].Attribute.Bits.Nx == 1)) {
470 DEBUG ((DEBUG_ERROR,
"SMM ConvertMemoryPageAttributes: [0x%lx, 0x%lx] is set from NX enabled to NX disabled\n", OverlappedRangeBase, OverlappedRangeLimit));
482 if (PagingAttrMask.Uint64 == 0) {
486 PageTableBufferSize = 0;
487 Status =
PageTableMap (&PageTableBase, PagingMode,
NULL, &PageTableBufferSize, BaseAddress, Length, &PagingAttribute, &PagingAttrMask, IsModified);
491 ASSERT (PageTableBuffer !=
NULL);
492 Status =
PageTableMap (&PageTableBase, PagingMode, PageTableBuffer, &PageTableBufferSize, BaseAddress, Length, &PagingAttribute, &PagingAttrMask, IsModified);
500 DEBUG ((DEBUG_ERROR,
"SMM ConvertMemoryPageAttributes: Only change EFI_MEMORY_XP/EFI_MEMORY_RO for non-present range in [0x%lx, 0x%lx] is not permitted\n", BaseAddress, BaseAddress + Length));
504 ASSERT (PageTableBufferSize == 0);
568 IN PAGING_MODE PagingMode,
578 if (!EFI_ERROR (Status)) {
617 IN PAGING_MODE PagingMode,
627 if (!EFI_ERROR (Status)) {
670 PageTableBase =
AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64;
705 PageTableBase =
AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64;
727 mIsShadowStack =
TRUE;
729 mIsShadowStack =
FALSE;
754 ASSERT (TableGuid !=
NULL);
755 ASSERT (Table !=
NULL);
765 return EFI_NOT_FOUND;
783 TileCodeSize =
ALIGN_VALUE (TileCodeSize, SIZE_4KB);
785 TileDataSize =
ALIGN_VALUE (TileDataSize, SIZE_4KB);
786 TileSize = TileDataSize + TileCodeSize - 1;
788 PageTableBase =
AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64;
790 DEBUG ((DEBUG_INFO,
"PatchSmmSaveStateMap:\n"));
791 for (Index = 0; Index < mMaxNumberOfCpus - 1; Index++) {
821 TileSize - TileCodeSize,
830 TileSize - TileCodeSize,
866 SIZE_32KB - TileCodeSize,
875 SIZE_32KB - TileCodeSize,
898 DEBUG ((DEBUG_INFO,
"PatchGdtIdtMap - GDT:\n"));
900 BaseAddress = mGdtBuffer;
915 DEBUG ((DEBUG_INFO,
"PatchGdtIdtMap - IDT:\n"));
917 BaseAddress = gcSmiIdtr.Base;
918 Size =
ALIGN_VALUE (gcSmiIdtr.Limit + 1, SIZE_4KB);
949 UINT64 NonPresentRangeStart;
951 NonPresentRangeStart = 0;
952 for (Index = 0; Index < Count; Index++) {
953 if ((Map[Index].LinearAddress > NonPresentRangeStart) &&
954 (Base < Map[Index].LinearAddress) && (Limit > NonPresentRangeStart))
963 if (Base < NonPresentRangeStart) {
966 NonPresentRangeStart - Base,
971 Base = Map[Index].LinearAddress;
974 NonPresentRangeStart = Map[Index].LinearAddress + Map[Index].Length;
975 if (NonPresentRangeStart >= Limit) {
980 Limit =
MIN (NonPresentRangeStart, Limit);
1007 UINTN MemoryMapEntryCount;
1008 UINTN DescriptorSize;
1014 UINT64 MemoryAttribute;
1015 BOOLEAN WriteProtect;
1018 ASSERT (MemoryAttributesTable !=
NULL);
1022 DEBUG ((DEBUG_INFO,
"MemoryAttributesTable:\n"));
1023 DEBUG ((DEBUG_INFO,
" Version - 0x%08x\n", MemoryAttributesTable->Version));
1024 DEBUG ((DEBUG_INFO,
" NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries));
1025 DEBUG ((DEBUG_INFO,
" DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize));
1027 MemoryMapEntryCount = MemoryAttributesTable->NumberOfEntries;
1028 DescriptorSize = MemoryAttributesTable->DescriptorSize;
1030 MemoryMap = MemoryMapStart;
1031 for (Index = 0; Index < MemoryMapEntryCount; Index++) {
1032 DEBUG ((DEBUG_INFO,
"Entry (0x%x)\n", MemoryMap));
1033 DEBUG ((DEBUG_INFO,
" Type - 0x%x\n", MemoryMap->
Type));
1037 DEBUG ((DEBUG_INFO,
" Attribute - 0x%016lx\n", MemoryMap->
Attribute));
1038 MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, DescriptorSize);
1051 ASSERT (Map !=
NULL);
1059 MemoryMap = MemoryMapStart;
1060 for (Index = 0; Index < MemoryMapEntryCount; Index++) {
1062 MemoryAttribute = MemoryMap->
Attribute & EFI_MEMORY_ACCESS_MASK;
1063 if (MemoryAttribute == 0) {
1065 MemoryAttribute = EFI_MEMORY_RO;
1071 MemoryAttribute = EFI_MEMORY_XP;
1087 MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, DescriptorSize);
1090 WRITE_PROTECT_RO_PAGES (WriteProtect, CetEnabled);
1129 IN UINT64 Attributes
1164 IN UINT64 Attributes
1184 IN PAGING_MODE PagingMode,
1185 IN UINT64 LinearAddress,
1191 RETURN_STATUS Status;
1192 UINTN PageTableBufferSize;
1193 VOID *PageTableBuffer;
1195 PageTableBufferSize = 0;
1201 &PageTableBufferSize,
1210 ASSERT (PageTableBuffer !=
NULL);
1215 &PageTableBufferSize,
1225 ASSERT (PageTableBufferSize == 0);
1239 IN PAGING_MODE PagingMode,
1240 IN UINT8 PhysicalAddressBits
1246 UINTN MemoryRegionCount;
1249 RETURN_STATUS Status;
1253 MemoryRegion =
NULL;
1254 MemoryRegionCount = 0;
1255 MapMask.Uint64 = MAX_UINT64;
1261 ASSERT (MemoryRegion !=
NULL && MemoryRegionCount != 0);
1266 for (Index = 0; Index < MemoryRegionCount; Index++) {
1267 ASSERT (MemoryRegion[Index].Base % SIZE_4KB == 0);
1268 ASSERT (MemoryRegion[Index].Length % EFI_PAGE_SIZE == 0);
1273 MapAttribute.Uint64 = mAddressEncMask|MemoryRegion[Index].
Base;
1274 MapAttribute.Bits.Present = 1;
1275 MapAttribute.Bits.ReadWrite = 1;
1276 MapAttribute.Bits.UserSupervisor = 1;
1277 MapAttribute.Bits.Accessed = 1;
1278 MapAttribute.Bits.Dirty = 1;
1283 if ((MemoryRegion[Index].Attribute & EFI_MEMORY_RO) != 0) {
1284 MapAttribute.Bits.ReadWrite = 0;
1287 if ((MemoryRegion[Index].Attribute & EFI_MEMORY_XP) != 0) {
1289 MapAttribute.Bits.Nx = 1;
1293 GenPageTable (&PageTable, PagingMode, MemoryRegion[Index].Base, (
UINTN)MemoryRegion[Index].Length, MapAttribute, MapMask);
1299 if (MemoryRegion !=
NULL) {
1306 for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
1307 ASSERT (mSmmCpuSmramRanges[Index].CpuStart % SIZE_4KB == 0);
1308 ASSERT (mSmmCpuSmramRanges[Index].PhysicalSize % EFI_PAGE_SIZE == 0);
1313 MapAttribute.Uint64 = mAddressEncMask|mSmmCpuSmramRanges[Index].
CpuStart;
1314 MapAttribute.Bits.Present = 1;
1315 MapAttribute.Bits.ReadWrite = 1;
1316 MapAttribute.Bits.UserSupervisor = 1;
1317 MapAttribute.Bits.Accessed = 1;
1318 MapAttribute.Bits.Dirty = 1;
1320 GenPageTable (&PageTable, PagingMode, mSmmCpuSmramRanges[Index].CpuStart, mSmmCpuSmramRanges[Index].PhysicalSize, MapAttribute, MapMask);
1327 for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.
NumberOfCpus; Index++) {
1328 GuardPage = mSmmStackArrayBase + EFI_PAGE_SIZE + Index * (mSmmStackSize + mSmmShadowStackSize);
1334 if ((
PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT1) != 0) {
1342 return (
UINTN)PageTable;
1372 OUT UINT64 *Attributes
1378 PAGE_ATTRIBUTE PageAttr;
1380 UINTN PageTableBase;
1381 BOOLEAN EnablePML5Paging;
1384 if ((Length < SIZE_4KB) || (Attributes ==
NULL)) {
1385 return EFI_INVALID_PARAMETER;
1388 Size = (INT64)Length;
1389 MemAttr = (UINT64)-1;
1391 PageTableBase =
AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64;
1393 EnablePML5Paging = (BOOLEAN)(Cr4.Bits.LA57 == 1);
1396 PageEntry =
GetPageTableEntry (PageTableBase, EnablePML5Paging, BaseAddress, &PageAttr);
1397 if ((PageEntry ==
NULL) || (PageAttr == PageNone)) {
1398 return EFI_UNSUPPORTED;
1406 if ((MemAttr != (UINT64)-1) && (*Attributes != MemAttr)) {
1407 return EFI_NO_MAPPING;
1412 Address = *PageEntry & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64;
1413 Size -= (SIZE_4KB - (BaseAddress - Address));
1414 BaseAddress += (SIZE_4KB - (BaseAddress - Address));
1418 Address = *PageEntry & ~mAddressEncMask & PAGING_2M_ADDRESS_MASK_64;
1419 Size -= SIZE_2MB - (BaseAddress - Address);
1420 BaseAddress += SIZE_2MB - (BaseAddress - Address);
1424 Address = *PageEntry & ~mAddressEncMask & PAGING_1G_ADDRESS_MASK_64;
1425 Size -= SIZE_1GB - (BaseAddress - Address);
1426 BaseAddress += SIZE_1GB - (BaseAddress - Address);
1430 return EFI_UNSUPPORTED;
1433 MemAttr = *Attributes;
1451 UINTN PageTableBase;
1453 if (mPageTablePool ==
NULL) {
1457 PageTableBase =
AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64;
1463 HeadPool = mPageTablePool;
1472 Pool = Pool->NextPool;
1473 }
while (Pool != HeadPool);
1494 if (((
PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) ||
1511 BOOLEAN WriteProtect;
1519 DEBUG ((DEBUG_INFO,
"SetPageTableAttributes\n"));
1528 DEBUG ((DEBUG_INFO,
"Start...\n"));
1534 WRITE_PROTECT_RO_PAGES (
TRUE, CetEnabled);
1536 mIsReadOnlyPageTable =
TRUE;
UINT32 EFIAPI GetPowerOfTwo32(IN UINT32 Operand)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID EFIAPI CpuFlushTlb(VOID)
RETURN_STATUS EFIAPI PageTableMap(IN OUT UINTN *PageTable OPTIONAL, IN PAGING_MODE PagingMode, IN VOID *Buffer, IN OUT UINTN *BufferSize, IN UINT64 LinearAddress, IN UINT64 Length, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask, OUT BOOLEAN *IsModified OPTIONAL)
RETURN_STATUS EFIAPI PageTableParse(IN UINTN PageTable, IN PAGING_MODE PagingMode, IN IA32_MAP_ENTRY *Map, IN OUT UINTN *MapCount)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI AsmReadCr3(VOID)
UINTN EFIAPI AsmReadCr0(VOID)
UINTN EFIAPI AsmWriteCr0(UINTN Cr0)
UINTN EFIAPI AsmReadCr4(VOID)
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_UNSUPPORTED
#define ALIGN_VALUE(Value, Alignment)
#define RETURN_INVALID_PARAMETER
#define ASSERT_RETURN_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define SMM_HANDLER_OFFSET
#define SMRAM_SAVE_STATE_MAP_OFFSET
VOID CreateNonMmramMemMap(IN UINT8 PhysicalAddressBits, OUT MM_CPU_MEMORY_REGION **MemoryRegion, OUT UINTN *MemoryRegionCount)
#define PcdGet8(TokenName)
#define FeaturePcdGet(TokenName)
EFI_STATUS(EFIAPI * EFI_AP_PROCEDURE2)(IN VOID *ProcedureArgument)
UINTN EFIAPI GetSmiHandlerSize(VOID)
#define WRITE_UNPROTECT_RO_PAGES(Wp, Cet)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID *EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
UINTN GenSmmPageTable(IN PAGING_MODE PagingMode, IN UINT8 PhysicalAddressBits)
EFI_STATUS SmmSetMemoryAttributes(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
EFI_STATUS SmmClearMemoryAttributesEx(IN UINTN PageTableBase, IN PAGING_MODE PagingMode, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
VOID * GetPageTableEntry(IN UINTN PageTableBase, IN BOOLEAN Enable5LevelPaging, IN PHYSICAL_ADDRESS Address, OUT PAGE_ATTRIBUTE *PageAttribute)
EFI_STATUS EFIAPI SmmGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
RETURN_STATUS ConvertMemoryPageAttributes(IN UINTN PageTableBase, IN PAGING_MODE PagingMode, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN BOOLEAN IsSet, OUT BOOLEAN *IsModified OPTIONAL)
BOOLEAN IfReadOnlyPageTableNeeded(VOID)
VOID EFIAPI FlushTlbOnCurrentProcessor(IN OUT VOID *Buffer)
UINT64 GetAttributesFromPageEntry(IN UINT64 *PageEntry)
EFI_STATUS SmmSetMemoryAttributesEx(IN UINTN PageTableBase, IN PAGING_MODE PagingMode, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
EFI_STATUS SetShadowStack(IN UINTN Cr3, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
VOID SmmWriteUnprotectReadOnlyPage(OUT BOOLEAN *WriteProtect)
VOID * AllocatePageTableMemory(IN UINTN Pages)
EFI_STATUS EFIAPI EdkiiSmmSetMemoryAttributes(IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
VOID GenPageTable(IN OUT UINTN *PageTable, IN PAGING_MODE PagingMode, IN UINT64 LinearAddress, IN UINT64 Length, IN IA32_MAP_ATTRIBUTE MapAttribute, IN IA32_MAP_ATTRIBUTE MapMask)
VOID FlushTlbForAll(VOID)
EFI_STATUS EFIAPI EdkiiSmmGetMemoryAttributes(IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, OUT UINT64 *Attributes)
VOID SetMemMapAttributes(EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable)
VOID SmmWriteProtectReadOnlyPage(IN BOOLEAN WriteProtect)
BOOLEAN InitializePageTablePool(IN UINTN PoolPages)
VOID PatchGdtIdtMap(VOID)
VOID PatchSmmSaveStateMap(VOID)
VOID SetPageTableAttributes(VOID)
VOID SetMemMapWithNonPresentRange(UINT64 Base, UINT64 Limit, UINT64 Attribute, IA32_MAP_ENTRY *Map, UINTN Count)
EFI_STATUS EFIAPI EdkiiSmmClearMemoryAttributes(IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
VOID EnablePageTableProtection(VOID)
EFI_STATUS SmmClearMemoryAttributes(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
EFI_STATUS InternalSmmStartupAllAPs(IN EFI_AP_PROCEDURE2 Procedure, IN UINTN TimeoutInMicroseconds, IN OUT VOID *ProcedureArguments OPTIONAL, IN OUT MM_COMPLETION *Token, IN OUT EFI_STATUS *CPUStatus)
EFI_CONFIGURATION_TABLE * MmConfigurationTable
UINTN NumberOfTableEntries
EFI_VIRTUAL_ADDRESS VirtualStart
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_PHYSICAL_ADDRESS CpuStart
EFI_PHYSICAL_ADDRESS Base