UefiCpuPkg/CpuExceptionHandlerLib: Add DumpCpuContext() implementation
Export DumpCpuCotext() to display CPU Context. We will invoke PeCoffGetEntrypointLib's PeCoffSerachImageBase() to get PE/COFF image base. Display exception data bit value for page fault exception. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
@ -106,82 +106,44 @@ InternalPrintMessage (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Find and display image base address and return image base and its entry point.
|
Find and display image base address and return image base and its entry point.
|
||||||
|
|
||||||
@param CurrentEip Current instruction pointer.
|
@param CurrentEip Current instruction pointer.
|
||||||
@param EntryPoint Return module entry point if module header is found.
|
|
||||||
|
|
||||||
@return !0 Image base address.
|
|
||||||
@return 0 Image header cannot be found.
|
|
||||||
**/
|
**/
|
||||||
UINTN
|
VOID
|
||||||
FindModuleImageBase (
|
DumpModuleImageInfo (
|
||||||
IN UINTN CurrentEip,
|
IN UINTN CurrentEip
|
||||||
OUT UINTN *EntryPoint
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
UINTN Pe32Data;
|
UINTN Pe32Data;
|
||||||
EFI_IMAGE_DOS_HEADER *DosHdr;
|
|
||||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
|
||||||
VOID *PdbPointer;
|
VOID *PdbPointer;
|
||||||
|
VOID *EntryPoint;
|
||||||
|
|
||||||
//
|
Pe32Data = PeCoffSerachImageBase (CurrentEip);
|
||||||
// Find Image Base
|
if (Pe32Data == 0) {
|
||||||
//
|
InternalPrintMessage ("!!!! Can't find image information. !!!!\n");
|
||||||
Pe32Data = CurrentEip & ~(mImageAlignSize - 1);
|
} else {
|
||||||
while (Pe32Data != 0) {
|
//
|
||||||
DosHdr = (EFI_IMAGE_DOS_HEADER *) Pe32Data;
|
// Find Image Base entry point
|
||||||
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
//
|
||||||
//
|
Status = PeCoffLoaderGetEntryPoint ((VOID *) Pe32Data, &EntryPoint);
|
||||||
// DOS image header is present, so read the PE header after the DOS image header.
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
EntryPoint = NULL;
|
||||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
|
|
||||||
//
|
|
||||||
// Make sure PE header address does not overflow and is less than the initial address.
|
|
||||||
//
|
|
||||||
if (((UINTN)Hdr.Pe32 > Pe32Data) && ((UINTN)Hdr.Pe32 < CurrentEip)) {
|
|
||||||
if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
|
||||||
//
|
|
||||||
// It's PE image.
|
|
||||||
//
|
|
||||||
InternalPrintMessage ("!!!! Find PE image ");
|
|
||||||
*EntryPoint = (UINTN)Pe32Data + (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// DOS image header is not present, TE header is at the image base.
|
|
||||||
//
|
|
||||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
|
|
||||||
if ((Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) &&
|
|
||||||
((Hdr.Te->Machine == IMAGE_FILE_MACHINE_I386) || Hdr.Te->Machine == IMAGE_FILE_MACHINE_X64)) {
|
|
||||||
//
|
|
||||||
// It's TE image, it TE header and Machine type match
|
|
||||||
//
|
|
||||||
InternalPrintMessage ("!!!! Find TE image ");
|
|
||||||
*EntryPoint = (UINTN)Pe32Data + (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) + sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
InternalPrintMessage ("!!!! Find image ");
|
||||||
//
|
|
||||||
// Not found the image base, check the previous aligned address
|
|
||||||
//
|
|
||||||
Pe32Data -= mImageAlignSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Pe32Data != 0) {
|
|
||||||
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data);
|
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data);
|
||||||
if (PdbPointer != NULL) {
|
if (PdbPointer != NULL) {
|
||||||
InternalPrintMessage ("%a", PdbPointer);
|
InternalPrintMessage ("%a", PdbPointer);
|
||||||
} else {
|
} else {
|
||||||
InternalPrintMessage ("(No PDB) " );
|
InternalPrintMessage ("(No PDB) " );
|
||||||
}
|
}
|
||||||
} else {
|
InternalPrintMessage (
|
||||||
InternalPrintMessage ("!!!! Can't find image information. !!!!\n");
|
" (ImageBase=%016lp, EntryPoint=%016p) !!!!\n",
|
||||||
|
(VOID *) Pe32Data,
|
||||||
|
EntryPoint
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Pe32Data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Common header file for CPU Exception Handler Library.
|
Common header file for CPU Exception Handler Library.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -24,11 +24,23 @@
|
|||||||
#include <Library/PeCoffGetEntryPointLib.h>
|
#include <Library/PeCoffGetEntryPointLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/SynchronizationLib.h>
|
#include <Library/SynchronizationLib.h>
|
||||||
|
#include <Library/CpuExceptionHandlerLib.h>
|
||||||
|
|
||||||
#define CPU_EXCEPTION_NUM 32
|
#define CPU_EXCEPTION_NUM 32
|
||||||
#define CPU_INTERRUPT_NUM 256
|
#define CPU_INTERRUPT_NUM 256
|
||||||
#define HOOKAFTER_STUB_SIZE 16
|
#define HOOKAFTER_STUB_SIZE 16
|
||||||
|
|
||||||
|
//
|
||||||
|
// Exception Error Code of Page-Fault Exception
|
||||||
|
//
|
||||||
|
#define IA32_PF_EC_P BIT0
|
||||||
|
#define IA32_PF_EC_WR BIT1
|
||||||
|
#define IA32_PF_EC_US BIT2
|
||||||
|
#define IA32_PF_EC_RSVD BIT3
|
||||||
|
#define IA32_PF_EC_ID BIT4
|
||||||
|
#define IA32_PF_EC_PK BIT5
|
||||||
|
#define IA32_PF_EC_SGX BIT15
|
||||||
|
|
||||||
#include "ArchInterruptDefs.h"
|
#include "ArchInterruptDefs.h"
|
||||||
|
|
||||||
#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \
|
#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \
|
||||||
@ -53,7 +65,6 @@ typedef struct {
|
|||||||
} EXCEPTION_HANDLER_DATA;
|
} EXCEPTION_HANDLER_DATA;
|
||||||
|
|
||||||
extern CONST UINT32 mErrorCodeFlag;
|
extern CONST UINT32 mErrorCodeFlag;
|
||||||
extern CONST UINTN mImageAlignSize;
|
|
||||||
extern CONST UINTN mDoFarReturnFlag;
|
extern CONST UINTN mDoFarReturnFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,15 +123,11 @@ InternalPrintMessage (
|
|||||||
Find and display image base address and return image base and its entry point.
|
Find and display image base address and return image base and its entry point.
|
||||||
|
|
||||||
@param CurrentEip Current instruction pointer.
|
@param CurrentEip Current instruction pointer.
|
||||||
@param EntryPoint Return module entry point if module header is found.
|
|
||||||
|
|
||||||
@return !0 Image base address.
|
|
||||||
@return 0 Image header cannot be found.
|
|
||||||
**/
|
**/
|
||||||
UINTN
|
VOID
|
||||||
FindModuleImageBase (
|
DumpModuleImageInfo (
|
||||||
IN UINTN CurrentEip,
|
IN UINTN CurrentEip
|
||||||
OUT UINTN *EntryPoint
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +137,7 @@ FindModuleImageBase (
|
|||||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
DumpCpuContent (
|
DumpImageAndCpuContent (
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
CPU exception handler library implemenation for DXE modules.
|
CPU exception handler library implemenation for DXE modules.
|
||||||
|
|
||||||
Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -19,11 +19,6 @@
|
|||||||
|
|
||||||
CONST UINTN mDoFarReturnFlag = 0;
|
CONST UINTN mDoFarReturnFlag = 0;
|
||||||
|
|
||||||
//
|
|
||||||
// Image align size for DXE/SMM
|
|
||||||
//
|
|
||||||
CONST UINTN mImageAlignSize = SIZE_4KB;
|
|
||||||
|
|
||||||
RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];
|
RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];
|
||||||
EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];
|
EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];
|
||||||
UINTN mEnabledInterruptNum = 0;
|
UINTN mEnabledInterruptNum = 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
IA32 CPU Exception Handler functons.
|
IA32 CPU Exception Handler functons.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -108,39 +108,49 @@ ArchRestoreExceptionContext (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Display CPU information.
|
Display processor context.
|
||||||
|
|
||||||
@param ExceptionType Exception type.
|
@param[in] ExceptionType Exception type.
|
||||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
@param[in] SystemContext Processor context to be display.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
DumpCpuContent (
|
EFIAPI
|
||||||
|
DumpCpuContext (
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN ImageBase;
|
|
||||||
UINTN EntryPoint;
|
|
||||||
|
|
||||||
InternalPrintMessage (
|
InternalPrintMessage (
|
||||||
"!!!! IA32 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n",
|
"!!!! IA32 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n",
|
||||||
ExceptionType,
|
ExceptionType,
|
||||||
GetExceptionNameStr (ExceptionType),
|
GetExceptionNameStr (ExceptionType),
|
||||||
GetApicId ()
|
GetApicId ()
|
||||||
);
|
);
|
||||||
|
if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) {
|
||||||
|
InternalPrintMessage (
|
||||||
|
"ExceptionData - %08x",
|
||||||
|
SystemContext.SystemContextIa32->ExceptionData
|
||||||
|
);
|
||||||
|
if (ExceptionType == EXCEPT_IA32_PAGE_FAULT) {
|
||||||
|
InternalPrintMessage (
|
||||||
|
" I:%x R:%x U:%x W:%x P:%x PK:%x S:%x",
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0,
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_RSVD) != 0,
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_US) != 0,
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_WR) != 0,
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_P) != 0,
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_PK) != 0,
|
||||||
|
(SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_SGX) != 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
InternalPrintMessage ("\n");
|
||||||
|
}
|
||||||
InternalPrintMessage (
|
InternalPrintMessage (
|
||||||
"EIP - %08x, CS - %08x, EFLAGS - %08x\n",
|
"EIP - %08x, CS - %08x, EFLAGS - %08x\n",
|
||||||
SystemContext.SystemContextIa32->Eip,
|
SystemContext.SystemContextIa32->Eip,
|
||||||
SystemContext.SystemContextIa32->Cs,
|
SystemContext.SystemContextIa32->Cs,
|
||||||
SystemContext.SystemContextIa32->Eflags
|
SystemContext.SystemContextIa32->Eflags
|
||||||
);
|
);
|
||||||
if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) {
|
|
||||||
InternalPrintMessage (
|
|
||||||
"ExceptionData - %08x\n",
|
|
||||||
SystemContext.SystemContextIa32->ExceptionData
|
|
||||||
);
|
|
||||||
}
|
|
||||||
InternalPrintMessage (
|
InternalPrintMessage (
|
||||||
"EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x\n",
|
"EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x\n",
|
||||||
SystemContext.SystemContextIa32->Eax,
|
SystemContext.SystemContextIa32->Eax,
|
||||||
@ -198,16 +208,23 @@ DumpCpuContent (
|
|||||||
"FXSAVE_STATE - %08x\n",
|
"FXSAVE_STATE - %08x\n",
|
||||||
&SystemContext.SystemContextIa32->FxSaveState
|
&SystemContext.SystemContextIa32->FxSaveState
|
||||||
);
|
);
|
||||||
|
}
|
||||||
//
|
|
||||||
// Find module image base and module entry point by RIP
|
/**
|
||||||
//
|
Display CPU information.
|
||||||
ImageBase = FindModuleImageBase (SystemContext.SystemContextIa32->Eip, &EntryPoint);
|
|
||||||
if (ImageBase != 0) {
|
@param ExceptionType Exception type.
|
||||||
InternalPrintMessage (
|
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
" (ImageBase=%08x, EntryPoint=%08x) !!!!\n",
|
**/
|
||||||
ImageBase,
|
VOID
|
||||||
EntryPoint
|
DumpImageAndCpuContent (
|
||||||
);
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
}
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DumpCpuContext (ExceptionType, SystemContext);
|
||||||
|
//
|
||||||
|
// Dump module image base and module entry point by EIP
|
||||||
|
//
|
||||||
|
DumpModuleImageInfo (SystemContext.SystemContextIa32->Eip);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
CPU exception handler library implementation for PEIM module.
|
CPU exception handler library implementation for PEIM module.
|
||||||
|
|
||||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -18,10 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <Library/HobLib.h>
|
#include <Library/HobLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
|
||||||
//
|
|
||||||
// Image Alignment size for PEI phase
|
|
||||||
//
|
|
||||||
CONST UINTN mImageAlignSize = 4;
|
|
||||||
CONST UINTN mDoFarReturnFlag = 0;
|
CONST UINTN mDoFarReturnFlag = 0;
|
||||||
|
|
||||||
EFI_GUID mCpuExceptrionHandlerLibHobGuid = CPU_EXCEPTION_HANDLER_LIB_HOB_GUID;
|
EFI_GUID mCpuExceptrionHandlerLibHobGuid = CPU_EXCEPTION_HANDLER_LIB_HOB_GUID;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
CPU Exception Library provides PEI/DXE/SMM CPU common exception handler.
|
CPU Exception Library provides PEI/DXE/SMM CPU common exception handler.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -101,7 +101,7 @@ CommonExceptionHandlerWorker (
|
|||||||
//
|
//
|
||||||
// Display ExceptionType, CPU information and Image information
|
// Display ExceptionType, CPU information and Image information
|
||||||
//
|
//
|
||||||
DumpCpuContent (ExceptionType, SystemContext);
|
DumpImageAndCpuContent (ExceptionType, SystemContext);
|
||||||
//
|
//
|
||||||
// Release Spinlock of output message
|
// Release Spinlock of output message
|
||||||
//
|
//
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
CPU exception handler library implemenation for SEC/PEIM modules.
|
CPU exception handler library implemenation for SEC/PEIM modules.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -15,10 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <PiPei.h>
|
#include <PiPei.h>
|
||||||
#include "CpuExceptionCommon.h"
|
#include "CpuExceptionCommon.h"
|
||||||
|
|
||||||
//
|
|
||||||
// Image Aglinment size for SEC/PEI phase
|
|
||||||
//
|
|
||||||
CONST UINTN mImageAlignSize = 4;
|
|
||||||
CONST UINTN mDoFarReturnFlag = 0;
|
CONST UINTN mDoFarReturnFlag = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +33,7 @@ CommonExceptionHandler (
|
|||||||
//
|
//
|
||||||
// Display ExceptionType, CPU information and Image information
|
// Display ExceptionType, CPU information and Image information
|
||||||
//
|
//
|
||||||
DumpCpuContent (ExceptionType, SystemContext);
|
DumpImageAndCpuContent (ExceptionType, SystemContext);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Enter a dead loop.
|
// Enter a dead loop.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
CPU exception handler library implemenation for SMM modules.
|
CPU exception handler library implemenation for SMM modules.
|
||||||
|
|
||||||
Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -22,11 +22,6 @@ CONST UINTN mDoFarReturnFlag = 1;
|
|||||||
//
|
//
|
||||||
SPIN_LOCK mDisplayMessageSpinLock;
|
SPIN_LOCK mDisplayMessageSpinLock;
|
||||||
|
|
||||||
//
|
|
||||||
// Image align size for DXE/SMM
|
|
||||||
//
|
|
||||||
CONST UINTN mImageAlignSize = SIZE_4KB;
|
|
||||||
|
|
||||||
RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];
|
RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];
|
||||||
EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];
|
EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];
|
||||||
EXCEPTION_HANDLER_DATA mExceptionHandlerData;
|
EXCEPTION_HANDLER_DATA mExceptionHandlerData;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
x64 CPU Exception Handler.
|
x64 CPU Exception Handler.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -119,33 +119,43 @@ ArchRestoreExceptionContext (
|
|||||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
DumpCpuContent (
|
EFIAPI
|
||||||
|
DumpCpuContext (
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN ImageBase;
|
|
||||||
UINTN EntryPoint;
|
|
||||||
|
|
||||||
InternalPrintMessage (
|
InternalPrintMessage (
|
||||||
"!!!! X64 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n",
|
"!!!! X64 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n",
|
||||||
ExceptionType,
|
ExceptionType,
|
||||||
GetExceptionNameStr (ExceptionType),
|
GetExceptionNameStr (ExceptionType),
|
||||||
GetApicId ()
|
GetApicId ()
|
||||||
);
|
);
|
||||||
|
if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) {
|
||||||
|
InternalPrintMessage (
|
||||||
|
"ExceptionData - %016lx",
|
||||||
|
SystemContext.SystemContextX64->ExceptionData
|
||||||
|
);
|
||||||
|
if (ExceptionType == EXCEPT_IA32_PAGE_FAULT) {
|
||||||
|
InternalPrintMessage (
|
||||||
|
" I:%x R:%x U:%x W:%x P:%x PK:%x S:%x",
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0,
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_RSVD) != 0,
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_US) != 0,
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_WR) != 0,
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_P) != 0,
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_PK) != 0,
|
||||||
|
(SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_SGX) != 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
InternalPrintMessage ("\n");
|
||||||
|
}
|
||||||
InternalPrintMessage (
|
InternalPrintMessage (
|
||||||
"RIP - %016lx, CS - %016lx, RFLAGS - %016lx\n",
|
"RIP - %016lx, CS - %016lx, RFLAGS - %016lx\n",
|
||||||
SystemContext.SystemContextX64->Rip,
|
SystemContext.SystemContextX64->Rip,
|
||||||
SystemContext.SystemContextX64->Cs,
|
SystemContext.SystemContextX64->Cs,
|
||||||
SystemContext.SystemContextX64->Rflags
|
SystemContext.SystemContextX64->Rflags
|
||||||
);
|
);
|
||||||
if (mErrorCodeFlag & (1 << ExceptionType)) {
|
|
||||||
InternalPrintMessage (
|
|
||||||
"ExceptionData - %016lx\n",
|
|
||||||
SystemContext.SystemContextX64->ExceptionData
|
|
||||||
);
|
|
||||||
}
|
|
||||||
InternalPrintMessage (
|
InternalPrintMessage (
|
||||||
"RAX - %016lx, RCX - %016lx, RDX - %016lx\n",
|
"RAX - %016lx, RCX - %016lx, RDX - %016lx\n",
|
||||||
SystemContext.SystemContextX64->Rax,
|
SystemContext.SystemContextX64->Rax,
|
||||||
@ -230,16 +240,23 @@ DumpCpuContent (
|
|||||||
"FXSAVE_STATE - %016lx\n",
|
"FXSAVE_STATE - %016lx\n",
|
||||||
&SystemContext.SystemContextX64->FxSaveState
|
&SystemContext.SystemContextX64->FxSaveState
|
||||||
);
|
);
|
||||||
|
}
|
||||||
//
|
|
||||||
// Find module image base and module entry point by RIP
|
/**
|
||||||
//
|
Display CPU information.
|
||||||
ImageBase = FindModuleImageBase (SystemContext.SystemContextX64->Rip, &EntryPoint);
|
|
||||||
if (ImageBase != 0) {
|
@param ExceptionType Exception type.
|
||||||
InternalPrintMessage (
|
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
" (ImageBase=%016lx, EntryPoint=%016lx) !!!!\n",
|
**/
|
||||||
ImageBase,
|
VOID
|
||||||
EntryPoint
|
DumpImageAndCpuContent (
|
||||||
);
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
}
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DumpCpuContext (ExceptionType, SystemContext);
|
||||||
|
//
|
||||||
|
// Dump module image base and module entry point by RIP
|
||||||
|
//
|
||||||
|
DumpModuleImageInfo (SystemContext.SystemContextX64->Rip);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user