diff options
author | Mary Ruthven <mruthven@chromium.org> | 2015-12-11 10:36:00 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-01-05 23:39:09 -0800 |
commit | c3ce180fb06e4d5097e9fd262ff54fa701df3cd3 (patch) | |
tree | 4aa26426131be50f0bf7fb745670c42ab4663a2f | |
parent | 7b3032b1c7b73d5543c979f945ae330d1d33709a (diff) | |
download | chrome-ec-c3ce180fb06e4d5097e9fd262ff54fa701df3cd3.tar.gz |
vboot_hash: check the current hash is for the right region
With the RO region being added to software sync, up to two hashes will
be requested during boot. Currently if vboot_hash has a valid hash when
the EC gets an EC_VBOOT_HASH_GET host command then it will return that
hash. When the EC gets a request for the RO hash after it has calculated
the RW hash it returns the RW hash in the response.
This change will add a check that the EC not only has a valid hash, but
that it is for the correct region.
BRANCH=none
BUG=none
TEST=Try to get the RO and RW hashes from depthcharge and make sure they
match the values gotten using ectool
Change-Id: I2449c8d79b4a74f4865dd1234fb253bcdac66a31
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/318861
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/vboot_hash.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/common/vboot_hash.c b/common/vboot_hash.c index 42d1a0f11c..30eaec661a 100644 --- a/common/vboot_hash.c +++ b/common/vboot_hash.c @@ -326,12 +326,27 @@ DECLARE_CONSOLE_COMMAND(hash, command_hash, /****************************************************************************/ /* Host commands */ +/** + * Return the offset of the RO or RW region if the either region is specifically + * requested otherwise return the current hash offset. + */ +static int get_offset(int offset) +{ + if (offset == EC_VBOOT_HASH_OFFSET_RO) + return CONFIG_EC_PROTECTED_STORAGE_OFF + CONFIG_RO_STORAGE_OFF; + if (offset == EC_VBOOT_HASH_OFFSET_RW) + return CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF; + return data_offset; +} + /* Fill in the response with the current hash status */ -static void fill_response(struct ec_response_vboot_hash *r) +static void fill_response(struct ec_response_vboot_hash *r, + int request_offset) { if (in_progress) r->status = EC_VBOOT_HASH_STATUS_BUSY; - else if (hash && !want_abort) { + else if (get_offset(request_offset) == data_offset && hash && + !want_abort) { r->status = EC_VBOOT_HASH_STATUS_DONE; r->hash_type = EC_VBOOT_HASH_TYPE_SHA256; r->digest_size = SHA256_DIGEST_SIZE; @@ -389,7 +404,7 @@ static int host_command_vboot_hash(struct host_cmd_handler_args *args) switch (p->cmd) { case EC_VBOOT_HASH_GET: - fill_response(r); + fill_response(r, p->offset); args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -408,7 +423,7 @@ static int host_command_vboot_hash(struct host_cmd_handler_args *args) while (in_progress) usleep(1000); - fill_response(r); + fill_response(r, p->offset); args->response_size = sizeof(*r); return EC_RES_SUCCESS; |