From c1c637bb53eaa9de9ead652dc9908eef6c15b8a5 Mon Sep 17 00:00:00 2001 From: Vadim Sukhomlinov Date: Tue, 28 Mar 2023 20:10:51 -0700 Subject: cr50: improve logging of dcrypto failures 1. Increase timeout from 700ms to 1000ms as we saw some timeouts of unknown origin. 2. INT_STATE wasn't collected for timeouts, change when we get it. 3. Add address of function to log so we can identify source of failure. BUG=b:273935442 TEST=make CRYPTO_TEST=1; tpm_test Change-Id: Ifbb1ea5d52662a71d944baa9a7a189224529d85e Signed-off-by: Vadim Sukhomlinov Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4380209 Reviewed-by: Mary Ruthven Reviewed-by: Vadim Sukhomlinov Commit-Queue: Vadim Sukhomlinov Tested-by: Vadim Sukhomlinov Code-Coverage: Vadim Sukhomlinov Reviewed-by: Andrey Pronin --- board/cr50/dcrypto/dcrypto_runtime.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/board/cr50/dcrypto/dcrypto_runtime.c b/board/cr50/dcrypto/dcrypto_runtime.c index da1f854c68..7ed1add4f3 100644 --- a/board/cr50/dcrypto/dcrypto_runtime.c +++ b/board/cr50/dcrypto/dcrypto_runtime.c @@ -86,7 +86,7 @@ void dcrypto_unlock(void) } #ifndef DCRYPTO_CALL_TIMEOUT_US -#define DCRYPTO_CALL_TIMEOUT_US (700 * 1000) +#define DCRYPTO_CALL_TIMEOUT_US (1000 * 1000) #endif /* * When running on Cr50 this event belongs in the TPM task event space. Make @@ -108,6 +108,7 @@ uint32_t dcrypto_call(uint32_t adr) event = fips_vtable->task_wait_event_mask(TASK_EVENT_DCRYPTO_DONE, DCRYPTO_CALL_TIMEOUT_US); + state = GREG32(CRYPTO, INT_STATE); /* TODO(ngm): switch return value to an enum. */ switch (event) { case TASK_EVENT_DCRYPTO_DONE: @@ -117,7 +118,6 @@ uint32_t dcrypto_call(uint32_t adr) * all other bits are indicative of error. * Except for MOD_OPERAND_OUT_OF_RANGE, which is noise. */ - state = GREG32(CRYPTO, INT_STATE); if ((state & ~(GC_CRYPTO_INT_STATE_MOD_OPERAND_OUT_OF_RANGE_MASK | GC_CRYPTO_INT_STATE_HOST_CMD_RECV_MASK)) == 0) @@ -126,9 +126,13 @@ uint32_t dcrypto_call(uint32_t adr) default: dcrypto_reset_and_wipe(); #ifdef CONFIG_FLASH_LOG + /* dcrypto status is only 12 bits, but for analysis we + * add dcrypto function address in top 16 bits. + */ + state |= (adr << 16); /* State value of zero indicates event timeout. */ fips_vtable->flash_log_add_event(FE_LOG_DCRYPTO_FAILURE, - sizeof(state), &state); + sizeof(state), &state); #endif return 1; } -- cgit v1.2.1