24 UINTN PageFaultHandlerHookAddress;
25 IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
33 mPhysicalAddressBits = 32;
34 mPagingMode = PagingPae;
36 if (mSmmProfileEnabled ||
37 HEAP_GUARD_NONSTOP_MODE ||
38 NULL_DETECTION_NONSTOP_MODE)
45 IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base;
46 IdtEntry += EXCEPT_IA32_PAGE_FAULT;
47 IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress;
48 IdtEntry->Bits.Reserved_0 = 0;
49 IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
50 IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16);
101 UINTN GuardPageAddress;
104 ASSERT (InterruptType == EXCEPT_IA32_PAGE_FAULT);
114 if ((PFAddress >= mCpuHotPlugData.SmrrBase) &&
115 (PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)))
119 GuardPageAddress = (mSmmStackArrayBase + EFI_PAGE_SIZE + CpuIndex * mSmmStackSize);
121 (PFAddress >= GuardPageAddress) &&
122 (PFAddress < (GuardPageAddress + EFI_PAGE_SIZE)))
124 DEBUG ((DEBUG_ERROR,
"SMM stack overflow!\n"));
126 if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) {
127 DEBUG ((DEBUG_ERROR,
"SMM exception at execution (0x%x)\n", PFAddress));
132 DEBUG ((DEBUG_ERROR,
"SMM exception at access (0x%x)\n", PFAddress));
138 if (HEAP_GUARD_NONSTOP_MODE) {
151 if ((PFAddress < mCpuHotPlugData.SmrrBase) ||
152 (PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))
154 if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) {
156 DEBUG ((DEBUG_ERROR,
"Code executed on IP(0x%x) out of SMM range after SMM is locked!\n", PFAddress));
167 if (((
PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT1) != 0) &&
168 (PFAddress < EFI_PAGE_SIZE))
171 DEBUG ((DEBUG_ERROR,
"!!! NULL pointer access !!!\n"));
176 if (NULL_DETECTION_NONSTOP_MODE) {
186 DEBUG ((DEBUG_ERROR,
"Access SMM communication forbidden address (0x%x)!\n", PFAddress));
190 if (mSmmProfileEnabled) {
192 SystemContext.SystemContextIa32->Eip,
193 SystemContext.SystemContextIa32->ExceptionData
VOID EFIAPI CpuDeadLoop(VOID)
EFI_STATUS EFIAPI SmmRegisterExceptionHandler(IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler)
UINTN EFIAPI AsmReadCr2(VOID)
UINT32 SmmInitPageTable(VOID)
VOID RestoreCr2(IN UINTN Cr2)
VOID EFIAPI SmiPFHandler(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext)
VOID SaveCr2(OUT UINTN *Cr2)
VOID EFIAPI InitializeIDTSmmStackGuard(VOID)
VOID EFIAPI DumpCpuContext(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
BOOLEAN IsSmmCommBufferForbiddenAddress(IN UINT64 Address)
#define PcdGet8(TokenName)
#define FeaturePcdGet(TokenName)
VOID DumpModuleInfoByIp(IN UINTN CallerIpAddress)
UINTN GenSmmPageTable(IN PAGING_MODE PagingMode, IN UINT8 PhysicalAddressBits)
VOID SmmProfilePFHandler(UINTN Rip, UINTN ErrorCode)
VOID GuardPagePFHandler(UINTN ErrorCode)
VOID EFIAPI PageFaultIdtHandlerSmmProfile(VOID)
SPIN_LOCK *EFIAPI AcquireSpinLock(IN OUT SPIN_LOCK *SpinLock)
SPIN_LOCK *EFIAPI InitializeSpinLock(OUT SPIN_LOCK *SpinLock)
SPIN_LOCK *EFIAPI ReleaseSpinLock(IN OUT SPIN_LOCK *SpinLock)
VOID EFIAPI Exit(IN EFI_STATUS Status)