From cb376dfc4203ece3ecf39244affaca105aa08c3c Mon Sep 17 00:00:00 2001 From: Nikolai Artemiev Date: Fri, 14 Jan 2022 17:09:05 +1100 Subject: Revert "vboot_reference/futility: pipe log level though" This reverts commit 2821ee7afac6b1a5d7998246f3a8026e914ef2e7. 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 Change-Id: Ic7dd82ac70d9f7047dd6f30450f8bb4a69a6f96c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3388971 Reviewed-by: Edward O'Callaghan --- futility/updater_utils.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/futility/updater_utils.c b/futility/updater_utils.c index a20a026b..dec0dab9 100644 --- a/futility/updater_utils.c +++ b/futility/updater_utils.c @@ -609,25 +609,31 @@ static int host_flashrom(enum flashrom_ops op, const char *image_path, return r; } -// global to allow verbosity level to be injected into callback. -static enum flashrom_log_level g_verbose_screen = FLASHROM_MSG_INFO; - static int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap) { int ret = 0; - FILE *output_type = (level < FLASHROM_MSG_INFO) ? stderr : stdout; + enum flashrom_log_level verbose_screen = FLASHROM_MSG_INFO; + FILE *output_type = (level < verbose_screen) ? stderr : stdout; - if (level > g_verbose_screen) + if (level > verbose_screen) return ret; +#define COLOUR_RESET "\033[0;m" +#define MAGENTA_TEXT "\033[35;1m" + + if (level != FLASHROM_MSG_SPEW) + fprintf(output_type, MAGENTA_TEXT); + ret = vfprintf(output_type, fmt, ap); /* msg_*spew often happens inside chip accessors * in possibly time-critical operations. * Don't slow them down by flushing. */ - if (level != FLASHROM_MSG_SPEW) + if (level != FLASHROM_MSG_SPEW) { + fprintf(output_type, COLOUR_RESET); fflush(output_type); + } return ret; } @@ -770,7 +776,6 @@ int load_system_firmware(struct firmware_image *image, { int r; - g_verbose_screen = verbosity + 1; r = host_flashrom_read(image); if (!r) r = parse_firmware_image(image); @@ -788,7 +793,6 @@ int write_system_firmware(const struct firmware_image *image, struct tempfile *tempfiles, int verbosity) { - g_verbose_screen = verbosity + 1; return host_flashrom_write(image, section_name, diff_image); } -- cgit v1.2.1