Tpm2Startup does not check TPM device return code.
It might cause problem, that error is not detected
in Tcg2Peim, for example, S3 resume case.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com>
Reviewed-by: "Zhang, Chao B" <chao.b.zhang@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19634
6f19259b-4bc3-4df7-8a09-
765794883524
/** @file\r
Implement TPM2 Startup related command.\r
\r
/** @file\r
Implement TPM2 Startup related command.\r
\r
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. <BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
TPM2_STARTUP_COMMAND Cmd;\r
TPM2_STARTUP_RESPONSE Res;\r
UINT32 ResultBufSize;\r
TPM2_STARTUP_COMMAND Cmd;\r
TPM2_STARTUP_RESPONSE Res;\r
UINT32 ResultBufSize;\r
\r
Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);\r
Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));\r
\r
Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);\r
Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));\r
\r
ResultBufSize = sizeof(Res);\r
Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);\r
\r
ResultBufSize = sizeof(Res);\r
Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
+\r
+ ResponseCode = SwapBytes32(Res.Header.responseCode);\r
+ switch (ResponseCode) {\r
+ case TPM_RC_SUCCESS:\r
+ case TPM_RC_INITIALIZE:\r
+ // TPM_RC_INITIALIZE can be returned if Tpm2Startup is not required.\r
+ return EFI_SUCCESS;\r
+ default:\r
+ DEBUG ((EFI_D_ERROR, "Tpm2Startup: Response Code error! 0x%08x\r\n", ResponseCode));\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
\r
ResultBufSize = sizeof(Res);\r
Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);\r
\r
ResultBufSize = sizeof(Res);\r
Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
+\r
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {\r
+ DEBUG ((EFI_D_ERROR, "Tpm2Shutdown: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));\r
+ return EFI_DEVICE_ERROR;\r
+ }\r