[PATCH v8 07/10] SecurityPkg/Tcg: Import Tcg2PlatformPei from edk2-platforms


Stefan Berger <stefanb@...>
 

Import Tcg2PlatformPei from edk2-platforms without any modifications.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
.../Tcg/Tcg2PlatformPei/Tcg2PlatformPei.c | 107 ++++++++++++++++++
.../Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf | 52 +++++++++
2 files changed, 159 insertions(+)
create mode 100644 SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.c
create mode 100644 SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf

diff --git a/SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.c b/SecurityPk=
g/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.c
new file mode 100644
index 0000000000..66ec75ad0e
--- /dev/null
+++ b/SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.c
@@ -0,0 +1,107 @@
+/** @file=0D
+=0D
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) Microsoft Corporation.<BR>=0D
+SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#include <PiPei.h>=0D
+#include <Library/PeiServicesLib.h>=0D
+#include <Library/DebugLib.h>=0D
+#include <Library/BaseMemoryLib.h>=0D
+#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/HobLib.h>=0D
+#include <Library/Tpm2CommandLib.h>=0D
+#include <Library/Tpm2DeviceLib.h>=0D
+#include <Library/TpmPlatformHierarchyLib.h>=0D
+#include <Library/RngLib.h>=0D
+=0D
+#include <Ppi/EndOfPeiPhase.h>=0D
+=0D
+#define MAX_NEW_AUTHORIZATION_SIZE SHA512_DIGEST_SIZE=0D
+=0D
+/**=0D
+ This function handles PlatformInit task at the end of PEI=0D
+=0D
+ @param[in] PeiServices Pointer to PEI Services Table.=0D
+ @param[in] NotifyDesc Pointer to the descriptor for the Notification =
event that=0D
+ caused this function to execute.=0D
+ @param[in] Ppi Pointer to the PPI data associated with this fu=
nction.=0D
+=0D
+ @retval EFI_SUCCESS The function completes successfully=0D
+ @retval others=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+PlatformInitEndOfPei (=0D
+ IN CONST EFI_PEI_SERVICES **PeiServices,=0D
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,=0D
+ IN VOID *Ppi=0D
+ )=0D
+{=0D
+ VOID *TcgEventLog;=0D
+=0D
+ //=0D
+ // Try to get TcgEventLog in S3 to see if S3 error is reported.=0D
+ //=0D
+ TcgEventLog =3D GetFirstGuidHob(&gTcgEventEntryHobGuid);=0D
+ if (TcgEventLog =3D=3D NULL) {=0D
+ TcgEventLog =3D GetFirstGuidHob(&gTcgEvent2EntryHobGuid);=0D
+ }=0D
+=0D
+ if (TcgEventLog =3D=3D NULL) {=0D
+ //=0D
+ // no S3 error reported=0D
+ //=0D
+ return EFI_SUCCESS;=0D
+ }=0D
+=0D
+ //=0D
+ // If there is S3 error on TPM_SU_STATE and success on TPM_SU_CLEAR,=0D
+ // configure the TPM Platform Hierarchy.=0D
+ //=0D
+ ConfigureTpmPlatformHierarchy ();=0D
+=0D
+ return EFI_SUCCESS;=0D
+}=0D
+=0D
+static EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiNotifyList =3D {=0D
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINA=
TE_LIST),=0D
+ &gEfiEndOfPeiSignalPpiGuid,=0D
+ (EFI_PEIM_NOTIFY_ENTRY_POINT)PlatformInitEndOfPei=0D
+};=0D
+=0D
+/**=0D
+ Main entry=0D
+=0D
+ @param[in] FileHandle Handle of the file being invoked.=0D
+ @param[in] PeiServices Pointer to PEI Services table.=0D
+=0D
+ @retval EFI_SUCCESS Install function successfully.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+Tcg2PlatformPeiEntryPoint (=0D
+ IN EFI_PEI_FILE_HANDLE FileHandle,=0D
+ IN CONST EFI_PEI_SERVICES **PeiServices=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ EFI_BOOT_MODE BootMode;=0D
+=0D
+ Status =3D PeiServicesGetBootMode (&BootMode);=0D
+ ASSERT_EFI_ERROR(Status);=0D
+=0D
+ if (BootMode !=3D BOOT_ON_S3_RESUME) {=0D
+ return EFI_SUCCESS;=0D
+ }=0D
+=0D
+ //=0D
+ // Performing PlatformInitEndOfPei after EndOfPei PPI produced=0D
+ //=0D
+ Status =3D PeiServicesNotifyPpi (&mEndOfPeiNotifyList);=0D
+=0D
+ return Status;=0D
+}=0D
diff --git a/SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf b/Security=
Pkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
new file mode 100644
index 0000000000..579f09b940
--- /dev/null
+++ b/SecurityPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
@@ -0,0 +1,52 @@
+### @file=0D
+#=0D
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+#=0D
+# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+#=0D
+###=0D
+=0D
+[Defines]=0D
+ INF_VERSION =3D 0x00010017=0D
+ BASE_NAME =3D Tcg2PlatformPei=0D
+ FILE_GUID =3D 47727552-A54B-4A84-8CC1-BFF23E239636=
=0D
+ VERSION_STRING =3D 1.0=0D
+ MODULE_TYPE =3D PEIM=0D
+ ENTRY_POINT =3D Tcg2PlatformPeiEntryPoint=0D
+=0D
+#=0D
+# The following information is for reference only and not required by the =
build tools.=0D
+#=0D
+# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC=0D
+#=0D
+=0D
+[LibraryClasses]=0D
+ PcdLib=0D
+ BaseMemoryLib=0D
+ MemoryAllocationLib=0D
+ PeiServicesLib=0D
+ PeimEntryPoint=0D
+ DebugLib=0D
+ Tpm2DeviceLib=0D
+ Tpm2CommandLib=0D
+ TpmPlatformHierarchyLib=0D
+ RngLib=0D
+=0D
+[Packages]=0D
+ MdePkg/MdePkg.dec=0D
+ SecurityPkg/SecurityPkg.dec=0D
+ MinPlatformPkg/MinPlatformPkg.dec=0D
+=0D
+[Sources]=0D
+ Tcg2PlatformPei.c=0D
+=0D
+[Guids]=0D
+ gTcgEventEntryHobGuid=0D
+ gTcgEvent2EntryHobGuid=0D
+=0D
+[Ppis]=0D
+ gEfiEndOfPeiSignalPpiGuid=0D
+=0D
+[Depex]=0D
+ gEfiTpmDeviceSelectedGuid=0D
+=0D
--=20
2.31.1