TianoCore EDK2 master
Loading...
Searching...
No Matches
TcgPei.c File Reference

Go to the source code of this file.

Macros

#define FIRMWARE_BLOB_GROWTH_STEP   4
 

Functions

EFI_STATUS EFIAPI HashLogExtendEvent (IN EDKII_TCG_PPI *This, IN UINT64 Flags, IN UINT8 *HashData, IN UINTN HashDataLen, IN TCG_PCR_EVENT_HDR *NewEventHdr, IN UINT8 *NewEventData)
 
EFI_STATUS EFIAPI PhysicalPresencePpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
 
EFI_STATUS EFIAPI FirmwareVolumeInfoPpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
 
EFI_STATUS EFIAPI EndofPeiSignalNotifyCallBack (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
 
EFI_STATUS EFIAPI TpmCommHashAll (IN CONST UINT8 *Data, IN UINTN DataLen, OUT TPM_DIGEST *Digest)
 
EFI_STATUS EFIAPI MeasureCRTMVersion (IN EFI_PEI_SERVICES **PeiServices)
 
EFI_STATUS EFIAPI MeasureFvImage (IN EFI_PHYSICAL_ADDRESS FvBase, IN UINT64 FvLength)
 
EFI_STATUS EFIAPI MeasureMainBios (IN EFI_PEI_SERVICES **PeiServices)
 
BOOLEAN IsTpmUsable (VOID)
 
EFI_STATUS EFIAPI PeimEntryMP (IN EFI_PEI_SERVICES **PeiServices)
 
EFI_STATUS EFIAPI PeimEntryMA (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 

Variables

BOOLEAN mImageInMemory = FALSE
 
EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList
 
EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList
 
EDKII_TCG_PPI mEdkiiTcgPpi
 
EFI_PEI_PPI_DESCRIPTOR mTcgPpiList
 
EFI_PLATFORM_FIRMWARE_BLOBmMeasuredBaseFvInfo
 
UINT32 mMeasuredMaxBaseFvIndex = 0
 
UINT32 mMeasuredBaseFvIndex = 0
 
EFI_PLATFORM_FIRMWARE_BLOBmMeasuredChildFvInfo
 
UINT32 mMeasuredMaxChildFvIndex = 0
 
UINT32 mMeasuredChildFvIndex = 0
 
EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPImMeasurementExcludedFvPpi
 
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList []
 

Detailed Description

Initialize TPM device and measure FVs before handing off control to DXE.

Copyright (c) 2005 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file TcgPei.c.

Macro Definition Documentation

◆ FIRMWARE_BLOB_GROWTH_STEP

#define FIRMWARE_BLOB_GROWTH_STEP   4

Definition at line 98 of file TcgPei.c.

Function Documentation

◆ EndofPeiSignalNotifyCallBack()

EFI_STATUS EFIAPI EndofPeiSignalNotifyCallBack ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor,
IN VOID *  Ppi 
)

Record all measured Firmware Volume Information into a Guid Hob

Parameters
[in]PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in]NotifyDescriptorAddress of the notification descriptor data structure.
[in]PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSThe FV Info is measured and recorded to TPM.
Returns
Others Fail to measure FV.

Record all measured Firmware Volume Information into a Guid Hob Guid Hob payload layout is

UINT32 *************************** FIRMWARE_BLOB number EFI_PLATFORM_FIRMWARE_BLOB******** BLOB Array

Parameters
[in]PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in]NotifyDescriptorAddress of the notification descriptor data structure.
[in]PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSThe FV Info is measured and recorded to TPM.
Returns
Others Fail to measure FV.

Definition at line 206 of file TcgPei.c.

◆ FirmwareVolumeInfoPpiNotifyCallback()

EFI_STATUS EFIAPI FirmwareVolumeInfoPpiNotifyCallback ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor,
IN VOID *  Ppi 
)

Measure and record the Firmware Volume Information once FvInfoPPI install.

Parameters
[in]PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in]NotifyDescriptorAddress of the notification descriptor data structure.
[in]PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSThe FV Info is measured and recorded to TPM.
Returns
Others Fail to measure FV.

Definition at line 588 of file TcgPei.c.

◆ HashLogExtendEvent()

EFI_STATUS EFIAPI HashLogExtendEvent ( IN EDKII_TCG_PPI This,
IN UINT64  Flags,
IN UINT8 *  HashData,
IN UINTN  HashDataLen,
IN TCG_PCR_EVENT_HDR NewEventHdr,
IN UINT8 *  NewEventData 
)

