From 07cae3f8e1f7e8b53c8b60752d4e7d519ff01a74 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Wed, 19 Sep 2012 14:22:58 -0700 Subject: EC recalculates RW code hash after all sysjumps This solves the problem where the AP updates EC-RW as part of software sync, then tells the EC to jump to EC-RW. On the next boot the EC still returned the saved old RW hash, causing a needless cold boot. This change is backwards/forwards compatible; existing RO code will simply save a hash new RW code won't look at, and existing RW code already knows to recompute the hash if the RO code didn't save it. Hash computation is done in the background and takes ~350ms, so this should have no noticeable effect on performance. BUG=chrome-os-partner:13511 BRANCH=all (not needed for FSI, since RW code with this change will do the right thing with existing RO code) TEST=at the EC console, "sysjump RW" and look at the EC debug log for "hash done". Change-Id: Ie5255727b9d896b7c4e4f537e91d831682afc7f6 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/33634 Reviewed-by: Tom Wai-Hong Tam Reviewed-by: Simon Glass --- common/vboot_hash.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/vboot_hash.c b/common/vboot_hash.c index c80c174588..ed011aee05 100644 --- a/common/vboot_hash.c +++ b/common/vboot_hash.c @@ -80,7 +80,6 @@ static int vboot_hash_start(uint32_t offset, uint32_t size, return EC_SUCCESS; } - /* Abort hash currently in progress, if any. */ static void vboot_hash_abort(void) { @@ -88,9 +87,9 @@ static void vboot_hash_abort(void) want_abort = 1; } - static void vboot_hash_init(void) { +#ifdef CONFIG_SAVE_VBOOT_HASH const struct vboot_hash_tag *tag; int version, size; @@ -103,15 +102,16 @@ static void vboot_hash_init(void) hash = tag->hash; data_offset = tag->offset; data_size = tag->size; - } else { - /* Start computing the hash of firmware A */ + } else +#endif + { + /* Start computing the hash of RW firmware */ vboot_hash_start(CONFIG_FW_RW_OFF, system_get_image_used(SYSTEM_IMAGE_RW), NULL, 0); } } - void vboot_hash_task(void) { vboot_hash_init(); @@ -154,6 +154,8 @@ void vboot_hash_task(void) /*****************************************************************************/ /* Hooks */ +#ifdef CONFIG_SAVE_VBOOT_HASH + static int vboot_hash_preserve_state(void) { struct vboot_hash_tag tag; @@ -172,6 +174,8 @@ static int vboot_hash_preserve_state(void) } DECLARE_HOOK(HOOK_SYSJUMP, vboot_hash_preserve_state, HOOK_PRIO_DEFAULT); +#endif + /****************************************************************************/ /* Console commands */ -- cgit v1.2.1