diff options
author | Jeremy Compostella <jeremy.compostella@intel.com> | 2022-09-08 10:11:53 -0700 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-09-15 13:01:42 +0000 |
commit | e1465e21570dc4344c25371fc213dcd01a807b25 (patch) | |
tree | 12a9590dd40f129b80e685d7b80ed1a652a9e007 /util/cbfstool | |
parent | 2c021383c0ab847c927e8e964c3f55dd4d6deb0c (diff) | |
download | coreboot-e1465e21570dc4344c25371fc213dcd01a807b25.tar.gz |
util/ifittool: Error out if microcodes do not fit the FIT table
parse_microcode_blob() returns success when it reaches max_fit_entries
microcode. It makes the FIT table size verification in
fit_add_microcode_file() useless. This patch makes
parse_microcode_blob() error out if max_fit_entries is reached.
Note that this size verification is critical as a FIT table only
partially listing the microcode patches can lead to boot failures as
recently observed on Raptor Lake-P.
BRANCH=firmware-brya-14505.B
BUG=b:245380705
TEST=compilation errors out when trying to stitch more than
CONFIG_CPU_INTEL_NUM_FIT_ENTRIES microcode patches.
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Change-Id: Id9c5fb6c1e264f3f5137d29201b9021c72d78fde
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67454
Reviewed-by: Selma Bensaid <selma.bensaid@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Zhixing Ma <zhixing.ma@intel.com>
Diffstat (limited to 'util/cbfstool')
-rw-r--r-- | util/cbfstool/fit.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/util/cbfstool/fit.c b/util/cbfstool/fit.c index 7f8218a745..8ed24943b8 100644 --- a/util/cbfstool/fit.c +++ b/util/cbfstool/fit.c @@ -275,8 +275,10 @@ parse_microcode_blob(struct cbfs_image *image, struct cbfs_file *mcode_file; mcode_file = cbfs_get_entry(image, blob_name); - if (!mcode_file) + if (!mcode_file) { + ERROR("Couldn't find microcode blob.\n"); return 1; + } fit_location_from_cbfs_header(¤t_offset, &file_length, mcode_file); @@ -301,6 +303,11 @@ parse_microcode_blob(struct cbfs_image *image, total_size > file_length) break; + if (num_mcus == max_fit_entries) { + ERROR("Maximum of FIT entries reached.\n"); + return 1; + } + /* FIXME: Should the checksum be validated? */ mcus[num_mcus].offset = current_offset; mcus[num_mcus].size = total_size; @@ -309,9 +316,6 @@ parse_microcode_blob(struct cbfs_image *image, current_offset += mcus[num_mcus].size; file_length -= mcus[num_mcus].size; num_mcus++; - /* Reached limit of FIT entries. */ - if (num_mcus == max_fit_entries) - break; if (file_length < sizeof(struct microcode_header)) break; } @@ -492,13 +496,6 @@ int fit_add_microcode_file(struct fit_table *fit, if (parse_microcode_blob(image, blob_name, &mcus_found, mcus, max_fit_entries)) { - ERROR("Couldn't parse microcode blob.\n"); - free(mcus); - return 1; - } - - if (mcus_found > fit_free_space(fit, max_fit_entries)) { - ERROR("Maximum of FIT entries reached.\n"); free(mcus); return 1; } |