]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: FSP should not override IDT
authorChasel, Chiu <chasel.chiu@intel.com>
Fri, 19 Oct 2018 09:10:30 +0000 (17:10 +0800)
committerChasel, Chiu <chasel.chiu@intel.com>
Thu, 25 Oct 2018 09:01:36 +0000 (17:01 +0800)
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>
IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
IntelFsp2Pkg/FspSecCore/SecMain.c
IntelFsp2Pkg/FspSecCore/SecMain.h
IntelFsp2Pkg/IntelFsp2Pkg.dec

index c61af10b8ad64ea858008a93cec6fc0ae99dbf74..dafe6f599304d2e2674cccce71be122bef0df048 100644 (file)
@@ -62,6 +62,7 @@
   gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamSize              ## CONSUMES\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspTemporaryRamSize           ## CONSUMES\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspHeapSizePercentage         ## CONSUMES\r
   gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamSize              ## CONSUMES\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspTemporaryRamSize           ## CONSUMES\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspHeapSizePercentage         ## CONSUMES\r
+  gIntelFsp2PkgTokenSpaceGuid.PcdFspMaxInterruptSupported      ## CONSUMES\r
 \r
 [Ppis]\r
   gEfiTemporaryRamSupportPpiGuid                              ## PRODUCES\r
 \r
 [Ppis]\r
   gEfiTemporaryRamSupportPpiGuid                              ## PRODUCES\r
index 37fd4dfdeb0d311608452d99f66f315840921c8c..ddbfc4fcdf0b5a14abf47a3546f9977785ec0410 100644 (file)
@@ -70,6 +70,7 @@ SecStartup (
   UINT32                      Index;\r
   FSP_GLOBAL_DATA             PeiFspData;\r
   UINT64                      ExceptionHandler;\r
   UINT32                      Index;\r
   FSP_GLOBAL_DATA             PeiFspData;\r
   UINT64                      ExceptionHandler;\r
+  UINTN                       IdtSize;\r
 \r
   //\r
   // Process all libraries constructor function linked to SecCore.\r
 \r
   //\r
   // Process all libraries constructor function linked to SecCore.\r
@@ -98,13 +99,26 @@ SecStartup (
   // |                   |\r
   // |-------------------|---->  TempRamBase\r
   IdtTableInStack.PeiService  = NULL;\r
   // |                   |\r
   // |-------------------|---->  TempRamBase\r
   IdtTableInStack.PeiService  = NULL;\r
-  ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);\r
-  for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) {\r
-    CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64));\r
+  AsmReadIdtr (&IdtDescriptor);\r
+  if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {\r
+    ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);\r
+    for (Index = 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported); Index ++) {\r
+      CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64));\r
+    }\r
+    IdtSize = sizeof (IdtTableInStack.IdtTable);\r
+  } else {\r
+    if (IdtDescriptor.Limit + 1 > sizeof (IdtTableInStack.IdtTable)) {\r
+      //\r
+      // ERROR: IDT table size from boot loader is larger than FSP can support, DeadLoop here!\r
+      //\r
+      CpuDeadLoop();\r
+    } else {\r
+      IdtSize = IdtDescriptor.Limit + 1;\r
+    }\r
+    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);\r
   }\r
   }\r
-\r
   IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;\r
   IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;\r
-  IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1);\r
+  IdtDescriptor.Limit = (UINT16)(IdtSize - 1);\r
 \r
   AsmWriteIdtr (&IdtDescriptor);\r
 \r
 \r
   AsmWriteIdtr (&IdtDescriptor);\r
 \r
index 291bc5ca5caa116062d5db18f7581fac64363eb8..19ac2fbfc168147f027e13c7ee57a6fecd69a5ec 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
 /** @file\r
 \r
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -29,8 +29,6 @@
 #include <Library/FspCommonLib.h>\r
 #include <FspEas.h>\r
 \r
 #include <Library/FspCommonLib.h>\r
 #include <FspEas.h>\r
 \r
-#define SEC_IDT_ENTRY_COUNT    34\r
-\r
 typedef VOID (*PEI_CORE_ENTRY) ( \\r
   IN CONST  EFI_SEC_PEI_HAND_OFF    *SecCoreData, \\r
   IN CONST  EFI_PEI_PPI_DESCRIPTOR  *PpiList \\r
 typedef VOID (*PEI_CORE_ENTRY) ( \\r
   IN CONST  EFI_SEC_PEI_HAND_OFF    *SecCoreData, \\r
   IN CONST  EFI_PEI_PPI_DESCRIPTOR  *PpiList \\r
@@ -38,7 +36,7 @@ typedef VOID (*PEI_CORE_ENTRY) ( \
 \r
 typedef struct _SEC_IDT_TABLE {\r
   EFI_PEI_SERVICES  *PeiService;\r
 \r
 typedef struct _SEC_IDT_TABLE {\r
   EFI_PEI_SERVICES  *PeiService;\r
-  UINT64            IdtTable[SEC_IDT_ENTRY_COUNT];\r
+  UINT64            IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];\r
 } SEC_IDT_TABLE;\r
 \r
 /**\r
 } SEC_IDT_TABLE;\r
 \r
 /**\r
index 5b037d65e23284c44b1d149d94d899770073e033..50496241dab14cf75b4017145949666e70ce615b 100644 (file)
   # x % of FSP temporary memory will be used for heap\r
   # (100 - x) % of FSP temporary memory will be used for stack\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspHeapSizePercentage    |        50| UINT8|0x10000004\r
   # x % of FSP temporary memory will be used for heap\r
   # (100 - x) % of FSP temporary memory will be used for stack\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspHeapSizePercentage    |        50| UINT8|0x10000004\r
+  #\r
+  # Maximal Interrupt supported in IDT table.\r
+  #\r
+  gIntelFsp2PkgTokenSpaceGuid.PcdFspMaxInterruptSupported |        34| UINT8|0x10000005\r
 \r
 [PcdsFixedAtBuild,PcdsDynamic,PcdsDynamicEx]\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength |0x00100000|UINT32|0x46530000\r
 \r
 [PcdsFixedAtBuild,PcdsDynamic,PcdsDynamicEx]\r
   gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength |0x00100000|UINT32|0x46530000\r