From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 658E78192A for ; Tue, 3 Jan 2017 23:50:59 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 03 Jan 2017 23:50:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,458,1477983600"; d="scan'208";a="209446598" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 03 Jan 2017 23:50:58 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 3 Jan 2017 23:50:58 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 3 Jan 2017 23:50:56 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Wed, 4 Jan 2017 15:50:56 +0800 From: "Long, Qin" To: "Zhang, Chao B" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [PATCH] SecurityPkg: Tcg2ConfigDxe: Display TPM2 HID in Tcg2Config Thread-Index: AQHSZlrl1tnJ/d/eSEuJZXYp3EWkkaEn8ccQ Date: Wed, 4 Jan 2017 07:50:55 +0000 Message-ID: References: <20170104071911.1044-1-chao.b.zhang@intel.com> In-Reply-To: <20170104071911.1044-1-chao.b.zhang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg: Tcg2ConfigDxe: Display TPM2 HID in Tcg2Config X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2017 07:50:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Qin Long > -----Original Message----- > From: Zhang, Chao B > Sent: Wednesday, January 04, 2017 3:19 PM > To: edk2-devel@lists.01.org > Cc: Long, Qin; Yao, Jiewen; Zhang, Chao B > Subject: [PATCH] SecurityPkg: Tcg2ConfigDxe: Display TPM2 HID in > Tcg2Config >=20 > Display TPM2 HID from TPM2 ACPI device object in Tcg2Config UI >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Chao Zhang > --- > SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr | 9 +- > SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 107 > ++++++++++++++++++++++- > SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.h | 4 +- > SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni | 6 +- > SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 3 +- > 5 files changed, 123 insertions(+), 6 deletions(-) >=20 > diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr > b/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr > index a805d53..ed833c6 100644 > --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr > +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr > @@ -1,7 +1,7 @@ > /** @file > VFR file used by the TCG2 configuration component. >=20 > -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -59,6 +59,13 @@ formset >=20 > suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice =3D=3D > TPM_DEVICE_NULL TPM_DEVICE_1_2; >=20 > + subtitle text =3D STRING_TOKEN(STR_NULL); > + > + text > + help =3D STRING_TOKEN(STR_TPM2_ACPI_HID_HELP), > + text =3D STRING_TOKEN(STR_TPM2_ACPI_HID_PROMPT), > + text =3D STRING_TOKEN(STR_TPM2_ACPI_HID_CONTENT); > + > oneof varid =3D TCG2_CONFIGURATION_NV_INFO.TpmAcpiTableRev, > questionid =3D KEY_TPM_ACPI_REVISION, > prompt =3D STRING_TOKEN(STR_TCG2_ACPI_REVISION_PROMPT), > diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c > b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c > index afba42c..013caf8 100644 > --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c > +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c > @@ -2,7 +2,7 @@ > HII Config Access protocol implementation of TCG2 configuration module= . > NOTE: This module is only for reference only, each platform should hav= e its > own setup page. >=20 > -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -429,6 +429,83 @@ Tcg2RouteConfig ( } >=20 > /** > + Get HID string of TPM2 ACPI device object > + > + @param[in] HID Points to HID String Buffer. > + @param[in] Size HID String size in bytes. Must >=3D > TPM_HID_ACPI_SIZE > + > + @return HID String get status. > + > +**/ > +EFI_STATUS > +GetTpm2HID( > + CHAR8 *HID, > + UINTN Size > + ) > +{ > + EFI_STATUS Status; > + UINT32 ManufacturerID; > + UINT32 FirmwareVersion1; > + UINT32 FirmwareVersion2; > + BOOLEAN PnpHID; > + > + PnpHID =3D TRUE; > + > + ZeroMem(HID, Size); > + > + // > + // Get Manufacturer ID > + // > + Status =3D Tpm2GetCapabilityManufactureID(&ManufacturerID); > + if (!EFI_ERROR(Status)) { > + DEBUG((DEBUG_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", > ManufacturerID)); > + // > + // ManfacturerID defined in TCG Vendor ID Registry > + // may tailed with 0x00 or 0x20 > + // > + if ((ManufacturerID >> 24) =3D=3D 0x00 || ((ManufacturerID >> 24) = =3D=3D 0x20)) { > + // > + // HID containing PNP ID "NNN####" > + // NNN is uppercase letter for Vendor ID specified by manufactur= er > + // > + CopyMem(HID, &ManufacturerID, 3); > + } else { > + // > + // HID containing ACP ID "NNNN####" > + // NNNN is uppercase letter for Vendor ID specified by manufactu= rer > + // > + CopyMem(HID, &ManufacturerID, 4); > + PnpHID =3D FALSE; > + } > + } else { > + DEBUG ((DEBUG_ERROR, "Get TPM_PT_MANUFACTURER failed %x!\n", > Status)); > + ASSERT(FALSE); > + return Status; > + } > + > + Status =3D Tpm2GetCapabilityFirmwareVersion(&FirmwareVersion1, > + &FirmwareVersion2); if (!EFI_ERROR(Status)) { > + DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_1 0x%x\n", > FirmwareVersion1)); > + DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_2 0x%x\n", > FirmwareVersion2)); > + // > + // #### is Firmware Version 1 > + // > + if (PnpHID) { > + AsciiSPrint(HID + 3, TPM_HID_PNP_SIZE - 3, "%02d%02d", > ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && > 0x0000FFFF)); > + } else { > + AsciiSPrint(HID + 4, TPM_HID_ACPI_SIZE - 4, "%02d%02d", > ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && > 0x0000FFFF)); > + } > + > + } else { > + DEBUG ((DEBUG_ERROR, "Get TPM_PT_FIRMWARE_VERSION_X > failed %x!\n", Status)); > + ASSERT(FALSE); > + return Status; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > This function processes the results of changes in configuration. >=20 > @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PRO= TOCOL. > @@ -461,12 +538,38 @@ Tcg2Callback ( > OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest > ) > { > - EFI_INPUT_KEY Key; > + EFI_STATUS Status; > + EFI_INPUT_KEY Key; > + CHAR8 HidStr[16]; > + CHAR16 UnHidStr[16]; > + TCG2_CONFIG_PRIVATE_DATA *Private; >=20 > if ((This =3D=3D NULL) || (Value =3D=3D NULL) || (ActionRequest =3D=3D= NULL)) { > return EFI_INVALID_PARAMETER; > } >=20 > + Private =3D TCG2_CONFIG_PRIVATE_DATA_FROM_THIS (This); > + > + if (Action =3D=3D EFI_BROWSER_ACTION_FORM_OPEN) { > + // > + // Update TPM2 HID info > + // > + if (QuestionId =3D=3D KEY_TPM_DEVICE) { > + Status =3D GetTpm2HID(HidStr, 16); > + > + if (EFI_ERROR(Status)) { > + // > + // Fail to get TPM2 HID > + // > + HiiSetString (Private->HiiHandle, STRING_TOKEN > (STR_TPM2_ACPI_HID_CONTENT), L"Unknown", NULL); > + } else { > + AsciiStrToUnicodeStrS(HidStr, UnHidStr, 16); > + HiiSetString (Private->HiiHandle, STRING_TOKEN > (STR_TPM2_ACPI_HID_CONTENT), UnHidStr, NULL); > + } > + } > + return EFI_SUCCESS; > + } > + > if (Action =3D=3D EFI_BROWSER_ACTION_CHANGING) { > if (QuestionId =3D=3D KEY_TPM_DEVICE_INTERFACE) { > EFI_STATUS Status; > diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.h > b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.h > index 1b9a845..91d0c27 100644 > --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.h > +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.h > @@ -2,7 +2,7 @@ > The header file of HII Config Access protocol implementation of TCG2 > configuration module. >=20 > -Copyright (c) 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -73,6 +73,8 @@ extern TCG2_CONFIG_PRIVATE_DATA > *mTcg2ConfigPrivateDate; > #define TCG2_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', > 'r', 'E', 'D') > #define TCG2_CONFIG_PRIVATE_DATA_FROM_THIS(a) CR (a, > TCG2_CONFIG_PRIVATE_DATA, ConfigAccess, > TCG2_CONFIG_PRIVATE_DATA_SIGNATURE) >=20 > +#define TPM_HID_PNP_SIZE 8 > +#define TPM_HID_ACPI_SIZE 9 >=20 > /** > This function publish the TCG2 configuration Form for TPM device. > diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni > b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni > index 7c63f99..64208e0 100644 > --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni > +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni > @@ -1,7 +1,7 @@ > /** @file > String definitions for TCG2 configuration form. >=20 > -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -29,6 +29,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #string STR_TCG2_ACPI_REVISION_HELP #language en-US "= Rev 3 > or Rev 4 (Rev 4 is defined in TCG ACPI Spec 00.37)" > #string STR_TCG2_ACPI_REVISION_CONTENT #language en-US "= " >=20 > +#string STR_TPM2_ACPI_HID_PROMPT #language en-US "HID f= rom > TPM2 ACPI Table" > +#string STR_TPM2_ACPI_HID_HELP #language en-US "HID f= rom > TPM2 ACPI Table: ManfacturerID + FirmwareVersion_1" > +#string STR_TPM2_ACPI_HID_CONTENT #language en-US "" > + > #string STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT #language en- > US "Current TPM Device Interface" > #string STR_TCG2_DEVICE_INTERFACE_STATE_HELP #language en-US > "Current TPM Device Interface: TIS, PTP FIFO, PTP CRB" > #string STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT #language en- > US "" > diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > index 4c6cd6d..aff8cb1 100644 > --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > @@ -397,7 +397,8 @@ UpdateHID ( >=20 > CopyMem(DataPtr, HID, TPM_HID_ACPI_SIZE); > } > - DEBUG((EFI_D_INFO, "TPM2 ACPI _HID updated to %a\n", HID)); > + DEBUG((DEBUG_INFO, "TPM2 ACPI _HID is patched to %a\n", > + DataPtr)); > + > return Status; > } > } > -- > 1.9.5.msysgit.1