Skip to content

Commit

Permalink
IntelFsp2WrapperPkg/FspiWrapperPeim : Support FSP-I measurement
Browse files Browse the repository at this point in the history
Add code to support FSP-I binary measurement.

Signed-off-by: Hongbin1 Zhang <[email protected]>
Cc: Chasel Chiu <[email protected]>
Cc: Nate DeSimone <[email protected]>
Cc: Duggapu Chinni B <[email protected]>
Cc: Chen Gang C <[email protected]>
Cc: Star Zeng <[email protected]>
Cc: Ted Kuo <[email protected]>
Cc: Ashraf Ali S <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Jiewen Yao <[email protected]>
  • Loading branch information
hongbin123 committed Dec 17, 2024
1 parent e9d1c6e commit 76f381c
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
90 changes: 90 additions & 0 deletions IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <Library/FspWrapperApiLib.h>
#include <Library/FspWrapperHobProcessLib.h>
#include <Library/FspWrapperApiTestLib.h>
#include <Library/FspMeasurementLib.h>
#include <Ppi/Tcg.h>
#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>

/**
Call FspSmmInit API.
Expand Down Expand Up @@ -135,6 +138,30 @@ FspiWrapperInitDispatchMode (
VOID
)
{
EFI_STATUS Status;
EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;
EFI_PEI_PPI_DESCRIPTOR *MeasurementExcludedPpiList;

MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));
if (MeasurementExcludedFvPpi != NULL) {
MeasurementExcludedFvPpi->Count = 1;
MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspiBaseAddress);
MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspiBaseAddress))->FvLength;
} else {
ASSERT (MeasurementExcludedFvPpi != NULL);
}

MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));
if (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);
} else {
ASSERT (MeasurementExcludedPpiList != NULL);
}

//
// FSP-I Wrapper running in Dispatch mode and reports FSP-I FV to PEI dispatcher.
Expand All @@ -150,6 +177,66 @@ FspiWrapperInitDispatchMode (
return EFI_SUCCESS;
}

/**
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 FSPI\n"));

FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);

if ((FspMeasureMask & FSP_MEASURE_FSPI) != 0) {
MeasureFspFirmwareBlob (
0,
"FSPI",
PcdGet32 (PcdFspiBaseAddress),
(UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspiBaseAddress))->FvLength
);
}

return EFI_SUCCESS;
}

/**
This is the entrypoint of PEIM.
Expand All @@ -169,6 +256,9 @@ FspiWrapperPeimEntryPoint (

DEBUG ((DEBUG_INFO, "FspiWrapperPeimEntryPoint\n"));

Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);
ASSERT_EFI_ERROR (Status);

if (PcdGet8 (PcdFspModeSelection) == 1) {
Status = FspiWrapperInitApiMode ();
} else {
Expand Down
5 changes: 5 additions & 0 deletions IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.inf
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,24 @@
PerformanceLib
FspWrapperApiLib
FspWrapperApiTestLib
FspMeasurementLib

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
IntelFsp2Pkg/IntelFsp2Pkg.dec
SecurityPkg/SecurityPkg.dec
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec

[Ppis]
gEdkiiTcgPpiGuid ## NOTIFY
gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid ## PRODUCES

[Pcd]
gIntelFsp2WrapperTokenSpaceGuid.PcdFspiBaseAddress ## CONSUMES
gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection ## CONSUMES
gIntelFsp2WrapperTokenSpaceGuid.PcdFspiUpdDataAddress ## CONSUMES
gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig ## CONSUMES

[Guids]
gFspHobGuid ## CONSUMES ## HOB
Expand Down
1 change: 1 addition & 0 deletions IntelFsp2WrapperPkg/Include/Library/FspMeasurementLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define FSP_MEASURE_FSPT BIT1
#define FSP_MEASURE_FSPM BIT2
#define FSP_MEASURE_FSPS BIT3
#define FSP_MEASURE_FSPI BIT4
#define FSP_MEASURE_FSPUPD BIT31

/**
Expand Down

0 comments on commit 76f381c

Please sign in to comment.