]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg CpuExceptionHandlerLib: Enhance DumpModuleImageInfo()
authorStar Zeng <star.zeng@intel.com>
Wed, 27 Dec 2017 09:24:04 +0000 (17:24 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 2 Jan 2018 01:35:48 +0000 (09:35 +0800)
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>
UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c
UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c

index dbfaae1d303806984de3d80189f31e38defafc1a..01b06103647b61d0c7313eaf014ae19254859649 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Exception Handler Library common functions.\r
 \r
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2017, 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
@@ -131,7 +131,7 @@ DumpModuleImageInfo (
     if (EFI_ERROR (Status)) {\r
       EntryPoint = NULL;\r
     }\r
-    InternalPrintMessage ("!!!! Find image ");\r
+    InternalPrintMessage ("!!!! Find image based on IP(0x%x) ", CurrentEip);\r
     PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data);\r
     if (PdbPointer != NULL) {\r
       InternalPrintMessage ("%a", PdbPointer);\r
index 6ac8549839cebb2f7f0a8e4cfd36ceb92d932bfd..04f2ab593c3e2b64a0f5ec728a04b7a356251c21 100644 (file)
@@ -414,5 +414,14 @@ DumpImageAndCpuContent (
   //\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
index 1dcf4277dea9164320f6072cec44afaecdaec914..56180f4c17e49bd42396792c8c9be9f8a3800db8 100644 (file)
@@ -414,5 +414,14 @@ DumpImageAndCpuContent (
   //\r
   // Dump module image base and module entry point by RIP\r
   //\r
-  DumpModuleImageInfo (SystemContext.SystemContextX64->Rip);\r
+  if ((ExceptionType == EXCEPT_IA32_PAGE_FAULT) &&\r
+      ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0)) {\r
+    //\r
+    // The RIP in SystemContext could not be used\r
+    // if it is page fault with I/D set.\r
+    //\r
+    DumpModuleImageInfo ((*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp));\r
+  } else {\r
+    DumpModuleImageInfo (SystemContext.SystemContextX64->Rip);\r
+  }\r
 }\r