From 535846763825f9bc4531b9322b1b61f3973cd6f8 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Mon, 11 Jan 2021 16:44:06 -0800 Subject: prog_loaders: Remove prog_locate() This patch rewrites the last few users of prog_locate() to access CBFS APIs directly and removes the call. This eliminates the double-meaning of prog_rdev() (referring to both the boot medium where the program is stored before loading, and the memory area where it is loaded after) and makes sure that programs are always located and loaded in a single operation. This makes CBFS verification easier to implement and secure because it avoids leaking a raw rdev of unverified data outside the CBFS core code. Signed-off-by: Julius Werner Change-Id: I7a5525f66e1d5f3a632e8f6f0ed9e116e3cebfcf Reviewed-on: https://review.coreboot.org/c/coreboot/+/49337 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/drivers/intel/fsp1_1/fsp_relocate.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/drivers/intel/fsp1_1/fsp_relocate.c') diff --git a/src/drivers/intel/fsp1_1/fsp_relocate.c b/src/drivers/intel/fsp1_1/fsp_relocate.c index d078f5998d..7aaba82e6b 100644 --- a/src/drivers/intel/fsp1_1/fsp_relocate.c +++ b/src/drivers/intel/fsp1_1/fsp_relocate.c @@ -1,29 +1,24 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include -int fsp_relocate(struct prog *fsp_relocd, const struct region_device *fsp_src) +int fsp_relocate(struct prog *fsp_relocd) { - void *new_loc; void *fih; ssize_t fih_offset; - size_t size = region_device_sz(fsp_src); - - new_loc = cbmem_add(CBMEM_ID_REFCODE, size); + size_t size; + void *new_loc = cbfs_cbmem_alloc(prog_name(fsp_relocd), + CBMEM_ID_REFCODE, &size); if (new_loc == NULL) { printk(BIOS_ERR, "ERROR: Unable to load FSP into memory.\n"); return -1; } - if (rdev_readat(fsp_src, new_loc, 0, size) != size) { - printk(BIOS_ERR, "ERROR: Can't read FSP's region device.\n"); - return -1; - } - fih_offset = fsp1_1_relocate((uintptr_t)new_loc, new_loc, size); if (fih_offset <= 0) { -- cgit v1.2.3