summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-07-16 12:35:19 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-07-17 14:50:23 +0000
commitba792e06e1d297333c192be4ef163a20c91d44b6 (patch)
tree3f2c27fc5bc1d273fa80c62210a6fb3745aa5e24
parentdd4c0d87f2db2e935190de5d8bef6063cff68eab (diff)
downloadchrome-ec-ba792e06e1d297333c192be4ef163a20c91d44b6.tar.gz
CR50: do not look for certs in uninitialized nvram.
When determining if the chip has been though manufacturing process, do not try looking for certd if NVRAM has not been initialized yet. Searching in uninitialized NVRAM causes infinite loops in the tpm2 source code. BRANCH=ToT BUG=chrome-os-partner:50645 TEST=it is possible now to run the device through manufacturing sequence repeatedly by erasing nvram section of the flash without falling into rolling reboots. Change-Id: Ib8b464b25ed4a647a84f971bd4e651daccf898be Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/360967 Reviewed-by: Nagendra Modadugu <ngm@google.com>
-rw-r--r--board/cr50/tpm2/manufacture.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/board/cr50/tpm2/manufacture.c b/board/cr50/tpm2/manufacture.c
index c8b3663c91..fb165fef8c 100644
--- a/board/cr50/tpm2/manufacture.c
+++ b/board/cr50/tpm2/manufacture.c
@@ -599,19 +599,27 @@ int tpm_manufactured(void)
flash_physical_info_read_word(INFO1_SENTINEL_OFFSET, &sentinel);
return sentinel == INFO1_SENTINEL_MANUFACTURE_DONE;
#else
-
- /* If either endorsement certificate is not installed,
- * consider the chip un-manufactured. Thus, wiping flash
- * causes the chip to be un-manufactured.
- */
+ uint32_t nv_ram_index;
const uint32_t rsa_ek_nv_index = EK_CERT_NV_START_INDEX;
const uint32_t ecc_ek_nv_index = EK_CERT_NV_START_INDEX + 1;
- if (NvIsUndefinedIndex(rsa_ek_nv_index) == TPM_RC_SUCCESS ||
- NvIsUndefinedIndex(ecc_ek_nv_index) == TPM_RC_SUCCESS)
+ /*
+ * If nvram_index (value written at NV RAM offset of zero) is all
+ * ones, or either endorsement certificate is not installed, consider
+ * the chip un-manufactured.
+ *
+ * Thus, wiping flash NV ram allows to re-manufacture the chip.
+ */
+ _plat__NvMemoryRead(0, sizeof(nv_ram_index), &nv_ram_index);
+ if ((nv_ram_index == ~0) ||
+ (NvIsUndefinedIndex(rsa_ek_nv_index) == TPM_RC_SUCCESS) ||
+ (NvIsUndefinedIndex(ecc_ek_nv_index) == TPM_RC_SUCCESS)) {
+ CPRINTF("%s: NOT manufactured\n", __func__);
return 0;
- else
+ } else {
+ CPRINTF("%s: manufactured\n", __func__);
return 1;
+ }
#endif
}