Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56127 )
Change subject: util/cbfstool: Catch baseaddress parameter errors early ......................................................................
util/cbfstool: Catch baseaddress parameter errors early
Instead of just failing, provide accurate errors early on, on why a base parameter might be wrong. Also return if a non-XIP FSP has a flash mapped base address, as loading a binary in RO flash will cause runtime errors.
Change-Id: Icfd121b34ce79fe1394f79d5cbd4da6ddf5c5656 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M util/cbfstool/cbfstool.c 1 file changed, 23 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/56127/1
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 1032ab2..678a28c 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -804,6 +804,29 @@ return 1; }
+ if (param.baseaddress_assigned) { + if (param.type == CBFS_TYPE_FSP && param.stage_xip) { + assert(create_mmap_windows()); + if (!find_mmap_window(HOST_SPACE_ADDR, param.baseaddress)) { + ERROR("Wrong -b parameter: FSP non-XIP has to be located outside of flash\n"); + return 1; + } + } else { + if (IS_HOST_SPACE_ADDRESS(param.baseaddress)) { + if (find_mmap_window(HOST_SPACE_ADDR, param.baseaddress)) { + ERROR("Wrong -b parameter: base not mapped inside flash\n"); + return 1; + } + } else { + if (param.baseaddress >= param.image_region->size) { + ERROR("Wrong -b parameter: base bigger than %s region\n", + param.region_name); + return 1; + } + } + } + } + if (!filename) { ERROR("You need to specify -f/--filename.\n"); return 1;