]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2WrapperPkg: Check header revision for MultiPhase support.
authorChasel Chiu <chasel.chiu@intel.com>
Tue, 25 Oct 2022 18:43:49 +0000 (11:43 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 25 Oct 2022 23:12:10 +0000 (23:12 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4119

Earlier version of FSP header may not have MultiPhase fields present in
the FspInfoHeader so the handler should verify header revision before
accessing the MultiPhase fields from the header.

Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c

index 1248accf872484a9c8f11de716c42e217838953c..834dca07a902083201e0ebec32ad4f9e60fe58a7 100644 (file)
@@ -73,15 +73,27 @@ CallFspMultiPhaseEntry (
   //\r
   // FSP_MULTI_PHASE_INIT and FSP_MULTI_PHASE_SI_INIT API functions having same prototype.\r
   //\r
-  UINTN       FspMultiPhaseApiEntry;\r
-  UINTN       FspMultiPhaseApiOffset;\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     InterruptState;\r
+  UINTN                   FspMultiPhaseApiEntry;\r
+  UINTN                   FspMultiPhaseApiOffset;\r
+  EFI_STATUS              Status;\r
+  BOOLEAN                 InterruptState;\r
+  BOOLEAN                 IsVariableServiceRequest;\r
+  FSP_MULTI_PHASE_PARAMS  *FspMultiPhaseParamsPtr;\r
+\r
+  FspMultiPhaseParamsPtr   = (FSP_MULTI_PHASE_PARAMS *)FspMultiPhaseParams;\r
+  IsVariableServiceRequest = FALSE;\r
+  if ((FspMultiPhaseParamsPtr->MultiPhaseAction == EnumMultiPhaseGetVariableRequestInfo) ||\r
+      (FspMultiPhaseParamsPtr->MultiPhaseAction == EnumMultiPhaseCompleteVariableRequest))\r
+  {\r
+    IsVariableServiceRequest = TRUE;\r
+  }\r
 \r
   if (ComponentIndex == FspMultiPhaseMemInitApiIndex) {\r
     FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));\r
     if (FspHeader == NULL) {\r
       return EFI_DEVICE_ERROR;\r
+    } else if (FspHeader->SpecVersion < 0x24) {\r
+      return EFI_UNSUPPORTED;\r
     }\r
 \r
     FspMultiPhaseApiOffset = FspHeader->FspMultiPhaseMemInitEntryOffset;\r
@@ -89,6 +101,10 @@ CallFspMultiPhaseEntry (
     FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));\r
     if (FspHeader == NULL) {\r
       return EFI_DEVICE_ERROR;\r
+    } else if (FspHeader->SpecVersion < 0x22) {\r
+      return EFI_UNSUPPORTED;\r
+    } else if ((FspHeader->SpecVersion < 0x24) && (IsVariableServiceRequest == TRUE)) {\r
+      return EFI_UNSUPPORTED;\r
     }\r
 \r
     FspMultiPhaseApiOffset = FspHeader->FspMultiPhaseSiInitEntryOffset;\r
@@ -117,10 +133,11 @@ CallFspMultiPhaseEntry (
 /**\r
   FSP Wrapper Variable Request Handler\r
 \r
-  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
-  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+  @param[in, out] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in]      ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
 \r
-  @retval EFI_UNSUPPORTED   FSP Wrapper cannot support the specific variable request\r
+  @retval EFI_UNSUPPORTED   FSP Wrapper cannot support the specific variable request,\r
+                            or FSP does not support VariableService\r
   @retval EFI_STATUS        Return FSP returned status\r
 \r
 **/\r
@@ -284,10 +301,11 @@ FspWrapperVariableRequestHandler (
 /**\r
   FSP Wrapper MultiPhase Handler\r
 \r
-  @param[in] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
-  @param[in] ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
+  @param[in, out] FspHobListPtr        - Pointer to FSP HobList (valid after FSP-M completed)\r
+  @param[in]      ComponentIndex       - FSP Component which executing MultiPhase initialization.\r
 \r
-  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+  @retval EFI_UNSUPPORTED   Specific MultiPhase action was not supported.\r
+  @retval EFI_SUCCESS       MultiPhase action were completed successfully.\r
 \r
 **/\r
 EFI_STATUS\r