From nobody Mon Feb 9 00:55:24 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+80454+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+80454+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1631231229; cv=none; d=zohomail.com; s=zohoarc; b=HOMegAJsNqrQZRU/e9yTdCGQwJ/Ydcl6iXduN+cOU43MdA1YCG+fBpdBNX/JdhVQfiye8dekt0x+1Zu8tlm9D1vdy1qjibCOCZnLTUfCMYrw9zjkiCVXQiL8FzyPEYDdBdQk3/Yxge8o4ZNbxb0+buz6bIKfGSJFkpUvqXcqtus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631231229; 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=9SwFHn8/cIGUfcsEONK7RCjkT5ZhbBc9PmjO3+uJdjw=; b=ctBssXqEML2MWtznDnEb5hBocGdRPFb3kMl1vNbO2BAwjNGfxMUq5YYqfW/088QyQPXkH/FOxGNFiorlpwcp10mHQzqQk256W1UXtwqITr7+ZOHWWhoLoZ1NIS/qquLuqTtiU1DTUmtMMt37gy/8W1ikAmvdJ2aEi/v/itVzlJg= 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+80454+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631231229761198.7107473126831; Thu, 9 Sep 2021 16:47:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id S4pPYY1788612xfsgZPcIG1f; Thu, 09 Sep 2021 16:47:09 -0700 X-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 X-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 X-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 X-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 X-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 X-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 X-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 X-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 X-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) X-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) X-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: [edk2-devel] [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> 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 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: M6ZWeNnTvjIBc77JWseAMEK5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631231229; bh=E0XeZY9nny4UtafPKrS3tyvvGR/7gRQwrjePSisEp0k=; h=Cc:Date:From:Reply-To:Subject:To; b=JUba+lzKmfHn2JdeVrhZkXkiMwPAynsmEkIH5j7E/oUZqs9JgYPgcOnyClfh92OnGb5 TEwmnZEm3CMok19I0hqWtbZxywnNm6irBJsxsj4o6p3mRkKmAsbDY7HNhCo9LYxKKO+gq FWJXFbtH984LePA3fSgeHen7jPxk4xYys9I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631231230772100005 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 (#80454): https://edk2.groups.io/g/devel/message/80454 Mute This Topic: https://groups.io/mt/85498426/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-