* [PATCH 1/2] SecurityPkg/Tpm2CommandLib: add new function Tpm2GetCapabilityIsCmdImpl.
2020-06-16 7:30 [PATCH v2 0/2] refine TPM2 operation pull down list Qi Zhang
@ 2020-06-16 7:30 ` Qi Zhang
2020-06-16 7:30 ` [PATCH 2/2] SecurityPkg/Tcg2Config: remove TPM2_ChangEPS if it is not supported Qi Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Qi Zhang @ 2020-06-16 7:30 UTC (permalink / raw)
To: devel; +Cc: Zhang, Qi, Jiewen Yao, Jian J Wang, Chao Zhang, Rahul Kumar
From: "Zhang, Qi" <qi1.zhang@intel.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2793
check if the commad is supported by comparing the command code with
command index.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Qi Zhang <qi1.zhang@intel.com>
---
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/Include/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
);
+/**
+ This function will query if the command is supported.
+
+ @param[In] Command TPM_CC command starts from TPM_CC_FIRST.
+ @param[out] IsCmdImpl The command is supported or not.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityIsCmdImpl (
+ IN TPM_CC Command,
+ OUT BOOLEAN *IsCmdImpl
+ );
+
/**
This command is used to check to see if specific combinations of algorithm parameters are supported.
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c b/SecurityPkg/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 {
#pragma pack()
+#define TPMA_CC_COMMANDINDEX_MASK 0x2000FFFF
+
/**
This command returns various information regarding the TPM and its current state.
@@ -628,6 +630,44 @@ Tpm2GetCapabilityAlgorithmSet (
return EFI_SUCCESS;
}
+/**
+ This function will query if the command is supported.
+
+ @param[In] Command TPM_CC command starts from TPM_CC_FIRST.
+ @param[out] IsCmdImpl The command is supported or not.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityIsCmdImpl (
+ IN TPM_CC Command,
+ OUT BOOLEAN *IsCmdImpl
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+ UINT32 Attribute;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_COMMANDS,
+ Command,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ CopyMem (&Attribute, &TpmCap.data.command.commandAttributes[0], sizeof (UINT32));
+ *IsCmdImpl = (Command == (SwapBytes32(Attribute) & TPMA_CC_COMMANDINDEX_MASK));
+
+ return EFI_SUCCESS;
+}
+
/**
This command is used to check to see if specific combinations of algorithm parameters are supported.
--
2.26.2.windows.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] SecurityPkg/Tcg2Config: remove TPM2_ChangEPS if it is not supported.
2020-06-16 7:30 [PATCH v2 0/2] refine TPM2 operation pull down list Qi Zhang
2020-06-16 7:30 ` [PATCH 1/2] SecurityPkg/Tpm2CommandLib: add new function Tpm2GetCapabilityIsCmdImpl Qi Zhang
@ 2020-06-16 7:30 ` Qi Zhang
2020-07-05 12:37 ` [PATCH v2 0/2] refine TPM2 operation pull down list Zhang, Qi1
2020-07-05 23:59 ` Yao, Jiewen
3 siblings, 0 replies; 5+ messages in thread
From: Qi Zhang @ 2020-06-16 7:30 UTC (permalink / raw)
To: devel; +Cc: Qi Zhang, Jiewen Yao, Jian J Wang, Chao Zhang, Rahul Kumar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2793
In current implementation TPM2_ChangeEPS command is always available
in the TPM2 operation pull down list in TCG2 Configuration, which
is confusing when the command is not supported by specific TPM chip.
As a user experience improvement, TPM2_ChangeEPS command should be
removed from the list when it is not supported.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Qi Zhang <qi1.zhang@intel.com>
---
SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr | 2 ++
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 7 +++++++
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr b/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr
index 91a463997c..47d63b009d 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr
@@ -144,7 +144,9 @@ formset
option text = STRING_TOKEN(STR_TCG2_DISABLE), value = TCG2_PHYSICAL_PRESENCE_DISABLE, flags = RESET_REQUIRED;
option text = STRING_TOKEN(STR_TCG2_CLEAR), value = TCG2_PHYSICAL_PRESENCE_CLEAR, flags = RESET_REQUIRED;
option text = STRING_TOKEN(STR_TCG2_SET_PCD_BANKS), value = TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS, flags = RESET_REQUIRED;
+ suppressif ideqval TCG2_CONFIGURATION_INFO.ChangeEPSSupported == 0;
option text = STRING_TOKEN(STR_TCG2_CHANGE_EPS), value = TCG2_PHYSICAL_PRESENCE_CHANGE_EPS, flags = RESET_REQUIRED;
+ endif
option text = STRING_TOKEN(STR_TCG2_LOG_ALL_DIGESTS), value = TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS, flags = RESET_REQUIRED;
option text = STRING_TOKEN(STR_TCG2_DISABLE_ENDORSEMENT_ENABLE_STORAGE_HIERARCHY), value = TCG2_PHYSICAL_PRESENCE_DISABLE_ENDORSEMENT_ENABLE_STORAGE_HIERARCHY, flags = RESET_REQUIRED;
endoneof;
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
index baa8fcd08d..464cacc207 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
@@ -788,6 +788,7 @@ InstallTcg2ConfigForm (
CHAR16 TempBuffer[1024];
TCG2_CONFIGURATION_INFO Tcg2ConfigInfo;
TPM2_PTP_INTERFACE_TYPE TpmDeviceInterfaceDetected;
+ BOOLEAN IsCmdImp = FALSE;
DriverHandle = NULL;
ConfigAccess = &PrivateData->ConfigAccess;
@@ -870,6 +871,12 @@ InstallTcg2ConfigForm (
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_SUPPORTED_HASH_ALGO_CONTENT), TempBuffer, NULL);
}
+ Status = Tpm2GetCapabilityIsCmdImpl(TPM_CC_ChangeEPS, &IsCmdImp);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityIsCmdImpl fails %r\n", Status));
+ }
+ Tcg2ConfigInfo.ChangeEPSSupported = IsCmdImp;
+
FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PcdGet32 (PcdTcg2HashAlgorithmBitmap));
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_BIOS_HASH_ALGO_CONTENT), TempBuffer, NULL);
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h
index a91c052850..b84af40a04 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h
@@ -70,6 +70,7 @@ typedef struct {
UINT8 TpmDeviceInterfaceAttempt;
BOOLEAN TpmDeviceInterfacePtpFifoSupported;
BOOLEAN TpmDeviceInterfacePtpCrbSupported;
+ BOOLEAN ChangeEPSSupported;
} TCG2_CONFIGURATION_INFO;
//
--
2.26.2.windows.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] refine TPM2 operation pull down list
2020-06-16 7:30 [PATCH v2 0/2] refine TPM2 operation pull down list Qi Zhang
2020-06-16 7:30 ` [PATCH 1/2] SecurityPkg/Tpm2CommandLib: add new function Tpm2GetCapabilityIsCmdImpl Qi Zhang
2020-06-16 7:30 ` [PATCH 2/2] SecurityPkg/Tcg2Config: remove TPM2_ChangEPS if it is not supported Qi Zhang
@ 2020-07-05 12:37 ` Zhang, Qi1
2020-07-05 23:59 ` Yao, Jiewen
3 siblings, 0 replies; 5+ messages in thread
From: Zhang, Qi1 @ 2020-07-05 12:37 UTC (permalink / raw)
To: devel@edk2.groups.io
Cc: Yao, Jiewen, Wang, Jian J, Zhang, Chao B, Kumar, Rahul1
Sorry for bothering you. But how about the review status of this patch?
> -----Original Message-----
> From: Zhang, Qi1 <qi1.zhang@intel.com>
> Sent: Tuesday, June 16, 2020 3:31 PM
> To: devel@edk2.groups.io
> Cc: Zhang, Qi1 <qi1.zhang@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
> Subject: [PATCH v2 0/2] refine TPM2 operation pull down list
>
> v1 change: separate the change into two patches
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Signed-off-by: Qi Zhang <qi1.zhang@intel.com>
>
> Qi Zhang (1):
> SecurityPkg/Tcg2Config: remove TPM2_ChangEPS if it is not supported.
>
> Zhang, Qi (1):
> SecurityPkg/Tpm2CommandLib: add new function
> Tpm2GetCapabilityIsCmdImpl.
>
> SecurityPkg/Include/Library/Tpm2CommandLib.h | 16
> ++++++++++++++++
> SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c | 40
> ++++++++++++++++++++++++++++++++++++++++
> SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr | 2 ++
> SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 7 +++++++
> SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h | 1 +
> 5 files changed, 66 insertions(+)
>
> --
> 2.26.2.windows.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] refine TPM2 operation pull down list
2020-06-16 7:30 [PATCH v2 0/2] refine TPM2 operation pull down list Qi Zhang
` (2 preceding siblings ...)
2020-07-05 12:37 ` [PATCH v2 0/2] refine TPM2 operation pull down list Zhang, Qi1
@ 2020-07-05 23:59 ` Yao, Jiewen
3 siblings, 0 replies; 5+ messages in thread
From: Yao, Jiewen @ 2020-07-05 23:59 UTC (permalink / raw)
To: Zhang, Qi1, devel@edk2.groups.io
Cc: Wang, Jian J, Zhang, Chao B, Kumar, Rahul1
Thanks.
I recommend we use full name Tpm2GetCapabilityIsCommandImplemented() instead of Tpm2GetCapabilityIsCmdImpl().
With that change, reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
> -----Original Message-----
> From: Zhang, Qi1 <qi1.zhang@intel.com>
> Sent: Tuesday, June 16, 2020 3:31 PM
> To: devel@edk2.groups.io
> Cc: Zhang, Qi1 <qi1.zhang@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
> Subject: [PATCH v2 0/2] refine TPM2 operation pull down list
>
> v1 change: separate the change into two patches
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Signed-off-by: Qi Zhang <qi1.zhang@intel.com>
>
> Qi Zhang (1):
> SecurityPkg/Tcg2Config: remove TPM2_ChangEPS if it is not supported.
>
> Zhang, Qi (1):
> SecurityPkg/Tpm2CommandLib: add new function
> Tpm2GetCapabilityIsCmdImpl.
>
> SecurityPkg/Include/Library/Tpm2CommandLib.h | 16 ++++++++++++++++
> SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c | 40
> ++++++++++++++++++++++++++++++++++++++++
> SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr | 2 ++
> SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 7 +++++++
> SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigNvData.h | 1 +
> 5 files changed, 66 insertions(+)
>
> --
> 2.26.2.windows.1
^ permalink raw reply [flat|nested] 5+ messages in thread