From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mx.groups.io with SMTP id smtpd.web09.2434.1631208943042158418 for ; Thu, 09 Sep 2021 10:35:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Z6zzMRYK; spf=none, err=permanent DNS error (domain: linux.vnet.ibm.com, ip: 148.163.156.1, mailfrom: stefanb@linux.vnet.ibm.com) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 189HWkiY038190; Thu, 9 Sep 2021 13:35:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BznH+zk4Cfm2W7MUEeHjtF4xg1Dbp29EVrmhMGaB7Lo=; b=Z6zzMRYK+OHd3RH30e8abt07rW75AVwvY8w9jjO/8yj/nrCOk2+GJQhEc9S7FVrA4ovh nepFUaE9+iMcFssrx1SGH3FF7MCQdFyDb/Jr5KxC/Bw3I6juFdrRXO5iNLwbT8708w4F 3La7DekOqvZIoxOyJOasBM2QL28sevDphEM5LvphvFy4ZQvDI74MfL+oi3y7As/8qM1L BBZD5w2SVSWaZBGyWOkF4gdnm1Mx+LOkvrj+L7+4lKqiVFxauwWdrBtVgx/v+P+cL4nS bu5diqEI8yniTpSUU/DwKQ7E74jcAuZguLp1sOz5qTBOU56Tr1iJ51FTBiriyTNLjat3 tw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aymu9u39q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Sep 2021 13:35:42 -0400 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 189HZYqE054266; Thu, 9 Sep 2021 13:35:42 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aymu9u39c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Sep 2021 13:35:42 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 189HMCjg028475; Thu, 9 Sep 2021 17:35:41 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma01dal.us.ibm.com with ESMTP id 3axcnrf31a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Sep 2021 17:35:41 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 189HZewN39518676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Sep 2021 17:35:40 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 33829AC062; Thu, 9 Sep 2021 17:35:40 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2465DAC06A; Thu, 9 Sep 2021 17:35:40 +0000 (GMT) Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 9 Sep 2021 17:35:40 +0000 (GMT) From: Stefan Berger To: devel@edk2.groups.io Cc: mhaeuser@posteo.de, spbrogan@outlook.com, marcandre.lureau@redhat.com, kraxel@redhat.com, jiewen.yao@intel.com, Stefan Berger , Stefan Berger Subject: [PATCH v7 7/9] SecurityPkg/Tcg: Import Tcg2PlatformPei from edk2-platforms Date: Thu, 9 Sep 2021 13:35:36 -0400 Message-Id: <20210909173538.2380673-8-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210909173538.2380673-1-stefanb@linux.vnet.ibm.com> References: <20210909173538.2380673-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Wj0YwmpA32Ty-xSTfeH7F3gz7t2Kw69X X-Proofpoint-GUID: fCRlFsWBsoE_VtK2llHOlJ6GoUFZYApv X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-09-09_06:2021-09-09,2021-09-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 adultscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109090107 Content-Transfer-Encoding: quoted-printable Import Tcg2PlatformPei from edk2-platforms without any modifications. Signed-off-by: Stefan Berger --- .../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.
=0D +Copyright (c) Microsoft Corporation.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include =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.
=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