Do a hash operation on a data buffer, extend a specific TPM PCR with the hash result, and build a GUIDed HOB recording the event which will be passed to the DXE phase and added into the Event Log.

Parameters
[in]ThisIndicates the calling context
[in]FlagsBitmap providing additional information.
[in]HashDataPhysical address of the start of the data buffer to be hashed, extended, and logged.
[in]HashDataLenThe length, in bytes, of the buffer referenced by HashData.
[in]NewEventHdrPointer to a TCG_PCR_EVENT_HDR data structure.
[in]NewEventDataPointer to the new event data.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_OUT_OF_RESOURCESNo enough memory to log the new event.
EFI_DEVICE_ERRORThe command was unsuccessful.

Do a hash operation on a data buffer, extend a specific TPM PCR with the hash result, and build a GUIDed HOB recording the event which will be passed to the DXE phase and added into the Event Log.

Parameters
[in]ThisIndicates the calling context.
[in]FlagsBitmap providing additional information.
[in]HashDataPhysical address of the start of the data buffer to be hashed, extended, and logged.
[in]HashDataLenThe length, in bytes, of the buffer referenced by HashData.
[in]NewEventHdrPointer to a TCG_PCR_EVENT_HDR data structure.
[in]NewEventDataPointer to the new event data.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_OUT_OF_RESOURCESNo enough memory to log the new event.
EFI_DEVICE_ERRORThe command was unsuccessful.

Definition at line 302 of file TcgPei.c.

◆ IsTpmUsable()

BOOLEAN IsTpmUsable ( VOID  )

Check if TPM chip is activated or not.

Parameters
[in]PeiServicesDescribes the list of possible PEI Services.
Return values
TRUETPM is activated.
FALSETPM is deactivated.

Definition at line 757 of file TcgPei.c.

◆ MeasureCRTMVersion()

EFI_STATUS EFIAPI MeasureCRTMVersion ( IN EFI_PEI_SERVICES **  PeiServices)

Measure CRTM version.

Parameters
[in]PeiServicesDescribes the list of possible PEI Services.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_OUT_OF_RESOURCESNo enough memory to log the new event.
EFI_DEVICE_ERRORThe command was unsuccessful.

Definition at line 378 of file TcgPei.c.

◆ MeasureFvImage()

EFI_STATUS EFIAPI MeasureFvImage ( IN EFI_PHYSICAL_ADDRESS  FvBase,
IN UINT64  FvLength 
)

Measure FV image. Add it into the measured FV list after the FV is measured successfully.

Parameters
[in]FvBaseBase address of FV image.
[in]FvLengthLength of FV image.
Return values
EFI_SUCCESSFv image is measured successfully or it has been already measured.
EFI_OUT_OF_RESOURCESNo enough memory to log the new event.
EFI_DEVICE_ERRORThe command was unsuccessful.

Definition at line 418 of file TcgPei.c.

◆ MeasureMainBios()

EFI_STATUS EFIAPI MeasureMainBios ( IN EFI_PEI_SERVICES **  PeiServices)

Measure main BIOS.

Parameters
[in]PeiServicesDescribes the list of possible PEI Services.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_OUT_OF_RESOURCESNo enough memory to log the new event.
EFI_DEVICE_ERRORThe command was unsuccessful.

Definition at line 529 of file TcgPei.c.

◆ PeimEntryMA()

EFI_STATUS EFIAPI PeimEntryMA ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Entry point of this module.

Parameters
[in]FileHandleHandle of the file being invoked.
[in]PeiServicesDescribes the list of possible PEI Services.
Returns
Status.

Definition at line 841 of file TcgPei.c.

◆ PeimEntryMP()

EFI_STATUS EFIAPI PeimEntryMP ( IN EFI_PEI_SERVICES **  PeiServices)

Do measurement after memory is ready.

Parameters
[in]PeiServicesDescribes the list of possible PEI Services.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_OUT_OF_RESOURCESNo enough memory to log the new event.
EFI_DEVICE_ERRORThe command was unsuccessful.

Definition at line 784 of file TcgPei.c.

◆ PhysicalPresencePpiNotifyCallback()

EFI_STATUS EFIAPI PhysicalPresencePpiNotifyCallback ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor,
IN VOID *  Ppi 
)

