summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-08-21 14:33:13 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-23 23:50:08 +0000
commit026e45300709faae9cc73d4f42f111fffab99120 (patch)
treedd04fd182aac0fba33cd855d25407d514ce7c5a8 /test
parent481da547186bc9989068ceef73ccd1556a911dad (diff)
downloadchrome-ec-026e45300709faae9cc73d4f42f111fffab99120.tar.gz
nvmem: reinitialize on catastrophic errors
If there is an NVMEM corruption which causes a reboot, persisting corruption would cause rolling reboot of the device. It is a harsh remedy, but at least the device remains functional. Added a log entry to explicitly report NVMEM reinitialization. BRANCH=cr50, cr50-mp BUG=b:139326267 TEST=verified by erasing a flash page assigned to NVMEM and rebooting the device. Observed two new flash log entries. Change-Id: Id292d7c66b81c03bbe3cd343ae75acb62d06582d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1758805 Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/nvmem.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/nvmem.c b/test/nvmem.c
index 4e7c3600be..df5457273b 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -11,6 +11,7 @@
#include "console.h"
#include "crc.h"
#include "flash.h"
+#include "flash_log.h"
#include "new_nvmem.h"
#include "nvmem.h"
#include "printf.h"
@@ -835,6 +836,7 @@ static int test_nvmem_incomplete_transaction(void)
uint8_t buf[nvmem_user_sizes[NVMEM_TPM]];
uint8_t *p;
size_t object_size;
+ union entry_u e;
TEST_ASSERT(prepare_post_migration_nvmem() == EC_SUCCESS);
num_objects = fill_obj_offsets(offsets, ARRAY_SIZE(offsets));
@@ -898,8 +900,19 @@ static int test_nvmem_incomplete_transaction(void)
failure_mode = TEST_SPANNING_PAGES;
new_nvmem_save();
failure_mode = TEST_NO_FAILURE;
+
+ /* Drain the event log. */
+ e.r.timestamp = 0;
+ while (flash_log_dequeue_event(e.r.timestamp, e.entry, sizeof(e)) > 0)
+ ;
+
TEST_ASSERT(nvmem_init() == EC_SUCCESS);
+ /* Let's verify that a container mismatch event has been added. */
+ TEST_ASSERT(flash_log_dequeue_event(e.r.timestamp, e.entry, sizeof(e))
+ > 0);
+ TEST_ASSERT(e.r.type == FE_LOG_NVMEM);
+ TEST_ASSERT(e.r.payload[0] == NVMEMF_CONTAINER_HASH_MISMATCH);
return EC_SUCCESS;
}