diff options
author | Keith Short <keithshort@chromium.org> | 2021-03-08 16:26:41 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-09 21:27:38 +0000 |
commit | 0e5fa530e2f1eba6e16188be65ac39974a151a17 (patch) | |
tree | 1a5d694dc7527072837d713782763345d805dbd0 /common/vboot_hash.c | |
parent | 4d5b07d43ba15f5f704722649def0c18ea967871 (diff) | |
download | chrome-ec-0e5fa530e2f1eba6e16188be65ac39974a151a17.tar.gz |
vboot_hash: Add watchdog reloads
When neither CONFIG_SHA256_HW_ACCELERATE nor CONFIG_SHA256_UNROLLED
are enabled, calculating the hash can trip the watchdog.
Add watchdog reloads at a rate of 1/2 the watchdog period when both
these options are disabled.
BUG=b:182208446
BRANCH=none
TEST=zmake testall
TEST=Boot zephyr-ec on Volteer, powerdown AP and observe watchdog
timeouts are fixed
Signed-off-by: Keith Short <keithshort@chromium.org>
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I6170b457c91f3247adf9ad47cd7e93b128a1d13b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2744356
Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'common/vboot_hash.c')
-rw-r--r-- | common/vboot_hash.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/vboot_hash.c b/common/vboot_hash.c index 04e3ae5f7f..9a6b9c196b 100644 --- a/common/vboot_hash.c +++ b/common/vboot_hash.c @@ -127,10 +127,27 @@ static void hash_next_chunk(size_t size) static void vboot_hash_all_chunks(void) { + uint64_t prev_watchdog; + + if (IS_ENABLED(CONFIG_VBOOT_HASH_RELOAD_WATCHDOG)) { + prev_watchdog = get_time().val; + watchdog_reload(); + } + do { size_t size = MIN(CHUNK_SIZE, data_size - curr_pos); hash_next_chunk(size); curr_pos += size; + + if (IS_ENABLED(CONFIG_VBOOT_HASH_RELOAD_WATCHDOG)) { + uint64_t cur_time = get_time().val; + + if ((cur_time - prev_watchdog) > + (CONFIG_WATCHDOG_PERIOD_MS * 1000 / 2)) { + watchdog_reload(); + prev_watchdog = cur_time; + } + } } while (curr_pos < data_size); hash = SHA256_final(&ctx); |