From 85541960df2c34d0e7c621cc1cfb3c169439d9d0 Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Sun, 3 Dec 2023 20:47:30 +0100 Subject: util/ifdtool/ifdtool.c: Add validation exception When validating the FMAP against the IFD, the BIOS region is a somewhat specical case, since the FMAP BIOS region usually does not match the IFD BIOS region. Instead the FMAP region usually resides somewhere inside the IFD BIOS region and the where depends on CONFIG_CBFS_SIZE. Signed-off-by: Maximilian Brune Change-Id: I920a0ee246cfd2b4ae0870256357d4f285e1730d Reviewed-on: https://review.coreboot.org/c/coreboot/+/79368 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- util/ifdtool/ifdtool.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c index 5993bfc99b..36477eef66 100644 --- a/util/ifdtool/ifdtool.c +++ b/util/ifdtool/ifdtool.c @@ -1227,6 +1227,19 @@ static void validate_layout(char *image, int size) matches++; // found a match between FMAP and IFD region if ((uint)region.base != area->offset || (uint)region.size != area->size) { + if (i == REGION_BIOS) { + /* + * BIOS FMAP region is a special case + * coreboots FMAP BIOS region depends on the CONFIG_CBFS_SIZE + * while the IFD BIOS region is always of static size. + * Therefore we just make sure that the BIOS region of the FMAP + * is inside the region specified by the IFD + */ + if ((uint)region.base <= area->offset && + ((uint)region.base + region.size) >= (area->offset + area->size)) { + continue; + } + } printf("Region mismatch between %s and %s\n", region_names[i].terse, area->name); printf(" Descriptor region %s:\n", region_names[i].terse); printf(" offset: 0x%08x\n", region.base); -- cgit v1.2.3