From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.50722.1594007243294503104 for ; Sun, 05 Jul 2020 20:47:23 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: qi1.zhang@intel.com) IronPort-SDR: vY3+veTsM1d4sGwvX5lWhOyxNWjHKnVgBVrTSX8wViPVV75/hNGBCVgTjC+k5lIskLyUL1r1Z4 IALP2dvxqJ/g== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="232202586" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="232202586" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2020 20:47:22 -0700 IronPort-SDR: 1ma/i+R5EoRfRPPBoqcDVMsnPZkFKUcI9lRCfKrzV9skBN3//BURkI1d7lxfEhBRUJMbtubsql /IFfw+aPxblA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="456555279" Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga005.jf.intel.com with ESMTP; 05 Jul 2020 20:47:20 -0700 From: Qi Zhang To: devel@edk2.groups.io Cc: "Zhang, Qi" , Jiewen Yao , Jian J Wang , Chao Zhang , Rahul Kumar Subject: [PATCH v3 1/2] SecurityPkg/Tpm2CommandLib: add new function Tpm2GetCapabilityIsCommandImplemented. Date: Mon, 6 Jul 2020 11:46:48 +0800 Message-Id: <20200706034649.3533-2-qi1.zhang@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20200706034649.3533-1-qi1.zhang@intel.com> References: <20200706034649.3533-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 ++++++++ .../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..ee8eb62295 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 +Tpm2GetCapabilityIsCommandImplemented (=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..17c0c3a151 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 +Tpm2GetCapabilityIsCommandImplemented (=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