diff options
author | Hung-Te Lin <hungte@chromium.org> | 2022-01-26 10:28:42 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-26 11:49:44 +0000 |
commit | ec240b9688b5240ff9e76baa62b83db3a427ddda (patch) | |
tree | f4a6ef57fc5517d51037a11cecbd76d60bbc92db | |
parent | 78bb610cc96862d5fb55acf8ef4c6c3e99843649 (diff) | |
download | vboot-ec240b9688b5240ff9e76baa62b83db3a427ddda.tar.gz |
futility: updater: allow changing GBB flags on erased flash
The --gbb_flags supports changing GBB flags but the value will be
ignored if the device flash was erased (e.g., no valid GBB section).
To fix that we should check the 'to' and 'from' flash contents
separately when preserving GBB data.
BUG=b:216295706
TEST=build; emerge test
BRANCH=None
Change-Id: Ie02138dd4234b461ca1913bef1cabde8becf57c9
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3414190
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
-rw-r--r-- | futility/updater.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/futility/updater.c b/futility/updater.c index 9a98adea..d58ea399 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -484,19 +484,27 @@ static int preserve_gbb(const struct firmware_image *image_from, const struct vb2_gbb_header *gbb_from; struct vb2_gbb_header *gbb_to; - gbb_from = find_gbb(image_from); - /* We do want to change GBB contents later. */ + /* Cast to non-const because we do want to change GBB contents later. */ gbb_to = (struct vb2_gbb_header *)find_gbb(image_to); - if (!gbb_from || !gbb_to) + /* + * For all cases, we need a valid gbb_to. Note for 'override GBB flags + * on a erased device', we only need gbb_to, not gbb_from. + */ + if (!gbb_to) return -1; + gbb_from = find_gbb(image_from); + /* Preserve (for non-factory mode) or override flags. */ if (override_flags) gbb_to->flags = override_value; - else if (preserve_flags) + else if (preserve_flags && gbb_from) gbb_to->flags = gbb_from->flags; + if (!gbb_from) + return -1; + /* Preserve HWID. */ return futil_set_gbb_hwid( gbb_to, (const char *)gbb_from + gbb_from->hwid_offset); |