Attention is currently required from: Zheng Bao.
Hello Zheng Bao,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/85468?usp=email
to review the following change.
Change subject: cbfstool: Add hash to more than one region ......................................................................
cbfstool: Add hash to more than one region
Change-Id: I8f9a5baa2699468380b942b3bdc104cab78adf5f Signed-off-by: Zheng Bao fishbaozi@gmail.com --- M util/cbfstool/cbfstool.c 1 file changed, 11 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/85468/1
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 25f4847..a8650fd 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -162,10 +162,16 @@ } else { struct cbfs_image cbfs; struct cbfs_file *mh_container; + const char *current_region; + if (strcmp(param.region_name, "COREBOOTB") == 0) + current_region = "COREBOOTB"; + else + current_region = SECTION_NAME_PRIMARY_CBFS; + if (!partitioned_file_read_region(&buffer, param.image_file, - SECTION_NAME_PRIMARY_CBFS)) + current_region)) goto no_metadata_hash; - mhc.region = SECTION_NAME_PRIMARY_CBFS; + mhc.region = current_region; if (cbfs_image_from_buffer(&cbfs, &buffer, param.headeroffset)) goto no_metadata_hash; mh_container = cbfs_get_entry(&cbfs, "bootblock"); @@ -245,7 +251,8 @@ will recalculate and update the metadata hash in the bootblock if needed. */ static int maybe_update_metadata_hash(struct cbfs_image *cbfs) { - if (strcmp(param.region_name, SECTION_NAME_PRIMARY_CBFS)) + if (strcmp(param.region_name, SECTION_NAME_PRIMARY_CBFS) && + strcmp(param.region_name, "COREBOOTB")) return 0; /* Metadata hash only embedded in primary CBFS. */
struct mh_cache *mhc = get_mh_cache(); @@ -1601,7 +1608,7 @@ vb2_digest_size(real_hash.algo)); printf("[METADATA HASH]\t%s:%s", vb2_get_hash_algorithm_name(real_hash.algo), hash_str); - if (!strcmp(param.region_name, SECTION_NAME_PRIMARY_CBFS)) { + if (mhc->cbfs_hash.algo != VB2_HASH_INVALID) { if (!memcmp(mhc->cbfs_hash.raw, real_hash.raw, vb2_digest_size(real_hash.algo))) { printf(":valid");