[coreboot-gerrit] Change in ...coreboot[master]: soc/intel/apl: Warn if CBFS is outside the memory mapped area

Nico Huber (Code Review) gerrit at coreboot.org
Wed Dec 5 18:13:48 CET 2018


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 at 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(&regn);
 	props->size = region_sz(&regn);
 
-	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, &regn)) {
+		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;
 }

-- 
To view, visit https://review.coreboot.org/c/coreboot/+/30055
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If5a5b553ad4853723bf13349c809c4f6154aa5f2
Gerrit-Change-Number: 30055
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181205/095a612e/attachment.html>


More information about the coreboot-gerrit mailing list