[edk2-devel] [PATCH v3 4/8] IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add FspBin measurement.

Qi Zhang posted 8 patches 5 years, 5 months ago
There is a newer version of this series
[edk2-devel] [PATCH v3 4/8] IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add FspBin measurement.
Posted by Qi Zhang 5 years, 5 months ago
From: Jiewen Yao <jiewen.yao@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2376

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
---
 .../FspmWrapperPeim/FspmWrapperPeim.c         | 90 ++++++++++++++++++-
 .../FspmWrapperPeim/FspmWrapperPeim.inf       | 20 +++--
 .../FspsWrapperPeim/FspsWrapperPeim.c         | 86 +++++++++++++++++-
 .../FspsWrapperPeim/FspsWrapperPeim.inf       | 27 +++---
 4 files changed, 204 insertions(+), 19 deletions(-)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
index 265b77ed60..24ab534620 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
   notify to call FspSiliconInit API.
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -25,11 +25,14 @@
 #include <Library/FspWrapperPlatformLib.h>
 #include <Library/FspWrapperHobProcessLib.h>
 #include <Library/FspWrapperApiLib.h>
+#include <Library/FspMeasurementLib.h>
 
 #include <Ppi/FspSiliconInitDone.h>
 #include <Ppi/EndOfPeiPhase.h>
 #include <Ppi/MemoryDiscovered.h>
 #include <Ppi/SecPlatformInformation.h>
+#include <Ppi/Tcg.h>
+#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
 #include <Library/FspWrapperApiTestLib.h>
 #include <FspEas.h>
 #include <FspStatusCode.h>
@@ -147,7 +150,21 @@ FspmWrapperInit (
   VOID
   )
 {
-  EFI_STATUS           Status;
+  EFI_STATUS                                            Status;
+  EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;
+  EFI_PEI_PPI_DESCRIPTOR                                *MeasurementExcludedPpiList;
+
+  MeasurementExcludedFvPpi = AllocatePool (sizeof(*MeasurementExcludedFvPpi));
+  ASSERT(MeasurementExcludedFvPpi != NULL);
+  MeasurementExcludedFvPpi->Count = 1;
+  MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspmBaseAddress);
+  MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspmBaseAddress))->FvLength;
+
+  MeasurementExcludedPpiList = AllocatePool (sizeof(*MeasurementExcludedPpiList));
+  ASSERT(MeasurementExcludedPpiList != NULL);
+  MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+  MeasurementExcludedPpiList->Guid  = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
+  MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
 
   Status = EFI_SUCCESS;
 
