summaryrefslogtreecommitdiff
path: root/src/drivers/mrc_cache
diff options
context:
space:
mode:
authorShelley Chen <shchen@google.com>2020-10-16 13:15:59 -0700
committerJulius Werner <jwerner@chromium.org>2020-10-20 23:25:39 +0000
commita79803cf299a2c4912d5368951c6356df2dcd906 (patch)
treeb7f0e9f9345dc424a185eb425753ebe9305f0fbb /src/drivers/mrc_cache
parent1fed53f08a8099e03e352034b1265cc7b2fd427a (diff)
security/vboot: Make mrc_cache hash functions generic
We need to extend the functionality of the mrc_cache hash functions to work for both recovery and normal mrc_cache data. Updating the API of these functions to pass in an index to identify the hash indices for recovery and normal mode. BUG=b:150502246 BRANCH=None TEST=make sure memory training still works on nami Change-Id: I9c0bb25eafc731ca9c7a95113ab940f55997fc0f Signed-off-by: Shelley Chen <shchen@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/46432 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/drivers/mrc_cache')
-rw-r--r--src/drivers/mrc_cache/mrc_cache.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/drivers/mrc_cache/mrc_cache.c b/src/drivers/mrc_cache/mrc_cache.c
index 95abc4f1f8..8d4df8f9b8 100644
--- a/src/drivers/mrc_cache/mrc_cache.c
+++ b/src/drivers/mrc_cache/mrc_cache.c
@@ -10,6 +10,7 @@
#include <fmap.h>
#include <ip_checksum.h>
#include <region_file.h>
+#include <security/vboot/antirollback.h>
#include <security/vboot/mrc_cache_hash_tpm.h>
#include <security/vboot/vboot_common.h>
#include <spi_flash.h>
@@ -179,6 +180,7 @@ static int mrc_data_valid(const struct mrc_metadata *md,
void *data, size_t data_size)
{
uint16_t checksum;
+ uint32_t hash_idx = MRC_REC_HASH_NV_INDEX;
if (md->data_size != data_size)
return -1;
@@ -191,7 +193,7 @@ static int mrc_data_valid(const struct mrc_metadata *md,
return -1;
}
- if (CONFIG(MRC_SAVE_HASH_IN_TPM) && !mrc_cache_verify_hash(data, data_size))
+ if (CONFIG(MRC_SAVE_HASH_IN_TPM) && !mrc_cache_verify_hash(hash_idx, data, data_size))
return -1;
return 0;
@@ -393,6 +395,7 @@ static void update_mrc_cache_by_type(int type,
const struct region_device *backing_rdev;
struct region_device latest_rdev;
const bool fail_bad_data = false;
+ uint32_t hash_idx = MRC_REC_HASH_NV_INDEX;
cr = lookup_region(&region, type);
@@ -453,7 +456,7 @@ static void update_mrc_cache_by_type(int type,
printk(BIOS_DEBUG, "MRC: updated '%s'.\n", cr->name);
log_event_cache_update(cr->elog_slot, UPDATE_SUCCESS);
if (CONFIG(MRC_SAVE_HASH_IN_TPM))
- mrc_cache_update_hash(new_data, new_data_size);
+ mrc_cache_update_hash(hash_idx, new_data, new_data_size);
}
}