diff options
author | Nikolai Artemiev <nartemiev@google.com> | 2022-01-14 17:09:15 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-18 22:50:48 +0000 |
commit | 4445b42c8d3d9c924e1a0d3326499eb6f7e93955 (patch) | |
tree | 65bd71646eebe5e378634f159c6c0c4edd42ed0e | |
parent | cb376dfc4203ece3ecf39244affaca105aa08c3c (diff) | |
download | vboot-4445b42c8d3d9c924e1a0d3326499eb6f7e93955.tar.gz |
Revert "vboot_reference/futility: Port R path to using libflashrom"
This reverts commit 0cd8ad2c330ee40beb54c2ce3def4ba6ea84fa3c.
Changing the write path in futility to use libflashrom had the side
effect of skipping the code in cli_classic that created a powerd lock
file. This could result in powerd suspending during a firmware update,
corrupting the RW firmware.
Revert back to subprocessing flashrom for M98.
BUG=b:214485250
BRANCH=release-R98-14388.B
TEST=emerge-grunt vboot_reference
TEST=flashed grunt DUT with R98-14388.30.0 test image, deployed \
vboot_reference with reverts
TEST=ran `futility --force -i image.bin`, monitored processes \
with `ps -ef | grep flashrom` verified that flashrom ran as \
a separate process for read/wp-status/write ops
TEST=verified /run/lock/power_override/flashrom.lock was created \
during update
TEST=ran `futility --force -i image.bin --wp=0`, verified only RW \
sections A/B were written
TEST=ran `futility --force -i image.bin`, waited for write to start, \
sent restart msg with: `dbus-send --type=method_call --system \
--dest=org.chromium.PowerManager /org/chromium/PowerManager \
org.chromium.PowerManager.RequestRestart`, verified restart was \
deferred until firmware write finished
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Change-Id: I3909e218258853a99753f38e27ca1b1b4fe54964
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3388972
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r-- | futility/updater_utils.c | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/futility/updater_utils.c b/futility/updater_utils.c index dec0dab9..3c7b3730 100644 --- a/futility/updater_utils.c +++ b/futility/updater_utils.c @@ -27,6 +27,7 @@ #define FLASHROM_OUTPUT_WP_PATTERN "write protect is " enum flashrom_ops { + FLASHROM_READ, FLASHROM_WP_STATUS, }; @@ -561,6 +562,11 @@ static int host_flashrom(enum flashrom_ops op, const char *image_path, } switch (op) { + case FLASHROM_READ: + op_cmd = "-r"; + assert(image_path); + break; + case FLASHROM_WP_STATUS: op_cmd = "--wp-status"; assert(image_path == NULL); @@ -646,37 +652,6 @@ static char *flashrom_extract_params(const char *str, char **prog, char **params return tmp; } -static int host_flashrom_read(struct firmware_image *image) -{ - int r = 0; - size_t len = 0; - - char *programmer, *params; - char *tmp = flashrom_extract_params(image->programmer, &programmer, ¶ms); - - struct flashrom_programmer *prog = NULL; - struct flashrom_flashctx *flashctx = NULL; - - flashrom_set_log_callback((flashrom_log_callback *)&flashrom_print_cb); - - r |= flashrom_init(1); - r |= flashrom_programmer_init(&prog, programmer, params); - r |= flashrom_flash_probe(&flashctx, prog, NULL); - - len = flashrom_flash_getsize(flashctx); - image->data = calloc(1, len); - image->size = len; - image->file_name = strdup("<none>"); - - r |= flashrom_image_read(flashctx, image->data, len); - - r |= flashrom_programmer_shutdown(prog); - flashrom_flash_release(flashctx); - free(tmp); - - return r; -} - static int host_flashrom_write(const struct firmware_image *image, const char *region, const struct firmware_image *diff_image) @@ -775,10 +750,26 @@ int load_system_firmware(struct firmware_image *image, struct tempfile *tempfiles, int verbosity) { int r; + const char *tmp_path = create_temp_file(tempfiles); + + if (!tmp_path) + return -1; - r = host_flashrom_read(image); + r = host_flashrom(FLASHROM_READ, tmp_path, image->programmer, + verbosity, NULL, NULL); + /* + * The verbosity for host_flashrom will be translated to + * (verbosity-1)*'-V', and usually 3*'-V' is enough for debugging. + */ + const int debug_verbosity = 4; + if (r && verbosity < debug_verbosity) { + /* Read again, with verbose messages for debugging. */ + WARN("Failed reading system firmware (%d), try again...\n", r); + r = host_flashrom(FLASHROM_READ, tmp_path, image->programmer, + debug_verbosity, NULL, NULL); + } if (!r) - r = parse_firmware_image(image); + r = load_firmware_image(image, tmp_path, NULL); return r; } |