diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-07-09 14:23:14 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-07-12 20:05:47 +0000 |
commit | 82185d64ee6d4115f19a5eee700b187ddf4eebfe (patch) | |
tree | d6aaa1215c203da3d0db59d2d97011a08185a5fe | |
parent | 6c20727c6fb4c429db633156b9832297ce3698a4 (diff) | |
download | chrome-ec-82185d64ee6d4115f19a5eee700b187ddf4eebfe.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>
(cherry picked from commit 65d6c6abbc2093067486e3e080adb4f24fc19acb)
Reviewed-on: https://chromium-review.googlesource.com/1135228
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-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 6746f178ef..8ae2be47e3 100644 --- a/common/flash.c +++ b/common/flash.c @@ -481,22 +481,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); } @@ -508,17 +521,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); } |