From 56dd2d6ff108105a9349d2644db9706e7d688eeb Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Wed, 5 Dec 2018 18:06:17 +0100 Subject: 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 Reviewed-on: https://review.coreboot.org/c/30055 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Patrick Georgi --- src/soc/intel/apollolake/mmap_boot.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/soc/intel') diff --git a/src/soc/intel/apollolake/mmap_boot.c b/src/soc/intel/apollolake/mmap_boot.c index db13cba62f..1c3077ed91 100644 --- a/src/soc/intel/apollolake/mmap_boot.c +++ b/src/soc/intel/apollolake/mmap_boot.c @@ -110,6 +110,8 @@ const struct region_device *boot_device_ro(void) 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 @@ static int iafw_boot_region_properties(struct cbfs_props *props) 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; } -- cgit v1.2.3