@@ -155,6 +172,9 @@ FspmWrapperInit (
     Status = PeiFspMemoryInit ();
     ASSERT_EFI_ERROR (Status);
   } else {
+    Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);
+    ASSERT_EFI_ERROR (Status);
+
     PeiServicesInstallFvInfoPpi (
       NULL,
       (VOID *)(UINTN) PcdGet32 (PcdFspmBaseAddress),
@@ -167,6 +187,67 @@ FspmWrapperInit (
   return Status;
 }
 
+/**
+  This function is called after TCG installed PPI.
+
+  @param[in] PeiServices    Pointer to PEI Services Table.
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that
+                            caused this function to execute.
+  @param[in] Ppi            Pointer to the PPI data associated with this function.
+
+  @retval EFI_STATUS        Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TcgPpiNotify (
+  IN EFI_PEI_SERVICES          **PeiServices,
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+  IN VOID                      *Ppi
+  );
+
+EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  &gEdkiiTcgPpiGuid,
+  TcgPpiNotify
+};
+
+/**
+  This function is called after TCG installed PPI.
+
+  @param[in] PeiServices    Pointer to PEI Services Table.
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that
+                            caused this function to execute.
+  @param[in] Ppi            Pointer to the PPI data associated with this function.
+
+  @retval EFI_STATUS        Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TcgPpiNotify (
+  IN EFI_PEI_SERVICES          **PeiServices,
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+  IN VOID                      *Ppi
+  )
+{
+  UINT32                    FspMeasureMask;
+
+  DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPM\n"));
+
+  FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);
+
+  if ((FspMeasureMask & FSP_MEASURE_FSPT) != 0) {
+    MeasureFspFirmwareBlob (0, "FSPT", PcdGet32(PcdFsptBaseAddress),
+                            (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFsptBaseAddress))->FvLength);
+  }
+
+  if ((FspMeasureMask & FSP_MEASURE_FSPM) != 0) {
+    MeasureFspFirmwareBlob (0, "FSPM", PcdGet32(PcdFspmBaseAddress),
+                            (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspmBaseAddress))->FvLength);
+  }
+
+  return EFI_SUCCESS;
+}
+
 /**
   This is the entrypoint of PEIM
 
@@ -182,8 +263,13 @@ FspmWrapperPeimEntryPoint (
   IN CONST EFI_PEI_SERVICES     **PeiServices
   )
 {
+  EFI_STATUS  Status;
+
   DEBUG((DEBUG_INFO, "FspmWrapperPeimEntryPoint\n"));
 
+  Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);
+  ASSERT_EFI_ERROR (Status);
+
   FspmWrapperInit ();
 
   return EFI_SUCCESS;
diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
index dce7ef3d0b..c3578397b6 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
@@ -6,7 +6,7 @@
 # register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
 # notify to call FspSiliconInit API.
 #
-#  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -44,17 +44,22 @@
   TimerLib
   FspWrapperApiLib
   FspWrapperApiTestLib
+  FspMeasurementLib
 
 [Packages]
   MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   UefiCpuPkg/UefiCpuPkg.dec
+  SecurityPkg/SecurityPkg.dec
   IntelFsp2Pkg/IntelFsp2Pkg.dec
   IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
 
 [Pcd]
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress     ## CONSUMES
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress  ## CONSUMES
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection    ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress       ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress    ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection      ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFsptBaseAddress       ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig  ## CONSUMES
 
 [Sources]
   FspmWrapperPeim.c
@@ -63,5 +68,10 @@
   gFspHobGuid                           ## PRODUCES ## HOB
   gFspApiPerformanceGuid                ## SOMETIMES_CONSUMES ## GUID
 
+[Ppis]
+  gEdkiiTcgPpiGuid                                       ## NOTIFY
+  gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid    ## PRODUCES
+
 [Depex]
-  gEfiPeiMasterBootModePpiGuid
+  gEfiPeiMasterBootModePpiGuid AND
+  gPeiTpmInitializationDonePpiGuid
diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
index b20f0805a0..9d4f279e81 100644
--- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
   notify to call FspSiliconInit API.
 
-  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -24,12 +24,15 @@
 #include <Library/TimerLib.h>
 #include <Library/PerformanceLib.h>
 #include <Library/FspWrapperApiLib.h>
+#include <Library/FspMeasurementLib.h>
 
 #include <Ppi/FspSiliconInitDone.h>
 #include <Ppi/EndOfPeiPhase.h>
 #include <Ppi/MemoryDiscovered.h>
 #include <Ppi/TemporaryRamDone.h>
 #include <Ppi/SecPlatformInformation.h>
+#include <Ppi/Tcg.h>
+#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
 #include <Library/FspWrapperApiTestLib.h>
 #include <FspEas.h>
 #include <FspStatusCode.h>
@@ -379,7 +382,25 @@ FspsWrapperInitDispatchMode (
   VOID
   )
 {
-  EFI_STATUS           Status;
+  EFI_STATUS                                            Status;
+  EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;
+  EFI_PEI_PPI_DESCRIPTOR                                *MeasurementExcludedPpiList;
+
+  MeasurementExcludedFvPpi = AllocatePool (sizeof(*MeasurementExcludedFvPpi));
+  ASSERT(MeasurementExcludedFvPpi != NULL);
+  MeasurementExcludedFvPpi->Count = 1;
+  MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspsBaseAddress);
+  MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspsBaseAddress))->FvLength;
+
+  MeasurementExcludedPpiList = AllocatePool (sizeof(*MeasurementExcludedPpiList));
+  ASSERT(MeasurementExcludedPpiList != NULL);
+  MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+  MeasurementExcludedPpiList->Guid  = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
+  MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
+
+  Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);
+  ASSERT_EFI_ERROR (Status);
+
   //
   // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI dispatcher.
   //
@@ -398,6 +419,62 @@ FspsWrapperInitDispatchMode (
   return Status;
 }
 
+/**
+  This function is called after TCG installed PPI.
+
+  @param[in] PeiServices    Pointer to PEI Services Table.
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that
+                            caused this function to execute.
+  @param[in] Ppi            Pointer to the PPI data associated with this function.
+
+  @retval EFI_STATUS        Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TcgPpiNotify (
+  IN EFI_PEI_SERVICES          **PeiServices,
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+  IN VOID                      *Ppi
+  );
+
+EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  &gEdkiiTcgPpiGuid,
+  TcgPpiNotify
+};
+
+/**
+  This function is called after TCG installed PPI.
+
+  @param[in] PeiServices    Pointer to PEI Services Table.
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that
+                            caused this function to execute.
+  @param[in] Ppi            Pointer to the PPI data associated with this function.
+
+  @retval EFI_STATUS        Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TcgPpiNotify (
+  IN EFI_PEI_SERVICES          **PeiServices,
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+  IN VOID                      *Ppi
+  )
+{
+  UINT32                    FspMeasureMask;
+
+  DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPS\n"));
+
+  FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);
+
+  if ((FspMeasureMask & FSP_MEASURE_FSPS) != 0) {
+    MeasureFspFirmwareBlob (0, "FSPS", PcdGet32(PcdFspsBaseAddress),
+                            (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspsBaseAddress))->FvLength);
+  }
+
+  return EFI_SUCCESS;
+}
+
 /**
   This is the entrypoint of PEIM.
 
@@ -413,8 +490,13 @@ FspsWrapperPeimEntryPoint (
   IN CONST EFI_PEI_SERVICES     **PeiServices
   )
 {
+  EFI_STATUS  Status;
+
   DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));
 
+  Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);
+  ASSERT_EFI_ERROR (Status);
+
   if (PcdGet8 (PcdFspModeSelection) == 1) {
     FspsWrapperInitApiMode ();
   } else {
diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
index 7da92991c8..884514747f 100644
--- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
@@ -6,7 +6,7 @@
 # register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
 # notify to call FspSiliconInit API.
 #
-#  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -44,24 +44,30 @@
   PerformanceLib
   FspWrapperApiLib
   FspWrapperApiTestLib
+  FspMeasurementLib
 
 [Packages]
   MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   UefiCpuPkg/UefiCpuPkg.dec
+  SecurityPkg/SecurityPkg.dec
   IntelFsp2Pkg/IntelFsp2Pkg.dec
   IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
 
 [Ppis]
-  gTopOfTemporaryRamPpiGuid             ## PRODUCES
-  gFspSiliconInitDonePpiGuid            ## PRODUCES
-  gEfiEndOfPeiSignalPpiGuid             ## PRODUCES
-  gEfiTemporaryRamDonePpiGuid           ## PRODUCES
-  gEfiPeiMemoryDiscoveredPpiGuid        ## NOTIFY
+  gTopOfTemporaryRamPpiGuid                              ## PRODUCES
+  gFspSiliconInitDonePpiGuid                             ## PRODUCES
+  gEfiEndOfPeiSignalPpiGuid                              ## PRODUCES
+  gEfiTemporaryRamDonePpiGuid                            ## PRODUCES
+  gEfiPeiMemoryDiscoveredPpiGuid                         ## NOTIFY
+  gEdkiiTcgPpiGuid                                       ## NOTIFY
+  gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid    ## PRODUCES
 
 [Pcd]
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress     ## CONSUMES
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsUpdDataAddress  ## CONSUMES
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection    ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress       ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsUpdDataAddress    ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection      ## CONSUMES
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig  ## CONSUMES
 
 [Guids]
   gFspHobGuid                           ## CONSUMES ## HOB
@@ -71,4 +77,5 @@
   FspsWrapperPeim.c
 
 [Depex]
-  gEfiPeiMemoryDiscoveredPpiGuid
+  gEfiPeiMemoryDiscoveredPpiGuid AND
+  gPeiTpmInitializationDonePpiGuid
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64278): https://edk2.groups.io/g/devel/message/64278
Mute This Topic: https://groups.io/mt/76183470/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v3 4/8] IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add FspBin measurement.
Posted by Chiu, Chasel 5 years, 5 months ago
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: Zhang, Qi1 <qi1.zhang@intel.com>
> Sent: Friday, August 14, 2020 2:32 PM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Zhang,
> Qi1 <qi1.zhang@intel.com>
> Subject: [PATCH v3 4/8] IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add
> FspBin measurement.
> 
> From: Jiewen Yao <jiewen.yao@intel.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2376
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Qi Zhang <qi1.zhang@intel.com>
> Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
> ---
>  .../FspmWrapperPeim/FspmWrapperPeim.c         | 90
> ++++++++++++++++++-
>  .../FspmWrapperPeim/FspmWrapperPeim.inf       | 20 +++--
>  .../FspsWrapperPeim/FspsWrapperPeim.c         | 86
> +++++++++++++++++-
>  .../FspsWrapperPeim/FspsWrapperPeim.inf       | 27 +++---
>  4 files changed, 204 insertions(+), 19 deletions(-)
> 
> diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
> b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
> index 265b77ed60..24ab534620 100644
> --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
> +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
> @@ -3,7 +3,7 @@
>    register TemporaryRamDonePpi to call TempRamExit API, and register
> MemoryDiscoveredPpi
> 
>    notify to call FspSiliconInit API.
> 
> 
> 
> -  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
> 
> +  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
>  **/
> 
> @@ -25,11 +25,14 @@
>  #include <Library/FspWrapperPlatformLib.h>
> 
>  #include <Library/FspWrapperHobProcessLib.h>
> 
>  #include <Library/FspWrapperApiLib.h>
> 
> +#include <Library/FspMeasurementLib.h>
> 
> 
> 
>  #include <Ppi/FspSiliconInitDone.h>
> 
>  #include <Ppi/EndOfPeiPhase.h>
> 
>  #include <Ppi/MemoryDiscovered.h>
> 
>  #include <Ppi/SecPlatformInformation.h>
> 
> +#include <Ppi/Tcg.h>
> 
> +#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
> 
>  #include <Library/FspWrapperApiTestLib.h>
> 
>  #include <FspEas.h>
> 
>  #include <FspStatusCode.h>
> 
> @@ -147,7 +150,21 @@ FspmWrapperInit (
>    VOID
> 
>    )
> 
>  {
> 
> -  EFI_STATUS           Status;
> 
> +  EFI_STATUS                                            Status;
> 
> +  EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI
> *MeasurementExcludedFvPpi;
> 
> +  EFI_PEI_PPI_DESCRIPTOR
> *MeasurementExcludedPpiList;
> 
> +
> 
> +  MeasurementExcludedFvPpi = AllocatePool
> (sizeof(*MeasurementExcludedFvPpi));
> 
> +  ASSERT(MeasurementExcludedFvPpi != NULL);
> 
> +  MeasurementExcludedFvPpi->Count = 1;
> 
> +  MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32
> (PcdFspmBaseAddress);
> 
> +  MeasurementExcludedFvPpi->Fv[0].FvLength =
> ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFspmBaseAddress))->FvLength;
> 
> +
> 
> +  MeasurementExcludedPpiList = AllocatePool
> (sizeof(*MeasurementExcludedPpiList));
> 
> +  ASSERT(MeasurementExcludedPpiList != NULL);
> 
> +  MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
> 
> +  MeasurementExcludedPpiList->Guid  =
> &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
> 
> +  MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
> 
> 
> 
>    Status = EFI_SUCCESS;
> 
> 
> 
> @@ -155,6 +172,9 @@ FspmWrapperInit (
>      Status = PeiFspMemoryInit ();
> 
>      ASSERT_EFI_ERROR (Status);
> 
>    } else {
> 
> +    Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);
> 
> +    ASSERT_EFI_ERROR (Status);
> 
> +
> 
>      PeiServicesInstallFvInfoPpi (
> 
>        NULL,
> 
>        (VOID *)(UINTN) PcdGet32 (PcdFspmBaseAddress),
> 
> @@ -167,6 +187,67 @@ FspmWrapperInit (
>    return Status;
> 
>  }
> 
> 
> 
> +/**
> 
> +  This function is called after TCG installed PPI.
> 
> +
> 
> +  @param[in] PeiServices    Pointer to PEI Services Table.
> 
> +  @param[in] NotifyDesc     Pointer to the descriptor for the
> Notification event that
> 
> +                            caused this function to execute.
> 
> +  @param[in] Ppi            Pointer to the PPI data associated with this
> function.
> 
> +
> 
> +  @retval EFI_STATUS        Always return EFI_SUCCESS
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +TcgPpiNotify (
> 
> +  IN EFI_PEI_SERVICES          **PeiServices,
> 
> +  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
> 
> +  IN VOID                      *Ppi
> 
> +  );
> 
> +
> 
> +EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {
> 
> +  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> 
> +  &gEdkiiTcgPpiGuid,
> 
> +  TcgPpiNotify
> 
> +};
> 
> +
> 
> +/**
> 
> +  This function is called after TCG installed PPI.
> 
> +
> 
> +  @param[in] PeiServices    Pointer to PEI Services Table.
> 
> +  @param[in] NotifyDesc     Pointer to the descriptor for the
> Notification event that
> 
> +                            caused this function to execute.
> 
> +  @param[in] Ppi            Pointer to the PPI data associated with this
> function.
> 
> +
> 
> +  @retval EFI_STATUS        Always return EFI_SUCCESS
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +TcgPpiNotify (
> 
> +  IN EFI_PEI_SERVICES          **PeiServices,
> 
> +  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
> 
> +  IN VOID                      *Ppi
> 
> +  )
> 
> +{
> 
> +  UINT32                    FspMeasureMask;
> 
> +
> 
> +  DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPM\n"));
> 
> +
> 
> +  FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);
> 
> +
> 
> +  if ((FspMeasureMask & FSP_MEASURE_FSPT) != 0) {
> 
> +    MeasureFspFirmwareBlob (0, "FSPT", PcdGet32(PcdFsptBaseAddress),
> 
> +
> (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFsptBaseAddress))->FvLength);
> 
> +  }
> 
> +
> 
> +  if ((FspMeasureMask & FSP_MEASURE_FSPM) != 0) {
> 
> +    MeasureFspFirmwareBlob (0, "FSPM",
> PcdGet32(PcdFspmBaseAddress),
> 
> +
> (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFspmBaseAddress))->FvLength);
> 
> +  }
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> +
> 
>  /**
> 
>    This is the entrypoint of PEIM
> 
> 
> 
> @@ -182,8 +263,13 @@ FspmWrapperPeimEntryPoint (
>    IN CONST EFI_PEI_SERVICES     **PeiServices
> 
>    )
> 
>  {
> 
> +  EFI_STATUS  Status;
> 
> +
> 
>    DEBUG((DEBUG_INFO, "FspmWrapperPeimEntryPoint\n"));
> 
> 
> 
> +  Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);
> 
> +  ASSERT_EFI_ERROR (Status);
> 
> +
> 
>    FspmWrapperInit ();
> 
> 
> 
>    return EFI_SUCCESS;
> 
> diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> index dce7ef3d0b..c3578397b6 100644
> --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> @@ -6,7 +6,7 @@
>  # register TemporaryRamDonePpi to call TempRamExit API, and register
> MemoryDiscoveredPpi
> 
>  # notify to call FspSiliconInit API.
> 
>  #
> 
> -#  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
> 
> +#  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
> 
>  #
> 
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #
> 
> @@ -44,17 +44,22 @@
>    TimerLib
> 
>    FspWrapperApiLib
> 
>    FspWrapperApiTestLib
> 
> +  FspMeasurementLib
> 
> 
> 
>  [Packages]
> 
>    MdePkg/MdePkg.dec
> 
> +  MdeModulePkg/MdeModulePkg.dec
> 
>    UefiCpuPkg/UefiCpuPkg.dec
> 
> +  SecurityPkg/SecurityPkg.dec
> 
>    IntelFsp2Pkg/IntelFsp2Pkg.dec
> 
>    IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
> 
> 
> 
>  [Pcd]
> 
> -  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress     ##
> CONSUMES
> 
> -  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress  ##
> CONSUMES
> 
> -  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection    ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress       ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress    ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection      ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFsptBaseAddress       ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig  ##
> CONSUMES
> 
> 
> 
>  [Sources]
> 
>    FspmWrapperPeim.c
> 
> @@ -63,5 +68,10 @@
>    gFspHobGuid                           ## PRODUCES ## HOB
> 
>    gFspApiPerformanceGuid                ## SOMETIMES_CONSUMES
> ## GUID
> 
> 
> 
> +[Ppis]
> 
> +  gEdkiiTcgPpiGuid                                       ##
> NOTIFY
> 
> +  gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid    ##
> PRODUCES
> 
> +
> 
>  [Depex]
> 
> -  gEfiPeiMasterBootModePpiGuid
> 
> +  gEfiPeiMasterBootModePpiGuid AND
> 
> +  gPeiTpmInitializationDonePpiGuid
> 
> diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
> b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
> index b20f0805a0..9d4f279e81 100644
> --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
> +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
> @@ -3,7 +3,7 @@
>    register TemporaryRamDonePpi to call TempRamExit API, and register
> MemoryDiscoveredPpi
> 
>    notify to call FspSiliconInit API.
> 
> 
> 
> -  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
> 
> +  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
>  **/
> 
> @@ -24,12 +24,15 @@
>  #include <Library/TimerLib.h>
> 
>  #include <Library/PerformanceLib.h>
> 
>  #include <Library/FspWrapperApiLib.h>
> 
> +#include <Library/FspMeasurementLib.h>
> 
> 
> 
>  #include <Ppi/FspSiliconInitDone.h>
> 
>  #include <Ppi/EndOfPeiPhase.h>
> 
>  #include <Ppi/MemoryDiscovered.h>
> 
>  #include <Ppi/TemporaryRamDone.h>
> 
>  #include <Ppi/SecPlatformInformation.h>
> 
> +#include <Ppi/Tcg.h>
> 
> +#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
> 
>  #include <Library/FspWrapperApiTestLib.h>
> 
>  #include <FspEas.h>
> 
>  #include <FspStatusCode.h>
> 
> @@ -379,7 +382,25 @@ FspsWrapperInitDispatchMode (
>    VOID
> 
>    )
> 
>  {
> 
> -  EFI_STATUS           Status;
> 
> +  EFI_STATUS                                            Status;
> 
> +  EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI
> *MeasurementExcludedFvPpi;
> 
> +  EFI_PEI_PPI_DESCRIPTOR
> *MeasurementExcludedPpiList;
> 
> +
> 
> +  MeasurementExcludedFvPpi = AllocatePool
> (sizeof(*MeasurementExcludedFvPpi));
> 
> +  ASSERT(MeasurementExcludedFvPpi != NULL);
> 
> +  MeasurementExcludedFvPpi->Count = 1;
> 
> +  MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32
> (PcdFspsBaseAddress);
> 
> +  MeasurementExcludedFvPpi->Fv[0].FvLength =
> ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFspsBaseAddress))->FvLength;
> 
> +
> 
> +  MeasurementExcludedPpiList = AllocatePool
> (sizeof(*MeasurementExcludedPpiList));
> 
> +  ASSERT(MeasurementExcludedPpiList != NULL);
> 
> +  MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
> 
> +  MeasurementExcludedPpiList->Guid  =
> &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
> 
> +  MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
> 
> +
> 
> +  Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);
> 
> +  ASSERT_EFI_ERROR (Status);
> 
> +
> 
>    //
> 
>    // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI
> dispatcher.
> 
>    //
> 
> @@ -398,6 +419,62 @@ FspsWrapperInitDispatchMode (
>    return Status;
> 
>  }
> 
> 
> 
> +/**
> 
> +  This function is called after TCG installed PPI.
> 
> +
> 
> +  @param[in] PeiServices    Pointer to PEI Services Table.
> 
> +  @param[in] NotifyDesc     Pointer to the descriptor for the
> Notification event that
> 
> +                            caused this function to execute.
> 
> +  @param[in] Ppi            Pointer to the PPI data associated with this
> function.
> 
> +
> 
> +  @retval EFI_STATUS        Always return EFI_SUCCESS
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +TcgPpiNotify (
> 
> +  IN EFI_PEI_SERVICES          **PeiServices,
> 
> +  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
> 
> +  IN VOID                      *Ppi
> 
> +  );
> 
> +
> 
> +EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {
> 
> +  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> 
> +  &gEdkiiTcgPpiGuid,
> 
> +  TcgPpiNotify
> 
> +};
> 
> +
> 
> +/**
> 
> +  This function is called after TCG installed PPI.
> 
> +
> 
> +  @param[in] PeiServices    Pointer to PEI Services Table.
> 
> +  @param[in] NotifyDesc     Pointer to the descriptor for the
> Notification event that
> 
> +                            caused this function to execute.
> 
> +  @param[in] Ppi            Pointer to the PPI data associated with this
> function.
> 
> +
> 
> +  @retval EFI_STATUS        Always return EFI_SUCCESS
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +TcgPpiNotify (
> 
> +  IN EFI_PEI_SERVICES          **PeiServices,
> 
> +  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
> 
> +  IN VOID                      *Ppi
> 
> +  )
> 
> +{
> 
> +  UINT32                    FspMeasureMask;
> 
> +
> 
> +  DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPS\n"));
> 
> +
> 
> +  FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);
> 
> +
> 
> +  if ((FspMeasureMask & FSP_MEASURE_FSPS) != 0) {
> 
> +    MeasureFspFirmwareBlob (0, "FSPS", PcdGet32(PcdFspsBaseAddress),
> 
> +
> (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFspsBaseAddress))->FvLength);
> 
> +  }
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> +
> 
>  /**
> 
>    This is the entrypoint of PEIM.
> 
> 
> 
> @@ -413,8 +490,13 @@ FspsWrapperPeimEntryPoint (
>    IN CONST EFI_PEI_SERVICES     **PeiServices
> 
>    )
> 
>  {
> 
> +  EFI_STATUS  Status;
> 
> +
> 
>    DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));
> 
> 
> 
> +  Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);
> 
> +  ASSERT_EFI_ERROR (Status);
> 
> +
> 
>    if (PcdGet8 (PcdFspModeSelection) == 1) {
> 
>      FspsWrapperInitApiMode ();
> 
>    } else {
> 
> diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> index 7da92991c8..884514747f 100644
> --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> @@ -6,7 +6,7 @@
>  # register TemporaryRamDonePpi to call TempRamExit API, and register
> MemoryDiscoveredPpi
> 
>  # notify to call FspSiliconInit API.
> 
>  #
> 
> -#  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
> 
> +#  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
> 
>  #
> 
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #
> 
> @@ -44,24 +44,30 @@
>    PerformanceLib
> 
>    FspWrapperApiLib
> 
>    FspWrapperApiTestLib
> 
> +  FspMeasurementLib
> 
> 
> 
>  [Packages]
> 
>    MdePkg/MdePkg.dec
> 
> +  MdeModulePkg/MdeModulePkg.dec
> 
>    UefiCpuPkg/UefiCpuPkg.dec
> 
> +  SecurityPkg/SecurityPkg.dec
> 
>    IntelFsp2Pkg/IntelFsp2Pkg.dec
> 
>    IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
> 
> 
> 
>  [Ppis]
> 
> -  gTopOfTemporaryRamPpiGuid             ## PRODUCES
> 
> -  gFspSiliconInitDonePpiGuid            ## PRODUCES
> 
> -  gEfiEndOfPeiSignalPpiGuid             ## PRODUCES
> 
> -  gEfiTemporaryRamDonePpiGuid           ## PRODUCES
> 
> -  gEfiPeiMemoryDiscoveredPpiGuid        ## NOTIFY
> 
> +  gTopOfTemporaryRamPpiGuid                              ##
> PRODUCES
> 
> +  gFspSiliconInitDonePpiGuid                             ##
> PRODUCES
> 
> +  gEfiEndOfPeiSignalPpiGuid                              ##
> PRODUCES
> 
> +  gEfiTemporaryRamDonePpiGuid                            ##
> PRODUCES
> 
> +  gEfiPeiMemoryDiscoveredPpiGuid                         ##
> NOTIFY
> 
> +  gEdkiiTcgPpiGuid                                       ##
> NOTIFY
> 
> +  gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid    ##
> PRODUCES
> 
> 
> 
>  [Pcd]
> 
> -  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress     ##
> CONSUMES
> 
> -  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsUpdDataAddress  ##
> CONSUMES
> 
> -  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection    ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress       ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsUpdDataAddress    ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection      ##
> CONSUMES
> 
> +  gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig  ##
> CONSUMES
> 
> 
> 
>  [Guids]
> 
>    gFspHobGuid                           ## CONSUMES ## HOB
> 
> @@ -71,4 +77,5 @@
>    FspsWrapperPeim.c
> 
> 
> 
>  [Depex]
> 
> -  gEfiPeiMemoryDiscoveredPpiGuid
> 
> +  gEfiPeiMemoryDiscoveredPpiGuid AND
> 
> +  gPeiTpmInitializationDonePpiGuid
> 
> --
> 2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64349): https://edk2.groups.io/g/devel/message/64349
Mute This Topic: https://groups.io/mt/76183470/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-