From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.92]) by mx.groups.io with SMTP id smtpd.web10.191.1587357374699424832 for ; Sun, 19 Apr 2020 21:36:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=Zfk/pSR9; spf=pass (domain: microsoft.com, ip: 40.107.220.92, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7XqpLTT6i4fSifw7fWljzklk3n5fRzGc9M7SBtdlqO17CW3VapgLASXb8djGO5Ok+9N2Rto1KIrR7ndai1XUUeZt9yKrZdDP5A09T50wfVfLva8gzL5S2PqzqHx10Nce5ZyjzUbk19tpRSAIE6iBSyWORbLBcvKs5+0SnyZKOVnL4uqBeshKhxFqSKGFqxkkJGmgVq93FkYAIpM9awkFp2ESrmASDQ6hHlnP0qMHUtRfRWH4lKkBphh45wOoqscsGvLgcZ44Wm1xdQoKkfTDTbcGyK3wIHwPxVMMrxagvB2e1JYHxPngwI50HW/KsdEahiND2GR/4WyMLhAMxFxNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RuZqHCrGjjsG2azFPpLIYxYAy/6mLr8mJwp6BHp5wKE=; b=DdQanxGAL8FNqACKa0MATF2rKJj8bc0Mvwl9Vi73/+G7/jbPjBwLZuXlUL6idRwoYQUbdN6HBaz/OAHhmgC5OR3BDI3og829nfwPDJca2MRMIJS4yzUPpdM32nHF+KOODxlILS1lrLDc1CgflttEqMhv2T4CYruptUXQkr/fn6FnVhont5ynuDtd3m+R/QD7kEIVI3taEd37ZIufEH/HNsZFl8U7hW7MAfN6BYxEQbJnsjV//6XhRZ02E1ojei7nzQJWTo8hQf7XOaixeZz0xfRCrvcX3xoq/GDbX7663jg4RvEGeqEjewlXDTSEs3ax6om2IByfkv7QkuYA+dWrYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RuZqHCrGjjsG2azFPpLIYxYAy/6mLr8mJwp6BHp5wKE=; b=Zfk/pSR95jz0Q2vlbXV739706KXX5I0BqP2OAKGdPn6LNJdVOG8pMORaOTqmlVn5IP7OWWMgbwqXAJ/aFcLMQ+DQb5Aii62uqWWDnSKB1EtY+9GcxI6e1f4GHwTHHW6AtiuexoXVPV874Zt4ChDnfVpUiV//4v/h9CgGxC5xVBE= Received: from CY4PR21MB0743.namprd21.prod.outlook.com (2603:10b6:903:b2::9) by MW2SPR01MB06.namprd21.prod.outlook.com (2603:10b6:302:10::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.2; Mon, 20 Apr 2020 04:36:13 +0000 Received: from CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::90d:10d9:c5bc:5318]) by CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::90d:10d9:c5bc:5318%12]) with mapi id 15.20.2958.001; Mon, 20 Apr 2020 04:36:13 +0000 From: "Bret Barkelew" To: "devel@edk2.groups.io" , "shenglei.zhang@intel.com" CC: Jiewen Yao , Jian J Wang , Chao Zhang Subject: Re: [EXTERNAL] [edk2-devel] [PATCH] SecurityPkg/TpmCommLib: Remove TpmCommLib Thread-Topic: [EXTERNAL] [edk2-devel] [PATCH] SecurityPkg/TpmCommLib: Remove TpmCommLib Thread-Index: AQHWFr80jzWPAob/UEKP0Sxj4vLLSqiBbOGt Date: Mon, 20 Apr 2020 04:36:12 +0000 Message-ID: References: <20200420025523.38500-1-shenglei.zhang@intel.com> In-Reply-To: <20200420025523.38500-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-04-20T04:35:58.3676225Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Privileged authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bret.Barkelew@microsoft.com; x-originating-ip: [71.212.145.195] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ebca7c15-930a-42f2-62a5-08d7e4e45b47 x-ms-traffictypediagnostic: MW2SPR01MB06: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-forefront-prvs: 03793408BA x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR21MB0743.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(366004)(396003)(136003)(346002)(376002)(110136005)(82950400001)(82960400001)(54906003)(186003)(71200400001)(9686003)(55016002)(8990500004)(81156014)(8676002)(52536014)(66556008)(64756008)(2906002)(66946007)(66476007)(33656002)(8936002)(15650500001)(4326008)(66446008)(76116006)(5660300002)(6506007)(316002)(966005)(478600001)(26005)(19627235002)(7696005)(30864003)(86362001)(10290500003)(53546011);DIR:OUT;SFP:1102; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mVWMacDPQxv1rC4oY4FQxVFg/37litFnZinJuplflTCo/AdzMeDZaZvshwMnHcQJhi2NgEXZ4LjTWcAl2kF/lUEf87DrM3gmLN+XI0JDvXplk3cfjTvdiVfO210d+nVYNtevIRXl+5G7qff/fSOglWCmeujoh1OW/hrh/EMm05dL+9BVyRBCKqma6OrToMdxvVErK3Yd63w3Wg4osoWsI4/nmztZ1jfV6GlB1E8ibS4rzE2xX7Gs5bbhLJYGBbCGYmvAc2UkH8hUrvGPpYUM2ZM5i3Xkxpf7s3sYt/6vJjZmhnl92Pl7RMU9YcvuQG2NTGRZ2+9C1URRFGJQyllcx96LRcWF+SiRGu0I67VtlicTzdf9Y6C7JWt3vdXof9zzl9Eu+BNJw9C1abdb+/16BK4r1Rd03KxbMIcrsTa5OztRGg8IcqvArEbnxa76JXsGPPZOn0U054IduvfUNOadu3w9Den3WzxdwcWu7D8CYbvrUqcHJfrcnyiHEqfTkxcySgiK3EhV7vWFwydSfrCI3A== x-ms-exchange-antispam-messagedata: bs2aU6vk6QXJYpUyLeOLlGpD8/3yUMETOKLEpgVBOlCPBR9Fzn8eKUp2hLFuOvwufUAvlohLECzfWE2xmp4vU2irhHSEkd6QA7AoJkvzXQsGXk01ZNDDKM+0rAlqHQLTpWuLjGVG/Lsq3HIw8YSerkQvIqY6lvLW7SVhN5cMfTGOWnGIAVDYfGjFFSqL3WoW6tGVQYtdOabl/hTzodKWawVQPcgcOvvEuSuWx31aOg4Z4Kxk3AdyS2iC3memT3nyC4XR/tKqfJHgN5vVGdz+eE8ctO/Bgn5HSnXIeT4qvAuSCxek9d7DRKWdWNKL02Eub5GVE1V2as2is8VWxCvP1+5GE9VbAD/FrVxWso1iO6gG6zeDOmohRqfeKVP9QG8YBihQ6QmDjLGmsTugsInsrwUsHLbdaZmTuZwAsHFY+dp4g2FQ19tQPA/C+ilREUsq2jtB2FY0bf4H9xmsv/WvBc/fag2kfdvxnh1Sh8vODfcEi48/nOyB4Eth16Nos6LWN8PR1S4XhFwbAkeaGytoMxquMcetb7QKhMun6cqiofTLClv+L9rGNY7OjF0jna7JoV+WskO8YrGaiNY4d3vpkUviCDJXgWA1adS5XkqBODS7osi8jMEN2VQ4lTO+guCoopzzxh6DierQCxDal9SxI3Nw8WSRG52R5/RiOjsPhEHbrs5SVuLahNzVgS1CsoNZePHf5Are2j5L+VE5nFxgR3xnZm8HHagJK9YwE3pADNjuB3TyTjTzdmfyXjwDzH4hw4W3RV/T4/NaRGFZx/Ydc03PbwL5od2ankydcRWp2kw= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebca7c15-930a-42f2-62a5-08d7e4e45b47 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2020 04:36:12.9821 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3SqxLTTXmx39vogQJFwmqGJOEl01xnQuQ2Ptvg+MkXmb5dqkXJvOwE8Clg5dx6qihqEswZlH+b+qsiSknCTBuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2SPR01MB06 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR21MB07434F4DA83360EF4A2FCA60EFD40CY4PR21MB0743namp_" --_000_CY4PR21MB07434F4DA83360EF4A2FCA60EFD40CY4PR21MB0743namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bret Barkelew - Bret ________________________________ From: devel@edk2.groups.io on behalf of Zhang, Shen= glei via groups.io Sent: Sunday, April 19, 2020 7:55:23 PM To: devel@edk2.groups.io Cc: Jiewen Yao ; Jian J Wang = ; Chao Zhang Subject: [EXTERNAL] [edk2-devel] [PATCH] SecurityPkg/TpmCommLib: Remove Tp= mCommLib REF: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fb= ugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1321&data=3D02%7C01%7Cbret.= barkelew%40microsoft.com%7C005eb77f141447b5197908d7e4d65585%7C72f988bf86f14= 1af91ab2d7cd011db47%7C1%7C0%7C637229481521987478&sdata=3DPaDpIoa7Z5Yf%2= F2dNp4x8jEPJ4HY8r4QkHIJSqpdILqo%3D&reserved=3D0 TpmCommLib is no longer used by TcgPei/TcgDxe/Tcg2ConfigPei modules. So it can be removed from SecurityPkg. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Signed-off-by: Shenglei Zhang --- SecurityPkg/Library/TpmCommLib/TisPc.c | 177 ------------------ SecurityPkg/Library/TpmCommLib/TpmComm.c | 44 ----- SecurityPkg/Library/TpmCommLib/CommonHeader.h | 23 --- SecurityPkg/Library/TpmCommLib/TpmCommLib.inf | 45 ----- SecurityPkg/Library/TpmCommLib/TpmCommLib.uni | 17 -- SecurityPkg/SecurityPkg.dec | 6 +- SecurityPkg/SecurityPkg.dsc | 4 +- 7 files changed, 2 insertions(+), 314 deletions(-) delete mode 100644 SecurityPkg/Library/TpmCommLib/TisPc.c delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmComm.c delete mode 100644 SecurityPkg/Library/TpmCommLib/CommonHeader.h delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.inf delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.uni diff --git a/SecurityPkg/Library/TpmCommLib/TisPc.c b/SecurityPkg/Library/= TpmCommLib/TisPc.c deleted file mode 100644 index 533a42e53cee..000000000000 --- a/SecurityPkg/Library/TpmCommLib/TisPc.c +++ /dev/null @@ -1,177 +0,0 @@ -/** @file - Basic TIS (TPM Interface Specification) functions. - -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "CommonHeader.h" - -/** - Check whether TPM chip exist. - - @param[in] TisReg Pointer to TIS register. - - @retval TRUE TPM chip exists. - @retval FALSE TPM chip is not found. -**/ -BOOLEAN -TisPcPresenceCheck ( - IN TIS_PC_REGISTERS_PTR TisReg - ) -{ - UINT8 RegRead; - - RegRead =3D MmioRead8 ((UINTN)&TisReg->Access); - return (BOOLEAN)(RegRead !=3D (UINT8)-1); -} - -/** - Check whether the value of a TPM chip register satisfies the input BIT = setting. - - @param[in] Register Address port of register to be checked. - @param[in] BitSet Check these data bits are set. - @param[in] BitClear Check these data bits are clear. - @param[in] TimeOut The max wait time (unit MicroSecond) when chec= king register. - - @retval EFI_SUCCESS The register satisfies the check bit. - @retval EFI_TIMEOUT The register can't run into the expected statu= s in time. -**/ -EFI_STATUS -EFIAPI -TisPcWaitRegisterBits ( - IN UINT8 *Register, - IN UINT8 BitSet, - IN UINT8 BitClear, - IN UINT32 TimeOut - ) -{ - UINT8 RegRead; - UINT32 WaitTime; - - for (WaitTime =3D 0; WaitTime < TimeOut; WaitTime +=3D 30){ - RegRead =3D MmioRead8 ((UINTN)Register); - if ((RegRead & BitSet) =3D=3D BitSet && (RegRead & BitClear) =3D=3D 0= ) - return EFI_SUCCESS; - MicroSecondDelay (30); - } - return EFI_TIMEOUT; -} - -/** - Get BurstCount by reading the burstCount field of a TIS register - in the time of default TIS_TIMEOUT_D. - - @param[in] TisReg Pointer to TIS register. - @param[out] BurstCount Pointer to a buffer to store the got = BurstCount. - - @retval EFI_SUCCESS Get BurstCount. - @retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is NULL. - @retval EFI_TIMEOUT BurstCount can't be got in time. -**/ -EFI_STATUS -EFIAPI -TisPcReadBurstCount ( - IN TIS_PC_REGISTERS_PTR TisReg, - OUT UINT16 *BurstCount - ) -{ - UINT32 WaitTime; - UINT8 DataByte0; - UINT8 DataByte1; - - if (BurstCount =3D=3D NULL || TisReg =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - WaitTime =3D 0; - do { - // - // TIS_PC_REGISTERS_PTR->burstCount is UINT16, but it is not 2bytes a= ligned, - // so it needs to use MmioRead8 to read two times - // - DataByte0 =3D MmioRead8 ((UINTN)&TisReg->BurstCount); - DataByte1 =3D MmioRead8 ((UINTN)&TisReg->BurstCount + 1); - *BurstCount =3D (UINT16)((DataByte1 << 8) + DataByte0); - if (*BurstCount !=3D 0) { - return EFI_SUCCESS; - } - MicroSecondDelay (30); - WaitTime +=3D 30; - } while (WaitTime < TIS_TIMEOUT_D); - - return EFI_TIMEOUT; -} - -/** - Set TPM chip to ready state by sending ready command TIS_PC_STS_READY - to Status Register in time. - - @param[in] TisReg Pointer to TIS register. - - @retval EFI_SUCCESS TPM chip enters into ready state. - @retval EFI_INVALID_PARAMETER TisReg is NULL. - @retval EFI_TIMEOUT TPM chip can't be set to ready state i= n time. -**/ -EFI_STATUS -EFIAPI -TisPcPrepareCommand ( - IN TIS_PC_REGISTERS_PTR TisReg - ) -{ - EFI_STATUS Status; - - if (TisReg =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY); - Status =3D TisPcWaitRegisterBits ( - &TisReg->Status, - TIS_PC_STS_READY, - 0, - TIS_TIMEOUT_B - ); - return Status; -} - -/** - Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQ= UUSE - to ACCESS Register in the time of default TIS_TIMEOUT_A. - - @param[in] TisReg Pointer to TIS register. - - @retval EFI_SUCCESS Get the control of TPM chip. - @retval EFI_INVALID_PARAMETER TisReg is NULL. - @retval EFI_NOT_FOUND TPM chip doesn't exit. - @retval EFI_TIMEOUT Can't get the TPM control in time. -**/ -EFI_STATUS -EFIAPI -TisPcRequestUseTpm ( - IN TIS_PC_REGISTERS_PTR TisReg - ) -{ - EFI_STATUS Status; - - if (TisReg =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (!TisPcPresenceCheck (TisReg)) { - return EFI_NOT_FOUND; - } - - MmioWrite8((UINTN)&TisReg->Access, TIS_PC_ACC_RQUUSE); - // - // No locality set before, ACCESS_X.activeLocality MUST be valid within= TIMEOUT_A - // - Status =3D TisPcWaitRegisterBits ( - &TisReg->Access, - (UINT8)(TIS_PC_ACC_ACTIVE |TIS_PC_VALID), - 0, - TIS_TIMEOUT_A - ); - return Status; -} diff --git a/SecurityPkg/Library/TpmCommLib/TpmComm.c b/SecurityPkg/Librar= y/TpmCommLib/TpmComm.c deleted file mode 100644 index dee64b24ffef..000000000000 --- a/SecurityPkg/Library/TpmCommLib/TpmComm.c +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - Basic TPM command functions. - -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "CommonHeader.h" - -/** - Single function calculates SHA1 digest value for all raw data. It - combines Sha1Init(), Sha1Update() and Sha1Final(). - - @param[in] Data Raw data to be digested. - @param[in] DataLen Size of the raw data. - @param[out] Digest Pointer to a buffer that stores the final dig= est. - - @retval EFI_SUCCESS Always successfully calculate the final diges= t. -**/ -EFI_STATUS -EFIAPI -TpmCommHashAll ( - IN CONST UINT8 *Data, - IN UINTN DataLen, - OUT TPM_DIGEST *Digest - ) -{ - VOID *Sha1Ctx; - UINTN CtxSize; - - CtxSize =3D Sha1GetContextSize (); - Sha1Ctx =3D AllocatePool (CtxSize); - ASSERT (Sha1Ctx !=3D NULL); - - Sha1Init (Sha1Ctx); - Sha1Update (Sha1Ctx, Data, DataLen); - Sha1Final (Sha1Ctx, (UINT8 *)Digest); - - FreePool (Sha1Ctx); - - return EFI_SUCCESS; -} - diff --git a/SecurityPkg/Library/TpmCommLib/CommonHeader.h b/SecurityPkg/L= ibrary/TpmCommLib/CommonHeader.h deleted file mode 100644 index aa2e412a116d..000000000000 --- a/SecurityPkg/Library/TpmCommLib/CommonHeader.h +++ /dev/null @@ -1,23 +0,0 @@ -/** @file - The internal header file for TpmCommLib. - -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef _TPMCOMMLIB_COMMON_HEADER_H_ -#define _TPMCOMMLIB_COMMON_HEADER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/SecurityPkg/Library/TpmCommLib/TpmCommLib.inf b/SecurityPkg/L= ibrary/TpmCommLib/TpmCommLib.inf deleted file mode 100644 index 4caabd496f59..000000000000 --- a/SecurityPkg/Library/TpmCommLib/TpmCommLib.inf +++ /dev/null @@ -1,45 +0,0 @@ -## @file -# Provides some common functions for the TCG feature -# -# This instance provides basic TPM Interface Specification (TIS) functio= ns -# and TPM hashall function. -# -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D TpmCommLib - MODULE_UNI_FILE =3D TpmCommLib.uni - FILE_GUID =3D 7d9fe32e-a6a9-4cdf-abff-10cc7f22e1c9 - MODULE_TYPE =3D PEIM - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D TpmCommLib|DXE_DRIVER UEFI_DRIVER PE= IM DXE_SMM_DRIVER - -# -# The following information is for reference only and not required by the= build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 -# - -[Sources] - TisPc.c - TpmComm.c - CommonHeader.h - -[Packages] - MdePkg/MdePkg.dec - SecurityPkg/SecurityPkg.dec - CryptoPkg/CryptoPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - IoLib - TimerLib - BaseCryptLib - MemoryAllocationLib - DebugLib - diff --git a/SecurityPkg/Library/TpmCommLib/TpmCommLib.uni b/SecurityPkg/L= ibrary/TpmCommLib/TpmCommLib.uni deleted file mode 100644 index 96194551be88..000000000000 --- a/SecurityPkg/Library/TpmCommLib/TpmCommLib.uni +++ /dev/null @@ -1,17 +0,0 @@ -// /** @file -// Provides some common functions for the TCG feature -// -// This instance provides basic TPM Interface Specification (TIS) functio= ns -// and TPM hashall function. -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Provides some co= mmon functions for the TCG feature" - -#string STR_MODULE_DESCRIPTION #language en-US "This instance pr= ovides basic TPM Interface Specification (TIS) functions and TPM hashall fu= nction." - diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index 2cdfb02cc5a2..240d422405cc 100644 --- a/SecurityPkg/SecurityPkg.dec +++ b/SecurityPkg/SecurityPkg.dec @@ -5,7 +5,7 @@ # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and li= brary classes) # and libraries instances, which are used for those features. # -# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
# (C) Copyright 2015 Hewlett Packard Enterprise Development LP
# Copyright (c) 2017, Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent @@ -55,10 +55,6 @@ [LibraryClasses] # Tpm12DeviceLib|Include/Library/Tpm12DeviceLib.h - ## @libraryclass Provides TPM Interface Specification (TIS) interface= s for TPM command. - # - TpmCommLib|Include/Library/TpmCommLib.h - ## @libraryclass Provides support for TCG Physical Presence Interface= (PPI) specification # >=3D 128 Vendor Specific PPI Operation. # diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 53fce0535316..8ef6c9ee2f4d 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -1,7 +1,7 @@ ## @file # Security Module Package for All Architectures. # -# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
# (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -45,7 +45,6 @@ [LibraryClasses] UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServi= cesLib.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - TpmCommLib|SecurityPkg/Library/TpmCommLib/TpmCommLib.inf PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSec= ureLibNull.inf TcgPhysicalPresenceLib|SecurityPkg/Library/DxeTcgPhysicalPresenceLib/Dx= eTcgPhysicalPresenceLib.inf TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasur= ementLib.inf @@ -185,7 +184,6 @@ [Components] # TPM # SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf - SecurityPkg/Library/TpmCommLib/TpmCommLib.inf SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib= .inf SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf -- 2.18.0.windows.1 --_000_CY4PR21MB07434F4DA83360EF4A2FCA60EFD40CY4PR21MB0743namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Reviewed-by: Bret Barkelew <bret.barkelew@micros= oft.com>

 

- Bret

 


From: devel@edk2.groups.io= <devel@edk2.groups.io> on behalf of Zhang, Shenglei via groups.io &l= t;shenglei.zhang=3Dintel.com@groups.io>
Sent: Sunday, April 19, 2020 7:55:23 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Jiewen Yao <jiewen.yao@intel.com>; Jian J Wang <jian.j= .wang@intel.com>; Chao Zhang <chao.b.zhang@intel.com>
Subject: [EXTERNAL] [edk2-devel] [PATCH] SecurityPkg/TpmCommLib: Re= move TpmCommLib
 
REF: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugzil= la.tianocore.org%2Fshow_bug.cgi%3Fid%3D1321&amp;data=3D02%7C01%7Cbret.b= arkelew%40microsoft.com%7C005eb77f141447b5197908d7e4d65585%7C72f988bf86f141= af91ab2d7cd011db47%7C1%7C0%7C637229481521987478&amp;sdata=3DPaDpIoa7Z5Y= f%2F2dNp4x8jEPJ4HY8r4QkHIJSqpdILqo%3D&amp;reserved=3D0
TpmCommLib is no longer used by TcgPei/TcgDxe/Tcg2ConfigPei modules.
So it can be removed from SecurityPkg.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 SecurityPkg/Library/TpmCommLib/TisPc.c     =    | 177 ------------------
 SecurityPkg/Library/TpmCommLib/TpmComm.c    &nbs= p; |  44 -----
 SecurityPkg/Library/TpmCommLib/CommonHeader.h |  23 ---
 SecurityPkg/Library/TpmCommLib/TpmCommLib.inf |  45 -----
 SecurityPkg/Library/TpmCommLib/TpmCommLib.uni |  17 --
 SecurityPkg/SecurityPkg.dec       = ;            | =   6 +-
 SecurityPkg/SecurityPkg.dsc       = ;            | =   4 +-
 7 files changed, 2 insertions(+), 314 deletions(-)
 delete mode 100644 SecurityPkg/Library/TpmCommLib/TisPc.c
 delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmComm.c
 delete mode 100644 SecurityPkg/Library/TpmCommLib/CommonHeader.h
 delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
 delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.uni

diff --git a/SecurityPkg/Library/TpmCommLib/TisPc.c b/SecurityPkg/Library/= TpmCommLib/TisPc.c
deleted file mode 100644
index 533a42e53cee..000000000000
--- a/SecurityPkg/Library/TpmCommLib/TisPc.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/** @file
-  Basic TIS (TPM Interface Specification) functions.
-
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR&= gt;
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "CommonHeader.h"
-
-/**
-  Check whether TPM chip exist.
-
-  @param[in] TisReg  Pointer to TIS register.
-
-  @retval    TRUE    TPM chip exists.<= br> -  @retval    FALSE   TPM chip is not found.=
-**/
-BOOLEAN
-TisPcPresenceCheck (
-  IN      TIS_PC_REGISTERS_PTR  &= nbsp;   TisReg
-  )
-{
-  UINT8          &= nbsp;           &nbs= p;      RegRead;
-
-  RegRead =3D MmioRead8 ((UINTN)&TisReg->Access);
-  return (BOOLEAN)(RegRead !=3D (UINT8)-1);
-}
-
-/**
-  Check whether the value of a TPM chip register satisfies the input= BIT setting.
-
-  @param[in]  Register     Address port of = register to be checked.
-  @param[in]  BitSet       Check = these data bits are set.
-  @param[in]  BitClear     Check these data= bits are clear.
-  @param[in]  TimeOut      The max wai= t time (unit MicroSecond) when checking register.
-
-  @retval     EFI_SUCCESS  The register sat= isfies the check bit.
-  @retval     EFI_TIMEOUT  The register can= 't run into the expected status in time.
-**/
-EFI_STATUS
-EFIAPI
-TisPcWaitRegisterBits (
-  IN      UINT8    &nbs= p;            &= nbsp;   *Register,
-  IN      UINT8    &nbs= p;            &= nbsp;   BitSet,
-  IN      UINT8    &nbs= p;            &= nbsp;   BitClear,
-  IN      UINT32    &nb= sp;            =    TimeOut
-  )
-{
-  UINT8          &= nbsp;           &nbs= p;      RegRead;
-  UINT32          =             &nb= sp;     WaitTime;
-
-  for (WaitTime =3D 0; WaitTime < TimeOut; WaitTime +=3D 30){=
-    RegRead =3D MmioRead8 ((UINTN)Register);
-    if ((RegRead & BitSet) =3D=3D BitSet && (R= egRead & BitClear) =3D=3D 0)
-      return EFI_SUCCESS;
-    MicroSecondDelay (30);
-  }
-  return EFI_TIMEOUT;
-}
-
-/**
-  Get BurstCount by reading the burstCount field of a TIS register -  in the time of default TIS_TIMEOUT_D.
-
-  @param[in]  TisReg       &= nbsp;        Pointer to TIS register. -  @param[out] BurstCount       &n= bsp;    Pointer to a buffer to store the got BurstCount.
-
-  @retval     EFI_SUCCESS    = ;       Get BurstCount.
-  @retval     EFI_INVALID_PARAMETER TisReg is NU= LL or BurstCount is NULL.
-  @retval     EFI_TIMEOUT    = ;       BurstCount can't be got in time.
-**/
-EFI_STATUS
-EFIAPI
-TisPcReadBurstCount (
-  IN      TIS_PC_REGISTERS_PTR  &= nbsp;   TisReg,
-     OUT  UINT16     &n= bsp;            = ;  *BurstCount
-  )
-{
-  UINT32          =             &nb= sp;     WaitTime;
-  UINT8          &= nbsp;           &nbs= p;      DataByte0;
-  UINT8          &= nbsp;           &nbs= p;      DataByte1;
-
-  if (BurstCount =3D=3D NULL || TisReg =3D=3D NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  WaitTime =3D 0;
-  do {
-    //
-    // TIS_PC_REGISTERS_PTR->burstCount is UINT16, but = it is not 2bytes aligned,
-    // so it needs to use MmioRead8 to read two times
-    //
-    DataByte0   =3D MmioRead8 ((UINTN)&TisRe= g->BurstCount);
-    DataByte1   =3D MmioRead8 ((UINTN)&TisRe= g->BurstCount + 1);
-    *BurstCount =3D (UINT16)((DataByte1 << 8) + = DataByte0);
-    if (*BurstCount !=3D 0) {
-      return EFI_SUCCESS;
-    }
-    MicroSecondDelay (30);
-    WaitTime +=3D 30;
-  } while (WaitTime < TIS_TIMEOUT_D);
-
-  return EFI_TIMEOUT;
-}
-
-/**
-  Set TPM chip to ready state by sending ready command TIS_PC_STS_RE= ADY
-  to Status Register in time.
-
-  @param[in] TisReg        &= nbsp;       Pointer to TIS register.
-
-  @retval    EFI_SUCCESS     = ;      TPM chip enters into ready state.
-  @retval    EFI_INVALID_PARAMETER TisReg is NULL. -  @retval    EFI_TIMEOUT     = ;      TPM chip can't be set to ready state in tim= e.
-**/
-EFI_STATUS
-EFIAPI
-TisPcPrepareCommand (
-  IN      TIS_PC_REGISTERS_PTR  &= nbsp;   TisReg
-  )
-{
-  EFI_STATUS         &n= bsp;            = ;  Status;
-
-  if (TisReg =3D=3D NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);
-  Status =3D TisPcWaitRegisterBits (
-             = &TisReg->Status,
-             = TIS_PC_STS_READY,
-             = 0,
-             = TIS_TIMEOUT_B
-             = );
-  return Status;
-}
-
-/**
-  Get the control of TPM chip by sending requestUse command TIS_PC_A= CC_RQUUSE
-  to ACCESS Register in the time of default TIS_TIMEOUT_A.
-
-  @param[in] TisReg        &= nbsp;       Pointer to TIS register.
-
-  @retval    EFI_SUCCESS     = ;      Get the control of TPM chip.
-  @retval    EFI_INVALID_PARAMETER TisReg is NULL. -  @retval    EFI_NOT_FOUND    &nb= sp;    TPM chip doesn't exit.
-  @retval    EFI_TIMEOUT     = ;      Can't get the TPM control in time.
-**/
-EFI_STATUS
-EFIAPI
-TisPcRequestUseTpm (
-  IN      TIS_PC_REGISTERS_PTR  &= nbsp;   TisReg
-  )
-{
-  EFI_STATUS         &n= bsp;            = ;  Status;
-
-  if (TisReg =3D=3D NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  if (!TisPcPresenceCheck (TisReg)) {
-    return EFI_NOT_FOUND;
-  }
-
-  MmioWrite8((UINTN)&TisReg->Access, TIS_PC_ACC_RQUUSE);
-  //
-  // No locality set before, ACCESS_X.activeLocality MUST be valid w= ithin TIMEOUT_A
-  //
-  Status =3D TisPcWaitRegisterBits (
-             = &TisReg->Access,
-             = (UINT8)(TIS_PC_ACC_ACTIVE |TIS_PC_VALID),
-             = 0,
-             = TIS_TIMEOUT_A
-             = );
-  return Status;
-}
diff --git a/SecurityPkg/Library/TpmCommLib/TpmComm.c b/SecurityPkg/Librar= y/TpmCommLib/TpmComm.c
deleted file mode 100644
index dee64b24ffef..000000000000
--- a/SecurityPkg/Library/TpmCommLib/TpmComm.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/** @file
-  Basic TPM command functions.
-
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR&= gt;
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "CommonHeader.h"
-
-/**
-  Single function calculates SHA1 digest value for all raw data. It<= br> -  combines Sha1Init(), Sha1Update() and Sha1Final().
-
-  @param[in]  Data       &nb= sp;  Raw data to be digested.
-  @param[in]  DataLen       Size = of the raw data.
-  @param[out] Digest        Point= er to a buffer that stores the final digest.
-
-  @retval     EFI_SUCCESS   Always suc= cessfully calculate the final digest.
-**/
-EFI_STATUS
-EFIAPI
-TpmCommHashAll (
-  IN  CONST UINT8       &nbs= p;           *Data,
-  IN        UINTN  &nbs= p;            &= nbsp;   DataLen,
-  OUT       TPM_DIGEST  &nbs= p;           *Digest
-  )
-{
-  VOID     *Sha1Ctx;
-  UINTN    CtxSize;
-
-  CtxSize =3D Sha1GetContextSize ();
-  Sha1Ctx =3D AllocatePool (CtxSize);
-  ASSERT (Sha1Ctx !=3D NULL);
-
-  Sha1Init (Sha1Ctx);
-  Sha1Update (Sha1Ctx, Data, DataLen);
-  Sha1Final (Sha1Ctx, (UINT8 *)Digest);
-
-  FreePool (Sha1Ctx);
-
-  return EFI_SUCCESS;
-}
-
diff --git a/SecurityPkg/Library/TpmCommLib/CommonHeader.h b/SecurityPkg/L= ibrary/TpmCommLib/CommonHeader.h
deleted file mode 100644
index aa2e412a116d..000000000000
--- a/SecurityPkg/Library/TpmCommLib/CommonHeader.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/** @file
-  The internal header file for TpmCommLib.
-
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR&= gt;
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _TPMCOMMLIB_COMMON_HEADER_H_
-#define _TPMCOMMLIB_COMMON_HEADER_H_
-
-#include <PiPei.h>
-#include <IndustryStandard/Tpm12.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/IoLib.h>
-#include <Library/TimerLib.h>
-#include <Library/TpmCommLib.h>
-#include <Library/BaseCryptLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-
-#endif
diff --git a/SecurityPkg/Library/TpmCommLib/TpmCommLib.inf b/SecurityPkg/L= ibrary/TpmCommLib/TpmCommLib.inf
deleted file mode 100644
index 4caabd496f59..000000000000
--- a/SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
+++ /dev/null
@@ -1,45 +0,0 @@
-## @file
-#  Provides some common functions for the TCG feature
-#
-#  This instance provides basic TPM Interface Specification (TIS) fu= nctions
-#  and TPM hashall function.
-#
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<B= R>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION         &= nbsp;          =3D 0x00010005<= br> -  BASE_NAME         &nb= sp;            =3D T= pmCommLib
-  MODULE_UNI_FILE        &nb= sp;       =3D TpmCommLib.uni
-  FILE_GUID         &nb= sp;            =3D 7= d9fe32e-a6a9-4cdf-abff-10cc7f22e1c9
-  MODULE_TYPE         &= nbsp;          =3D PEIM
-  VERSION_STRING        &nbs= p;        =3D 1.0
-  LIBRARY_CLASS         = ;         =3D TpmCommLib|DXE_DRIVER= UEFI_DRIVER PEIM DXE_SMM_DRIVER
-
-#
-# The following information is for reference only and not required by the= build tools.
-#
-#  VALID_ARCHITECTURES       &nbs= p;   =3D IA32 X64
-#
-
-[Sources]
-  TisPc.c
-  TpmComm.c
-  CommonHeader.h
-
-[Packages]
-  MdePkg/MdePkg.dec
-  SecurityPkg/SecurityPkg.dec
-  CryptoPkg/CryptoPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  BaseMemoryLib
-  IoLib
-  TimerLib
-  BaseCryptLib
-  MemoryAllocationLib
-  DebugLib
-
diff --git a/SecurityPkg/Library/TpmCommLib/TpmCommLib.uni b/SecurityPkg/L= ibrary/TpmCommLib/TpmCommLib.uni
deleted file mode 100644
index 96194551be88..000000000000
--- a/SecurityPkg/Library/TpmCommLib/TpmCommLib.uni
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file
-// Provides some common functions for the TCG feature
-//
-// This instance provides basic TPM Interface Specification (TIS) functio= ns
-// and TPM hashall function.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<= BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT       &nbs= p;     #language en-US "Provides some common funct= ions for the TCG feature"
-
-#string STR_MODULE_DESCRIPTION       &= nbsp;  #language en-US "This instance provides basic TPM Interfac= e Specification (TIS) functions and TPM hashall function."
-
diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 2cdfb02cc5a2..240d422405cc 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -5,7 +5,7 @@
 #  It also provides the definitions(including PPIs/PROTOCOLs/GU= IDs and library classes)
 #  and libraries instances, which are used for those features.<= br>  #
-# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<B= R>
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.&= lt;BR>
 # (C) Copyright 2015 Hewlett Packard Enterprise Development LP <B= R>
 # Copyright (c) 2017, Microsoft Corporation.  All rights reserv= ed. <BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -55,10 +55,6 @@ [LibraryClasses]
   #
   Tpm12DeviceLib|Include/Library/Tpm12DeviceLib.h
 
-  ##  @libraryclass  Provides TPM Interface Specification = (TIS) interfaces for TPM command.
-  #
-  TpmCommLib|Include/Library/TpmCommLib.h
-
   ##  @libraryclass  Provides support for TCG Physica= l Presence Interface (PPI) specification
   #   >=3D 128 Vendor Specific PPI Operation.
   #
diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 53fce0535316..8ef6c9ee2f4d 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  Security Module Package for All Architectures.
 #
-# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<B= R>
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.&= lt;BR>
 # (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP&= lt;BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -45,7 +45,6 @@ [LibraryClasses]
   UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/Ue= fiHiiServicesLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.in= f
-  TpmCommLib|SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
   PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/P= latformSecureLibNull.inf
   TcgPhysicalPresenceLib|SecurityPkg/Library/DxeTcgPhysicalPres= enceLib/DxeTcgPhysicalPresenceLib.inf
   TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/Dx= eTpmMeasurementLib.inf
@@ -185,7 +184,6 @@ [Components]
   # TPM
   #
   SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib= .inf
-  SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
   SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalP= resenceLib.inf
   SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
   SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf=
--
2.18.0.windows.1




--_000_CY4PR21MB07434F4DA83360EF4A2FCA60EFD40CY4PR21MB0743namp_--