diff options
author | Yao, Jiewen <jiewen.yao@intel.com> | 2016-01-11 05:15:18 +0000 |
---|---|---|
committer | jyao1 <jyao1@Edk2> | 2016-01-11 05:15:18 +0000 |
commit | f1e95ab8173ab8ea68ce58ba147e91ce1229a17d (patch) | |
tree | 7a47c415df93ff5ce5382a3e5d46a4e40b1d13ee /SecurityPkg/Library/Tpm2CommandLib | |
parent | afcef7560f7122e0e5cf5dd480fb4f2047d40a20 (diff) | |
download | edk2-f1e95ab8173ab8ea68ce58ba147e91ce1229a17d.tar.gz edk2-f1e95ab8173ab8ea68ce58ba147e91ce1229a17d.tar.bz2 edk2-f1e95ab8173ab8ea68ce58ba147e91ce1229a17d.zip |
SecurityPkg: Add Tpm2Startup return code check.
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
Diffstat (limited to 'SecurityPkg/Library/Tpm2CommandLib')
-rw-r--r-- | SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c index e8af4033ce..f67043b84b 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c @@ -1,7 +1,7 @@ /** @file
Implement TPM2 Startup related command.
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -59,6 +59,7 @@ Tpm2Startup ( TPM2_STARTUP_COMMAND Cmd;
TPM2_STARTUP_RESPONSE Res;
UINT32 ResultBufSize;
+ TPM_RC ResponseCode;
Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
@@ -67,8 +68,20 @@ Tpm2Startup ( ResultBufSize = sizeof(Res);
Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
-
- return Status;
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ ResponseCode = SwapBytes32(Res.Header.responseCode);
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ case TPM_RC_INITIALIZE:
+ // TPM_RC_INITIALIZE can be returned if Tpm2Startup is not required.
+ return EFI_SUCCESS;
+ default:
+ DEBUG ((EFI_D_ERROR, "Tpm2Startup: Response Code error! 0x%08x\r\n", ResponseCode));
+ return EFI_DEVICE_ERROR;
+ }
}
/**
@@ -97,6 +110,14 @@ Tpm2Shutdown ( ResultBufSize = sizeof(Res);
Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2Shutdown: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
- return Status;
+ return EFI_SUCCESS;
}
|