2 Configure TPM 2 platform hierarchy on TPM state resume failure on S3 resume
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) Microsoft Corporation.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/PeiServicesLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/BaseMemoryLib.h>
14 #include <Library/MemoryAllocationLib.h>
15 #include <Library/HobLib.h>
16 #include <Library/Tpm2CommandLib.h>
17 #include <Library/Tpm2DeviceLib.h>
18 #include <Library/TpmPlatformHierarchyLib.h>
19 #include <Library/RngLib.h>
21 #include <Ppi/EndOfPeiPhase.h>
23 #define MAX_NEW_AUTHORIZATION_SIZE SHA512_DIGEST_SIZE
26 This function handles PlatformInit task at the end of PEI
28 @param[in] PeiServices Pointer to PEI Services Table.
29 @param[in] NotifyDescriptor Pointer to the descriptor for the Notification event that
30 caused this function to execute.
31 @param[in] Ppi Pointer to the PPI data associated with this function.
33 @retval EFI_SUCCESS The function completes successfully
38 PlatformInitEndOfPei (
39 IN CONST EFI_PEI_SERVICES
**PeiServices
,
40 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
47 // Try to get TcgEventLog in S3 to see if S3 error is reported.
49 TcgEventLog
= GetFirstGuidHob (&gTcgEventEntryHobGuid
);
50 if (TcgEventLog
== NULL
) {
51 TcgEventLog
= GetFirstGuidHob (&gTcgEvent2EntryHobGuid
);
54 if (TcgEventLog
== NULL
) {
56 // no S3 error reported
62 // If there is S3 error on TPM_SU_STATE and success on TPM_SU_CLEAR,
63 // configure the TPM Platform Hierarchy.
65 ConfigureTpmPlatformHierarchy ();
70 static EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiNotifyList
= {
71 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
72 &gEfiEndOfPeiSignalPpiGuid
,
73 (EFI_PEIM_NOTIFY_ENTRY_POINT
)PlatformInitEndOfPei
79 @param[in] FileHandle Handle of the file being invoked.
80 @param[in] PeiServices Pointer to PEI Services table.
82 @retval EFI_SUCCESS Install function successfully.
87 Tcg2PlatformPeiEntryPoint (
88 IN EFI_PEI_FILE_HANDLE FileHandle
,
89 IN CONST EFI_PEI_SERVICES
**PeiServices
93 EFI_BOOT_MODE BootMode
;
95 Status
= PeiServicesGetBootMode (&BootMode
);
96 ASSERT_EFI_ERROR (Status
);
98 if (BootMode
!= BOOT_ON_S3_RESUME
) {
103 // Performing PlatformInitEndOfPei after EndOfPei PPI produced
105 Status
= PeiServicesNotifyPpi (&mEndOfPeiNotifyList
);