SecurityPkg/Tcg/TrEEPei/TrEEPei.c File Reference


Defines

#define PERF_ID_TREE_PEI   0x3080

Functions

EFI_STATUS EFIAPI FirmwareVolmeInfoPpiNotifyCallback (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 Tpm2GetDigestFromDigestList (IN TPMI_ALG_HASH HashAlg, IN TPML_DIGEST_VALUES *DigestList, IN VOID *Digest)
EFI_STATUS LogHashEvent (IN TPML_DIGEST_VALUES *DigestList, IN OUT TCG_PCR_EVENT_HDR *NewEventHdr, IN UINT8 *NewEventData)
EFI_STATUS HashLogExtendEvent (IN UINT64 Flags, IN UINT8 *HashData, IN UINTN HashDataLen, IN TCG_PCR_EVENT_HDR *NewEventHdr, IN UINT8 *NewEventData)
EFI_STATUS MeasureCRTMVersion (VOID)
EFI_STATUS MeasureFvImage (IN EFI_PHYSICAL_ADDRESS FvBase, IN UINT64 FvLength)
EFI_STATUS MeasureMainBios (VOID)
EFI_STATUS PeimEntryMP (IN EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI PeimEntryMA (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)

Variables

TREE_EVENT_INFO_STRUCT mTreeEventInfo []
BOOLEAN mImageInMemory = FALSE
EFI_PEI_FILE_HANDLE mFileHandle
EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList
EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList
EFI_PLATFORM_FIRMWARE_BLOB * mMeasuredBaseFvInfo
UINT32 mMeasuredBaseFvIndex = 0
EFI_PLATFORM_FIRMWARE_BLOB * mMeasuredChildFvInfo
UINT32 mMeasuredChildFvIndex = 0
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList []
EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPImMeasurementExcludedFvPpi

Detailed Description

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

Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.


Define Documentation

#define PERF_ID_TREE_PEI   0x3080

Referenced by MeasureMainBios().


Function Documentation

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

Record all measured Firmware Volum Information into a Guid Hob

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS The FV Info is measured and recorded to TPM.
Returns:
Others Fail to measure FV.
Record all measured Firmware Volum Information into a Guid Hob Guid Hob payload layout is

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

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS The FV Info is measured and recorded to TPM.
Returns:
Others Fail to measure FV.

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

Measure and record the Firmware Volum Information once FvInfoPPI install.

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS The FV Info is measured and recorded to TPM.
Returns:
Others Fail to measure FV.

EFI_STATUS HashLogExtendEvent ( 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] Flags Bitmap providing additional information.
[in] HashData Physical address of the start of the data buffer to be hashed, extended, and logged.
[in] HashDataLen The length, in bytes, of the buffer referenced by HashData.
[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
[in] NewEventData Pointer to the new event data.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_STATUS(), gTpmErrorHobGuid, HashAndExtend(), and LogHashEvent().

EFI_STATUS LogHashEvent ( IN TPML_DIGEST_VALUES *  DigestList,
IN OUT TCG_PCR_EVENT_HDR *  NewEventHdr,
IN UINT8 *  NewEventData 
)

Add a new entry to the Event Log.

Parameters:
[in] DigestList A list of digest.
[in,out] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
[in] NewEventData Pointer to the new event data.
Return values:
EFI_SUCCESS The new event log entry was added.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.

References EFI_STATUS(), gTcgEventEntryHobGuid, mTreeEventInfo, Tpm2GetDigestFromDigestList(), and UINTN().

EFI_STATUS MeasureCRTMVersion ( VOID   ) 

Measure CRTM version.

Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References HashLogExtendEvent().

EFI_STATUS 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] FvBase Base address of FV image.
[in] FvLength Length of FV image.
Return values:
EFI_SUCCESS Fv image is measured successfully or it has been already measured.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI::Count, EFI_STATUS(), EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI::Fv, EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_FV::FvBase, HashLogExtendEvent(), mMeasuredBaseFvIndex, mMeasuredBaseFvInfo, and UINTN().

EFI_STATUS MeasureMainBios ( VOID   ) 

Measure main BIOS.

Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_STATUS(), MeasureFvImage(), mFileHandle, PERF_ID_TREE_PEI, TRUE, and UINTN().

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

Entry point of this module.

Parameters:
[in] FileHandle Handle of the file being invoked.
[in] PeiServices Describes the list of possible PEI Services.
Returns:
Status.

References EFI_STATUS(), gEfiTpmDeviceInstanceNoneGuid, gEfiTpmDeviceInstanceTpm12Guid, gTpmErrorHobGuid, mFileHandle, mImageInMemory, mTpmInitializationDonePpiList, mTpmInitializedPpiList, PeimEntryMP(), Tpm2RequestUseTpm(), Tpm2SelfTest(), Tpm2Startup(), and TRUE.

EFI_STATUS PeimEntryMP ( IN EFI_PEI_SERVICES **  PeiServices  ) 

Do measurement after memory is ready.

Parameters:
[in] PeiServices Describes the list of possible PEI Services.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_STATUS(), gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid, MeasureCRTMVersion(), MeasureMainBios(), mMeasuredBaseFvInfo, mMeasuredChildFvInfo, and mNotifyList.

EFI_STATUS Tpm2GetDigestFromDigestList ( IN TPMI_ALG_HASH  HashAlg,
IN TPML_DIGEST_VALUES *  DigestList,
IN VOID *  Digest 
)

This function get digest from digest list.

Parameters:
HashAlg digest algorithm
DigestList digest list
Digest digest
Return values:
EFI_SUCCESS Sha1Digest is found and returned.
EFI_NOT_FOUND Sha1Digest is not found.

References GetHashSizeFromAlgo(), and UINTN().


Variable Documentation

EFI_PEI_FILE_HANDLE mFileHandle

BOOLEAN mImageInMemory = FALSE

EFI_PLATFORM_FIRMWARE_BLOB* mMeasuredBaseFvInfo

EFI_PLATFORM_FIRMWARE_BLOB* mMeasuredChildFvInfo

EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList[]

Initial value:

 {
  {
    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
    &gEfiPeiFirmwareVolumeInfoPpiGuid,
    FirmwareVolmeInfoPpiNotifyCallback 
  },
  {
    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
    &gEfiPeiFirmwareVolumeInfo2PpiGuid,
    FirmwareVolmeInfoPpiNotifyCallback 
  },
  {
    (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
    &gEfiEndOfPeiSignalPpiGuid,
    EndofPeiSignalNotifyCallBack
  }
}

EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList

Initial value:

 {
  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  &gPeiTpmInitializationDonePpiGuid,
  NULL
}

EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList

Initial value:

 {
  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  &gPeiTpmInitializedPpiGuid,
  NULL
}

TREE_EVENT_INFO_STRUCT mTreeEventInfo[]

Initial value:

 {
  {&gTcgEventEntryHobGuid,             TREE_EVENT_LOG_FORMAT_TCG_1_2},
}


Generated on Thu Sep 24 23:44:24 2015 for SecurityPkg[ALL] by  doxygen 1.5.7.1