From nobody Mon Feb 9 07:22:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80574+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80574+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1631551372; cv=none; d=zohomail.com; s=zohoarc; b=B3hPphksEwiN3LWvsSe8XRizYUITtBSr1qLCsoQ21z1fVGmnptwdNPNjxwKF6wXdMdOpszmKr3u5F1N/LHz43ZcEuBvP5JI6D6aSevkxvUX1cK8eB09nugYgrbBhK/H7Vbuw0MLODq2sDOQBPxyW1xoCnLTLh6ygtfM0rJ/3Fjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631551372; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=byjcEwdzBrQbn/a4QHyrWcB6m/Hp846hdHiHoSmIO3Y=; b=UTIskoNPIftR4Eim1aE4+qXtCO/+O7x6h1O+K5hzokbZrca2T4kDoXqXkFLfO8/mbc9uB4Xmpoqd0U/fYvTTzxjmlC9Ln0Ox8UF1NgPUtdSlclAFkVQ0k2lk6lj2LRgJWOndBV+FXUfHea0fQ48VWTqd/WGMNw3B6WBlUGU4skc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80574+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631551372126718.1397489081971; Mon, 13 Sep 2021 09:42:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DIN7YY1788612xpEWk8K0ZKE; Mon, 13 Sep 2021 09:42:51 -0700 X-Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by mx.groups.io with SMTP id smtpd.web12.30409.1631542878629486183 for ; Mon, 13 Sep 2021 07:21:18 -0700 X-Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 18DD5PhO033085; Mon, 13 Sep 2021 10:21:17 -0400 X-Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b232j0u5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Sep 2021 10:21:17 -0400 X-Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18DBkeDO022617; Mon, 13 Sep 2021 10:21:16 -0400 X-Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b232j0u5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Sep 2021 10:21:16 -0400 X-Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18DEDi2v018642; Mon, 13 Sep 2021 14:21:16 GMT X-Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma03dal.us.ibm.com with ESMTP id 3b0m3a29jk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Sep 2021 14:21:15 +0000 X-Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18DELEI125559356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Sep 2021 14:21:14 GMT X-Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7199B13605E; Mon, 13 Sep 2021 14:21:14 +0000 (GMT) X-Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0163F13604F; Mon, 13 Sep 2021 14:21:14 +0000 (GMT) X-Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 13 Sep 2021 14:21:13 +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: [edk2-devel] [PATCH v8 07/10] SecurityPkg/Tcg: Import Tcg2PlatformPei from edk2-platforms Date: Mon, 13 Sep 2021 10:21:03 -0400 Message-Id: <20210913142106.2526997-8-stefanb@linux.vnet.ibm.com> In-Reply-To: <20210913142106.2526997-1-stefanb@linux.vnet.ibm.com> References: <20210913142106.2526997-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: LZTpqLcyYjLXqtdyRcuUQoxeNi-16hE_ X-Proofpoint-ORIG-GUID: bjErFKD88OrG4wCs6xi328oeD418lNMR Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,stefanb@linux.vnet.ibm.com X-Gm-Message-State: 8bu4bL0UwXiJna8ixAEYcDxex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631551371; bh=+We5BLW2dgbh40ng2IMtffx2Ny7xwRddgCbX1veNBBc=; h=Cc:Date:From:Reply-To:Subject:To; b=ldEmHK8yMafNrkfOX+eQhsy9aWUCF5TiTaPU1XV4S3zghQ/qhRIxTos4UMicsDdvgH/ /J9k8MdbCP0MIj0XGDcZBoMd0X2H9POjd0ibAH/KinnZplhcaW1XUqFlgifOrBbQZ9nMH Pjfylena0Sf/crIk619i6txB1/G0CvsIWyY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631551372537100032 Content-Type: text/plain; charset="utf-8" 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 + +Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define MAX_NEW_AUTHORIZATION_SIZE SHA512_DIGEST_SIZE + +/** + This function handles PlatformInit task at the end of PEI + + @param[in] PeiServices Pointer to PEI Services Table. + @param[in] NotifyDesc Pointer to the descriptor for the Notification = event that + caused this function to execute. + @param[in] Ppi Pointer to the PPI data associated with this fu= nction. + + @retval EFI_SUCCESS The function completes successfully + @retval others +**/ +EFI_STATUS +EFIAPI +PlatformInitEndOfPei ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + VOID *TcgEventLog; + + // + // Try to get TcgEventLog in S3 to see if S3 error is reported. + // + TcgEventLog =3D GetFirstGuidHob(&gTcgEventEntryHobGuid); + if (TcgEventLog =3D=3D NULL) { + TcgEventLog =3D GetFirstGuidHob(&gTcgEvent2EntryHobGuid); + } + + if (TcgEventLog =3D=3D NULL) { + // + // no S3 error reported + // + return EFI_SUCCESS; + } + + // + // If there is S3 error on TPM_SU_STATE and success on TPM_SU_CLEAR, + // configure the TPM Platform Hierarchy. + // + ConfigureTpmPlatformHierarchy (); + + return EFI_SUCCESS; +} + +static EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiNotifyList =3D { + (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINA= TE_LIST), + &gEfiEndOfPeiSignalPpiGuid, + (EFI_PEIM_NOTIFY_ENTRY_POINT)PlatformInitEndOfPei +}; + +/** + Main entry + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Pointer to PEI Services table. + + @retval EFI_SUCCESS Install function successfully. + +**/ +EFI_STATUS +EFIAPI +Tcg2PlatformPeiEntryPoint ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR(Status); + + if (BootMode !=3D BOOT_ON_S3_RESUME) { + return EFI_SUCCESS; + } + + // + // Performing PlatformInitEndOfPei after EndOfPei PPI produced + // + Status =3D PeiServicesNotifyPpi (&mEndOfPeiNotifyList); + + return Status; +} 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 +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D Tcg2PlatformPei + FILE_GUID =3D 47727552-A54B-4A84-8CC1-BFF23E239636 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D PEIM + ENTRY_POINT =3D Tcg2PlatformPeiEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[LibraryClasses] + PcdLib + BaseMemoryLib + MemoryAllocationLib + PeiServicesLib + PeimEntryPoint + DebugLib + Tpm2DeviceLib + Tpm2CommandLib + TpmPlatformHierarchyLib + RngLib + +[Packages] + MdePkg/MdePkg.dec + SecurityPkg/SecurityPkg.dec + MinPlatformPkg/MinPlatformPkg.dec + +[Sources] + Tcg2PlatformPei.c + +[Guids] + gTcgEventEntryHobGuid + gTcgEvent2EntryHobGuid + +[Ppis] + gEfiEndOfPeiSignalPpiGuid + +[Depex] + gEfiTpmDeviceSelectedGuid + --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80574): https://edk2.groups.io/g/devel/message/80574 Mute This Topic: https://groups.io/mt/85580083/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-