drivers/mrc_cache: Don't compute checksum if TPM hash is used

When MRC_SAVE_HASH_IN_TPM is selected, mrc_data_valid() uses the TPM
hash to verify the MRC cache data, not the checksum. However, we still
calculate the checksum when updating the cache. Skip this calculation
when MRC_SAVE_HASH_IN_TPM is selected to save boot time.

On nissa, this reduces boot time by ~14 ms:

Before:
  3:after RAM initialization                          854,298 (28,226)

After:
  3:after RAM initialization                          849,626 (14,463)

Note, the reason the calculation is so slow is that the new MRC data
lives in CBMEM, which is not yet marked as cacheable in romstage.

BUG=b:242667207
TEST=MRC caching still works as expected on nivviks. After clearing
the MRC cache, memory training happens on the next boot, but doesn't on
subsequent boots.

Change-Id: Ifbb75ecfa17421c0565aec1f3eb48d950244f821
Signed-off-by: Reka Norman <rekanorman@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67042
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Shelley Chen <shchen@google.com>
This commit is contained in:
Reka Norman 2022-08-17 16:18:55 +10:00 committed by Martin Roth
parent 2515c5e313
commit f83b7d494e
1 changed files with 3 additions and 3 deletions

View File

@ -693,10 +693,10 @@ int mrc_cache_stash_data(int type, uint32_t version, const void *data,
.signature = MRC_DATA_SIGNATURE,
.data_size = size,
.version = version,
.data_checksum = compute_ip_checksum(data, size),
};
md.header_checksum =
compute_ip_checksum(&md, sizeof(md));
if (!CONFIG(MRC_SAVE_HASH_IN_TPM))
md.data_checksum = compute_ip_checksum(data, size);
md.header_checksum = compute_ip_checksum(&md, sizeof(md));
if (CONFIG(MRC_STASH_TO_CBMEM)) {
/* Store data in cbmem for use in ramstage */