mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
fmap: Skip unreadable regions when attempting to locate FMAP
When using the on-chip FMAP to restrict flashrom operations to one or more regions (--fmap), flashrom must first locate the FMAP. This requires flashrom to read from multiple addresses, some of which may be located in regions which are not readable (such as the Intel ME region). In order to avoid a substantial amount of output from read_flash() when trying to locate the FMAP in these regions, set `the skip_unreadable_regions` flag before performing any reads to locate the FMAP, and restore the original flag value when finished. This resolves https://ticket.coreboot.org/issues/587 TEST=build flashrom, use cli to update COREBOOT and EC FMAP regions on an Intel Alderlake-N platform board (starlabs/starlite_adl). Change-Id: Ie78b977b4e6a5db02a25e69603f697834043ea99 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/87748 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:

committed by
Anastasia Klimchuk

parent
9d6ce34659
commit
1516420f3f
11
fmap.c
11
fmap.c
@ -190,6 +190,7 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash
|
||||
struct fmap *fmap;
|
||||
const unsigned int chip_size = flashctx->chip->total_size * 1024;
|
||||
const int sig_len = strlen(FMAP_SIGNATURE);
|
||||
bool skip_unreadable_orig = flashctx->flags.skip_unreadable_regions;
|
||||
|
||||
if (rom_offset + len > flashctx->chip->total_size * 1024)
|
||||
return 1;
|
||||
@ -206,6 +207,13 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash
|
||||
goto _free_ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ignore unreadable regions when trying to locate the FMAP, in order
|
||||
* to avoid a large amount of false-error prints to stderr. Unreadable
|
||||
* regions have already reported so errors here are redundant.
|
||||
*/
|
||||
flashctx->flags.skip_unreadable_regions = true;
|
||||
|
||||
/*
|
||||
* For efficient operation, we start with the largest stride possible
|
||||
* and then decrease the stride on each iteration. Also, check for a
|
||||
@ -264,6 +272,9 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash
|
||||
break;
|
||||
}
|
||||
|
||||
/* Restore original flag, since we're done searching */
|
||||
flashctx->flags.skip_unreadable_regions = skip_unreadable_orig;
|
||||
|
||||
if (!fmap_found)
|
||||
goto _free_ret;
|
||||
|
||||
|
Reference in New Issue
Block a user