summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-04-25 20:10:16 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-01 11:03:04 -0700
commitf4f26f19d1ce3d3f4904ddf8bb69185665f73c5b (patch)
treeb2d8ae91c15c8735900fc0f14e80976edbdac930
parentd15d77489e3dd10b4b884c555e477f5647d86bb3 (diff)
downloadchrome-ec-f4f26f19d1ce3d3f4904ddf8bb69185665f73c5b.tar.gz
nvmem: populate default tpm objects after wipeout
TPM memory wipe code is removing all TPM objects from the flash, including the reserved objects, which are supposed to be always present. The assumption was that the Cr50 would be reset after the wipe out and the initialization code would populated the reserved objects with default values. But in fact Cr50 reset is not guaranteed after TPM wipeout, so it is better to call the init function explicitly to make sure that all reserved objects are in the flash at all times. BRANCH=cr50, cr50-mp BUG=b:69907320 TEST='dump' command ran on the Cr50 console after RMA open shows all reserved objects present. Change-Id: Id9e227de0995c6491da9f38fc8ca11df3661c71f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1584658 Reviewed-by: Andrey Pronin <apronin@chromium.org>
-rw-r--r--common/new_nvmem.c6
-rw-r--r--test/nvmem.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/common/new_nvmem.c b/common/new_nvmem.c
index 9b3b399a67..9a9973bd4b 100644
--- a/common/new_nvmem.c
+++ b/common/new_nvmem.c
@@ -2811,8 +2811,6 @@ static void dump_contents(const struct nn_container *ch)
* objects, then compact the flash storage, removing all TPM related objects.
* This would guarantee that all pages where TPM objecs were stored would be
* erased.
- *
- * TODO(vbendeb): need to seed reserved objects after this is done.
*/
int nvmem_erase_tpm_data(void)
{
@@ -2894,6 +2892,10 @@ int nvmem_erase_tpm_data(void)
} while (master_at.list_index != (saved_list_index + 1));
rv = compact_nvmem();
+
+ if (rv == EC_SUCCESS)
+ rv = new_nvmem_init();
+
return rv;
}
diff --git a/test/nvmem.c b/test/nvmem.c
index 52cf40138a..75bd9f2856 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -627,10 +627,10 @@ static int test_nvmem_erase_tpm_data(void)
TEST_ASSERT(iterate_over_flash() == EC_SUCCESS);
TEST_ASSERT(test_result.deleted_obj_count == 0);
TEST_ASSERT(test_result.var_count == 3);
- TEST_ASSERT(test_result.reserved_obj_count == 0);
+ TEST_ASSERT(test_result.reserved_obj_count == 38);
TEST_ASSERT(test_result.evictable_obj_count == 0);
TEST_ASSERT(test_result.unexpected_count == 0);
- TEST_ASSERT(test_result.valid_data_size == 86);
+ TEST_ASSERT(test_result.valid_data_size == 1174);
TEST_ASSERT(test_result.erased_data_size == 0);
return EC_SUCCESS;