IntelFsp2Pkg: FSP should not override IDT
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1265 FSP should not override IDT table when it is initialized by boot loader. IDT should be re-initialized in FSP only when it is invalid. To mitigate temporary memory usage a PCD PcdFspMaxInterruptSupported created for platform to decide how many interrupts the FSP IDT table can support. Test: Verified on internal platform and boots successfully. Cc: Jiewen Yao <Jiewen.yao@intel.com> Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chasel Chiu <chasel.chiu@intel.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
This commit is contained in:
@@ -70,6 +70,7 @@ SecStartup (
|
||||
UINT32 Index;
|
||||
FSP_GLOBAL_DATA PeiFspData;
|
||||
UINT64 ExceptionHandler;
|
||||
UINTN IdtSize;
|
||||
|
||||
//
|
||||
// Process all libraries constructor function linked to SecCore.
|
||||
@@ -98,13 +99,26 @@ SecStartup (
|
||||
// | |
|
||||
// |-------------------|----> TempRamBase
|
||||
IdtTableInStack.PeiService = NULL;
|
||||
ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);
|
||||
for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) {
|
||||
CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64));
|
||||
AsmReadIdtr (&IdtDescriptor);
|
||||
if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {
|
||||
ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);
|
||||
for (Index = 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported); Index ++) {
|
||||
CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64));
|
||||
}
|
||||
IdtSize = sizeof (IdtTableInStack.IdtTable);
|
||||
} else {
|
||||
if (IdtDescriptor.Limit + 1 > sizeof (IdtTableInStack.IdtTable)) {
|
||||
//
|
||||
// ERROR: IDT table size from boot loader is larger than FSP can support, DeadLoop here!
|
||||
//
|
||||
CpuDeadLoop();
|
||||
} else {
|
||||
IdtSize = IdtDescriptor.Limit + 1;
|
||||
}
|
||||
CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);
|
||||
}
|
||||
|
||||
IdtDescriptor.Base = (UINTN) &IdtTableInStack.IdtTable;
|
||||
IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1);
|
||||
IdtDescriptor.Limit = (UINT16)(IdtSize - 1);
|
||||
|
||||
AsmWriteIdtr (&IdtDescriptor);
|
||||
|
||||
|
Reference in New Issue
Block a user