IntelFsp2Pkg: Update SEC_IDT_TABLE struct

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3957
The reserved IDT table size in SecCore is too small for X64. Changed the type
of IdtTable in SEC_IDT_TABLE from UINT64 to IA32_IDT_GATE_DESCRIPTOR to have
sufficient size reserved in IdtTable for X64.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
This commit is contained in:
Kuo, Ted 2022-07-12 02:30:58 -07:00 committed by mergify[bot]
parent 9ab389c01b
commit 470206ba7f
4 changed files with 21 additions and 20 deletions

View File

@ -16,19 +16,20 @@
@return FSP specific IDT gate descriptor. @return FSP specific IDT gate descriptor.
**/ **/
UINT64 IA32_IDT_GATE_DESCRIPTOR
FspGetExceptionHandler ( FspGetExceptionHandler (
IN UINT64 IdtEntryTemplate IN UINT64 IdtEntryTemplate
) )
{ {
UINT32 Entry; UINT32 Entry;
UINT64 ExceptionHandler; IA32_IDT_GATE_DESCRIPTOR ExceptionHandler;
IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor; IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor;
FSP_INFO_HEADER *FspInfoHeader; FSP_INFO_HEADER *FspInfoHeader;
ZeroMem ((VOID *)&ExceptionHandler, sizeof (IA32_IDT_GATE_DESCRIPTOR));
FspInfoHeader = (FSP_INFO_HEADER *)(UINTN)AsmGetFspInfoHeader (); FspInfoHeader = (FSP_INFO_HEADER *)(UINTN)AsmGetFspInfoHeader ();
ExceptionHandler = IdtEntryTemplate; *(UINT64 *) &ExceptionHandler = IdtEntryTemplate;
IdtGateDescriptor = (IA32_IDT_GATE_DESCRIPTOR *)&ExceptionHandler; IdtGateDescriptor = &ExceptionHandler;
Entry = (IdtGateDescriptor->Bits.OffsetHigh << 16) | IdtGateDescriptor->Bits.OffsetLow; Entry = (IdtGateDescriptor->Bits.OffsetHigh << 16) | IdtGateDescriptor->Bits.OffsetLow;
Entry = FspInfoHeader->ImageBase + FspInfoHeader->ImageSize - (~Entry + 1); Entry = FspInfoHeader->ImageBase + FspInfoHeader->ImageSize - (~Entry + 1);
IdtGateDescriptor->Bits.OffsetHigh = (UINT16)(Entry >> 16); IdtGateDescriptor->Bits.OffsetHigh = (UINT16)(Entry >> 16);
@ -200,11 +201,11 @@ FspGlobalDataInit (
(PeiFspData->FspInfoHeader->ImageRevision >> 24) & 0xFF, \ (PeiFspData->FspInfoHeader->ImageRevision >> 24) & 0xFF, \
(PeiFspData->FspInfoHeader->ImageRevision >> 16) & 0xFF, \ (PeiFspData->FspInfoHeader->ImageRevision >> 16) & 0xFF, \
(PeiFspData->FspInfoHeader->HeaderRevision >= 6) ? \ (PeiFspData->FspInfoHeader->HeaderRevision >= 6) ? \
(((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF) | (PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF00)) :\ (((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF) | (PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF00)) : \
((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF), \ ((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF), \
(PeiFspData->FspInfoHeader->HeaderRevision >= 6) ? \ (PeiFspData->FspInfoHeader->HeaderRevision >= 6) ? \
((PeiFspData->FspInfoHeader->ImageRevision & 0xFF) | ((PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF) << 8)): \ ((PeiFspData->FspInfoHeader->ImageRevision & 0xFF) | ((PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF) << 8)) : \
(PeiFspData->FspInfoHeader->ImageRevision & 0xFF) (PeiFspData->FspInfoHeader->ImageRevision & 0xFF)
)); ));
} }

View File

@ -30,7 +30,7 @@
@return FSP specific IDT gate descriptor. @return FSP specific IDT gate descriptor.
**/ **/
UINT64 IA32_IDT_GATE_DESCRIPTOR
FspGetExceptionHandler ( FspGetExceptionHandler (
IN UINT64 IdtEntryTemplate IN UINT64 IdtEntryTemplate
); );

View File

@ -58,13 +58,13 @@ SecStartup (
IN UINT32 ApiIdx IN UINT32 ApiIdx
) )
{ {
EFI_SEC_PEI_HAND_OFF SecCoreData; EFI_SEC_PEI_HAND_OFF SecCoreData;
IA32_DESCRIPTOR IdtDescriptor; IA32_DESCRIPTOR IdtDescriptor;
SEC_IDT_TABLE IdtTableInStack; SEC_IDT_TABLE IdtTableInStack;
UINT32 Index; UINT32 Index;
FSP_GLOBAL_DATA PeiFspData; FSP_GLOBAL_DATA PeiFspData;
UINT64 ExceptionHandler; IA32_IDT_GATE_DESCRIPTOR ExceptionHandler;
UINTN IdtSize; UINTN IdtSize;
// //
// Process all libraries constructor function linked to SecCore. // Process all libraries constructor function linked to SecCore.
@ -119,7 +119,7 @@ SecStartup (
if (IdtDescriptor.Base == 0) { if (IdtDescriptor.Base == 0) {
ExceptionHandler = FspGetExceptionHandler (mIdtEntryTemplate); ExceptionHandler = FspGetExceptionHandler (mIdtEntryTemplate);
for (Index = 0; Index < FixedPcdGet8 (PcdFspMaxInterruptSupported); Index++) { for (Index = 0; Index < FixedPcdGet8 (PcdFspMaxInterruptSupported); Index++) {
CopyMem ((VOID *)&IdtTableInStack.IdtTable[Index], (VOID *)&ExceptionHandler, sizeof (UINT64)); CopyMem ((VOID *)&IdtTableInStack.IdtTable[Index], (VOID *)&ExceptionHandler, sizeof (IA32_IDT_GATE_DESCRIPTOR));
} }
IdtSize = sizeof (IdtTableInStack.IdtTable); IdtSize = sizeof (IdtTableInStack.IdtTable);

View File

@ -26,7 +26,7 @@
typedef typedef
VOID VOID
(EFIAPI *PEI_CORE_ENTRY) ( (EFIAPI *PEI_CORE_ENTRY)(
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
); );
@ -38,8 +38,8 @@ typedef struct _SEC_IDT_TABLE {
// Note: For IA32, only the 4 bytes immediately preceding IDT is used to store // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store
// EFI_PEI_SERVICES** // EFI_PEI_SERVICES**
// //
UINT64 PeiService; UINT64 PeiService;
UINT64 IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)]; IA32_IDT_GATE_DESCRIPTOR IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];
} SEC_IDT_TABLE; } SEC_IDT_TABLE;
/** /**