diff options
-rw-r--r-- | common/tpm_registers.c | 42 | ||||
-rwxr-xr-x | util/getversion.sh | 2 |
2 files changed, 38 insertions, 6 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c index e7cfeff547..f228503e7a 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -26,12 +26,21 @@ #include "watchdog.h" #include "wp.h" +/* + * Do not enable TPM if crypto test is enabled - there is no room in the flash + * for both. + */ +#ifndef CRYPTO_TEST_SETUP +#define ENABLE_TPM + /* TPM2 library includes. */ #include "ExecCommand_fp.h" #include "Platform.h" #include "_TPM_Init_fp.h" #include "Manufacture_fp.h" +#endif + /****************************************************************************/ /* * CAUTION: Variables defined in this in this file are treated specially. @@ -549,12 +558,13 @@ void tpm_register_interface(interface_control_func interface_start, static void tpm_init(void) { +#ifdef ENABLE_TPM /* * 0xc0 Means successful endorsement. Actual endorsement reasult code * is added in lower bits to indicate endorsement failure, if any. */ uint8_t underrun_char = 0xc0; - +#endif /* This is more related to TPM task activity than TPM transactions */ cprints(CC_TASK, "%s", __func__); @@ -573,12 +583,13 @@ static void tpm_init(void) tpm_.regs.sts = (tpm_family_tpm2 << tpm_family_shift) | (63 << burst_count_shift) | sts_valid; - /* TPM2 library functions. */ - _plat__Signal_PowerOn(); - /* Create version string to be read by host */ set_version_string(); +#ifdef ENABLE_TPM + /* TPM2 library functions. */ + _plat__Signal_PowerOn(); + watchdog_reload(); /* @@ -620,6 +631,7 @@ static void tpm_init(void) _plat__SetNvAvail(); } +#endif } size_t tpm_get_burst_size(void) @@ -939,7 +951,7 @@ void tpm_task(void *u) tpm_reset_now(0); while (1) { - uint8_t *response; + uint8_t *response = NULL; unsigned response_size; uint32_t command_code; struct tpm_cmd_header *tpmh; @@ -1023,10 +1035,30 @@ void tpm_task(void *u) memcpy(response, tpm_broken_response, response_size); } else { +#ifdef ENABLE_TPM ExecuteCommand(tpm_.fifo_write_index, (uint8_t *)tpmh, &response_size, &response); +#else + { + /* + * This response is sent by actual + * TPM2 when replying to gibberish + * input. Copy it here to avoid the + * need to add conditional compilation + * cases below. + */ + const uint8_t bad_cmd_resp[] = { + 0x00, 0xc4, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x1e + }; + response = (uint8_t *)tpmh; + response_size = sizeof(bad_cmd_resp); + memcpy(response, bad_cmd_resp, + response_size); + } +#endif } } CPRINTF("got %d bytes in response\n", response_size); diff --git a/util/getversion.sh b/util/getversion.sh index de9a74fc52..d775100e8d 100755 --- a/util/getversion.sh +++ b/util/getversion.sh @@ -89,7 +89,7 @@ main() { local ver IFS="${dc}" - ver="${CR50_SQA:+SQA/}${CR50_DEV:+DBG/}${BOARD}_" + ver="${CR50_SQA:+SQA/}${CR50_DEV:+DBG/}${CRYPTO_TEST:+CT/}${BOARD}_" tool_ver="" global_dirty= # set if any of the component repos is 'dirty'. dir_list=( . ) # list of component directories, always includes the EC tree |