post_code: 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>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/32770
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
Keith Short 2019-05-06 16:12:57 -06:00 committed by Duncan Laurie
parent ba44a27f7f
commit 7006458777
5 changed files with 24 additions and 9 deletions

View File

@ -16,6 +16,7 @@ This is an (incomplete) list of POST codes emitted by coreboot v4.
0x66 Devices have been enumerated 0x66 Devices have been enumerated
0x88 Devices have been configured 0x88 Devices have been configured
0x89 Devices have been enabled 0x89 Devices have been enabled
0xe0 Boot media (e.g. SPI ROM) is corrupt
0xf8 Entry into elf boot 0xf8 Entry into elf boot
0xf3 Jumping to payload 0xf3 Jumping to payload

View File

@ -141,13 +141,16 @@ static void load_postcar_cbfs(struct prog *prog, struct postcar_frame *pcf)
}; };
if (prog_locate(prog)) if (prog_locate(prog))
die("Failed to locate after CAR program.\n"); die_with_post_code(POST_INVALID_ROM,
"Failed to locate after CAR program.\n");
if (rmodule_stage_load(&rsl)) if (rmodule_stage_load(&rsl))
die("Failed to load after CAR program.\n"); die_with_post_code(POST_INVALID_ROM,
"Failed to load after CAR program.\n");
/* Set the stack pointer within parameters of the program loaded. */ /* Set the stack pointer within parameters of the program loaded. */
if (rsl.params == NULL) if (rsl.params == NULL)
die("No parameters found in after CAR program.\n"); die_with_post_code(POST_INVALID_ROM,
"No parameters found in after CAR program.\n");
finalize_load(rsl.params, pcf->stack); finalize_load(rsl.params, pcf->stack);

View File

@ -318,6 +318,13 @@
*/ */
#define POST_JUMPING_TO_PAYLOAD 0xf3 #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 * \brief TPM failure
* *

View File

@ -69,7 +69,8 @@ void run_romstage(void)
fail: fail:
if (CONFIG(BOOTBLOCK_CONSOLE)) if (CONFIG(BOOTBLOCK_CONSOLE))
die("Couldn't load romstage.\n"); die_with_post_code(POST_INVALID_ROM,
"Couldn't load romstage.\n");
halt(); halt();
} }
@ -162,7 +163,7 @@ void run_ramstage(void)
prog_run(&ramstage); prog_run(&ramstage);
fail: fail:
die("Ramstage was not loaded!\n"); die_with_post_code(POST_INVALID_ROM, "Ramstage was not loaded!\n");
} }
#ifdef __RAMSTAGE__ // gc-sections should take care of this #ifdef __RAMSTAGE__ // gc-sections should take care of this
@ -195,13 +196,14 @@ void payload_load(void)
break; break;
} /* else fall-through */ } /* else fall-through */
default: default:
die("Unsupported payload type.\n"); die_with_post_code(POST_INVALID_ROM,
"Unsupported payload type.\n");
break; break;
} }
out: out:
if (prog_entry(payload) == NULL) if (prog_entry(payload) == NULL)
die("Payload not loaded.\n"); die_with_post_code(POST_INVALID_ROM, "Payload not loaded.\n");
} }
void payload_run(void) void payload_run(void)

View File

@ -320,7 +320,8 @@ void verstage_main(void)
if (CONFIG(VBOOT_MEASURED_BOOT) && if (CONFIG(VBOOT_MEASURED_BOOT) &&
!(ctx.flags & VB2_CONTEXT_S3_RESUME)) { !(ctx.flags & VB2_CONTEXT_S3_RESUME)) {
if (vboot_init_crtm() != VB2_SUCCESS) if (vboot_init_crtm() != VB2_SUCCESS)
die("Initializing measured boot mode failed!"); die_with_post_code(POST_INVALID_ROM,
"Initializing measured boot mode failed!");
} }
if (get_recovery_mode_switch()) { if (get_recovery_mode_switch()) {
@ -395,7 +396,8 @@ void verstage_main(void)
printk(BIOS_INFO, "Phase 4\n"); printk(BIOS_INFO, "Phase 4\n");
rv = locate_firmware(&ctx, &fw_main); rv = locate_firmware(&ctx, &fw_main);
if (rv) if (rv)
die("Failed to read FMAP to locate firmware"); die_with_post_code(POST_INVALID_ROM,
"Failed to read FMAP to locate firmware");
rv = hash_body(&ctx, &fw_main); rv = hash_body(&ctx, &fw_main);
save_if_needed(&ctx); save_if_needed(&ctx);