From c705d6376c04451840697d7b7e97c42a5c1befb8 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Tue, 14 Feb 2023 19:21:17 +1100 Subject: host/lib/flashrom_drv.c: Move flag to avoid locked ME issue Older Intel DUT's have a ME in "locked" mode in the descriptor and while the write_flash() attempts to write back to flash to a specific region it needs to read the FMAP to obtain the region name. This read overlaps with the "locked" region and thus the following is observed in logs: ``` FREG2: Management Engine region (0x00001000-0x001fffff) is locked. [..] read_flash: cannot read inside Management Engine region (0x001000..0x1fffff). ``` BUG=b:269199980 TEST=builds. Change-Id: If7bebf28cd4d34cc4074700184233c83edbd2409 Signed-off-by: Edward O'Callaghan Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4248344 Auto-Submit: Edward O'Callaghan Reviewed-by: Sam McNally Reviewed-by: Hung-Te Lin Tested-by: Edward O'Callaghan Commit-Queue: Edward O'Callaghan --- host/lib/flashrom_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/host/lib/flashrom_drv.c b/host/lib/flashrom_drv.c index 6f0057aa..d30d1dec 100644 --- a/host/lib/flashrom_drv.c +++ b/host/lib/flashrom_drv.c @@ -184,6 +184,9 @@ int flashrom_write_image(const struct firmware_image *image, } } + /* Must occur before attempting to read FMAP from SPI flash. */ + flashrom_flag_set(flashctx, FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS, true); + if (regions) { int i; r = flashrom_layout_read_fmap_from_buffer( @@ -216,7 +219,6 @@ int flashrom_write_image(const struct firmware_image *image, goto err_cleanup; } - flashrom_flag_set(flashctx, FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS, true); flashrom_flag_set(flashctx, FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS, true); flashrom_flag_set(flashctx, FLASHROM_FLAG_VERIFY_WHOLE_CHIP, false); flashrom_flag_set(flashctx, FLASHROM_FLAG_VERIFY_AFTER_WRITE, -- cgit v1.2.1