cbfs: Move more stuff into cbfs_boot_lookup()

cbfs_boot_locate() is supposed to be deprecated eventually, after slowly
migrating all APIs to bypass it. That means common features (like
RO-fallback or measurement) need to be moved to the new
cbfs_boot_lookup().

Also export the function externally. Since it is a low-level API and
most code should use the higher-level loading or mapping functions
instead, put it into a new <cbfs_private.h> to raise the mental barrier
for using this API (this will make more sense once cbfs_boot_locate() is
removed from <cbfs.h>).

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I4bc9b7cbc42a4211d806a3e3389abab7f589a25a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39327
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Julius Werner
2020-03-05 12:51:08 -08:00
committed by Patrick Georgi
parent baf27dbaeb
commit 0d9072b1a1
6 changed files with 74 additions and 41 deletions

View File

@@ -102,11 +102,10 @@ static bool is_runtime_data(const char *name)
return !strcmp(allowlist, name);
}
uint32_t tspi_measure_cbfs_hook(struct cbfsf *fh, const char *name)
uint32_t tspi_measure_cbfs_hook(const struct region_device *rdev, const char *name,
uint32_t cbfs_type)
{
uint32_t pcr_index;
uint32_t cbfs_type;
struct region_device rdev;
char tcpa_metadata[TCPA_PCR_HASH_NAME];
if (!tcpa_log_available()) {
@@ -118,9 +117,6 @@ uint32_t tspi_measure_cbfs_hook(struct cbfsf *fh, const char *name)
printk(BIOS_DEBUG, "CRTM initialized.\n");
}
cbfsf_file_type(fh, &cbfs_type);
cbfs_file_data(&rdev, fh);
switch (cbfs_type) {
case CBFS_TYPE_MRC_CACHE:
pcr_index = TPM_RUNTIME_DATA_PCR;
@@ -143,10 +139,10 @@ uint32_t tspi_measure_cbfs_hook(struct cbfsf *fh, const char *name)
break;
}
if (create_tcpa_metadata(&rdev, name, tcpa_metadata) < 0)
if (create_tcpa_metadata(rdev, name, tcpa_metadata) < 0)
return VB2_ERROR_UNKNOWN;
return tpm_measure_region(&rdev, pcr_index, tcpa_metadata);
return tpm_measure_region(rdev, pcr_index, tcpa_metadata);
}
int tspi_measure_cache_to_pcr(void)