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 <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/413089
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
Vadim Bendebury
2016-11-21 11:05:18 -08:00
committed by chrome-bot
parent 242d298584
commit 481fede513

View File

@@ -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;