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 <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Stefan Berger 2017-06-15 12:29:13 -04:00
parent 3cf528aaac
commit 0eaae34cc5

View File

@ -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;
}