diff options
-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; |