summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-07-29 17:19:47 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-31 19:19:15 +0000
commita7f759a384ca2e1ff0daf559949a40d45aa76863 (patch)
tree53f7f436773b6416a58050779d31e0f2ed47b9cd
parent74340f2dbe5ededa6cd466d32a727c7df977b956 (diff)
downloadchrome-ec-stabilize-12386.B.tar.gz
g: add flash log entry for dcrypto failuresstabilize-12386.B
We want to keep an eye on the dcrypto failures (which are never supposed to happen of course). Let's add logging a flash event so that the failures are visible through UMA. BRANCH=cr50, cr50-mp BUG=b:135772657 TEST=using additional code simulated a single failure, observed new flash log entry by running 'gsctool -a -L' on the DUT. Change-Id: Ib675bb1928166cadc069bf4be3b053a9cf837077 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1723097 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--chip/g/dcrypto/dcrypto_runtime.c18
-rw-r--r--include/flash_log.h1
2 files changed, 14 insertions, 5 deletions
diff --git a/chip/g/dcrypto/dcrypto_runtime.c b/chip/g/dcrypto/dcrypto_runtime.c
index 3f2efb54be..b20f561393 100644
--- a/chip/g/dcrypto/dcrypto_runtime.c
+++ b/chip/g/dcrypto/dcrypto_runtime.c
@@ -2,10 +2,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "internal.h"
-#include "task.h"
+#include "flash_log.h"
+#include "internal.h"
#include "registers.h"
+#include "task.h"
#define DMEM_NUM_WORDS 1024
#define IMEM_NUM_WORDS 1024
@@ -95,6 +96,7 @@ void dcrypto_unlock(void)
uint32_t dcrypto_call(uint32_t adr)
{
uint32_t event;
+ uint32_t state = 0;
do {
/* Reset all the status bits. */
@@ -114,13 +116,19 @@ uint32_t dcrypto_call(uint32_t adr)
* all other bits are indicative of error.
* Except for MOD_OPERAND_OUT_OF_RANGE, which is noise.
*/
- if ((GREG32(CRYPTO, INT_STATE) &
- ~(GC_CRYPTO_INT_STATE_MOD_OPERAND_OUT_OF_RANGE_MASK |
- GC_CRYPTO_INT_STATE_HOST_CMD_RECV_MASK)) == 0)
+ 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)
return 0;
/* fall through */
default:
dcrypto_reset_and_wipe();
+#ifdef CONFIG_FLASH_LOG
+ /* State value of zero indicates event timeout. */
+ flash_log_add_event(FE_LOG_DCRYPTO_FAILURE,
+ sizeof(state), &state);
+#endif
return 1;
}
}
diff --git a/include/flash_log.h b/include/flash_log.h
index 3e2dca8c2c..bb4baf651c 100644
--- a/include/flash_log.h
+++ b/include/flash_log.h
@@ -20,6 +20,7 @@ enum flash_event_type {
FE_LOG_NVMEM = 5, /* NVMEM failure, variable structure. */
FE_LOG_TPM_WIPE_ERROR = 6, /* Failed to wipe the TPM */
FE_LOG_TRNG_STALL = 7, /* Stall while retrieving a random number. */
+ FE_LOG_DCRYPTO_FAILURE = 8, /* Dcrypto had to be reset. */
/*
* Fixed padding value makes it easier to parse log space