Lock physical presence if needed.

Parameters
[in]PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
[in]NotifyDescriptorAddress of the notification descriptor data structure.
[in]PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSOperation completed successfully.

Set physicalPresenceLifetimeLock, physicalPresenceHWEnable and physicalPresenceCMDEnable bit by corresponding PCDs. And lock physical presence if needed.

Parameters
[in]PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
[in]NotifyDescriptorAddress of the notification descriptor data structure.
[in]PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_ABORTEDphysicalPresenceCMDEnable is locked.
EFI_DEVICE_ERRORThe command was unsuccessful.

Definition at line 662 of file TcgPei.c.

◆ TpmCommHashAll()

EFI_STATUS EFIAPI TpmCommHashAll ( IN CONST UINT8 *  Data,
IN UINTN  DataLen,
OUT TPM_DIGEST Digest 
)

Single function calculates SHA1 digest value for all raw data. It combines Sha1Init(), Sha1Update() and Sha1Final().

Parameters
[in]DataRaw data to be digested.
[in]DataLenSize of the raw data.
[out]DigestPointer to a buffer that stores the final digest.
Return values
EFI_SUCCESSAlways successfully calculate the final digest.

Definition at line 260 of file TcgPei.c.

Variable Documentation

◆ mEdkiiTcgPpi

EDKII_TCG_PPI mEdkiiTcgPpi
Initial value:
= {
}
EFI_STATUS EFIAPI HashLogExtendEvent(IN EDKII_TCG_PPI *This, IN UINT64 Flags, IN UINT8 *HashData, IN UINTN HashDataLen, IN TCG_PCR_EVENT_HDR *NewEventHdr, IN UINT8 *NewEventData)
Definition: TcgPei.c:302

Definition at line 85 of file TcgPei.c.

◆ mImageInMemory

BOOLEAN mImageInMemory = FALSE

Definition at line 42 of file TcgPei.c.

◆ mMeasuredBaseFvIndex

UINT32 mMeasuredBaseFvIndex = 0

Definition at line 102 of file TcgPei.c.

◆ mMeasuredBaseFvInfo

EFI_PLATFORM_FIRMWARE_BLOB* mMeasuredBaseFvInfo

Definition at line 100 of file TcgPei.c.

◆ mMeasuredChildFvIndex

UINT32 mMeasuredChildFvIndex = 0

Definition at line 106 of file TcgPei.c.

◆ mMeasuredChildFvInfo

EFI_PLATFORM_FIRMWARE_BLOB* mMeasuredChildFvInfo

Definition at line 104 of file TcgPei.c.

◆ mMeasuredMaxBaseFvIndex

UINT32 mMeasuredMaxBaseFvIndex = 0

Definition at line 101 of file TcgPei.c.

◆ mMeasuredMaxChildFvIndex

UINT32 mMeasuredMaxChildFvIndex = 0

Definition at line 105 of file TcgPei.c.

◆ mMeasurementExcludedFvPpi

Definition at line 108 of file TcgPei.c.

◆ mNotifyList

Initial value:
= {
{
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
&gPeiLockPhysicalPresencePpiGuid,
},
{
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
&gEfiPeiFirmwareVolumeInfoPpiGuid,
},
{
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
&gEfiPeiFirmwareVolumeInfo2PpiGuid,
},
{
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiEndOfPeiSignalPpiGuid,
}
}
EFI_STATUS EFIAPI FirmwareVolumeInfoPpiNotifyCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
Definition: TcgPei.c:588
EFI_STATUS EFIAPI PhysicalPresencePpiNotifyCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
Definition: TcgPei.c:662
EFI_STATUS EFIAPI EndofPeiSignalNotifyCallBack(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
Definition: TcgPei.c:206

Definition at line 166 of file TcgPei.c.

◆ mTcgPpiList

Initial value:
= {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEdkiiTcgPpiGuid,
&mEdkiiTcgPpi
}

Definition at line 89 of file TcgPei.c.

◆ mTpmInitializationDonePpiList

EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList
Initial value:
= {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gPeiTpmInitializationDonePpiGuid,
}
#define NULL
Definition: Base.h:319

Definition at line 50 of file TcgPei.c.

◆ mTpmInitializedPpiList

EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList
Initial value:
= {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gPeiTpmInitializedPpiGuid,
}

Definition at line 44 of file TcgPei.c.