]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported
authorStar Zeng <star.zeng@intel.com>
Fri, 30 Nov 2018 09:14:49 +0000 (17:14 +0800)
committerStar Zeng <star.zeng@intel.com>
Wed, 19 Dec 2018 04:33:28 +0000 (12:33 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405

Background as below.

Problem:
As static configuration from the PCDs, the binary PeiCore (for example
in FSP binary with dispatch mode) could not predict how many FVs,
Files or PPIs for different platforms.

Burden:
Platform developers need configure the PCDs accordingly for different
platforms.

To solve the problem and remove the burden, we can update PeiCore to
remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
File and PPI management.

This patch removes the using of PcdPeiCoreMaxFvSupported in Tcg(2)Pei.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
SecurityPkg/Tcg/TcgPei/TcgPei.c
SecurityPkg/Tcg/TcgPei/TcgPei.inf

index 09ef0c70a50b8b2b06471212947376df3e85d635..152e3f737b569b184f583dec7a1c4bafa05b3e3a 100644 (file)
@@ -71,10 +71,17 @@ EFI_PEI_PPI_DESCRIPTOR  mTpmInitializationDonePpiList = {
   NULL\r
 };\r
 \r
+//\r
+// Number of firmware blobs to grow by each time we run out of room\r
+//\r
+#define FIRMWARE_BLOB_GROWTH_STEP 4\r
+\r
 EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredBaseFvInfo;\r
+UINT32 mMeasuredMaxBaseFvIndex = 0;\r
 UINT32 mMeasuredBaseFvIndex = 0;\r
 \r
 EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredChildFvInfo;\r
+UINT32 mMeasuredMaxChildFvIndex = 0;\r
 UINT32 mMeasuredChildFvIndex = 0;\r
 \r
 /**\r
@@ -615,13 +622,20 @@ MeasureFvImage (
   //\r
   // Add new FV into the measured FV list.\r
   //\r
-  ASSERT (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-  if (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
-    mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase   = FvBase;\r
-    mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;\r
-    mMeasuredBaseFvIndex++;\r
+  if (mMeasuredBaseFvIndex >= mMeasuredMaxBaseFvIndex) {\r
+    mMeasuredBaseFvInfo = ReallocatePool (\r
+                            sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxBaseFvIndex,\r
+                            sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP),\r
+                            mMeasuredBaseFvInfo\r
+                            );\r
+    ASSERT (mMeasuredBaseFvInfo != NULL);\r
+    mMeasuredMaxBaseFvIndex = mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP;\r
   }\r
 \r
+  mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase   = FvBase;\r
+  mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;\r
+  mMeasuredBaseFvIndex++;\r
+\r
   return Status;\r
 }\r
 \r
@@ -724,20 +738,26 @@ FirmwareVolmeInfoPpiNotifyCallback (
   //\r
   if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {\r
 \r
-    ASSERT (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-    if (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
-      //\r
-      // Check whether FV is in the measured child FV list.\r
-      //\r
-      for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {\r
-        if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {\r
-          return EFI_SUCCESS;\r
-        }\r
+    if (mMeasuredChildFvIndex >= mMeasuredMaxChildFvIndex) {\r
+      mMeasuredChildFvInfo = ReallocatePool (\r
+                               sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxChildFvIndex,\r
+                               sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP),\r
+                               mMeasuredChildFvInfo\r
+                               );\r
+      ASSERT (mMeasuredChildFvInfo != NULL);\r
+      mMeasuredMaxChildFvIndex = mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP;\r
+    }\r
+    //\r
+    // Check whether FV is in the measured child FV list.\r
+    //\r
+    for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {\r
+      if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {\r
+        return EFI_SUCCESS;\r
       }\r
-      mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase   = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;\r
-      mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;\r
-      mMeasuredChildFvIndex++;\r
     }\r
+    mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase   = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;\r
+    mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;\r
+    mMeasuredChildFvIndex++;\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -761,11 +781,6 @@ PeimEntryMP (
 {\r
   EFI_STATUS                        Status;\r
 \r
-  mMeasuredBaseFvInfo  = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-  ASSERT (mMeasuredBaseFvInfo != NULL);\r
-  mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-  ASSERT (mMeasuredChildFvInfo != NULL);\r
-\r
   if (PcdGet8 (PcdTpm2ScrtmPolicy) == 1) {\r
     Status = MeasureCRTMVersion ();\r
   }\r
index ea9dc759ab0a07f0c6d2dff6be284aa0338287cc..2f3dcb7e812b5b57aa33faa04263a9aa9507f9d4 100644 (file)
@@ -83,7 +83,6 @@
   gEfiSecurityPkgTokenSpaceGuid.PcdTpm2InitializationPolicy            ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpm2SelfTestPolicy                  ## SOMETIMES_CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpm2ScrtmPolicy                     ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported              ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice         ## SOMETIMES_CONSUMES\r
   ## SOMETIMES_CONSUMES\r
   ## SOMETIMES_PRODUCES\r
index d07047580c5b2d9eb0cd4a7bf7cfa8237b120f52..8b063c081b528e7fbf3685673fcd4efe585de4b5 100644 (file)
@@ -57,10 +57,17 @@ EFI_PEI_PPI_DESCRIPTOR  mTpmInitializationDonePpiList = {
   NULL\r
 };\r
 \r
+//\r
+// Number of firmware blobs to grow by each time we run out of room\r
+//\r
+#define FIRMWARE_BLOB_GROWTH_STEP 4\r
+\r
 EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredBaseFvInfo;\r
+UINT32 mMeasuredMaxBaseFvIndex = 0;\r
 UINT32 mMeasuredBaseFvIndex = 0;\r
 \r
 EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredChildFvInfo;\r
+UINT32 mMeasuredMaxChildFvIndex = 0;\r
 UINT32 mMeasuredChildFvIndex = 0;\r
 \r
 EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *mMeasurementExcludedFvPpi;\r
@@ -424,13 +431,20 @@ MeasureFvImage (
   //\r
   // Add new FV into the measured FV list.\r
   //\r
-  ASSERT (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-  if (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
-    mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase   = FvBase;\r
-    mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;\r
-    mMeasuredBaseFvIndex++;\r
+  if (mMeasuredBaseFvIndex >= mMeasuredMaxBaseFvIndex) {\r
+    mMeasuredBaseFvInfo = ReallocatePool (\r
+                            sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxBaseFvIndex,\r
+                            sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP),\r
+                            mMeasuredBaseFvInfo\r
+                            );\r
+    ASSERT (mMeasuredBaseFvInfo != NULL);\r
+    mMeasuredMaxBaseFvIndex = mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP;\r
   }\r
 \r
+  mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase   = FvBase;\r
+  mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;\r
+  mMeasuredBaseFvIndex++;\r
+\r
   return Status;\r
 }\r
 \r
@@ -537,20 +551,26 @@ FirmwareVolmeInfoPpiNotifyCallback (
   //\r
   if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {\r
 \r
-    ASSERT (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-    if (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
-      //\r
-      // Check whether FV is in the measured child FV list.\r
-      //\r
-      for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {\r
-        if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {\r
-          return EFI_SUCCESS;\r
-        }\r
+    if (mMeasuredChildFvIndex >= mMeasuredMaxChildFvIndex) {\r
+      mMeasuredChildFvInfo = ReallocatePool (\r
+                               sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxChildFvIndex,\r
+                               sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP),\r
+                               mMeasuredChildFvInfo\r
+                               );\r
+      ASSERT (mMeasuredChildFvInfo != NULL);\r
+      mMeasuredMaxChildFvIndex = mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP;\r
+    }\r
+    //\r
+    // Check whether FV is in the measured child FV list.\r
+    //\r
+    for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {\r
+      if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {\r
+        return EFI_SUCCESS;\r
       }\r
-      mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase   = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;\r
-      mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;\r
-      mMeasuredChildFvIndex++;\r
     }\r
+    mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase   = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;\r
+    mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;\r
+    mMeasuredChildFvIndex++;\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -707,11 +727,6 @@ PeimEntryMP (
                );\r
   // Do not check status, because it is optional\r
 \r
-  mMeasuredBaseFvInfo  = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-  ASSERT (mMeasuredBaseFvInfo != NULL);\r
-  mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-  ASSERT (mMeasuredChildFvInfo != NULL);\r
-\r
   Status = Tpm12RequestUseTpm ();\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
index 4c8a055c6ca54e1cbc378aacb4073e68c565980b..8db93b908fe4a7af5d676c5df9742398cab5f4cc 100644 (file)
@@ -81,7 +81,6 @@
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid                    ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy            ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy                     ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported             ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice        ## SOMETIMES_CONSUMES\r
 \r
 [Depex]\r