26UINTN mMsrDsAreaSize = SMM_PROFILE_DTS_SIZE;
31BOOLEAN mXdSupported =
TRUE;
36BOOLEAN mXdEnabled =
FALSE;
41BOOLEAN mBtsSupported =
TRUE;
46BOOLEAN mSmmProfileEnabled =
FALSE;
51BOOLEAN mSmmProfileStart =
FALSE;
56BOOLEAN mSetupDebugTrap =
FALSE;
63UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT];
64UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT];
68UINTN mBTSRecordNumber;
76UINTN mProtectionMemRangeCount = 0;
95 { 0x00000000, 0x00000000 },
TRUE,
TRUE
118UINTN mSplitMemRangeCount = 0;
123UINT32 mSmiCommandPort;
175 for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
176 if (gSmmCpuPrivate->ProcessorInfo[Index].
ProcessorId == ApicId) {
205 for (Index = 0; Index < mBTSRecordNumber; Index++) {
206 if ((
UINTN)CurrentBTSRecord < (
UINTN)mMsrBTSRecord[CpuIndex]) {
214 if (CurrentBTSRecord->LastBranchTo == DestinationIP) {
227 return CurrentBTSRecord->LastBranchFrom;
255 if (!mSmmProfileStart &&
256 !HEAP_GUARD_NONSTOP_MODE &&
257 !NULL_DETECTION_NONSTOP_MODE)
267 for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {
268 *mLastPFEntryPointer[CpuIndex][PFEntry] = mLastPFEntryValue[CpuIndex][PFEntry];
274 mPFEntryCount[CpuIndex] = 0;
302 if ((Address >= mCpuHotPlugData.SmrrBase) && (Address < mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {
306 for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
307 if ((Address >= mSmmCpuSmramRanges[Index].CpuStart) &&
308 (Address < mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize))
338 for (Index = 0; Index < mProtectionMemRangeCount; Index++) {
339 if ((Address >= mProtectionMemRange[Index].Range.Base) && (Address < mProtectionMemRange[Index].Range.Top)) {
340 *Nx = mProtectionMemRange[Index].Nx;
341 return mProtectionMemRange[Index].Present;
362 if (mSmmProfileEnabled) {
366 for (Index = 0; Index < mSplitMemRangeCount; Index++) {
367 if ((Address >= mSplitMemRange[Index].Base) && (Address < mSplitMemRange[Index].Top)) {
372 if (Address < mCpuHotPlugData.SmrrBase) {
373 if ((mCpuHotPlugData.SmrrBase - Address) < BASE_2MB) {
376 }
else if (Address > (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) {
377 if ((Address - (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) < BASE_2MB) {
426 UINTN MemoryRegionCount;
427 UINTN NumberOfAddedDescriptors;
428 UINTN NumberOfProtectRange;
429 UINTN NumberOfSpliteRange;
435 UINT64 High4KBPageSize;
436 UINT64 Low4KBPageSize;
440 MemoryRegionCount = 0;
441 NumberOfAddedDescriptors = mSmmCpuSmramRangeCount;
442 NumberOfSpliteRange = 0;
451 ASSERT (MemoryRegion !=
NULL);
453 NumberOfAddedDescriptors += MemoryRegionCount;
455 ASSERT (NumberOfAddedDescriptors != 0);
457 TotalSize = NumberOfAddedDescriptors *
sizeof (
MEMORY_PROTECTION_RANGE) +
sizeof (mProtectionMemRangeTemplate);
459 ASSERT (mProtectionMemRange !=
NULL);
465 CopyMem (mProtectionMemRange, mProtectionMemRangeTemplate,
sizeof (mProtectionMemRangeTemplate));
472 ASSERT (mSplitMemRange !=
NULL);
478 for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
479 if ((mSmmCpuSmramRanges[Index].CpuStart >= mProtectionMemRange[0].Range.Base) &&
480 (mSmmCpuSmramRanges[Index].
CpuStart + mSmmCpuSmramRanges[Index].
PhysicalSize < mProtectionMemRange[0].Range.Top))
488 mProtectionMemRange[NumberOfProtectRange].Range.Base = mSmmCpuSmramRanges[Index].
CpuStart;
489 mProtectionMemRange[NumberOfProtectRange].Range.Top = mSmmCpuSmramRanges[Index].
CpuStart + mSmmCpuSmramRanges[Index].
PhysicalSize;
490 mProtectionMemRange[NumberOfProtectRange].Present =
TRUE;
491 mProtectionMemRange[NumberOfProtectRange].Nx =
FALSE;
492 NumberOfProtectRange++;
498 for (Index = 0; Index < MemoryRegionCount; Index++) {
499 mProtectionMemRange[NumberOfProtectRange].Range.Base = MemoryRegion[Index].
Base;
500 mProtectionMemRange[NumberOfProtectRange].Range.Top = MemoryRegion[Index].
Base + MemoryRegion[Index].
Length;
501 mProtectionMemRange[NumberOfProtectRange].Present =
TRUE;
502 mProtectionMemRange[NumberOfProtectRange].Nx =
TRUE;
503 NumberOfProtectRange++;
509 if (MemoryRegion !=
NULL) {
516 ASSERT (NumberOfProtectRange <= mProtectionMemRangeCount);
517 mProtectionMemRangeCount = NumberOfProtectRange;
522 NumberOfSpliteRange = 0;
523 NumberOfProtectRange = mProtectionMemRangeCount;
524 for (Index = 0; Index < NumberOfProtectRange; Index++) {
528 ProtectBaseAddress = mProtectionMemRange[Index].Range.Base;
529 ProtectEndAddress = mProtectionMemRange[Index].Range.Top;
530 if (((ProtectBaseAddress & (SIZE_2MB - 1)) != 0) || ((ProtectEndAddress & (SIZE_2MB - 1)) != 0)) {
535 Top2MBAlignedAddress = ProtectEndAddress & ~(SIZE_2MB - 1);
536 Base2MBAlignedAddress = (ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1);
537 if ((Top2MBAlignedAddress > Base2MBAlignedAddress) &&
538 ((Top2MBAlignedAddress - Base2MBAlignedAddress) >= SIZE_2MB))
543 High4KBPageSize = ((ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1)) - (ProtectEndAddress & ~(SIZE_2MB - 1));
544 Low4KBPageSize = ((ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1)) - (ProtectBaseAddress & ~(SIZE_2MB - 1));
545 if (High4KBPageSize != 0) {
549 mSplitMemRange[NumberOfSpliteRange].Base = ProtectEndAddress & ~(SIZE_2MB - 1);
550 mSplitMemRange[NumberOfSpliteRange].Top = (ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1);
551 NumberOfSpliteRange++;
554 if (Low4KBPageSize != 0) {
558 mSplitMemRange[NumberOfSpliteRange].Base = ProtectBaseAddress & ~(SIZE_2MB - 1);
559 mSplitMemRange[NumberOfSpliteRange].Top = (ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1);
560 NumberOfSpliteRange++;
566 mSplitMemRange[NumberOfSpliteRange].Base = ProtectBaseAddress & ~(SIZE_2MB - 1);
567 mSplitMemRange[NumberOfSpliteRange].Top = (ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1);
568 NumberOfSpliteRange++;
573 mSplitMemRangeCount = NumberOfSpliteRange;
580 DEBUG ((DEBUG_INFO,
"SMM Profile Memory Ranges:\n"));
581 for (Index = 0; Index < mProtectionMemRangeCount; Index++) {
582 DEBUG ((DEBUG_INFO,
"mProtectionMemRange[%d].Base = %lx\n", Index, mProtectionMemRange[Index].Range.Base));
583 DEBUG ((DEBUG_INFO,
"mProtectionMemRange[%d].Top = %lx\n", Index, mProtectionMemRange[Index].Range.Top));
586 for (Index = 0; Index < mSplitMemRangeCount; Index++) {
587 DEBUG ((DEBUG_INFO,
"mSplitMemRange[%d].Base = %lx\n", Index, mSplitMemRange[Index].Base));
588 DEBUG ((DEBUG_INFO,
"mSplitMemRange[%d].Top = %lx\n", Index, mSplitMemRange[Index].Top));
601 RETURN_STATUS Status;
607 UINT64 PreviousAddress;
608 UINT64 MemoryAttrMask;
609 BOOLEAN WriteProtect;
612 DEBUG ((DEBUG_INFO,
"SmmProfileUpdateMemoryAttributes Start...\n"));
617 Limit =
LShiftU64 (1, mPhysicalAddressBits);
622 PreviousAddress = ((
PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT1) != 0) ? BASE_4KB : 0;
624 for (Index = 0; Index < mProtectionMemRangeCount; Index++) {
626 if (mProtectionMemRange[Index].Nx ==
TRUE) {
627 MemoryAttrMask = EFI_MEMORY_XP;
630 if (mProtectionMemRange[Index].Present ==
FALSE) {
631 MemoryAttrMask = EFI_MEMORY_RP;
634 Base = mProtectionMemRange[Index].Range.Base;
635 Length = mProtectionMemRange[Index].Range.Top - Base;
636 if (MemoryAttrMask != 0) {
641 if (Base > PreviousAddress) {
649 PreviousAddress = Base + Length;
655 if (PreviousAddress < Limit) {
670 WRITE_PROTECT_RO_PAGES (WriteProtect, CetEnabled);
672 DEBUG ((DEBUG_INFO,
"SmmProfileUpdateMemoryAttributes Done.\n"));
689 mSmmProfileStart =
TRUE;
694 mSetupDebugTrap =
TRUE;
720 Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid,
NULL, (VOID **)&SmmProfileVariable);
726 SmmProfileVariable->SmmSetVariable (
729 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
730 sizeof (mSmmProfileBase),
749 UINTN MsrDsAreaSizePerCpu;
750 UINT64 SmmProfileSize;
753 ASSERT (mPFEntryCount !=
NULL);
755 sizeof (mLastPFEntryValue[0]) * mMaxNumberOfCpus
757 ASSERT (mLastPFEntryValue !=
NULL);
759 sizeof (mLastPFEntryPointer[0]) * mMaxNumberOfCpus
761 ASSERT (mLastPFEntryPointer !=
NULL);
767 DEBUG ((DEBUG_ERROR,
"SmmProfileBase = 0x%016x.\n", (
UINTN)mSmmProfileBase));
768 DEBUG ((DEBUG_ERROR,
"SmmProfileSize = 0x%016x.\n", (
UINTN)SmmProfileSize));
771 ASSERT (SmmProfileSize > mMsrDsAreaSize);
772 mSmmProfileSize = (
UINTN)SmmProfileSize - mMsrDsAreaSize;
774 mSmmProfileSize = (
UINTN)SmmProfileSize;
777 ASSERT ((mSmmProfileSize & 0xFFF) == 0);
785 mSmmProfileBase->CurDataEntries = 0;
786 mSmmProfileBase->CurDataSize = 0;
787 mSmmProfileBase->TsegStart = mCpuHotPlugData.SmrrBase;
788 mSmmProfileBase->TsegSize = mCpuHotPlugData.SmrrSize;
789 mSmmProfileBase->NumSmis = 0;
790 mSmmProfileBase->NumCpus = gSmmCpuPrivate->SmmCoreEntryContext.
NumberOfCpus;
794 ASSERT (mMsrDsArea !=
NULL);
796 ASSERT (mMsrBTSRecord !=
NULL);
798 ASSERT (mMsrPEBSRecord !=
NULL);
801 MsrDsAreaSizePerCpu = mMsrDsAreaSize / mMaxNumberOfCpus;
803 for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
806 mMsrPEBSRecord[Index] = (
PEBS_RECORD *)((
UINTN)mMsrDsArea[Index] + MsrDsAreaSizePerCpu -
sizeof (
PEBS_RECORD) * PEBS_RECORD_NUMBER);
808 mMsrDsArea[Index]->BTSBufferBase = (
UINTN)mMsrBTSRecord[Index];
809 mMsrDsArea[Index]->BTSIndex = mMsrDsArea[Index]->BTSBufferBase;
810 mMsrDsArea[Index]->BTSAbsoluteMaximum = mMsrDsArea[Index]->BTSBufferBase + mBTSRecordNumber *
sizeof (
BRANCH_TRACE_RECORD) + 1;
811 mMsrDsArea[Index]->BTSInterruptThreshold = mMsrDsArea[Index]->BTSAbsoluteMaximum + 1;
813 mMsrDsArea[Index]->PEBSBufferBase = (
UINTN)mMsrPEBSRecord[Index];
814 mMsrDsArea[Index]->PEBSIndex = mMsrDsArea[Index]->PEBSBufferBase;
815 mMsrDsArea[Index]->PEBSAbsoluteMaximum = mMsrDsArea[Index]->PEBSBufferBase + PEBS_RECORD_NUMBER *
sizeof (
PEBS_RECORD) + 1;
816 mMsrDsArea[Index]->PEBSInterruptThreshold = mMsrDsArea[Index]->PEBSAbsoluteMaximum + 1;
820 mProtectionMemRange = mProtectionMemRangeTemplate;
826 mProtectionMemRange[0].Range.Base = mCpuHotPlugData.SmrrBase;
827 mProtectionMemRange[0].Range.Top = mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize;
843 Status = gMmst->MmRegisterProtocolNotify (
844 &gEfiSmmReadyToLockProtocolGuid,
868 if ((
PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported) {
872 if ((RegEcx & CPUID_CET_SS) == 0) {
873 mCetSupported =
FALSE;
877 mCetSupported =
FALSE;
884 if ((RegEdx & CPUID1_EDX_BTS_AVAILABLE) != 0) {
894 if (MiscEnableMsr.
Bits.
BTS == 1) {
898 mBtsSupported =
FALSE;
903 if (mSmmCodeAccessCheckEnable) {
909 ((
AsmReadMsr64 (EFI_MSR_SMM_MCA_CAP) & SMM_CODE_ACCESS_CHK_BIT) == 0))
911 mSmmCodeAccessCheckEnable =
FALSE;
928 if ((Dr6 & DR6_SINGLE_STEP) != 0) {
932 Dr6 |= DR6_SINGLE_STEP;
995 if (mSmmProfileStart) {
996 mSmmProfileBase->NumSmis++;
1016 if (mBtsSupported) {
1043 mSmmProfileCr3 = Cr3;
1048 if (!mSmmProfileEnabled &&
1049 !HEAP_GUARD_NONSTOP_MODE &&
1050 !NULL_DETECTION_NONSTOP_MODE)
1088 BOOLEAN Enable5LevelPaging;
1091 Enable5LevelPaging = (BOOLEAN)(Cr4.Bits.LA57 == 1);
1096 if (Enable5LevelPaging) {
1098 ASSERT (PageTable[PTIndex] != 0);
1099 PageTable = (UINT64 *)(
UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK);
1105 if (
sizeof (UINT64) ==
sizeof (
UINTN)) {
1107 ASSERT (PageTable[PTIndex] != 0);
1108 PageTable = (UINT64 *)(
UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK);
1116 if ((PageTable[PTIndex] & IA32_PG_P) == 0) {
1122 ASSERT (
sizeof (UINT64) ==
sizeof (
UINTN));
1127 PageTable[PTIndex] =
AllocPage () | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
1130 ASSERT (PageTable[PTIndex] != 0);
1131 PageTable = (UINT64 *)(
UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK);
1137 if ((PageTable[PTIndex] & IA32_PG_P) == 0) {
1147 ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT);
1148 if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) {
1149 PFIndex = mPFEntryCount[CpuIndex];
1150 mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex];
1151 mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex];
1152 mPFEntryCount[CpuIndex]++;
1158 PageTable[PTIndex] = (PFAddress & ~((1ull << 21) - 1));
1159 PageTable[PTIndex] |= (UINT64)IA32_PG_PS;
1160 PageTable[PTIndex] |= (UINT64)PAGE_ATTRIBUTE_BITS;
1161 if ((ErrorCode & IA32_PF_EC_ID) != 0) {
1162 PageTable[PTIndex] &= ~IA32_PG_NX;
1169 ASSERT (PageTable[PTIndex] != 0);
1170 PageTable = (UINT64 *)(
UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK);
1182 ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT);
1183 if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) {
1184 PFIndex = mPFEntryCount[CpuIndex];
1185 mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex];
1186 mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex];
1187 mPFEntryCount[CpuIndex]++;
1193 PageTable[PTIndex] = (PFAddress & ~((1ull << 12) - 1));
1194 PageTable[PTIndex] |= (UINT64)PAGE_ATTRIBUTE_BITS;
1195 if ((ErrorCode & IA32_PF_EC_ID) != 0) {
1196 PageTable[PTIndex] &= ~IA32_PG_NX;
1214 UINT64 RestoreAddress;
1215 UINTN RestorePageNumber;
1227 RestorePageNumber = 2;
1228 RestoreAddress = PFAddress;
1229 while (RestorePageNumber > 0) {
1231 RestoreAddress += EFI_PAGE_SIZE;
1232 RestorePageNumber--;
1256 UINT64 RestoreAddress;
1257 UINTN RestorePageNumber;
1260 UINT64 InstructionAddress;
1261 UINTN MaxEntryNumber;
1262 UINTN CurrentEntryNumber;
1263 BOOLEAN IsValidPFAddress;
1270 if (mBtsSupported) {
1274 IsValidPFAddress =
FALSE;
1284 RestorePageNumber = 2;
1285 RestoreAddress = PFAddress;
1286 while (RestorePageNumber > 0) {
1287 if (RestoreAddress <= 0xFFFFFFFF) {
1293 RestoreAddress += EFI_PAGE_SIZE;
1294 RestorePageNumber--;
1297 if (!IsValidPFAddress) {
1298 InstructionAddress = Rip;
1299 if (((ErrorCode & IA32_PF_EC_ID) != 0) && (mBtsSupported)) {
1304 if (InstructionAddress == 0) {
1309 InstructionAddress = PFAddress;
1316 SmiCommand = 0xFFFFFFFFFFFFFFFFULL;
1317 for (Index = 0; Index < gMmst->
NumberOfCpus; Index++) {
1319 if (EFI_ERROR (Status)) {
1323 if (IoInfo.
IoPort == mSmiCommandPort) {
1327 SoftSmiValue =
IoRead8 (mSmiCommandPort);
1328 SmiCommand = (UINT64)SoftSmiValue;
1337 for (Index = 0; Index < (
UINTN)mSmmProfileBase->CurDataEntries; Index++) {
1338 if ((SmmProfileEntry[Index].ErrorCode == (UINT64)ErrorCode) &&
1339 (SmmProfileEntry[Index].Address == PFAddress) &&
1340 (SmmProfileEntry[Index].CpuNum == (UINT64)CpuIndex) &&
1341 (SmmProfileEntry[Index].Instruction == InstructionAddress) &&
1342 (SmmProfileEntry[Index].SmiCmd == SmiCommand))
1351 if (Index == mSmmProfileBase->CurDataEntries) {
1352 CurrentEntryNumber = (
UINTN)mSmmProfileBase->CurDataEntries;
1353 MaxEntryNumber = (
UINTN)mSmmProfileBase->MaxDataEntries;
1355 CurrentEntryNumber = CurrentEntryNumber % MaxEntryNumber;
1358 if (CurrentEntryNumber < MaxEntryNumber) {
1362 SmmProfileEntry[CurrentEntryNumber].SmiNum = mSmmProfileBase->NumSmis;
1363 SmmProfileEntry[CurrentEntryNumber].ErrorCode = (UINT64)ErrorCode;
1364 SmmProfileEntry[CurrentEntryNumber].ApicId = (UINT64)
GetApicId ();
1365 SmmProfileEntry[CurrentEntryNumber].CpuNum = (UINT64)CpuIndex;
1366 SmmProfileEntry[CurrentEntryNumber].Address = PFAddress;
1367 SmmProfileEntry[CurrentEntryNumber].Instruction = InstructionAddress;
1368 SmmProfileEntry[CurrentEntryNumber].SmiCmd = SmiCommand;
1372 mSmmProfileBase->CurDataEntries++;
1383 if (mBtsSupported) {
UINT64 EFIAPI MultU64x64(IN UINT64 Multiplicand, IN UINT64 Multiplier)
INTN(EFIAPI * BASE_SORT_COMPARE)(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
VOID EFIAPI QuickSort(IN OUT VOID *BufferToSort, IN CONST UINTN Count, IN CONST UINTN ElementSize, IN BASE_SORT_COMPARE CompareFunction, OUT VOID *BufferOneElement)
UINT64 EFIAPI BitFieldRead64(IN UINT64 Operand, IN UINTN StartBit, IN UINTN EndBit)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINT32 EFIAPI AsmCpuidEx(IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
VOID EFIAPI CpuFlushTlb(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)
EFI_STATUS EFIAPI SmmRegisterExceptionHandler(IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI AsmReadCr3(VOID)
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
UINTN EFIAPI AsmReadCr2(VOID)
UINT64 EFIAPI AsmWriteMsr64(IN UINT32 Index, IN UINT64 Value)
UINTN EFIAPI AsmReadCr4(VOID)
UINTN EFIAPI AsmReadDr6(VOID)
UINTN EFIAPI AsmWriteDr6(UINTN Dr6)
VOID ClearTrapFlag(IN OUT EFI_SYSTEM_CONTEXT SystemContext)
VOID InitPagesForPFHandler(VOID)
VOID RestorePageTableAbove4G(UINT64 *PageTable, UINT64 PFAddress, UINTN CpuIndex, UINTN ErrorCode, BOOLEAN *IsValidPFAddress)
UINT8 EFIAPI IoRead8(IN UINTN Port)
UINT32 EFIAPI GetApicId(VOID)
#define ASSERT_EFI_ERROR(StatusParameter)
#define ASSERT_RETURN_ERROR(StatusParameter)
#define DEBUG(Expression)
#define MSR_IA32_DEBUGCTL
#define MSR_IA32_MISC_ENABLE
#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS
#define CPUID_VERSION_INFO
#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
VOID CreateExtendedProtectionRange(OUT MM_CPU_MEMORY_REGION **MemoryRegion, OUT UINTN *MemoryRegionCount)
EFI_PHYSICAL_ADDRESS GetSmmProfileData(IN OUT UINT64 *Size)
BOOLEAN EFIAPI SmmCpuFeaturesIsSmmRegisterSupported(IN UINTN CpuIndex, IN SMM_REG_NAME RegName)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
#define FeaturePcdGet(TokenName)
EFI_SMM_CPU_PROTOCOL mSmmCpu
EFI_STATUS EFIAPI SmmReadSaveState(IN CONST EFI_SMM_CPU_PROTOCOL *This, IN UINTN Width, IN EFI_SMM_SAVE_STATE_REGISTER Register, IN UINTN CpuIndex, OUT VOID *Buffer)
#define WRITE_UNPROTECT_RO_PAGES(Wp, Cet)
EFI_STATUS EFIAPI InitSmmProfileCallBack(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
INTN EFIAPI ProtectionRangeCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
VOID SmmProfilePFHandler(UINTN Rip, UINTN ErrorCode)
UINT64 GetSourceFromDestinationOnBts(UINTN CpuIndex, UINT64 DestinationIP)
VOID GuardPagePFHandler(UINTN ErrorCode)
VOID SmmProfileStart(VOID)
VOID InitSmmProfileInternal(VOID)
BOOLEAN IsSmmProfilePFAddressAbove4GValid(IN EFI_PHYSICAL_ADDRESS Address, OUT BOOLEAN *Nx)
VOID InitProtectedMemRange(VOID)
VOID SmmProfileRecordSmiNum(VOID)
VOID ActivateSmmProfile(IN UINTN CpuIndex)
BOOLEAN IsInSmmRanges(IN EFI_PHYSICAL_ADDRESS Address)
VOID SmmProfileUpdateMemoryAttributes(VOID)
VOID CheckFeatureSupported(IN UINTN CpuIndex)
VOID ActivateBTS(IN UINTN CpuIndex)
VOID RestorePageTableBelow4G(UINT64 *PageTable, UINT64 PFAddress, UINTN CpuIndex, UINTN ErrorCode)
VOID EFIAPI DebugExceptionHandler(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext)
BOOLEAN IsAddressSplit(IN EFI_PHYSICAL_ADDRESS Address)
VOID InitSmmProfile(UINT32 Cr3)
VOID ActivateSingleStepDB(VOID)
UINT64 EFI_PHYSICAL_ADDRESS
VOID EFIAPI PatchInstructionX86(OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd, IN UINT64 PatchValue, IN UINTN ValueSize)
EFI_PHYSICAL_ADDRESS CpuStart
EFI_PHYSICAL_ADDRESS Base
struct MSR_IA32_DEBUGCTL_REGISTER::@645 Bits
struct MSR_IA32_MISC_ENABLE_REGISTER::@641 Bits