From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:25 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: qi1.zhang@intel.com) IronPort-SDR: aIP44kIe9UOjn2HyZwE2Q5O/VRG6ciWPasniwZ/ExOMuLout43u9BQs3nanRNDDFATk7Ydd5PH LgaaQwoebfiw== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113491" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113491" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:25 -0700 IronPort-SDR: J8ovL6oyvBjnzTloSG7UoidqwbL8GB5rtvJHslv3jQ8UpabZTxoC1rZ/3zDxOmqz9B83Log2XF t0MDiug+UTGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273529" Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:23 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang , Rahul Kumar Subject: [PATCH v3 3/6] SecurityPkg/Tcg: Add TcgPpi Date: Fri, 17 Jul 2020 15:33:09 +0800 Message-Id: <20200717073312.10594-4-qi1.zhang@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-1-qi1.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jiewen Yao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Jiewen Yao --- SecurityPkg/Tcg/TcgPei/TcgPei.c | 61 ++++++++++++++++++++++++++++--- SecurityPkg/Tcg/TcgPei/TcgPei.inf | 3 +- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPe= i.c index a9a808c9ec..2533388849 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c @@ -1,7 +1,7 @@ /** @file=0D Initialize TPM device and measure FVs before handing off control to DXE.= =0D =0D -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2005 - 2020, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D +#include =0D =0D #include =0D #include =0D @@ -51,6 +52,45 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = =3D { NULL=0D };=0D =0D +/**=0D + Do a hash operation on a data buffer, extend a specific TPM PCR with the= hash result,=0D + and build a GUIDed HOB recording the event which will be passed to the D= XE phase and=0D + added into the Event Log.=0D +=0D + @param[in] This Indicates the calling context=0D + @param[in] Flags Bitmap providing additional information.=0D + @param[in] HashData Physical address of the start of the data = buffer=0D + to be hashed, extended, and logged.=0D + @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData.=0D + @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data struct= ure.=0D + @param[in] NewEventData Pointer to the new event data.=0D +=0D + @retval EFI_SUCCESS Operation completed successfully.=0D + @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.=0D + @retval EFI_DEVICE_ERROR The command was unsuccessful.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +HashLogExtendEvent (=0D + IN EDKII_TCG_PPI *This,=0D + IN UINT64 Flags,=0D + IN UINT8 *HashData,=0D + IN UINTN HashDataLen,=0D + IN TCG_PCR_EVENT_HDR *NewEventHdr,=0D + IN UINT8 *NewEventData=0D + );=0D +=0D +EDKII_TCG_PPI mEdkiiTcgPpi =3D {=0D + HashLogExtendEvent=0D +};=0D +=0D +EFI_PEI_PPI_DESCRIPTOR mTcgPpiList =3D {=0D + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,=0D + &gEdkiiTcgPpiGuid,=0D + &mEdkiiTcgPpi=0D +};=0D +=0D //=0D // Number of firmware blobs to grow by each time we run out of room=0D //=0D @@ -243,7 +283,8 @@ TpmCommHashAll ( and build a GUIDed HOB recording the event which will be passed to the D= XE phase and=0D added into the Event Log.=0D =0D - @param[in] PeiServices Describes the list of possible PEI Service= s.=0D + @param[in] This Indicates the calling context.=0D + @param[in] Flags Bitmap providing additional information.=0D @param[in] HashData Physical address of the start of the data = buffer=0D to be hashed, extended, and logged.=0D @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData.=0D @@ -256,8 +297,10 @@ TpmCommHashAll ( =0D **/=0D EFI_STATUS=0D +EFIAPI=0D HashLogExtendEvent (=0D - IN EFI_PEI_SERVICES **PeiServices,=0D + IN EDKII_TCG_PPI *This,=0D + IN UINT64 Flags,=0D IN UINT8 *HashData,=0D IN UINTN HashDataLen,=0D IN TCG_PCR_EVENT_HDR *NewEventHdr,=0D @@ -346,7 +389,8 @@ MeasureCRTMVersion ( TcgEventHdr.EventSize =3D (UINT32) StrSize((CHAR16*)PcdGetPtr (PcdFirmwa= reVersionString));=0D =0D return HashLogExtendEvent (=0D - PeiServices,=0D + &mEdkiiTcgPpi,=0D + 0,=0D (UINT8*)PcdGetPtr (PcdFirmwareVersionString),=0D TcgEventHdr.EventSize,=0D &TcgEventHdr,=0D @@ -415,7 +459,8 @@ MeasureFvImage ( TcgEventHdr.EventSize =3D sizeof (FvBlob);=0D =0D Status =3D HashLogExtendEvent (=0D - (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),=0D + &mEdkiiTcgPpi,=0D + 0,=0D (UINT8*) (UINTN) FvBlob.BlobBase,=0D (UINTN) FvBlob.BlobLength,=0D &TcgEventHdr,=0D @@ -744,6 +789,12 @@ PeimEntryMP ( Status =3D PeiServicesNotifyPpi (&mNotifyList[0]);=0D ASSERT_EFI_ERROR (Status);=0D =0D + //=0D + // install Tcg Services=0D + //=0D + Status =3D PeiServicesInstallPpi (&mTcgPpiList);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D return Status;=0D }=0D =0D diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/Tcg= Pei.inf index c0bff6e85e..4ab4edd657 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf @@ -4,7 +4,7 @@ # This module will initialize TPM device, measure reported FVs and BIOS v= ersion.=0D # This module may also lock TPM physical presence and physicalPresenceLif= etimeLock.=0D #=0D -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -67,6 +67,7 @@ gPeiTpmInitializedPpiGuid ## S= OMETIMES_PRODUCES=0D gPeiTpmInitializationDonePpiGuid ## P= RODUCES=0D gEfiEndOfPeiSignalPpiGuid ## S= OMETIMES_CONSUMES ## NOTIFY=0D + gEdkiiTcgPpiGuid ## P= RODUCES=0D =0D [Pcd]=0D gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceLifetimeLock ## S= OMETIMES_CONSUMES=0D --=20 2.26.2.windows.1