From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.58693.1597720532123540067 for ; Mon, 17 Aug 2020 20:15:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=m1oSSmo+; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: chasel.chiu@intel.com) IronPort-SDR: Sp/D5+WKNvrflrpIjK+iW9JmNvTj4JXhpx59aw84YplyDTIHcrPQZ84XQ4qI2fkBBlrqyO5l4d mlIdBYbvK4mg== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="239657269" X-IronPort-AV: E=Sophos;i="5.76,325,1592895600"; d="scan'208";a="239657269" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 20:15:31 -0700 IronPort-SDR: YLC7NXQ4mImCYFT20UP+iUamzx1+gCxc6E7pTGH03X8Us+UE52Mf3pFKQxmjieR6BZq450UNtB lqwIH/rwei0Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,325,1592895600"; d="scan'208";a="310297134" Received: from orsmsx604-2.jf.intel.com (HELO ORSMSX604.amr.corp.intel.com) ([10.22.229.84]) by orsmga002.jf.intel.com with ESMTP; 17 Aug 2020 20:15:30 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 17 Aug 2020 20:15:30 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 17 Aug 2020 20:15:30 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.177) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 17 Aug 2020 20:15:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DY/WMQsIh+bQNjAYJclLbehPFRoK+6le8ub0/lTB78WA9eI0ruvykJ+JlQDjMhiuiIF3lU1lksqIL2OAh8SmUfmzi0oC4cJaYDjak0f4nk7hOpwtYW8DXcvNaxTKXJFlBvE7KzKr+Oa/27ynV7lu0K9SD1BDYxWBfQTXKT60IDOiCxeYNrr4682QI/xcxTXh3eRoJhZtq9bhuFWO/Ill6Fc8OTvFB0c5HxC1+UvnTx8ztFDV3apc4iC9DGM30cMhUoOktWLiY4a3QluO7Lu5ElDIS18ly6cYQutdz0l5mLJrJ3AFHvW3DNa2iLLh1mMtIzhJYmcw9O9hJXFtsCmkwg== 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=CENu6W4PWeUCDs4pzn4ON+SEDTESsiOJa0Kg7LqLuuo=; b=M3zdcX3WDZDSd8HQhICvGWegJBBB9K49ZihVgt/cLsDqayr6nZLHiGtlzyGf56qaiMC0IMN3yeTvxbtf2KhAL8jItxTha0sEk7/MxdrhUopMnWisCYk6uTGEJVEek9DkJ9BF/ayZHfYSwIfgDWufpvmM/1O3uWI+vsmrjOHQFWPFXyoKyArfKV92yqtbImSeXZP8HPVoyFS/36ojMOodOFuCe5xEPVv3Vx4oNmO+2xhcBPIdice3bEOTtpW2AWdZQedgmZ6XkEQwFA25p2YQQpSn4y6fJSrVx+Y27dMHUxoc2vsYWRUpUGoriVuHEQeKk9BCrqz3EpQ8/d//+xEAVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CENu6W4PWeUCDs4pzn4ON+SEDTESsiOJa0Kg7LqLuuo=; b=m1oSSmo+RavZ8kFpMqmQaIoEnN2KpDfua+q+jf5h8XeTxG4znq1QXVmS4aMnKw+vrVHgbg/0rf9Vpf4GaTzeLNfOwWikym+JJSIXTyCr2MB+AD+Ed11dqpuo4o8tf+dPlrJvgvsp8tIWjH4f9ekcrzHGwXLT2X4edUxG5O9XT9A= Received: from SN6PR11MB2814.namprd11.prod.outlook.com (2603:10b6:805:55::15) by SA0PR11MB4576.namprd11.prod.outlook.com (2603:10b6:806:97::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Tue, 18 Aug 2020 03:15:27 +0000 Received: from SN6PR11MB2814.namprd11.prod.outlook.com ([fe80::4843:7aba:799b:326]) by SN6PR11MB2814.namprd11.prod.outlook.com ([fe80::4843:7aba:799b:326%5]) with mapi id 15.20.3283.028; Tue, 18 Aug 2020 03:15:27 +0000 From: "Chiu, Chasel" To: "Zhang, Qi1" , "devel@edk2.groups.io" CC: "Yao, Jiewen" , "Desimone, Nathaniel L" , "Zeng, Star" Subject: Re: [PATCH v3 3/8] IntelFsp2WrapperPkg/FspMeasurementLib: Add BaseFspMeasurementLib. Thread-Topic: [PATCH v3 3/8] IntelFsp2WrapperPkg/FspMeasurementLib: Add BaseFspMeasurementLib. Thread-Index: AQHWcgSsr6uNIGbCu0i4iw5LKgHgHKk9N2KQ Date: Tue, 18 Aug 2020 03:15:27 +0000 Message-ID: References: <20200814063159.2477-1-qi1.zhang@intel.com> <20200814063159.2477-4-qi1.zhang@intel.com> In-Reply-To: <20200814063159.2477-4-qi1.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [61.60.205.141] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4ce475c6-11fa-4293-ca84-08d84324f483 x-ms-traffictypediagnostic: SA0PR11MB4576: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HED7YLSIjlKNg00J8pN4oOl6WjcDx/N2ZsCzZ4jq0E8svURDAGXzVum2XFxtbcmGSN0Z/L24NTu9WDxd/z0etbC8ieOdZJb2CJ1hdIMiWWnXqtvhjuj+gwYqjnK3pxv0K1FEmm+/BaLOsNAdxr5tpD3xOpRt13ymtyCZTf7+uj/sWoMUtE9rUPzxrnDWaY8I8iM9GB7jlSr849aN3nV22Rs89G8vzF7ZnLtl5z79vVp2xozPL3hKjeL+USWibaSHYUMBLx1nB5Isjm5whDIqNrQiKiweXhnS55CAOrA+i3lLKSSwwh3URBVcJlnAo04vqRSS8l34dktoJUgukXwzbU/EckoiSErggS3oWuW/kXRVuoMJvyftngl3lfuLHnFqZErb7VBgFxYFqNY5jiy9Xg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2814.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39860400002)(136003)(366004)(376002)(346002)(4326008)(33656002)(8936002)(107886003)(2906002)(8676002)(110136005)(9686003)(26005)(5660300002)(55016002)(186003)(19627235002)(71200400001)(30864003)(66476007)(86362001)(966005)(76116006)(316002)(64756008)(83380400001)(53546011)(66446008)(66946007)(6506007)(54906003)(66556008)(52536014)(478600001)(7696005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: fTeEXZoNlDyrM0DHEzqjpQz1IK/NAlQmB7gnwifV1r4ffghHvavHwBhw0Cp6uxEdi1Xq0l4DIDjgDma5feIvPaPmfPL47egfKQH5bHouviQ122aicjaFI7NVlclmSkNYjLzLkg+h92XVUs2VS8U9ZpG0tOIhRmGk4genltiAEA8rRIdTQ293m034EfN6sk14wf3zRQuPlPmHbUwo7YffsaVdyR0NgElDl0oZgk3BYhtJTUNffzRrgN/qsiHZYkvqgtxCIsaxqOB+oF+uyeU9zxOSoixTUsy0ZdbE0xITy62QuFjKYroZsJbLUCdD5P3rd3SHnZOEb4D/gqKz9vROrtol786abQL93HeanzaFBG5wKIFOU44Vi1AVjw5wP9YnhqylfVVPzktGT6/cQtWQO/KAkzMISxcvOeKxLnrG+OeBOFU8OIBpCMsS6TgHJCBST1nTiLBmopAtVhdhN4tYNsxyYL55ZnjJFhb2Q5U1tBeGhWi5qG+qa89AGUk1rGU1nHpXPXWjDn2oFPZwTXr5qTdx6RNYaD3tghUIgwd4W8NEfnzjnR5iDWA4I4x8IE+YORH4Xd93ZSakm7ijOTzVOlcUCHl3gRWyIh6GhJK+QArj7girFOXq2dvkczeEvPNiI24mdmBeFLCci+fqB52elw== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2814.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ce475c6-11fa-4293-ca84-08d84324f483 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2020 03:15:27.1907 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zyZMeyEh2Hh6+ZldpMAXVzEgtKENce984p9hIRZA7b1aYoSpDrNI1PZl5GVDQMC2KOefJTeBhJbuxTFzWjBtpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4576 Return-Path: chasel.chiu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Chasel Chiu > -----Original Message----- > From: Zhang, Qi1 > Sent: Friday, August 14, 2020 2:32 PM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Chiu, Chasel > ; Desimone, Nathaniel L > ; Zeng, Star ; Zhang= , > Qi1 > Subject: [PATCH v3 3/8] IntelFsp2WrapperPkg/FspMeasurementLib: Add > BaseFspMeasurementLib. >=20 > From: Jiewen Yao >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2376 >=20 > Cc: Jiewen Yao > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Star Zeng > Cc: Qi Zhang > Signed-off-by: Jiewen Yao > --- > .../BaseFspMeasurementLib.inf | 54 ++++ > .../BaseFspMeasurementLib/FspMeasurementLib.c | 248 > ++++++++++++++++++ > 2 files changed, 302 insertions(+) > create mode 100644 > IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasuremen > tLib.inf > create mode 100644 > IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLib. > c >=20 > diff --git > a/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurem > entLib.inf > b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurem > entLib.inf > new file mode 100644 > index 0000000000..9c0dd9fb40 > --- /dev/null > +++ > b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurem > entLib.inf > @@ -0,0 +1,54 @@ > +## @file >=20 > +# Provides FSP measurement functions. >=20 > +# >=20 > +# This library provides MeasureFspFirmwareBlob() to measure FSP binary. >=20 > +# >=20 > +# Copyright (c) 2020, Intel Corporation. All rights reserved.
>=20 > +# SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +# >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010005 >=20 > + BASE_NAME =3D FspMeasurementLib >=20 > + FILE_GUID =3D > 9A62C49D-C45A-4322-9F3C-45958DF0056B >=20 > + MODULE_TYPE =3D BASE >=20 > + VERSION_STRING =3D 1.0 >=20 > + LIBRARY_CLASS =3D FspMeasurementLib >=20 > + >=20 > +# >=20 > +# The following information is for reference only and not required by th= e > build tools. >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D IA32 X64 >=20 > +# >=20 > + >=20 > +[Sources] >=20 > + FspMeasurementLib.c >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > + MdeModulePkg/MdeModulePkg.dec >=20 > + SecurityPkg/SecurityPkg.dec >=20 > + IntelFsp2Pkg/IntelFsp2Pkg.dec >=20 > + IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec >=20 > + >=20 > +[LibraryClasses] >=20 > + BaseLib >=20 > + BaseMemoryLib >=20 > + DebugLib >=20 > + PrintLib >=20 > + PcdLib >=20 > + PeiServicesLib >=20 > + PeiServicesTablePointerLib >=20 > + FspWrapperApiLib >=20 > + FvEventLogRecordLib >=20 > + HashLib >=20 > + >=20 > +[Ppis] >=20 > + gEdkiiTcgPpiGuid > ## CONSUMES >=20 > + >=20 > +[Pcd] >=20 > + gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig > ## CONSUMES >=20 > + gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress > ## CONSUMES >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTcgPfpMeasurementRevision > ## CONSUMES >=20 > + >=20 > diff --git > a/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLi > b.c > b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLi > b.c > new file mode 100644 > index 0000000000..adb4393426 > --- /dev/null > +++ > b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLi > b.c > @@ -0,0 +1,248 @@ > +/** @file >=20 > + This library is used by FSP modules to measure data to TPM. >=20 > + >=20 > +Copyright (c) 2020, Intel Corporation. All rights reserved.
>=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > + >=20 > +#include >=20 > +#include >=20 > + >=20 > +/** >=20 > + Tpm measure and log data, and extend the measurement result into a > specific PCR. >=20 > + >=20 > + @param[in] PcrIndex PCR Index. >=20 > + @param[in] EventType Event type. >=20 > + @param[in] EventLog Measurement event log. >=20 > + @param[in] LogLen Event log length in bytes. >=20 > + @param[in] HashData The start of the data buffer to be > hashed, extended. >=20 > + @param[in] HashDataLen The length, in bytes, of the buffer > referenced by HashData >=20 > + @param[in] Flags Bitmap providing additional > information. >=20 > + >=20 > + @retval EFI_SUCCESS Operation completed successfully. >=20 > + @retval EFI_UNSUPPORTED TPM device not available. >=20 > + @retval EFI_OUT_OF_RESOURCES Out of memory. >=20 > + @retval EFI_DEVICE_ERROR The operation was unsuccessful. >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TpmMeasureAndLogDataWithFlags ( >=20 > + IN UINT32 PcrIndex, >=20 > + IN UINT32 EventType, >=20 > + IN VOID *EventLog, >=20 > + IN UINT32 LogLen, >=20 > + IN VOID *HashData, >=20 > + IN UINT64 HashDataLen, >=20 > + IN UINT64 Flags >=20 > + ) >=20 > +{ >=20 > + EFI_STATUS Status; >=20 > + EDKII_TCG_PPI *TcgPpi; >=20 > + TCG_PCR_EVENT_HDR TcgEventHdr; >=20 > + >=20 > + Status =3D PeiServicesLocatePpi( >=20 > + &gEdkiiTcgPpiGuid, >=20 > + 0, >=20 > + NULL, >=20 > + (VOID**)&TcgPpi >=20 > + ); >=20 > + if (EFI_ERROR(Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + TcgEventHdr.PCRIndex =3D PcrIndex; >=20 > + TcgEventHdr.EventType =3D EventType; >=20 > + TcgEventHdr.EventSize =3D LogLen; >=20 > + >=20 > + Status =3D TcgPpi->HashLogExtendEvent ( >=20 > + TcgPpi, >=20 > + Flags, >=20 > + HashData, >=20 > + (UINTN)HashDataLen, >=20 > + &TcgEventHdr, >=20 > + EventLog >=20 > + ); >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Measure a FSP FirmwareBlob. >=20 > + >=20 > + @param[in] Description Description for this > FirmwareBlob. >=20 > + @param[in] FirmwareBlobBase Base address of this > FirmwareBlob. >=20 > + @param[in] FirmwareBlobLength Size in bytes of this > FirmwareBlob. >=20 > + @param[in] CfgRegionOffset Configuration region offset in > bytes. >=20 > + @param[in] CfgRegionSize Configuration region in bytes. >=20 > + >=20 > + @retval EFI_SUCCESS Operation completed successfully. >=20 > + @retval EFI_UNSUPPORTED TPM device not available. >=20 > + @retval EFI_OUT_OF_RESOURCES Out of memory. >=20 > + @retval EFI_DEVICE_ERROR The operation was unsuccessful. >=20 > +**/ >=20 > +STATIC >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +MeasureFspFirmwareBlobWithCfg ( >=20 > + IN CHAR8 *Description OPTIONAL, >=20 > + IN EFI_PHYSICAL_ADDRESS FirmwareBlobBase, >=20 > + IN UINT64 FirmwareBlobLength, >=20 > + IN UINT32 CfgRegionOffset, >=20 > + IN UINT32 CfgRegionSize >=20 > + ) >=20 > +{ >=20 > + EFI_PLATFORM_FIRMWARE_BLOB FvBlob, UpdBlob; >=20 > + PLATFORM_FIRMWARE_BLOB2_STRUCT FvBlob2, UpdBlob2; >=20 > + VOID *FvName; >=20 > + UINT32 FvEventType; >=20 > + VOID *FvEventLog, *UpdEventLog; >=20 > + UINT32 FvEventLogSize, > UpdEventLogSize; >=20 > + EFI_STATUS Status; >=20 > + HASH_HANDLE HashHandle; >=20 > + UINT8 *HashBase; >=20 > + UINTN HashSize; >=20 > + TPML_DIGEST_VALUES DigestList; >=20 > + >=20 > + FvName =3D TpmMeasurementGetFvName (FirmwareBlobBase, > FirmwareBlobLength); >=20 > + >=20 > + if (((Description !=3D NULL) || (FvName !=3D NULL)) && >=20 > + (PcdGet32(PcdTcgPfpMeasurementRevision) >=3D > TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105)) { >=20 > + if (Description !=3D NULL) { >=20 > + AsciiSPrint((CHAR8*)FvBlob2.BlobDescription, > sizeof(FvBlob2.BlobDescription), "%a", Description); >=20 > + AsciiSPrint((CHAR8*)UpdBlob2.BlobDescription, > sizeof(UpdBlob2.BlobDescription), "%aUDP", Description); >=20 > + } else { >=20 > + AsciiSPrint((CHAR8*)FvBlob2.BlobDescription, > sizeof(FvBlob2.BlobDescription), "Fv(%g)", FvName); >=20 > + AsciiSPrint((CHAR8*)UpdBlob2.BlobDescription, > sizeof(UpdBlob2.BlobDescription), "(%g)UDP", FvName); >=20 > + } >=20 > + >=20 > + FvBlob2.BlobDescriptionSize =3D sizeof(FvBlob2.BlobDescription); >=20 > + FvBlob2.BlobBase =3D FirmwareBlobBase; >=20 > + FvBlob2.BlobLength =3D FirmwareBlobLength; >=20 > + FvEventType =3D EV_EFI_PLATFORM_FIRMWARE_BLOB2; >=20 > + FvEventLog =3D &FvBlob2; >=20 > + FvEventLogSize =3D sizeof(FvBlob2); >=20 > + >=20 > + UpdBlob2.BlobDescriptionSize =3D sizeof(UpdBlob2.BlobDescription); >=20 > + UpdBlob2.BlobBase =3D CfgRegionOffset; >=20 > + UpdBlob2.BlobLength =3D CfgRegionSize; >=20 > + UpdEventLog =3D &UpdBlob2; >=20 > + UpdEventLogSize =3D sizeof(UpdBlob2); >=20 > + } else { >=20 > + FvBlob.BlobBase =3D FirmwareBlobBase; >=20 > + FvBlob.BlobLength =3D FirmwareBlobLength; >=20 > + FvEventType =3D EV_EFI_PLATFORM_FIRMWARE_BLOB; >=20 > + FvEventLog =3D &FvBlob; >=20 > + FvEventLogSize =3D sizeof(FvBlob); >=20 > + >=20 > + UpdBlob.BlobBase =3D CfgRegionOffset; >=20 > + UpdBlob.BlobLength =3D CfgRegionSize; >=20 > + UpdEventLog =3D &UpdBlob; >=20 > + UpdEventLogSize =3D sizeof(UpdBlob); >=20 > + } >=20 > + >=20 > + /** Initialize a SHA hash context. **/ >=20 > + Status =3D HashStart (&HashHandle); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "HashStart failed - %r\n", Status)); >=20 > + return Status; >=20 > + } >=20 > + >=20 > + /** Hash FSP binary before UDP **/ >=20 > + HashBase =3D (UINT8 *) (UINTN) FirmwareBlobBase; >=20 > + HashSize =3D (UINTN) CfgRegionOffset; >=20 > + Status =3D HashUpdate (HashHandle, HashBase, HashSize); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "HashUpdate failed - %r\n", Status)); >=20 > + return Status; >=20 > + } >=20 > + >=20 > + /** Hash FSP binary after UDP **/ >=20 > + HashBase =3D (UINT8 *) (UINTN) FirmwareBlobBase + CfgRegionOffset + > CfgRegionSize; >=20 > + HashSize =3D (UINTN)(FirmwareBlobLength - CfgRegionOffset - > CfgRegionSize); >=20 > + Status =3D HashUpdate (HashHandle, HashBase, HashSize); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "HashUpdate failed - %r\n", Status)); >=20 > + return Status; >=20 > + } >=20 > + >=20 > + /** Finalize the SHA hash. **/ >=20 > + Status =3D HashCompleteAndExtend (HashHandle, 0, NULL, 0, &DigestList)= ; >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "HashCompleteAndExtend failed - %r\n", > Status)); >=20 > + return Status; >=20 > + } >=20 > + >=20 > + Status =3D TpmMeasureAndLogDataWithFlags ( >=20 > + 0, >=20 > + FvEventType, >=20 > + FvEventLog, >=20 > + FvEventLogSize, >=20 > + (UINT8 *) &DigestList, >=20 > + (UINTN) sizeof(DigestList), >=20 > + EDKII_TCG_PRE_HASH_LOG_ONLY >=20 > + ); >=20 > + >=20 > + Status =3D TpmMeasureAndLogData ( >=20 > + 1, >=20 > + EV_PLATFORM_CONFIG_FLAGS, >=20 > + UpdEventLog, >=20 > + UpdEventLogSize, >=20 > + (UINT8 *) (UINTN) FirmwareBlobBase + CfgRegionOffset, >=20 > + CfgRegionSize >=20 > + ); >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Measure a FSP FirmwareBlob. >=20 > + >=20 > + @param[in] PcrIndex PCR Index. >=20 > + @param[in] Description Description for this > FirmwareBlob. >=20 > + @param[in] FirmwareBlobBase Base address of this > FirmwareBlob. >=20 > + @param[in] FirmwareBlobLength Size in bytes of this > FirmwareBlob. >=20 > + >=20 > + @retval EFI_SUCCESS Operation completed successfully. >=20 > + @retval EFI_UNSUPPORTED TPM device not available. >=20 > + @retval EFI_OUT_OF_RESOURCES Out of memory. >=20 > + @retval EFI_DEVICE_ERROR The operation was unsuccessful. >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +MeasureFspFirmwareBlob ( >=20 > + IN UINT32 PcrIndex, >=20 > + IN CHAR8 *Description OPTIONAL, >=20 > + IN EFI_PHYSICAL_ADDRESS FirmwareBlobBase, >=20 > + IN UINT64 FirmwareBlobLength >=20 > + ) >=20 > +{ >=20 > + UINT32 FspMeasureMask; >=20 > + FSP_INFO_HEADER *FspHeaderPtr; >=20 > + >=20 > + FspMeasureMask =3D PcdGet32 (PcdFspMeasurementConfig); >=20 > + if ((FspMeasureMask & FSP_MEASURE_FSPUPD) !=3D 0) { >=20 > + FspHeaderPtr =3D (FSP_INFO_HEADER *) FspFindFspHeader > (FirmwareBlobBase); >=20 > + if (FspHeaderPtr !=3D NULL) { >=20 > + return MeasureFspFirmwareBlobWithCfg(Description, > FirmwareBlobBase, FirmwareBlobLength, >=20 > + > FspHeaderPtr->CfgRegionOffset, FspHeaderPtr->CfgRegionSize); >=20 > + } >=20 > + } >=20 > + >=20 > + return MeasureFirmwareBlob (PcrIndex, Description, FirmwareBlobBase, > FirmwareBlobLength); >=20 > +} >=20 > + >=20 > -- > 2.26.2.windows.1