This should be called after every time the FMAP or the bootblock itself might have changed, and will write the new FMAP hash into the metadata hash anchor in the bootblock if required (usually when the bootblock is first added). */
| 307 | have changed, and will write the new FMAP hash into the metadata hash anchor |
| 308 | in the bootblock if required (usually when the bootblock is first added). */ |
| 309 | static int maybe_update_fmap_hash(void) |
| 310 | { |
| 311 | if (strcmp(param.region_name, SECTION_NAME_BOOTBLOCK) && |
| 312 | strcmp(param.region_name, SECTION_NAME_BOOTBLOCK_B) && |
| 313 | strcmp(param.region_name, SECTION_NAME_FMAP) && |
| 314 | param.type != CBFS_TYPE_BOOTBLOCK && |
| 315 | param.type != CBFS_TYPE_AMDFW) |
| 316 | return 0; /* FMAP and bootblock didn't change. */ |
| 317 | |
| 318 | struct mh_cache *mhc = get_mh_cache(); |
| 319 | if (mhc->cbfs_hash.algo == VB2_HASH_INVALID) |
| 320 | return 0; |
| 321 | |
| 322 | struct vb2_hash fmap_hash; |
| 323 | const struct fmap *fmap = partitioned_file_get_fmap(param.image_file); |
| 324 | if (!fmap || vb2_hash_calculate(false, fmap, fmap_size(fmap), |
| 325 | mhc->cbfs_hash.algo, &fmap_hash)) |
| 326 | return -1; |
| 327 | return update_anchor(mhc, fmap_hash.raw); |
| 328 | } |
| 329 | |
| 330 | static bool verification_exclude(enum cbfs_type type) |
| 331 | { |
no test coverage detected