diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-07-09 14:23:14 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-11 23:06:39 -0700 |
commit | 65d6c6abbc2093067486e3e080adb4f24fc19acb (patch) | |
tree | bbe07f5b5807d3577be5713204dca7f0cc2413c8 /common/flash.c | |
parent | 263a7ad89c702e6b34dfbe782e347a2d35178630 (diff) | |
download | chrome-ec-65d6c6abbc2093067486e3e080adb4f24fc19acb.tar.gz |
vboot: Don't invalidate cached hash for EXEC_IN_RAM boards
Currently, a cached hash is invalidated on flash erase or write. This
causes the hash to be (unintentionally) equal to the one expected by the
AP after flashrom updates EC-RW directly on EXEC_IN_RAM devices.
This patch makes EC skip invalidation of the cached hash if the board
supports EXEC_IN_RAM. At the next AP reboot, AP will catch the hash
mismatch and triggers software sync to resolve the mismatch.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b:78285812,b:80143039
BRANCH=none
TEST=Verify EC-RO/RW versions are updated on a dogfood Akali as follows:
1. emerge-nami chromeos-firmware-nami to build chromeos-firmwareupdate
2. Replace bios.bin and ec.bin in chromeos-firmwareupdate with new images
4. Run 'chromeos-firmwareupdate -m autoupdate' on DUT
5. Run reboot command on AP
Change-Id: Ie5f80e4784814569c14d4cf2a03ddb9d1257cfd5
Reviewed-on: https://chromium-review.googlesource.com/1130552
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/flash.c')
-rw-r--r-- | common/flash.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/common/flash.c b/common/flash.c index f52023dbb9..bc23636550 100644 --- a/common/flash.c +++ b/common/flash.c @@ -483,22 +483,35 @@ int flash_read(int offset, int size, char *data) #endif } +static void flash_abort_or_invalidate_hash(int offset, int size) +{ +#ifdef CONFIG_VBOOT_HASH + if (vboot_hash_in_progress()) { + /* Abort hash calculation when flash update is in progress. */ + vboot_hash_abort(); + return; + } + +#ifdef CONFIG_EXTERNAL_STORAGE + /* + * If EC executes in RAM, we keep the current hash. On the next + * hash check, AP will catch hash mismatch between the flash + * copy and the RAM copy, then take necessary actions. + */ + return; +#endif + + /* If EC executes in place, we need to invalidate the cached hash. */ + vboot_hash_invalidate(offset, size); +#endif +} + int flash_write(int offset, int size, const char *data) { if (!flash_range_ok(offset, size, CONFIG_FLASH_WRITE_SIZE)) return EC_ERROR_INVAL; /* Invalid range */ -#ifdef CONFIG_VBOOT_HASH - /* - * Abort hash calculations when flashrom flash updates - * are in progress.Otherwise invalidate the pre-computed hash, - * since it's likely to change after flash write - */ - if (vboot_hash_in_progress()) - vboot_hash_abort(); - else - vboot_hash_invalidate(offset, size); -#endif + flash_abort_or_invalidate_hash(offset, size); return flash_physical_write(offset, size, data); } @@ -510,17 +523,7 @@ int flash_erase(int offset, int size) return EC_ERROR_INVAL; /* Invalid range */ #endif -#ifdef CONFIG_VBOOT_HASH - /* - * Abort hash calculations when flashrom flash updates - * are in progress.Otherwise invalidate the pre-computed hash, - * since it's likely to be wrong after erase. - */ - if (vboot_hash_in_progress()) - vboot_hash_abort(); - else - vboot_hash_invalidate(offset, size); -#endif + flash_abort_or_invalidate_hash(offset, size); return flash_physical_erase(offset, size); } |