From 481fede513cf43e8bdd145614cd04dd2b2566e17 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 21 Nov 2016 11:05:18 -0800 Subject: [PATCH] g: do not consider valid headers with the 'magic' field corrupted When cr50 rollback happens, the newer header's magic field is set to zero to prevent it from ever running again. Take this into consideration when displaying versions of the inactive RW image. BRANCH=none BUG=none TEST=loaded two versions of the new code on a cr50 and then modified the fallback counter to force it to boot the older version and reboot a Reef. Once Reef fully boots to chrome os examine CR50 version report: Before: > vers ... RW_A: 0.0.9/DEV/cr50_v1.1.5654-2228b76+ RW_B: * 0.0.11/DEV/cr50_v1.1.5654-2228b76+ ... After: > vers ... RW_A: * 0.0.9/DEV/cr50_v1.1.5654-2228b76+ RW_B: Error Change-Id: I2a9ee13117a0bc91710226cd733c5c484c6d0595 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/413089 Reviewed-by: Bill Richardson --- chip/g/system.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chip/g/system.c b/chip/g/system.c index 4945aee082..61129984d4 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -260,7 +260,8 @@ const char *system_get_version(enum system_image_copy_t copy) * the version string. */ if (v->cookie1 == version_data.cookie1 && - v->cookie2 == version_data.cookie2) { + v->cookie2 == version_data.cookie2 && + h->magic) { /* Corrupted header's magic is set to zero. */ snprintf(vers_str, sizeof(vers_str), "%d.%d.%d/%s", h->epoch_, h->major_, h->minor_, v->version); return vers_str;