Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30055
Change subject: soc/intel/apl: Warn if CBFS is outside the memory mapped area ......................................................................
soc/intel/apl: Warn if CBFS is outside the memory mapped area
As part of the memory mapped BIOS region is covered by SRAM, check that CBFS always fits the effectively mapped region of flash. This is usually taken care of by reserving the SRAM range in the FMAP (e.g. as BIOS_UNUSABLE), but can be missed.
Change-Id: If5a5b553ad4853723bf13349c809c4f6154aa5f2 Signed-off-by: Nico Huber nico.huber@secunet.com --- M src/soc/intel/apollolake/mmap_boot.c 1 file changed, 15 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/30055/1
diff --git a/src/soc/intel/apollolake/mmap_boot.c b/src/soc/intel/apollolake/mmap_boot.c index db13cba..1c3077e 100644 --- a/src/soc/intel/apollolake/mmap_boot.c +++ b/src/soc/intel/apollolake/mmap_boot.c @@ -110,6 +110,8 @@
static int iafw_boot_region_properties(struct cbfs_props *props) { + struct xlate_region_device *real_dev_ptr; + struct region *real_dev_reg; struct region regn;
/* use fmap to locate CBFS area */ @@ -119,7 +121,19 @@ props->offset = region_offset(®n); props->size = region_sz(®n);
- printk(BIOS_DEBUG, "CBFS @ %zx size %zx\n", props->offset, props->size); + /* Check that we are within the memory mapped area. It's too + easy to forget the SRAM mapping when crafting an FMAP file. */ + real_dev_ptr = car_get_var_ptr(&real_dev); + real_dev_reg = &real_dev_ptr->sub_region; + if (region_is_subregion(real_dev_reg, ®n)) { + printk(BIOS_DEBUG, "CBFS @ %zx size %zx\n", + props->offset, props->size); + } else { + printk(BIOS_CRIT, + "ERROR: CBFS @ %zx size %zx exceeds mem-mapped area @ %zx size %zx\n", + props->offset, props->size, + region_offset(real_dev_reg), region_sz(real_dev_reg)); + }
return 0; }