From 7fbac79e9473a7766c38e682f4b0212d0aec553b Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sat, 30 Jul 2016 17:40:45 -0700 Subject: [PATCH] tpm: make TPM_FW_VER register return both build and version strings Both build string (which includes status of all firmware components of the running image) and the firmware version string (which show versions of various objects in the flash) are important to the user. Let's include both of these strings into the TPM_FW_VER register output. Buffer storing the string needs to be increased accordingly. BRANCH=none BUG=chrome-os-partner:55558 TEST=verified the contents of the AP firmware console log: localhost ~ # grep cr50 /sys/firmware/log Firmware version: RO_A: 0.0.1/84e2dde7 RO_B:* 0.0.2/13eda43f RW_A: ... cr50_v1.1.5003-af11829+ private-cr51:v0.0.66-bd9a0fe tpm2:v0.0.259-8f3d735... Change-Id: I67df3e810bd07053d0b7d8b6fac350253ca06bb0 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/364830 Reviewed-by: Bill Richardson --- common/tpm_registers.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/tpm_registers.c b/common/tpm_registers.c index 3236c7d8a5..da8b75c023 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -109,7 +109,13 @@ enum tpm_sts_bits { /* Used to count bytes read in version string */ static int tpm_fw_ver_index; -static uint8_t tpm_fw_ver[180]; +/* + * Used to store the full version string, which includes version of the two RO + * and two RW regions in the flash as well as the version string of the four + * cr50 image components. The number is somewhat arbitrary, calculated for the + * worst case scenario when all compontent trees are 'dirty'. + */ +static uint8_t tpm_fw_ver[260]; /* * We need to be able to report firmware version to the host, both RO and RW @@ -155,6 +161,12 @@ static void set_version_string(void) " RW_B:%s %s", (active_rw == SYSTEM_IMAGE_RW_B ? "*" : ""), system_get_version(SYSTEM_IMAGE_RW_B)); + offset = strlen(tpm_fw_ver); + if (offset == sizeof(tpm_fw_ver) - 1) + return; + + snprintf(tpm_fw_ver + offset, sizeof(tpm_fw_ver) - offset, + "\n%s", system_get_build_info()); } static void set_tpm_state(enum tpm_states state)