[coreboot] New patch to review for coreboot: 76150be armv7: Prevent CBFS data overlapping bootblock.

Hung-Te Lin (hungte@chromium.org) gerrit at coreboot.org
Wed Feb 6 05:56:54 CET 2013


Hung-Te Lin (hungte at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2295

-gerrit

commit 76150be9534747d0d7df44d679eed9ffc1a67375
Author: Hung-Te Lin <hungte at chromium.org>
Date:   Wed Feb 6 12:41:49 2013 +0800

    armv7: Prevent CBFS data overlapping bootblock.
    
    For arm/snow, current bootblock is larger than previously assigned CBFS offset
    and will fail to boot. To prevent this happening again in future, cbfstool now
    checks if CBFS will overlap bootblock.
    
    A sample error message:
    	E: Bootblock (0x0+0x71d4) overlap CBFS data (0x5000)
    	E: Failed to create build/coreboot.pre1.tmp.
    
    arm/snow offset is also enlarged and moved to Kconfig variable.
    
    Change-Id: I4556aef27ff716556040312ae8ccb78078abc82d
    Signed-off-by: Hung-Te Lin <hungte at chromium.org>
---
 src/arch/armv7/Makefile.inc        | 6 ++++--
 src/cpu/samsung/exynos5250/Kconfig | 5 +++++
 util/cbfstool/cbfs_image.c         | 6 ++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/arch/armv7/Makefile.inc b/src/arch/armv7/Makefile.inc
index f2f4a47..7d02e7c 100644
--- a/src/arch/armv7/Makefile.inc
+++ b/src/arch/armv7/Makefile.inc
@@ -45,10 +45,12 @@ prebuild-files = \
 	$(if $(call extract_nth,4,$(file)),-b $(call extract_nth,4,$(file))) &&)
 prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
 
-# TODO Change -b, -H, -o to Kconfig variables.
+# TODO Change -b to Kconfig variable.
 $(obj)/coreboot.pre1: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(CBFSTOOL)
 	$(CBFSTOOL) $@.tmp create -m armv7 -s $(CONFIG_COREBOOT_ROMSIZE_KB)K \
-		-B $(objcbfs)/bootblock.bin -a 64 -b 0x0000 -H 0x2040 -o 0x5000
+		-B $(objcbfs)/bootblock.bin -a 64 -b 0x0000 \
+		-H $(CONFIG_CBFS_HEADER_ROM_OFFSET) \
+		-o $(CONFIG_CBFS_ROM_OFFSET)
 	$(prebuild-files) true
 	mv $@.tmp $@
 else
diff --git a/src/cpu/samsung/exynos5250/Kconfig b/src/cpu/samsung/exynos5250/Kconfig
index 477ee51..6a09d88 100644
--- a/src/cpu/samsung/exynos5250/Kconfig
+++ b/src/cpu/samsung/exynos5250/Kconfig
@@ -48,6 +48,11 @@ config ROMSTAGE_SIZE
 	hex
 	default 0x10000
 
+config CBFS_ROM_OFFSET
+	# Calculated by BL1 + max bootblock size.
+	hex "offset of CBFS data in ROM"
+	default 0x0A000
+
 # TODO Change this to some better address not overlapping bootblock when
 # cbfstool supports creating header in arbitrary location.
 config CBFS_HEADER_ROM_OFFSET
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index b7c6ee5..5c2ac26 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -174,6 +174,12 @@ int cbfs_image_create(struct cbfs_image *image,
 		      bootblock_offset, bootblock->size, size);
 		return -1;
 	}
+	if (entries_offset > bootblock_offset &&
+	    entries_offset < bootblock->size) {
+		ERROR("Bootblock (0x%x+0x%zx) overlap CBFS data (0x%x)\n",
+		      bootblock_offset, bootblock->size, entries_offset);
+		return -1;
+	}
 	memcpy(image->buffer.data + bootblock_offset, bootblock->data,
 	       bootblock->size);
 



More information about the coreboot mailing list