From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.65734.1597756025317677383 for ; Tue, 18 Aug 2020 06:07:05 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=TFbkjoTE; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: chasel.chiu@intel.com) IronPort-SDR: yfmOJqyLUqD3g3UjL8TpLiE+mdKCICno3GEWxUUIqNDhj2KouzU+LfkaJnDKMFwfBt5DtDb4Gc qfUvil2vbCpw== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="155974528" X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="155974528" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 06:07:04 -0700 IronPort-SDR: mRq4aIxWbuzBRPrtqCsZ0TyZXgDuftWREFtiFQ6EaLDUezRBC9Q8ANp6RCfCOgQviPFTDpTmF9 UU6SnYxO1hxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="334365323" Received: from orsmsx601-2.jf.intel.com (HELO ORSMSX601.amr.corp.intel.com) ([10.22.229.81]) by FMSMGA003.fm.intel.com with ESMTP; 18 Aug 2020 06:07:04 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 18 Aug 2020 06:07:03 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 18 Aug 2020 06:07:03 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 18 Aug 2020 06:06:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIn/lnjbjE4cVkqLOD4ukYINFzinDYDfS7EVMzTgpS5kO7IVvt84Vqd96KxD1xp/LuXjtFwrTkXVmZRtts94iKpx2ZzjazNwT/CF+LFsuvlBYzebhliTD8p2KlAfmMCEqu43wEf78uxa4tP4+Rg8F7yHMAMeFOfkocOZzAq8FjfY0YZnMe6X/1peUtGBP34R6jacpourrrB8rAlCQ3SQhKbxDQS/FYE0c5NJjbUHGLyhEFRqDxUpqOf6MCYlBH9XI1GzgM+c+SLMc8tMtTCjJyGJSKAQOqln/XcLfgwjZ0kFWYLW4jro+e21CZAZhIiGRIZNdZ0zxKu8TiobRLmloQ== 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=EsDdYCypPMqPv4GFgEFf0IwZg4LCbhwvOOUX12Q7TOM=; b=QlZHXmBVrCbhz0mRgtIJm+p2uKYGV+m7mnV1tjTKDK36Qh/pEgrDrraX1OIPqjMaaqQvcZo91vnsJF2SrgXqUX/RKalZEmU25Ppia/LI14M4RPBvy4Jtmwkalh/3NwhD7LMz1DI0JXAK+qRbvr/tc9XvnKPwCzkcmkBmsSuwQud608PvgElXR6KXnqhlHaAoRTNo3PD/FffBr6Ik4aFVWlUreLd8lI0Xz1UpxOmUQgz897Fxkgrvd/rINTEYbGH2qbLdvq0ZCaeOGOjOGFBnO7aoLcUGH/AetGWCFIZaurEK5nfGk7ouYI1DEacKwfbTiPXBabTX61FHfXZqzqZB4w== 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=EsDdYCypPMqPv4GFgEFf0IwZg4LCbhwvOOUX12Q7TOM=; b=TFbkjoTEdsU25hrS0pWpYx7xtuDyJCCcbJMU9t6Fjwg91ajrVxIYG3RnvbgPrgtKXJ99FV2kg17j2BqduvD560m2GRhzCZ5OJSxwMJ0h+swl3FmPWgLZ/mPfBgCtJyl1iyG2NojuDLMPdGiYATRzm7BbobvZ8sGeqLlCVQSYUwA= Received: from SN6PR11MB2814.namprd11.prod.outlook.com (2603:10b6:805:55::15) by SN6PR11MB2559.namprd11.prod.outlook.com (2603:10b6:805:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.25; Tue, 18 Aug 2020 13:06:55 +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.3305.024; Tue, 18 Aug 2020 13:06:55 +0000 From: "Chiu, Chasel" To: "Zhang, Qi1" , "devel@edk2.groups.io" CC: "Yao, Jiewen" , "Desimone, Nathaniel L" , "Zeng, Star" Subject: Re: [PATCH v4 3/8] IntelFsp2WrapperPkg/FspMeasurementLib: Add BaseFspMeasurementLib. Thread-Topic: [PATCH v4 3/8] IntelFsp2WrapperPkg/FspMeasurementLib: Add BaseFspMeasurementLib. Thread-Index: AQHWdSiMyOSkkODlw0eMX7HW12kHNKk91oeg Date: Tue, 18 Aug 2020 13:06:54 +0000 Message-ID: References: <20200818062618.3698-1-qi1.zhang@intel.com> <20200818062618.3698-4-qi1.zhang@intel.com> In-Reply-To: <20200818062618.3698-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: [220.129.108.102] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b3dea2be-e007-420c-e37f-08d8437794da x-ms-traffictypediagnostic: SN6PR11MB2559: 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: 3KXuMkTMAf0vXRwUEqErQZMTH18tTZ2rs2V64N4M6Z8+YrLgSeoUBVMIa8d92SF8V97C2BlnkNvg/II8GVbuTnQytzO0m4PeSTkdM/AFeD6bAOqLa6Re29Ob5qJ5a4gr4lVz1NNo5PQ6Gomq9Co0Tm2GyOrPWulB/y5wRYuh9cu1x70cxFNX4rs+qRxPvGI35HuAj4SxlL6C2DUVLzlcOOIaVUu1G99QQ+DQ/VPWcIU8YSVSZ2l6HibrH1/IgygbQVBOfh5BgBpLEp4WmFvpkwhFPpxh7LXz0gK/gKgyskAjbitaQXYRRnE5fxsLlk0wkrHfJwA6o4HbM9NjjgSI4/7uodtilV9LQaQ68cYvgIPLBrrp7t4XyGo7loE8M2AJS4VWe4CVONXcXU7EeJ1rcA== 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)(346002)(136003)(396003)(39860400002)(366004)(376002)(966005)(4326008)(30864003)(186003)(8936002)(478600001)(26005)(64756008)(83380400001)(33656002)(19627235002)(66946007)(66476007)(71200400001)(76116006)(66556008)(66446008)(107886003)(86362001)(5660300002)(9686003)(54906003)(53546011)(8676002)(7696005)(6506007)(110136005)(55016002)(52536014)(316002)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: kZRrnCmwgrJXmrfP2xXb0Z5RkVtQTtkKyhagObO8nBDXSxmYEptHSQGPtXTIZ3U7JNRUSKX7u/TQYteYgwtnJizzlAB6s/5mJOMlwqGlAuNhXIssXHUx9reHYB5EwCwdFHQ7lPGlsfsOt/Oylxn2Ti6whS9hBiHbN3c3KvrrgCs0R/aVDbheT3hVok0uAgouEQR+DDTq49iDLa53jht2/t6zJde19pzf12xMm27ro3yTAQUpXYRBWWt6k5cpv0FhipGUe5Jce4GLvVogNrjW4rlF+c8FRLTVCiGEp4G9F0V8E2DY2d4v5VlddWznYdateu5juotFRlXtcgAlitxy6Sb4F7Tt6mki6rEQZdSl+qv5h3F4J9OMdHAmSqsXfNwbnD8k9AEREEtB4QtMboStoiGEHUxqwM4FW5CgjieQKpOe64SK6qlQAfyDZhKCpljGXMPWZBJjTJstvzpKeOOZHimO5yoHNyY1wUndRr1lAxy9/WeIrNQwBRW19nSOOVCK/dUNbkbicUe/wSnadSI6UERV1Z+PW/dLIJ+ELFhQrXtRoOpmbDkEDLPZ669MrtNBSW5rMBtGoCF2h/9WsZw3S13OIPoSUOKDTZFuogEN4sG1Exj6+IUBw3zDZ/efg5Kr4bV2egftBtVpWDwoTBds8g== 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: b3dea2be-e007-420c-e37f-08d8437794da X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2020 13:06:54.7928 (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: 2ghpr6Gr7sm1xzNzVhc4Sx96N1u6doTwcwMlBwNidK0clwH4snK7z3Z30Swppoksm+IrwPWChQj0YIzGm+dmsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2559 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: Tuesday, August 18, 2020 2:26 PM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Chiu, Chasel > ; Desimone, Nathaniel L > ; Zeng, Star ; Zhang= , > Qi1 > Subject: [PATCH v4 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..1b5f0012aa > --- /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 > 890B12B4-56CC-453E-B062-4597FC6D3D8C >=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 > + TcgEventLogRecordLib >=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..0fe0606a6d > --- /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