MdeModulePkg/SecurityPkg: Update TreePei to handle FvInfo2 and update FwVol of PeiCor...
authorStar Zeng <star.zeng@intel.com>
Tue, 15 Apr 2014 09:19:04 +0000 (09:19 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Apr 2014 09:19:04 +0000 (09:19 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15467 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/FwVol/FwVol.c
SecurityPkg/Tcg/TcgPei/TcgPei.c
SecurityPkg/Tcg/TrEEPei/TrEEPei.c
SecurityPkg/Tcg/TrEEPei/TrEEPei.inf

index ec855a8..fe876ed 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Firmware File System service routines.\r
   \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, 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
@@ -525,6 +525,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
   UINTN                                 FvIndex;\r
   EFI_PEI_FILE_HANDLE                   FileHandle;\r
   VOID                                  *DepexData;\r
+  BOOLEAN                               IsFvInfo2;\r
   \r
   Status       = EFI_SUCCESS;\r
   PrivateData  = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
@@ -540,12 +541,14 @@ FirmwareVolmeInfoPpiNotifyCallback (
     // It is FvInfo2PPI.\r
     //\r
     CopyMem (&FvInfo2Ppi, Ppi, sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));\r
+    IsFvInfo2 = TRUE;\r
   } else {\r
     //\r
     // It is FvInfoPPI.\r
     //\r
     CopyMem (&FvInfo2Ppi, Ppi, sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r
     FvInfo2Ppi.AuthenticationStatus = 0;\r
+    IsFvInfo2 = FALSE;\r
   }\r
 \r
   //\r
@@ -572,6 +575,10 @@ FirmwareVolmeInfoPpiNotifyCallback (
     //\r
     for (FvIndex = 0; FvIndex < PrivateData->FvCount; FvIndex ++) {\r
       if (PrivateData->Fv[FvIndex].FvHandle == FvHandle) {\r
+        if (IsFvInfo2 && (FvInfo2Ppi.AuthenticationStatus != PrivateData->Fv[FvIndex].AuthenticationStatus)) {\r
+          PrivateData->Fv[FvIndex].AuthenticationStatus = FvInfo2Ppi.AuthenticationStatus;\r
+          DEBUG ((EFI_D_INFO, "Update AuthenticationStatus of the %dth FV to 0x%x!\n", FvIndex, FvInfo2Ppi.AuthenticationStatus));          \r
+        }\r
         DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvInfo2Ppi.FvInfo));\r
         return EFI_SUCCESS;\r
       }\r
@@ -1337,8 +1344,16 @@ ProcessFvFile (
   ASSERT_EFI_ERROR (Status);\r
   \r
   //\r
-  // Install FvInfo2 Ppi and Build FvHob\r
+  // Install FvInfo(2) Ppi\r
   //\r
+  PeiServicesInstallFvInfoPpi (\r
+    &FvHeader->FileSystemGuid,\r
+    (VOID**) FvHeader,\r
+    (UINT32) FvHeader->FvLength,\r
+    &ParentFvImageInfo.FvName,\r
+    &FileInfo.FileName\r
+    );\r
+\r
   PeiServicesInstallFvInfo2Ppi (\r
     &FvHeader->FileSystemGuid,\r
     (VOID**) FvHeader,\r
index f3f4b3f..f2650a2 100644 (file)
@@ -461,6 +461,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
   EFI_PEI_FIRMWARE_VOLUME_INFO_PPI  *Fv;\r
   EFI_STATUS                        Status;\r
   EFI_PEI_FIRMWARE_VOLUME_PPI       *FvPpi;\r
+  UINTN                             Index;\r
 \r
   Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *) Ppi;\r
 \r
@@ -485,6 +486,14 @@ FirmwareVolmeInfoPpiNotifyCallback (
     \r
     ASSERT (mMeasuredChildFvIndex < FixedPcdGet32 (PcdPeiCoreMaxFvSupported));\r
     if (mMeasuredChildFvIndex < FixedPcdGet32 (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
+      }\r
       mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase   = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;\r
       mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;\r
       mMeasuredChildFvIndex++;\r
index 5dfbd8d..001a45b 100644 (file)
@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <IndustryStandard/UefiTcgPlatform.h>\r
 #include <Ppi/FirmwareVolumeInfo.h>\r
+#include <Ppi/FirmwareVolumeInfo2.h>\r
 #include <Ppi/LockPhysicalPresence.h>\r
 #include <Ppi/TpmInitialized.h>\r
 #include <Ppi/FirmwareVolume.h>\r
@@ -112,6 +113,11 @@ EFI_PEI_NOTIFY_DESCRIPTOR           mNotifyList[] = {
     &gEfiPeiFirmwareVolumeInfoPpiGuid,\r
     FirmwareVolmeInfoPpiNotifyCallback \r
   },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r
+    &gEfiPeiFirmwareVolumeInfo2PpiGuid,\r
+    FirmwareVolmeInfoPpiNotifyCallback \r
+  },\r
   {\r
     (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
     &gEfiEndOfPeiSignalPpiGuid,\r
@@ -518,6 +524,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
   EFI_PEI_FIRMWARE_VOLUME_INFO_PPI  *Fv;\r
   EFI_STATUS                        Status;\r
   EFI_PEI_FIRMWARE_VOLUME_PPI       *FvPpi;\r
+  UINTN                             Index;\r
 \r
   Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *) Ppi;\r
 \r
@@ -542,6 +549,14 @@ FirmwareVolmeInfoPpiNotifyCallback (
     \r
     ASSERT (mMeasuredChildFvIndex < FixedPcdGet32 (PcdPeiCoreMaxFvSupported));\r
     if (mMeasuredChildFvIndex < FixedPcdGet32 (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
+      }\r
       mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase   = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;\r
       mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;\r
       mMeasuredChildFvIndex++;\r
index 719f2b4..f5fb3d1 100644 (file)
@@ -53,6 +53,7 @@
 \r
 [Ppis]\r
   gEfiPeiFirmwareVolumeInfoPpiGuid\r
+  gEfiPeiFirmwareVolumeInfo2PpiGuid\r
   gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid\r
   gPeiTpmInitializedPpiGuid\r
   gEfiEndOfPeiSignalPpiGuid\r