mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg: Add ExceptionHandlerData for ArchSaveExceptionContext()
mReservedVectors is not set, we could add parameter ExceptionHandlerData for ArchSaveExceptionContext() that could use it instead of mReservedVectors. Cc: Feng Tian <feng.tian@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
parent
1e09ec0946
commit
81b21fc250
|
@ -197,14 +197,15 @@ UpdateIdtTable (
|
||||||
/**
|
/**
|
||||||
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
|
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
|
||||||
|
|
||||||
@param[in] ExceptionType Exception type.
|
@param[in] ExceptionType Exception type.
|
||||||
@param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
@param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
|
@param[in] ExceptionHandlerData Pointer to exception handler data.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ArchSaveExceptionContext (
|
ArchSaveExceptionContext (
|
||||||
IN UINTN ExceptionType,
|
IN UINTN ExceptionType,
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||||
|
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
IA32 CPU Exception Handler functons.
|
IA32 CPU Exception Handler functons.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2016, 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
|
||||||
|
@ -50,24 +50,28 @@ ArchGetIdtHandler (
|
||||||
/**
|
/**
|
||||||
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
|
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
|
||||||
|
|
||||||
@param ExceptionType Exception type.
|
@param[in] ExceptionType Exception type.
|
||||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
@param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
|
@param[in] ExceptionHandlerData Pointer to exception handler data.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ArchSaveExceptionContext (
|
ArchSaveExceptionContext (
|
||||||
IN UINTN ExceptionType,
|
IN UINTN ExceptionType,
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||||
|
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
IA32_EFLAGS32 Eflags;
|
IA32_EFLAGS32 Eflags;
|
||||||
|
RESERVED_VECTORS_DATA *ReservedVectors;
|
||||||
|
|
||||||
|
ReservedVectors = ExceptionHandlerData->ReservedVectors;
|
||||||
//
|
//
|
||||||
// Save Exception context in global variable
|
// Save Exception context in global variable
|
||||||
//
|
//
|
||||||
mReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextIa32->Eflags;
|
ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextIa32->Eflags;
|
||||||
mReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextIa32->Cs;
|
ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextIa32->Cs;
|
||||||
mReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextIa32->Eip;
|
ReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextIa32->Eip;
|
||||||
mReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextIa32->ExceptionData;
|
ReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextIa32->ExceptionData;
|
||||||
//
|
//
|
||||||
// Clear IF flag to avoid old IDT handler enable interrupt by IRET
|
// Clear IF flag to avoid old IDT handler enable interrupt by IRET
|
||||||
//
|
//
|
||||||
|
@ -77,7 +81,7 @@ ArchSaveExceptionContext (
|
||||||
//
|
//
|
||||||
// Modify the EIP in stack, then old IDT handler will return to the stub code
|
// Modify the EIP in stack, then old IDT handler will return to the stub code
|
||||||
//
|
//
|
||||||
SystemContext.SystemContextIa32->Eip = (UINTN) mReservedVectors[ExceptionType].HookAfterStubHeaderCode;
|
SystemContext.SystemContextIa32->Eip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,7 @@ CommonExceptionHandlerWorker (
|
||||||
// Need to execute old IDT handler before running this exception handler
|
// Need to execute old IDT handler before running this exception handler
|
||||||
//
|
//
|
||||||
ReservedVectors[ExceptionType].ApicId = GetApicId ();
|
ReservedVectors[ExceptionType].ApicId = GetApicId ();
|
||||||
ArchSaveExceptionContext (ExceptionType, SystemContext);
|
ArchSaveExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData);
|
||||||
ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE;
|
ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE;
|
||||||
ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler;
|
ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
x64 CPU Exception Handler.
|
x64 CPU Exception Handler.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2016, 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
|
||||||
|
@ -51,25 +51,30 @@ ArchGetIdtHandler (
|
||||||
/**
|
/**
|
||||||
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
|
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
|
||||||
|
|
||||||
@param ExceptionType Exception type.
|
@param[in] ExceptionType Exception type.
|
||||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
@param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
|
@param[in] ExceptionHandlerData Pointer to exception handler data.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ArchSaveExceptionContext (
|
ArchSaveExceptionContext (
|
||||||
IN UINTN ExceptionType,
|
IN UINTN ExceptionType,
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||||
|
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
IA32_EFLAGS32 Eflags;
|
IA32_EFLAGS32 Eflags;
|
||||||
|
RESERVED_VECTORS_DATA *ReservedVectors;
|
||||||
|
|
||||||
|
ReservedVectors = ExceptionHandlerData->ReservedVectors;
|
||||||
//
|
//
|
||||||
// Save Exception context in global variable
|
// Save Exception context in global variable
|
||||||
//
|
//
|
||||||
mReservedVectors[ExceptionType].OldSs = SystemContext.SystemContextX64->Ss;
|
ReservedVectors[ExceptionType].OldSs = SystemContext.SystemContextX64->Ss;
|
||||||
mReservedVectors[ExceptionType].OldSp = SystemContext.SystemContextX64->Rsp;
|
ReservedVectors[ExceptionType].OldSp = SystemContext.SystemContextX64->Rsp;
|
||||||
mReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextX64->Rflags;
|
ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextX64->Rflags;
|
||||||
mReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextX64->Cs;
|
ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextX64->Cs;
|
||||||
mReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextX64->Rip;
|
ReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextX64->Rip;
|
||||||
mReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextX64->ExceptionData;
|
ReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextX64->ExceptionData;
|
||||||
//
|
//
|
||||||
// Clear IF flag to avoid old IDT handler enable interrupt by IRET
|
// Clear IF flag to avoid old IDT handler enable interrupt by IRET
|
||||||
//
|
//
|
||||||
|
@ -79,7 +84,7 @@ ArchSaveExceptionContext (
|
||||||
//
|
//
|
||||||
// Modify the EIP in stack, then old IDT handler will return to the stub code
|
// Modify the EIP in stack, then old IDT handler will return to the stub code
|
||||||
//
|
//
|
||||||
SystemContext.SystemContextX64->Rip = (UINTN) mReservedVectors[ExceptionType].HookAfterStubHeaderCode;
|
SystemContext.SystemContextX64->Rip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue