X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=UefiCpuPkg%2FLibrary%2FCpuExceptionHandlerLib%2FCpuExceptionCommon.h;h=4593c204a6e8ac078dac602d8ee0359a3e578b87;hb=HEAD;hp=e66a5df86423365df055225a015c0f8edf8415f8;hpb=1b2f7b3e4906fbee727677e827dacee7a9fc9b7f;p=mirror_edk2.git
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index e66a5df864..4593c204a6 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -1,14 +1,8 @@
/** @file
Common header file for CPU Exception Handler Library.
- Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials
- 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -26,46 +20,53 @@
#include
#include
-#define CPU_EXCEPTION_NUM 32
-#define CPU_INTERRUPT_NUM 256
-#define HOOKAFTER_STUB_SIZE 16
+#define CPU_EXCEPTION_NUM 32
+#define CPU_INTERRUPT_NUM 256
+#define HOOKAFTER_STUB_SIZE 18
//
// 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
+#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_SS BIT6
+#define IA32_PF_EC_SGX BIT15
#include "ArchInterruptDefs.h"
-#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \
- { \
- 0xb21d9148, 0x9211, 0x4d8f, { 0xad, 0xd3, 0x66, 0xb1, 0x89, 0xc9, 0x2c, 0x83 } \
- }
+#define CPU_STACK_SWITCH_EXCEPTION_NUMBER \
+ FixedPcdGetSize (PcdCpuStackSwitchExceptionList)
+
+#define CPU_STACK_SWITCH_EXCEPTION_LIST \
+ FixedPcdGetPtr (PcdCpuStackSwitchExceptionList)
+
+#define CPU_KNOWN_GOOD_STACK_SIZE \
+ FixedPcdGet32 (PcdCpuKnownGoodStackSize)
+
+#define CPU_TSS_GDT_SIZE (SIZE_2KB + CPU_TSS_DESC_SIZE + CPU_TSS_SIZE)
//
// Record exception handler information
//
typedef struct {
- UINTN ExceptionStart;
- UINTN ExceptionStubHeaderSize;
- UINTN HookAfterStubHeaderStart;
+ UINTN ExceptionStart;
+ UINTN ExceptionStubHeaderSize;
+ UINTN HookAfterStubHeaderStart;
} EXCEPTION_HANDLER_TEMPLATE_MAP;
typedef struct {
- UINTN IdtEntryCount;
- SPIN_LOCK DisplayMessageSpinLock;
- RESERVED_VECTORS_DATA *ReservedVectors;
- EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;
+ UINTN IdtEntryCount;
+ SPIN_LOCK DisplayMessageSpinLock;
+ RESERVED_VECTORS_DATA *ReservedVectors;
+ EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;
} EXCEPTION_HANDLER_DATA;
-extern CONST UINT32 mErrorCodeFlag;
-extern CONST UINTN mDoFarReturnFlag;
+extern CONST UINT32 mErrorCodeFlag;
+extern CONST UINTN mDoFarReturnFlag;
/**
Return address map of exception handler template so that C code can generate
@@ -76,7 +77,7 @@ extern CONST UINTN mDoFarReturnFlag;
VOID
EFIAPI
AsmGetTemplateAddressMap (
- OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap
+ OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap
);
/**
@@ -89,8 +90,8 @@ AsmGetTemplateAddressMap (
**/
VOID
ArchUpdateIdtEntry (
- IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry,
- IN UINTN InterruptHandler
+ OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry,
+ IN UINTN InterruptHandler
);
/**
@@ -101,14 +102,14 @@ ArchUpdateIdtEntry (
**/
UINTN
ArchGetIdtHandler (
- IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
+ IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
);
/**
Prints a message to the serial port.
@param Format Format string for the message to print.
- @param ... Variable argument list whose contents are accessed
+ @param ... Variable argument list whose contents are accessed
based on the format string specified by Format.
**/
@@ -121,13 +122,13 @@ InternalPrintMessage (
/**
Find and display image base address and return image base and its entry point.
-
+
@param CurrentEip Current instruction pointer.
-
+
**/
-VOID
+VOID
DumpModuleImageInfo (
- IN UINTN CurrentEip
+ IN UINTN CurrentEip
);
/**
@@ -138,8 +139,8 @@ DumpModuleImageInfo (
**/
VOID
DumpImageAndCpuContent (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN EFI_SYSTEM_CONTEXT SystemContext
);
/**
@@ -147,8 +148,8 @@ DumpImageAndCpuContent (
@param[in] VectorInfo Pointer to reserved vector list.
@param[in, out] ExceptionHandlerData Pointer to exception handler data.
-
- @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
+
+ @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported.
@@ -156,8 +157,8 @@ DumpImageAndCpuContent (
**/
EFI_STATUS
InitializeCpuExceptionHandlersWorker (
- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
- IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
+ IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData
);
/**
@@ -179,9 +180,9 @@ InitializeCpuExceptionHandlersWorker (
**/
EFI_STATUS
RegisterCpuInterruptHandlerWorker (
- IN EFI_EXCEPTION_TYPE InterruptType,
- IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
- IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
);
/**
@@ -209,9 +210,9 @@ UpdateIdtTable (
**/
VOID
ArchSaveExceptionContext (
- IN UINTN ExceptionType,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
+ IN UINTN ExceptionType,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
);
/**
@@ -223,14 +224,14 @@ ArchSaveExceptionContext (
**/
VOID
ArchRestoreExceptionContext (
- IN UINTN ExceptionType,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
+ IN UINTN ExceptionType,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
);
/**
Fix up the vector number and function address in the vector code.
-
+
@param[in] NewVectorAddr New vector handler address.
@param[in] VectorNum Index of vector.
@param[in] OldVectorAddr Old vector handler address.
@@ -239,27 +240,27 @@ ArchRestoreExceptionContext (
VOID
EFIAPI
AsmVectorNumFixup (
- IN VOID *NewVectorAddr,
- IN UINT8 VectorNum,
- IN VOID *OldVectorAddr
+ IN VOID *NewVectorAddr,
+ IN UINT8 VectorNum,
+ IN VOID *OldVectorAddr
);
/**
Read and save reserved vector information
-
+
@param[in] VectorInfo Pointer to reserved vector list.
@param[out] ReservedVector Pointer to reserved vector data buffer.
@param[in] VectorCount Vector number to be updated.
-
+
@return EFI_SUCCESS Read and save vector info successfully.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
**/
EFI_STATUS
ReadAndVerifyVectorInfo (
- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo,
- OUT RESERVED_VECTORS_DATA *ReservedVector,
- IN UINTN VectorCount
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo,
+ OUT RESERVED_VECTORS_DATA *ReservedVector,
+ IN UINTN VectorCount
);
/**
@@ -271,7 +272,7 @@ ReadAndVerifyVectorInfo (
**/
CONST CHAR8 *
GetExceptionNameStr (
- IN EFI_EXCEPTION_TYPE ExceptionType
+ IN EFI_EXCEPTION_TYPE ExceptionType
);
/**
@@ -283,10 +284,41 @@ GetExceptionNameStr (
**/
VOID
CommonExceptionHandlerWorker (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
);
-#endif
+/**
+ Setup separate stacks for certain exception handlers.
+
+ @param[in] Buffer Point to buffer used to separate exception stack.
+ @param[in, out] BufferSize On input, it indicates the byte size of Buffer.
+ If the size is not enough, the return status will
+ be EFI_BUFFER_TOO_SMALL, and output BufferSize
+ will be the size it needs.
+ @retval EFI_SUCCESS The stacks are assigned successfully.
+ @retval EFI_BUFFER_TOO_SMALL This BufferSize is too small.
+ @retval EFI_UNSUPPORTED This function is not supported.
+**/
+EFI_STATUS
+ArchSetupExceptionStack (
+ IN VOID *Buffer,
+ IN OUT UINTN *BufferSize
+ );
+
+/**
+ Return address map of exception handler template so that C code can generate
+ exception tables. The template is only for exceptions using task gate instead
+ of interrupt gate.
+
+ @param AddressMap Pointer to a buffer where the address map is returned.
+**/
+VOID
+EFIAPI
+AsmGetTssTemplateMap (
+ OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap
+ );
+
+#endif