Martin Roth has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46112 )
Change subject: soc/amd/picasso: Refactor workbuf check into separate function ......................................................................
soc/amd/picasso: Refactor workbuf check into separate function
BUG=None TEST=Build Branch=Zork
Signed-off-by: Martin Roth martinroth@chromium.org Change-Id: Idf46f8edb6b70c63f623522e2bcd2f22d6d4790b --- M src/soc/amd/picasso/bootblock/bootblock.c 1 file changed, 29 insertions(+), 19 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/46112/1
diff --git a/src/soc/amd/picasso/bootblock/bootblock.c b/src/soc/amd/picasso/bootblock/bootblock.c index 316396d..1626c55 100644 --- a/src/soc/amd/picasso/bootblock/bootblock.c +++ b/src/soc/amd/picasso/bootblock/bootblock.c @@ -113,6 +113,33 @@ wrmsr(S3_RESUME_EIP_MSR, s3_resume_entry); }
+#if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) +static void verify_workbuf(void) +{ + if (*(uint32_t *)_vboot2_work == VB2_SHARED_DATA_MAGIC) { + cmos_write(0x00, CMOS_RECOVERY_BYTE); + return; + } + + /* + * If CMOS is valid and the system has already been rebooted once, but + * still returns here, instead of rebooting to verstage again, assume + * that the system is in a reboot loop and halt. + */ + if (cmos_read(RTC_CLK_ALTCENTURY) != 0xff && + cmos_read(CMOS_RECOVERY_BYTE) == CMOS_RECOVERY_MAGIC_VAL) + die("Error: Reboot into recovery was unsuccessful. Halting."); + + printk(BIOS_ERR, "ERROR: VBOOT workbuf not valid.\n"); + printk(BIOS_DEBUG, "Signature: %#08x\n", *(uint32_t *)_vboot2_work); + cmos_init(0); + cmos_write(CMOS_RECOVERY_MAGIC_VAL, CMOS_RECOVERY_BYTE); + warm_reset(); +} +#else +static void verify_workbuf(void) {} +#endif + asmlinkage void bootblock_c_entry(uint64_t base_timestamp) { set_caching(); @@ -132,26 +159,9 @@ u32 val = cpuid_eax(1); printk(BIOS_DEBUG, "Family_Model: %08x\n", val);
-#if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) - if (*(uint32_t *)_vboot2_work != VB2_SHARED_DATA_MAGIC) { - /* - * If the system has already been rebooted once, but still returns here, - * instead of rebooting to verstage again, assume that the system is in - * a reboot loop and halt. - */ - if (cmos_read(RTC_CLK_ALTCENTURY) != 0xff && - cmos_read(CMOS_RECOVERY_BYTE) == CMOS_RECOVERY_MAGIC_VAL) - die("Error: Reboot into recovery was unsuccessful. Halting."); - - printk(BIOS_ERR, "ERROR: VBOOT workbuf not valid.\n"); - printk(BIOS_DEBUG, "Signature: %#08x\n", *(uint32_t *)_vboot2_work); - cmos_init(0); - cmos_write(CMOS_RECOVERY_MAGIC_VAL, CMOS_RECOVERY_BYTE); - warm_reset(); - } else { - cmos_write(0x00, CMOS_RECOVERY_BYTE); + if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { + verify_workbuf(); } -#endif
fch_early_init(); }