Keith Short has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32770
Change subject: coreboot: add post code for failure to load next stage ......................................................................
coreboot: add post code for failure to load next stage
Add a new post code, POST_INVALID_ROM, used when coreboot fails to locate or validate a resource that is stored in ROM.
BUG=b:124401932 BRANCH=sarien TEST=build coreboot for sarien and arcada platforms
Change-Id: Ie6de6590595d8fcdc57ad156237fffa03d5ead38 Signed-off-by: Keith Short keithshort@chromium.org --- M src/arch/x86/postcar_loader.c M src/include/console/post_codes.h M src/lib/prog_loaders.c M src/security/vboot/vboot_logic.c 4 files changed, 25 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/70/32770/1
diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c index d62487e..9975931 100644 --- a/src/arch/x86/postcar_loader.c +++ b/src/arch/x86/postcar_loader.c @@ -140,14 +140,20 @@ .prog = prog, };
- if (prog_locate(prog)) + if (prog_locate(prog)) { + post_code(POST_INVALID_ROM); die("Failed to locate after CAR program.\n"); - if (rmodule_stage_load(&rsl)) + } + if (rmodule_stage_load(&rsl)) { + post_code(POST_INVALID_ROM); die("Failed to load after CAR program.\n"); + }
/* Set the stack pointer within parameters of the program loaded. */ - if (rsl.params == NULL) + if (rsl.params == NULL) { + post_code(POST_INVALID_ROM); die("No parameters found in after CAR program.\n"); + }
finalize_load(rsl.params, pcf->stack);
diff --git a/src/include/console/post_codes.h b/src/include/console/post_codes.h index f482ae9..89a65ca 100644 --- a/src/include/console/post_codes.h +++ b/src/include/console/post_codes.h @@ -319,6 +319,13 @@ #define POST_JUMPING_TO_PAYLOAD 0xf3
/** + * \brief Invalid or corrupt ROM + * + * Set if firmware failed to find or validate a resource that is stored in ROM. + */ +#define POST_INVALID_ROM 0xE0 + +/** * \brief TPM failure * * An error with the TPM, either unexepcted state or communications failure. diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index 3b77712..16eb746 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -68,8 +68,10 @@ prog_run(&romstage);
fail: - if (CONFIG(BOOTBLOCK_CONSOLE)) + if (CONFIG(BOOTBLOCK_CONSOLE)) { + post_code(POST_INVALID_ROM); die("Couldn't load romstage.\n"); + } halt(); }
diff --git a/src/security/vboot/vboot_logic.c b/src/security/vboot/vboot_logic.c index df34490..c61dfa9 100644 --- a/src/security/vboot/vboot_logic.c +++ b/src/security/vboot/vboot_logic.c @@ -319,8 +319,10 @@ /* Enable measured boot mode */ if (CONFIG(VBOOT_MEASURED_BOOT) && !(ctx.flags & VB2_CONTEXT_S3_RESUME)) { - if (vboot_init_crtm() != VB2_SUCCESS) + if (vboot_init_crtm() != VB2_SUCCESS) { + post_code(POST_INVALID_ROM); die("Initializing measured boot mode failed!"); + } }
if (get_recovery_mode_switch()) { @@ -391,8 +393,10 @@
printk(BIOS_INFO, "Phase 4\n"); rv = locate_firmware(&ctx, &fw_main); - if (rv) + if (rv) { + post_code(POST_INVALID_ROM); die("Failed to read FMAP to locate firmware"); + }
rv = hash_body(&ctx, &fw_main); save_if_needed(&ctx);