diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2016-07-06 17:15:38 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-07-08 00:34:49 +0000 |
commit | 9de5e5ff8646357eaec6e1d6a2ddf251b1f6c768 (patch) | |
tree | 935204bbfbf2eda51d9b29444f2c0a978c5b079a | |
parent | 11c156aedd6c28a23ad710493f806ea69b976183 (diff) | |
download | chrome-ec-9de5e5ff8646357eaec6e1d6a2ddf251b1f6c768.tar.gz |
HACK: cr50: make sure manufacturing sequence is invoked only once
While the proper manufacturing initialization is in the works, we need
to be able to initialized the device, but do not want to run
manufacturing process on every reboot.
Let's store the state in the lowest location of the NVRAM, this patch
will be reverted when the proper initialization procedure is in place.
BRANCH=none
BUG=chrome-os-partner:50115
TEST=used the device in Kevin. Observed that factory initialization
sequence was invoked only on the first boot, the following boots
had no problems reading rollback counters.
Change-Id: I812cbad4d91db47de76ecfa5a14c56ae9c0efdab
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/358680
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
(cherry picked from commit 46a9a118429f0a785c7ad29ade950c1e3c867440)
Reviewed-on: https://chromium-review.googlesource.com/359024
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Commit-Queue: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Bernie Thompson <bhthompson@chromium.org>
-rw-r--r-- | common/tpm_registers.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c index 24c56ca475..bb07a32330 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -12,6 +12,7 @@ #include "byteorder.h" #include "console.h" #include "extension.h" +#include "nvmem.h" #include "printf.h" #include "signed_header.h" #include "system.h" @@ -448,6 +449,9 @@ void tpm_register_get(uint32_t regaddr, uint8_t *dest, uint32_t data_size) static void tpm_init(void) { + uint32_t saved_value; + const uint32_t manufacturing_done = 0x12344321; + set_tpm_state(tpm_state_idle); tpm_.regs.access = tpm_reg_valid_sts; tpm_.regs.sts = (tpm_family_tpm2 << tpm_family_shift) | @@ -455,9 +459,24 @@ static void tpm_init(void) /* TPM2 library functions. */ _plat__Signal_PowerOn(); - /* TODO(ngm): CRBUG/50115, initialize state expected by TPM2 - * compliance tests. */ - TPM_Manufacture(1); + + + /* + * TODO(ngm): CRBUG/50115, initialize state expected by TPM2 + * compliance tests. + * + * Until it is done properly, use location at offset 0 in the generic + * section of NVRAM to store the manufacturing status. Otherwise the + * NV RAM is wiped out on every reboot. + */ + nvmem_read(0, sizeof(saved_value), &saved_value, NVMEM_CR50); + if (saved_value != manufacturing_done) { + TPM_Manufacture(1); + saved_value = manufacturing_done; + nvmem_write(0, sizeof(saved_value), &saved_value, NVMEM_CR50); + nvmem_commit(); + } + _TPM_Init(); _plat__SetNvAvail(); } |