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/+/59381
to review the following change.
Change subject: amdfwtool: Check duplicated entry ......................................................................
amdfwtool: Check duplicated entry
Change-Id: I19c5c8e2acfcdac3a8dff0f1c1e3a9fe19220389 Signed-off-by: Zheng Bao fishbaozi@gmail.com --- M util/amdfwtool/amdfwtool.c 1 file changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/81/59381/1
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index ee360f0..3c012ca 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -337,6 +337,36 @@ { .type = AMD_BIOS_INVALID }, };
+bool check_duplicate_psp_entry(amd_fw_entry *table) +{ + amd_fw_entry *entry_i, *entry_j; + + for (entry_i = table; entry_i->type != AMD_FW_INVALID; entry_i ++) + for (entry_j = entry_i + 1; entry_j->type != AMD_FW_INVALID; entry_j ++) + if (entry_i->type == entry_j->type && + entry_i->subprog == entry_j->subprog) { + fprintf(stderr, "duplicated entries:type=%x, subprog=%x\n", + entry_i->type, entry_i->subprog); + return true; + } + return false; +} + +bool check_duplicate_bios_entry(amd_bios_entry *table) +{ + amd_bios_entry *entry_i, *entry_j; + + for (entry_i = table; entry_i->type != AMD_BIOS_INVALID; entry_i ++) + for (entry_j = entry_i + 1; entry_j->type != AMD_BIOS_INVALID; entry_j ++) + if (entry_i->type == entry_j->type && + entry_i->inst == entry_j->inst && + entry_i->subpr == entry_j->subpr) { + fprintf(stderr, "duplicated entries:type=%x, inst=%x, subprog=%x\n", + entry_i->type, entry_i->inst, entry_i->subpr); + return true; + } + return false; +}
#define MAX_BIOS_ENTRIES 0x2f
@@ -1501,6 +1531,9 @@ } /* For debug. */ if (debug) { + if (check_duplicate_psp_entry(amd_psp_fw_table) || + check_duplicate_bios_entry(amd_bios_table)) + return 1; dump_psp_firmwares(amd_psp_fw_table); dump_bdt_firmwares(amd_bios_table); }