From 0eaae34cc512fa8b28ca28b1d461b2371b5dd989 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Thu, 15 Jun 2017 12:29:13 -0400 Subject: [PATCH] tpm2: Return failure code if TPM was put into failure mode Return a failure code to the control command initiated initialization of the TPM 2. Reset the failure move on every INIT call so that corrections can be done without having to restart the TPM emulator. Signed-off-by: Stefan Berger --- src/tpm_tpm2_interface.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/tpm_tpm2_interface.c b/src/tpm_tpm2_interface.c index 58710542..bbb92433 100644 --- a/src/tpm_tpm2_interface.c +++ b/src/tpm_tpm2_interface.c @@ -61,6 +61,8 @@ #include "tpm2/_TPM_Hash_Data_fp.h" #include "tpm2/_TPM_Init_fp.h" +extern BOOL g_inFailureMode; + /* * Check whether the main NVRAM file exists. Return TRUE if it doesn, FALSE otherwise */ @@ -88,6 +90,8 @@ TPM_RESULT TPM2_MainInit(void) { TPM_RESULT ret = TPM_SUCCESS; + g_inFailureMode = FALSE; + #ifdef TPM_LIBTPMS_CALLBACKS struct libtpms_callbacks *cbs = TPMLIB_GetCallbacks(); @@ -115,6 +119,11 @@ TPM_RESULT TPM2_MainInit(void) _rpc__Signal_NvOn(); + if (ret == TPM_SUCCESS) { + if (g_inFailureMode) + ret = TPM_RC_FAILURE; + } + return ret; }