intel: fsp2_0: Move last pieces to new CBFS API

This patch ports the last remaining use of cbfs_boot_locate() in the
Intel FSP drivers to the new CBFS API. As a consequence, there is no
longer a reason for fsp_validate_component() to operate on rdevs, and
the function is simplified to take a direct void pointer and size to a
memory-mapping of the FSP blob instead.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: If1f0239eefa4542e4d23f6e2e3ff19106f2e3c0d
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52281
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Julius Werner 2021-04-12 17:00:16 -07:00
parent b3182fbb00
commit 43c9d709c7
4 changed files with 18 additions and 30 deletions

View File

@ -104,9 +104,8 @@ void lb_string_platform_blob_version(struct lb_header *header);
void report_fspt_output(void);
void soc_validate_fsp_version(const struct fsp_header *hdr);
/* Fill in header and validate sanity of component within region device. */
enum cb_err fsp_validate_component(struct fsp_header *hdr,
const struct region_device *rdev);
/* Fill in header and validate a loaded FSP component. */
enum cb_err fsp_validate_component(struct fsp_header *hdr, void *fsp_blob, size_t size);
struct fsp_load_descriptor {
/* fsp_prog object will have region_device initialized to final

View File

@ -204,10 +204,7 @@ void fsps_load(void)
if (resume_from_stage_cache()) {
printk(BIOS_DEBUG, "Loading FSPS from stage_cache\n");
stage_cache_load_stage(STAGE_REFCODE, fsps);
struct region_device prog_rdev;
prog_chain_rdev(fsps, &prog_rdev);
if (fsp_validate_component(&fsps_hdr, &prog_rdev) != CB_SUCCESS)
if (fsp_validate_component(&fsps_hdr, prog_start(fsps), prog_size(fsps)))
die("On resume fsps header is invalid\n");
load_done = 1;
return;

View File

@ -12,18 +12,17 @@ void fsp_temp_ram_exit(void)
struct fsp_header hdr;
uint32_t status;
temp_ram_exit_fn temp_ram_exit;
struct cbfsf file_desc;
struct region_device file_data;
void *mapping;
size_t size;
const char *name = CONFIG_FSP_M_CBFS;
if (cbfs_boot_locate(&file_desc, name, NULL)) {
printk(BIOS_CRIT, "Could not locate %s in CBFS\n", name);
mapping = cbfs_map(name, &size);
if (!mapping) {
printk(BIOS_CRIT, "Could not map %s from CBFS\n", name);
die("FSPM not available for CAR Exit!\n");
}
cbfs_file_data(&file_data, &file_desc);
if (fsp_validate_component(&hdr, &file_data) != CB_SUCCESS)
if (fsp_validate_component(&hdr, mapping, size) != CB_SUCCESS)
die("Invalid FSPM header!\n");
temp_ram_exit = (void *)(hdr.image_base + hdr.temp_ram_exit_entry);
@ -34,6 +33,8 @@ void fsp_temp_ram_exit(void)
printk(BIOS_CRIT, "TempRamExit returned 0x%08x\n", status);
die("TempRamExit returned an error!\n");
}
cbfs_unmap(mapping);
}
void late_car_teardown(void)

View File

@ -55,32 +55,25 @@ enum cb_err fsp_identify(struct fsp_header *hdr, const void *fsp_blob)
return CB_SUCCESS;
}
enum cb_err fsp_validate_component(struct fsp_header *hdr,
const struct region_device *rdev)
enum cb_err fsp_validate_component(struct fsp_header *hdr, void *fsp_file, size_t file_size)
{
void *membase;
void *raw_hdr = fsp_file + FSP_HDR_OFFSET;
/* Map just enough of the file to be able to parse the header. */
membase = rdev_mmap(rdev, FSP_HDR_OFFSET, FSP_HDR_LEN);
if (membase == NULL) {
printk(BIOS_CRIT, "Could not mmap() FSP header.\n");
if (file_size < FSP_HDR_OFFSET + FSP_HDR_LEN) {
printk(BIOS_CRIT, "FSP blob too small.\n");
return CB_ERR;
}
if (fsp_identify(hdr, membase) != CB_SUCCESS) {
rdev_munmap(rdev, membase);
if (fsp_identify(hdr, raw_hdr) != CB_SUCCESS) {
printk(BIOS_CRIT, "No valid FSP header\n");
return CB_ERR;
}
rdev_munmap(rdev, membase);
if (CONFIG(DISPLAY_FSP_HEADER))
fsp_print_header_info(hdr);
/* Check if size specified in the header matches the cbfs file size */
if (region_device_sz(rdev) < hdr->image_size) {
if (file_size < hdr->image_size) {
printk(BIOS_CRIT, "Component size bigger than cbfs file.\n");
return CB_ERR;
}
@ -145,7 +138,6 @@ enum cb_err fsp_load_component(struct fsp_load_descriptor *fspld, struct fsp_hea
{
size_t output_size;
void *dest;
struct region_device prog_rdev;
struct prog *fsp_prog = &fspld->fsp_prog;
dest = cbfs_alloc(prog_name(fsp_prog), fspld->alloc, fspld, &output_size);
@ -160,8 +152,7 @@ enum cb_err fsp_load_component(struct fsp_load_descriptor *fspld, struct fsp_hea
prog_set_area(fsp_prog, dest, output_size);
prog_chain_rdev(fsp_prog, &prog_rdev);
if (fsp_validate_component(hdr, &prog_rdev) != CB_SUCCESS) {
if (fsp_validate_component(hdr, dest, output_size) != CB_SUCCESS) {
printk(BIOS_ERR, "Invalid FSP header after load!\n");
return CB_ERR;
}