]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: Update SEC_IDT_TABLE struct
authorKuo, Ted <ted.kuo@intel.com>
Tue, 12 Jul 2022 09:30:58 +0000 (02:30 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 14 Jul 2022 18:13:44 +0000 (18:13 +0000)
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>
IntelFsp2Pkg/FspSecCore/SecFsp.c
IntelFsp2Pkg/FspSecCore/SecFsp.h
IntelFsp2Pkg/FspSecCore/SecMain.c
IntelFsp2Pkg/FspSecCore/SecMain.h

index 7fde6e7f418c99a46a24ed4ae65cfbbbcdb14e06..d9085ef51fb94166d60bb9accd3e0c0ddeae9b02 100644 (file)
   @return                     FSP specific IDT gate descriptor.\r
 \r
 **/\r
-UINT64\r
+IA32_IDT_GATE_DESCRIPTOR\r
 FspGetExceptionHandler (\r
   IN  UINT64  IdtEntryTemplate\r
   )\r
 {\r
   UINT32                    Entry;\r
-  UINT64                    ExceptionHandler;\r
+  IA32_IDT_GATE_DESCRIPTOR  ExceptionHandler;\r
   IA32_IDT_GATE_DESCRIPTOR  *IdtGateDescriptor;\r
   FSP_INFO_HEADER           *FspInfoHeader;\r
 \r
+  ZeroMem ((VOID *)&ExceptionHandler, sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
   FspInfoHeader                      = (FSP_INFO_HEADER *)(UINTN)AsmGetFspInfoHeader ();\r
-  ExceptionHandler                   = IdtEntryTemplate;\r
-  IdtGateDescriptor                  = (IA32_IDT_GATE_DESCRIPTOR *)&ExceptionHandler;\r
+  *(UINT64 *) &ExceptionHandler      = IdtEntryTemplate;\r
+  IdtGateDescriptor                  = &ExceptionHandler;\r
   Entry                              = (IdtGateDescriptor->Bits.OffsetHigh << 16) | IdtGateDescriptor->Bits.OffsetLow;\r
   Entry                              = FspInfoHeader->ImageBase + FspInfoHeader->ImageSize - (~Entry + 1);\r
   IdtGateDescriptor->Bits.OffsetHigh = (UINT16)(Entry >> 16);\r
@@ -200,11 +201,11 @@ FspGlobalDataInit (
     (PeiFspData->FspInfoHeader->ImageRevision >> 24) & 0xFF, \\r
     (PeiFspData->FspInfoHeader->ImageRevision >> 16) & 0xFF, \\r
     (PeiFspData->FspInfoHeader->HeaderRevision >= 6) ? \\r
-      (((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF) | (PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF00)) :\\r
-        ((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF), \\r
+    (((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF) | (PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF00)) : \\r
+    ((PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xFF), \\r
     (PeiFspData->FspInfoHeader->HeaderRevision >= 6) ? \\r
-      ((PeiFspData->FspInfoHeader->ImageRevision & 0xFF) | ((PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF) << 8)): \\r
-        (PeiFspData->FspInfoHeader->ImageRevision & 0xFF)\r
+    ((PeiFspData->FspInfoHeader->ImageRevision & 0xFF) | ((PeiFspData->FspInfoHeader->ExtendedImageRevision & 0xFF) << 8)) : \\r
+    (PeiFspData->FspInfoHeader->ImageRevision & 0xFF)\r
     ));\r
 }\r
 \r
index 41931a33dd31e45f944ce956d364f9cb55187548..e84528b3784908120e87991ed40d723fee1c7586 100644 (file)
@@ -30,7 +30,7 @@
   @return                     FSP specific IDT gate descriptor.\r
 \r
 **/\r
-UINT64\r
+IA32_IDT_GATE_DESCRIPTOR\r
 FspGetExceptionHandler (\r
   IN  UINT64  IdtEntryTemplate\r
   );\r
index 8effe2225c145596b184b4021d051ffdd60afade..94ea3865b45f947e03b5d6f9acdb6d9f3c9b00ec 100644 (file)
@@ -58,13 +58,13 @@ SecStartup (
   IN UINT32          ApiIdx\r
   )\r
 {\r
-  EFI_SEC_PEI_HAND_OFF  SecCoreData;\r
-  IA32_DESCRIPTOR       IdtDescriptor;\r
-  SEC_IDT_TABLE         IdtTableInStack;\r
-  UINT32                Index;\r
-  FSP_GLOBAL_DATA       PeiFspData;\r
-  UINT64                ExceptionHandler;\r
-  UINTN                 IdtSize;\r
+  EFI_SEC_PEI_HAND_OFF      SecCoreData;\r
+  IA32_DESCRIPTOR           IdtDescriptor;\r
+  SEC_IDT_TABLE             IdtTableInStack;\r
+  UINT32                    Index;\r
+  FSP_GLOBAL_DATA           PeiFspData;\r
+  IA32_IDT_GATE_DESCRIPTOR  ExceptionHandler;\r
+  UINTN                     IdtSize;\r
 \r
   //\r
   // Process all libraries constructor function linked to SecCore.\r
@@ -119,7 +119,7 @@ SecStartup (
   if (IdtDescriptor.Base == 0) {\r
     ExceptionHandler = FspGetExceptionHandler (mIdtEntryTemplate);\r
     for (Index = 0; Index < FixedPcdGet8 (PcdFspMaxInterruptSupported); Index++) {\r
-      CopyMem ((VOID *)&IdtTableInStack.IdtTable[Index], (VOID *)&ExceptionHandler, sizeof (UINT64));\r
+      CopyMem ((VOID *)&IdtTableInStack.IdtTable[Index], (VOID *)&ExceptionHandler, sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
     }\r
 \r
     IdtSize = sizeof (IdtTableInStack.IdtTable);\r
index 7c2642ad48bbd799b771dc2acac55818fee934e6..a09653da96714899561e75a4976b93e5dda544fd 100644 (file)
@@ -26,7 +26,7 @@
 \r
 typedef\r
 VOID\r
-(EFIAPI *PEI_CORE_ENTRY) (\r
+(EFIAPI *PEI_CORE_ENTRY)(\r
   IN CONST  EFI_SEC_PEI_HAND_OFF    *SecCoreData,\r
   IN CONST  EFI_PEI_PPI_DESCRIPTOR  *PpiList\r
   );\r
@@ -38,8 +38,8 @@ typedef struct _SEC_IDT_TABLE {
   // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store\r
   // EFI_PEI_SERVICES**\r
   //\r
-  UINT64    PeiService;\r
-  UINT64    IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];\r
+  UINT64                      PeiService;\r
+  IA32_IDT_GATE_DESCRIPTOR    IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];\r
 } SEC_IDT_TABLE;\r
 \r
 /**\r