From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 A0CB981933 for ; Thu, 29 Dec 2016 00:35:40 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP; 29 Dec 2016 00:35:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,425,1477983600"; d="scan'208";a="48223271" Received: from czhan46-mobl.ccr.corp.intel.com ([10.239.196.141]) by fmsmga006.fm.intel.com with ESMTP; 29 Dec 2016 00:35:39 -0800 From: "Zhang, Chao B" To: edk2-devel@lists.01.org Cc: jiewen.yao@intel.com, star.zeng@intel.com, Chao Zhang Date: Thu, 29 Dec 2016 16:35:38 +0800 Message-Id: <1483000538-17592-1-git-send-email-chao.b.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [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: Thu, 29 Dec 2016 08:35:40 -0000 Display TPM2 HID from TPM2 ACPI device object in Tcg2Config UI Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chao Zhang --- SecurityPkg/SecurityPkg.dec | 6 +++++- SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr | 7 ++++++ SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf | 1 + SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 27 +++++++++++++++++++++++- SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni | 4 ++++ SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 7 +++++- SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf | 1 + 7 files changed, 50 insertions(+), 3 deletions(-) diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index 9840311..f2efac3 100644 --- a/SecurityPkg/SecurityPkg.dec +++ b/SecurityPkg/SecurityPkg.dec @@ -455,6 +455,10 @@ # So this PCD is final value of how many hash algo is extended to PCR. # @Prompt Hash Algorithm bitmap. gEfiSecurityPkgTokenSpaceGuid.PcdTcg2HashAlgorithmBitmap|0xFFFFFFFF|UINT32|0x00010016 - + + ## This PCD provides TPM2 ACPI device object HID info + # @Prompt HID info of TPM2 ACPI device object + gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiHid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x0001001C + [UserExtensions.TianoCore."ExtraFiles"] SecurityPkgExtra.uni diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr b/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr index a805d53..5155acf 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr @@ -59,6 +59,13 @@ formset suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2; + subtitle text = STRING_TOKEN(STR_NULL); + + text + help = STRING_TOKEN(STR_TPM2_ACPI_HID_HELP), + text = STRING_TOKEN(STR_TPM2_ACPI_HID_PROMPT), + text = STRING_TOKEN(STR_TPM2_ACPI_HID_CONTENT); + oneof varid = TCG2_CONFIGURATION_NV_INFO.TpmAcpiTableRev, questionid = KEY_TPM_ACPI_REVISION, prompt = STRING_TOKEN(STR_TCG2_ACPI_REVISION_PROMPT), diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf index 02cb1a4..ea7b117 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf @@ -78,6 +78,7 @@ gEfiSecurityPkgTokenSpaceGuid.PcdTcg2HashAlgorithmBitmap ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev ## CONSUMES + gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiHid ## CONSUMES [Depex] gEfiTcg2ProtocolGuid AND diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c index afba42c..000eb01 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c @@ -461,12 +461,37 @@ Tcg2Callback ( OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { - EFI_INPUT_KEY Key; + EFI_INPUT_KEY Key; + CHAR8 *Hid; + CHAR16 UnHid[16]; + TCG2_CONFIG_PRIVATE_DATA *Private; if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } + Private = TCG2_CONFIG_PRIVATE_DATA_FROM_THIS (This); + + if (Action == EFI_BROWSER_ACTION_FORM_OPEN) { + // + // Update TPM2 HID info + // + if (QuestionId == KEY_TPM_DEVICE) { + Hid = (CHAR8 *)PcdGetPtr(PcdTpm2AcpiHid); + + if (AsciiStrLen(Hid) != 7 && AsciiStrLen(Hid) != 8) { + // + // HID must be PNP ("AAA####") or ACPI ID ("NNNN####") + // + HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), L"Unkown", NULL); + } else { + AsciiStrToUnicodeStr(Hid, UnHid); + HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), UnHid, NULL); + } + } + return EFI_SUCCESS; + } + if (Action == EFI_BROWSER_ACTION_CHANGING) { if (QuestionId == KEY_TPM_DEVICE_INTERFACE) { EFI_STATUS Status; diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni index 7c63f99..57c9dbe 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni @@ -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 "" +#string STR_TPM2_ACPI_HID_PROMPT #language en-US "HID from TPM2 ACPI Table" +#string STR_TPM2_ACPI_HID_HELP #language en-US "HID from 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 8b03d98..5a31a87 100644 --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c @@ -323,6 +323,7 @@ UpdateHID ( UINT32 FirmwareVersion1; UINT32 FirmwareVersion2; BOOLEAN PnpHID; + UINTN Size; PnpHID = TRUE; @@ -390,13 +391,17 @@ UpdateHID ( if (AsciiStrCmp((CHAR8 *)DataPtr, TPM_HID_TAG) == 0) { if (PnpHID) { CopyMem(DataPtr, HID, TPM_HID_PNP_SIZE); + Size = TPM_HID_PNP_SIZE; } else { // // NOOP will be patched to '\0' // CopyMem(DataPtr, HID, TPM_HID_ACPI_SIZE); + Size = TPM_HID_ACPI_SIZE; } - DEBUG((EFI_D_INFO, "TPM2 ACPI _HID updated to %a\n", HID)); + PcdSetPtrS(PcdTpm2AcpiHid, &Size, DataPtr); + DEBUG((DEBUG_INFO, "TPM2 ACPI _HID is patched to %a\n", DataPtr)); + return Status; } } diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf index b3c5d92..4abb941 100644 --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf @@ -74,6 +74,7 @@ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev ## CONSUMES + gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiHid ## PRODUCES [Depex] gEfiAcpiTableProtocolGuid AND -- 1.9.5.msysgit.1