HACK tpm: reset fallback counter when ready

As a temp measure until a proper solution is implemented, reset the
restart counter when the PCR_Read command is issued by the host.

This is a good indication that Chrome OS is through the boot process,
as PCR value is used to determine the boot mode.

BRANCH=none
BUG=chrome-os-partner:55667
TEST=installed the new image on a Kevin cr50 and rebooted it in normal
     and recovery modes, observed on the cr50 console the message like
  > system_process_retry_counter:retry counter 1

Change-Id: Ib55e161d5edbf8f6e2d387fd756b94aa53c20ed8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364311
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
Vadim Bendebury
2016-07-28 17:17:19 -07:00
committed by chrome-bot
parent 17276a7a7e
commit 3d01f46a5b
4 changed files with 22 additions and 2 deletions

View File

@@ -323,11 +323,11 @@ int system_process_retry_counter(void)
GREG32(PMU, LONG_LIFE_SCRATCH0) = 0;
GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
ccprintf("%s:retry counter %d\n", __func__, retry_counter);
if (retry_counter <= RW_BOOT_MAX_RETRY_COUNT)
return EC_SUCCESS;
ccprintf("%s:retry counter %d\n", __func__, retry_counter);
if (system_get_image_copy() == SYSTEM_IMAGE_RW) {
me = (struct SignedHeader *)
get_program_memory_addr(SYSTEM_IMAGE_RW);

View File

@@ -568,6 +568,12 @@ void tpm_task(void)
CPRINTF("got %d bytes in response\n", response_size);
if (response_size &&
(response_size <= sizeof(tpm_.regs.data_fifo))) {
/*
* TODO(vbendeb): revisit this when
* crosbug.com/p/55667 has been addressed.
*/
if (command_code == TPM2_PCR_Read)
system_process_retry_counter();
#ifdef CONFIG_EXTENSION_COMMAND
if (command_code != CONFIG_EXTENSION_COMMAND)
#endif

View File

@@ -458,4 +458,12 @@ uintptr_t system_get_fw_reset_vector(uintptr_t base);
*/
int system_is_reboot_warm(void);
/**
* On systems with protection from a failing RW update: read the retry counter
* and act on it.
*
* @return EC_SUCCESS if no flash write errors were encounterd.
*/
int system_process_retry_counter(void);
#endif /* __CROS_EC_SYSTEM_H */

View File

@@ -40,4 +40,10 @@ struct tpm_cmd_header {
uint16_t subcommand_code; /* Not a standard field. */
} __packed;
/*
* The only TPM2 command we care about on the driver level, see
* crosbug.com/p/55667 for detals.
*/
#define TPM2_PCR_Read 0x0000017e
#endif /* __CROS_EC_TPM_REGISTERS_H */