UefiCpuPkg CpuExceptionHandlerLib: Enhance DumpModuleImageInfo()

Enhance DumpModuleImageInfo() for page fault with I/D set.

If it is page fault with I/D set, the (E/R)IP in SystemContext
could not be used for DumpModuleImageInfo(), instead of, the next
IP of the IP triggering this page fault could be found from stack
by (E/R)SP in SystemContext.

IA32 SDM:
— I/D flag (bit 4).
This flag is 1 if the access causing the page-fault exception was
an instruction fetch. This flag describes the access causing the
page-fault exception, not the access rights specified by paging.

The idea comes from SmiPFHandler () in
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c and
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Star Zeng
2017-12-27 17:24:04 +08:00
parent 7dbc50bd24
commit bb207f6cda
3 changed files with 22 additions and 4 deletions

View File

@@ -414,5 +414,14 @@ DumpImageAndCpuContent (
//
// Dump module image base and module entry point by RIP
//
DumpModuleImageInfo (SystemContext.SystemContextX64->Rip);
if ((ExceptionType == EXCEPT_IA32_PAGE_FAULT) &&
((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0)) {
//
// The RIP in SystemContext could not be used
// if it is page fault with I/D set.
//
DumpModuleImageInfo ((*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp));
} else {
DumpModuleImageInfo (SystemContext.SystemContextX64->Rip);
}
}