summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2020-03-10 17:56:18 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-11 20:55:42 +0000
commit3def48bef02dbd81acab77163924bc3bbb20983b (patch)
treee1e625a384a80a5459c8ede88a90ac559d87a5e1
parent744a123033a043f7b10b7937ed7814fa1505d3fd (diff)
downloadchrome-ec-3def48bef02dbd81acab77163924bc3bbb20983b.tar.gz
add corrupt and reload options to 'ec_comm' console cmd
Two new options for 'ec_comm' are for test usage only. - ec_comm corrupt: it corrupts the ECRW hash in ec_comm module. Hash corruption will cause EC-FW verification failure. It can be useful to check how AP firmware performs software sync on this failure. - ec_comm reload: it forces Cr50 to reload ECRW hash from tpm nvmem. This is to restore the EC EFS2 status in Cr50 from corrupted status. BUG=b:150650877 BRANCH=cr50 TEST=manually ran 'ec_comm corrupt' or 'ec_comm reload' with dev image. Checked cr50 normal image refuses those command lines. Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Ib4aa9532132e1ee786e623bd658a68987e4681dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094781 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--common/ec_comm.c29
-rw-r--r--common/ec_efs.c10
-rw-r--r--include/ec_comm.h2
3 files changed, 39 insertions, 2 deletions
diff --git a/common/ec_comm.c b/common/ec_comm.c
index e24c2af94c..169e65eb55 100644
--- a/common/ec_comm.c
+++ b/common/ec_comm.c
@@ -322,6 +322,23 @@ static int command_ec_comm(int argc, char **argv)
return EC_ERROR_INVAL;
}
+ if (argc > 1) {
+#ifdef CR50_RELAXED
+ if (!strcasecmp(argv[1], "corrupt"))
+ ec_efs_corrupt_hash();
+ else if (!strcasecmp(argv[1], "reload"))
+ ec_efs_refresh();
+ else
+ return EC_ERROR_PARAM1;
+ /*
+ * let's keep processing so that we can see how the context
+ * values are changed.
+ */
+#else
+ return EC_ERROR_PARAM_COUNT;
+#endif
+ }
+
/*
* EC Packet Context
*/
@@ -343,5 +360,13 @@ static int command_ec_comm(int argc, char **argv)
return EC_SUCCESS;
}
-DECLARE_SAFE_CONSOLE_COMMAND(ec_comm, command_ec_comm, NULL,
- "Dump EC-CR50-comm status");
+DECLARE_SAFE_CONSOLE_COMMAND(ec_comm, command_ec_comm,
+#ifdef CR50_RELAXED
+ "[corrupt|reload]",
+ "Dump EC-CR50-comm status, or corrupt ECRW hash,"
+ "or reload it"
+#else
+ NULL,
+ "Dump EC-CR50-comm status"
+#endif
+);
diff --git a/common/ec_efs.c b/common/ec_efs.c
index 9cc4061882..9952e0bc1c 100644
--- a/common/ec_efs.c
+++ b/common/ec_efs.c
@@ -281,6 +281,16 @@ void ec_efs_print_status(void)
#endif
}
+#ifdef CR50_RELAXED
+void ec_efs_corrupt_hash(void)
+{
+ int i;
+
+ for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+ ec_efs_ctx.hash[i] = ~ec_efs_ctx.hash[i] + 0x01;
+}
+#endif
+
#ifdef BOARD_HOST
uint8_t ec_efs_get_boot_mode(void)
{
diff --git a/include/ec_comm.h b/include/ec_comm.h
index dee31df4be..c599868488 100644
--- a/include/ec_comm.h
+++ b/include/ec_comm.h
@@ -41,6 +41,8 @@ uint16_t ec_efs_verify_hash(const char *hash_data, const uint8_t size);
void ec_efs_refresh(void);
/* print EC-EFS status */
void ec_efs_print_status(void);
+/* corrupt ECRW hash */
+void ec_efs_corrupt_hash(void);
#ifdef BOARD_HOST
/* return the current boot mode. For test purpose only. */