diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-02-14 15:19:27 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-15 14:07:18 -0800 |
commit | 8664d3093e613b7e84fdc1c3a4b715749045064e (patch) | |
tree | fefc713f5b79597cfc04157d9a011934e22e1707 | |
parent | 490626600b577a07d9d21c59c45bb8a2c8ab775e (diff) | |
download | chrome-ec-8664d3093e613b7e84fdc1c3a4b715749045064e.tar.gz |
tpm: explicitly include tpm2 data in the appropriate section
With the recent move to enabling LTO the tpm_registers module's data
variables which are supposed to be cleared on TPM reset ended up not
included in the appropriate part of the .bss section.
With this patch all variables of interest are marked with the section
name they need to be placed in.
BRANCH=cr50, cr50-mp
BUG=b:124450448
TEST=before this patch after RMA clear every TPM reset was wiping out
the TPM NVMEM, with this patch in place only the following reset
wipes out the NVMEM.
Change-Id: If0cbdeae2ff37f2b9cf67672c0a3b5c57efd6248
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1474892
Reviewed-by: Andrey Pronin <apronin@chromium.org>
-rw-r--r-- | common/tpm_registers.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c index 397d067742..7447ef3191 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -42,16 +42,16 @@ * executable, because the loader can just zero .bss prior to running the * program. * - * However, the tpm_reset_request() function will zero the .bss section for THIS - * FILE and all files in the TPM library. Any uninitialized variables defined in - * this file that must be preserved across tpm_reset_request() must be placed in - * a separate section. + * In addition to that, the tpm_reset_request() function will zero the .bss of + * all modules of the TPM library and variables of this file explicitly added + * to the .bss.Tpm2_common section, which will allow restarting TPM without + * rebooting the device. * * On the other hand, initialized variables (in the .data section) are NOT * affected by tpm_reset_request(), so any variables that should be * reinitialized must be dealt with manually in the tpm_reset_request() * function. To prevent initialized variables from being added to the TPM - * library without notice, the compiler will reject any that aren't explicitly + * library without notice, the linker will reject any that aren't explicitly * flagged. */ @@ -114,7 +114,7 @@ static struct { uint32_t fifo_read_index; /* for read commands */ uint32_t fifo_write_index; /* for write commands */ struct tpm_register_file regs; -} tpm_; +} tpm_ __attribute__((section(".bss.Tpm2_common"))); /* Bit definitions for some TPM registers. */ enum tpm_access_bits { @@ -142,14 +142,14 @@ enum tpm_sts_bits { }; /* Used to count bytes read in version string */ -static int tpm_fw_ver_index; +static int tpm_fw_ver_index __attribute__((section(".bss.Tpm2_common"))); /* * 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[80]; +static uint8_t tpm_fw_ver[80] __attribute__((section(".bss.Tpm2_common"))); /* * We need to be able to report firmware version to the host, both RO and RW @@ -750,7 +750,7 @@ static __preserved int wipe_result; /* * Did tpm_reset_request() request nvmem wipe? (intentionally cleared on reset) */ -static int wipe_requested; +static int wipe_requested __attribute__((section(".bss.Tpm2_common"))); int tpm_reset_request(int wait_until_done, int wipe_nvmem_first) { |