From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.5599.1592292701361334119 for ; Tue, 16 Jun 2020 00:31:41 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: qi1.zhang@intel.com) IronPort-SDR: iBs/UiupxtypuL8UVcr/suqwI2bjO7Q2gOSM00mp1Rm9AF1wRVd2c6Wsbma17WzC+ZUy1TJjZt cS9y5gUx1AEA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2020 00:31:40 -0700 IronPort-SDR: crm5IMfuQJ7fjJgPyyF8uRLOxhixM+/rc6u37NhHQW8tKVvFoF4XncFdfWuyAVUAYEoXN4FbXh Dfdw6b1nF3Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,518,1583222400"; d="scan'208";a="420673754" Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 16 Jun 2020 00:31:38 -0700 From: Qi Zhang To: devel@edk2.groups.io Cc: "Zhang, Qi" , Jiewen Yao , Jian J Wang , Chao Zhang , Rahul Kumar Subject: [PATCH 1/2] SecurityPkg/Tpm2CommandLib: add new function Tpm2GetCapabilityIsCmdImpl. Date: Tue, 16 Jun 2020 15:30:49 +0800 Message-Id: <20200616073048.2019-2-qi1.zhang@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20200616073048.2019-1-qi1.zhang@intel.com> References: <20200616073048.2019-1-qi1.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: "Zhang, Qi" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2793 check if the commad is supported by comparing the command code with command index. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Cc: Rahul Kumar Signed-off-by: Qi Zhang --- SecurityPkg/Include/Library/Tpm2CommandLib.h | 16 ++++++++++++++++ SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c | 40 +++++++++++++++++= +++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Inc= lude/Library/Tpm2CommandLib.h index ce381e786b..ce7290c0f5 100644 --- a/SecurityPkg/Include/Library/Tpm2CommandLib.h +++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h @@ -790,6 +790,22 @@ Tpm2GetCapabilityAlgorithmSet ( OUT UINT32 *AlgorithmSet=0D );=0D =0D +/**=0D + This function will query if the command is supported.=0D +=0D + @param[In] Command TPM_CC command starts from TPM_CC_FIRST.=0D + @param[out] IsCmdImpl The command is supported or not.=0D +=0D + @retval EFI_SUCCESS Operation completed successfully.=0D + @retval EFI_DEVICE_ERROR The command was unsuccessful.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +Tpm2GetCapabilityIsCmdImpl (=0D + IN TPM_CC Command,=0D + OUT BOOLEAN *IsCmdImpl=0D + );=0D +=0D /**=0D This command is used to check to see if specific combinations of algorit= hm parameters are supported.=0D =0D diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c b/Security= Pkg/Library/Tpm2CommandLib/Tpm2Capability.c index 85b11c7715..0c8f980e69 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c @@ -39,6 +39,8 @@ typedef struct { =0D #pragma pack()=0D =0D +#define TPMA_CC_COMMANDINDEX_MASK 0x2000FFFF=0D +=0D /**=0D This command returns various information regarding the TPM and its curre= nt state.=0D =0D @@ -628,6 +630,44 @@ Tpm2GetCapabilityAlgorithmSet ( return EFI_SUCCESS;=0D }=0D =0D +/**=0D + This function will query if the command is supported.=0D +=0D + @param[In] Command TPM_CC command starts from TPM_CC_FIRST.=0D + @param[out] IsCmdImpl The command is supported or not.=0D +=0D + @retval EFI_SUCCESS Operation completed successfully.=0D + @retval EFI_DEVICE_ERROR The command was unsuccessful.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +Tpm2GetCapabilityIsCmdImpl (=0D + IN TPM_CC Command,=0D + OUT BOOLEAN *IsCmdImpl=0D + )=0D +{=0D + TPMS_CAPABILITY_DATA TpmCap;=0D + TPMI_YES_NO MoreData;=0D + EFI_STATUS Status;=0D + UINT32 Attribute;=0D +=0D + Status =3D Tpm2GetCapability (=0D + TPM_CAP_COMMANDS,=0D + Command,=0D + 1,=0D + &MoreData,=0D + &TpmCap=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + CopyMem (&Attribute, &TpmCap.data.command.commandAttributes[0], sizeof (= UINT32));=0D + *IsCmdImpl =3D (Command =3D=3D (SwapBytes32(Attribute) & TPMA_CC_COMMAND= INDEX_MASK));=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D /**=0D This command is used to check to see if specific combinations of algorit= hm parameters are supported.=0D =0D --=20 2.26.2.windows.1