* [PATCH] SecurityPkg/Library: Adjust the status codes for SubmitCommand
@ 2020-07-23 8:14 Gary Lin
0 siblings, 0 replies; only message in thread
From: Gary Lin @ 2020-07-23 8:14 UTC (permalink / raw)
To: devel; +Cc: Jiewen Yao, Jian J Wang, Qi Zhang, Rahul Kumar
The status codes of EFI_TCG2_PROTOCOL.SubmitCommand() defined in
"TCG EFI Protocol Specification for TPM 2.0" Version 1.0 Revision 0.13
are EFI_SUCCESS, EFI_DEVICE_ERROR, EFI_INVALID_PARAMETER, and
EFI_BUFFER_TOO_SMALL. Since Tcg2SubmitCommand() returns the status
code of Tpm2SubmitCommand() directly, Tpm2SubmitCommand() should follow
the spec to return the status codes. However, Tpm2SubmitCommand() may
return the status codes other than those defined in the spec in the
following call path:
Tpm2SubmitCommand() -> DTpm2SubmitCommand() -+-> PtpCrbTpmCommand()
|
+-> Tpm2TisTpmCommand()
1. Tpm2SubmitCommand() returned EFI_UNSUPPORTED if the function isn't
implemented in mInternalTpm2DeviceInterface. Change it to
EFI_DEVICE_ERROR to align the spec.
2. DTpm2SubmitCommand() returned EFI_NOT_FOUND when PtpInterface doesn't
match any interface. Change it to EFI_DEVICE_ERROR to align the spec.
3. PtpCrbTpmCommand() returned EFI_UNSUPPORTED in a conditional check.
Change it to EFI_DEVICE_ERROR. Also update the comment to reflect this
change.
4. At the end of PtpCrbTpmCommand(), it returns the status code from
PtpCrbWaitRegisterBits() directly. However, PtpCrbWaitRegisterBits()
may return EFI_TIMEOUT. Convert EFI_TIMEOUT to EFI_DEVICE_ERROR instead
of returning it directly.
5. Tpm2TisTpmCommand() returned EFI_UNSUPPORTED in a conditional check.
Change it to EFI_DEVICE_ERROR. Also update the comment to reflect the
change.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 9 +++++----
SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c | 3 +--
.../Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
index 2c73385b6ce5..91b5b16095ac 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
@@ -130,7 +130,6 @@ PtpCrbRequestUseTpm (
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
- @retval EFI_UNSUPPORTED Unsupported TPM version
**/
EFI_STATUS
@@ -296,7 +295,7 @@ PtpCrbTpmCommand (
// TPM2 should not use this RSP_COMMAND
if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) {
DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));
- Status = EFI_UNSUPPORTED;
+ Status = EFI_DEVICE_ERROR;
goto GoIdle_Exit;
}
@@ -357,6 +356,9 @@ GoIdle_Exit:
0,
PTP_TIMEOUT_C
);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_DEVICE_ERROR;
+ }
}
return Status;
@@ -374,7 +376,6 @@ GoIdle_Exit:
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
- @retval EFI_UNSUPPORTED Unsupported TPM version
**/
EFI_STATUS
@@ -584,7 +585,7 @@ DTpm2SubmitCommand (
OutputParameterBlockSize
);
default:
- return EFI_NOT_FOUND;
+ return EFI_DEVICE_ERROR;
}
}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
index 9a809612b3d9..1fb9cfccc46c 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
@@ -199,7 +199,6 @@ TisPcRequestUseTpm (
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
- @retval EFI_UNSUPPORTED Unsupported TPM version
**/
EFI_STATUS
@@ -346,7 +345,7 @@ Tpm2TisTpmCommand (
// TPM2 should not use this RSP_COMMAND
if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) {
DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));
- Status = EFI_UNSUPPORTED;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c
index 227aa406bda2..d97c4d65fd0a 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c
@@ -38,7 +38,7 @@ Tpm2SubmitCommand (
)
{
if (mInternalTpm2DeviceInterface.Tpm2SubmitCommand == NULL) {
- return EFI_UNSUPPORTED;
+ return EFI_DEVICE_ERROR;
}
return mInternalTpm2DeviceInterface.Tpm2SubmitCommand (
InputParameterBlockSize,
--
2.27.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-07-23 8:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-23 8:14 [PATCH] SecurityPkg/Library: Adjust the status codes for SubmitCommand Gary Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox