/** @file\r
IA32 CPU Exception Handler functons.\r
\r
- Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
ReservedVectors = ExceptionHandlerData->ReservedVectors;\r
//\r
- // Save Exception context in global variable\r
+ // Save Exception context in global variable in first entry of the exception handler.\r
+ // So when original exception handler returns to the new exception handler (second entry),\r
+ // the Eflags/Cs/Eip/ExceptionData can be used.\r
//\r
ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextIa32->Eflags;\r
ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextIa32->Cs;\r
Eflags.Bits.IF = 0;\r
SystemContext.SystemContextIa32->Eflags = Eflags.UintN;\r
//\r
- // Modify the EIP in stack, then old IDT handler will return to the stub code\r
+ // Modify the EIP in stack, then old IDT handler will return to HookAfterStubBegin.\r
//\r
SystemContext.SystemContextIa32->Eip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode;\r
}\r
\r
**/\r
EFI_STATUS\r
-ArchSetupExcpetionStack (\r
+ArchSetupExceptionStack (\r
IN CPU_EXCEPTION_INIT_DATA *StackSwitchData\r
)\r
{\r
//\r
TssBase = (UINTN)Tss;\r
\r
+ TssDesc->Uint64 = 0;\r
TssDesc->Bits.LimitLow = sizeof(IA32_TASK_STATE_SEGMENT) - 1;\r
TssDesc->Bits.BaseLow = (UINT16)TssBase;\r
TssDesc->Bits.BaseMid = (UINT8)(TssBase >> 16);\r
//\r
TssBase = (UINTN)Tss;\r
\r
+ TssDesc->Uint64 = 0;\r
TssDesc->Bits.LimitLow = sizeof(IA32_TASK_STATE_SEGMENT) - 1;\r
TssDesc->Bits.BaseLow = (UINT16)TssBase;\r
TssDesc->Bits.BaseMid = (UINT8)(TssBase >> 16);\r
continue;\r
}\r
\r
+ ZeroMem (Tss, sizeof (*Tss));\r
Tss->EIP = (UINT32)(TemplateMap.ExceptionStart\r
+ Vector * TemplateMap.ExceptionStubHeaderSize);\r
Tss->EFLAGS = 0x2;\r
//\r
// Dump module image base and module entry point by EIP\r
//\r
- DumpModuleImageInfo (SystemContext.SystemContextIa32->Eip);\r
+ if ((ExceptionType == EXCEPT_IA32_PAGE_FAULT) &&\r
+ ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0)) {\r
+ //\r
+ // The EIP in SystemContext could not be used\r
+ // if it is page fault with I/D set.\r
+ //\r
+ DumpModuleImageInfo ((*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp));\r
+ } else {\r
+ DumpModuleImageInfo (SystemContext.SystemContextIa32->Eip);\r
+ }\r
}\r