From 0822ce8b08aa96c74a3d1a0d6b717c019924e8c3 Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Mon, 5 Dec 2022 14:54:53 -0700 Subject: [PATCH] soc/amd/common/psp_verstage: Report previous boot status Add support to report previous PSP boot failure to verified boot. This is required specifically on mainboards where the signed AMDFW blobs are excluded from vboot verification. BUG=b:242825052 TEST=Build Skyrim BIOS image and boot to OS in Skyrim. Corrupt either one of SIGNED_AMDFW_A/B sections or both the sections to ensure that the appropriate FW slot is chosen. Cq-Depend: chromium:4064425 Change-Id: Iada0ec7c373db75765ba42cb531b16c2236b6cc3 Signed-off-by: Karthikeyan Ramasubramanian Reviewed-on: https://review.coreboot.org/c/coreboot/+/70382 Reviewed-by: Yu-Ping Wu Reviewed-by: Raul Rangel Tested-by: build bot (Jenkins) --- .../amd/common/psp_verstage/psp_verstage.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/soc/amd/common/psp_verstage/psp_verstage.c b/src/soc/amd/common/psp_verstage/psp_verstage.c index 4e2832444e..969c1c0863 100644 --- a/src/soc/amd/common/psp_verstage/psp_verstage.c +++ b/src/soc/amd/common/psp_verstage/psp_verstage.c @@ -3,6 +3,7 @@ #include "psp_verstage.h" #include +#include #include #include #include @@ -136,6 +137,25 @@ static uint32_t update_boot_region(struct vb2_context *ctx) return 0; } +static void report_prev_boot_status_to_vboot(void) +{ + uint32_t boot_status = 0; + int ret; + struct vb2_context *ctx = vboot_get_context(); + + /* Already in recovery mode. No need to report previous boot status. */ + if (ctx->flags & VB2_CONTEXT_RECOVERY_MODE) + return; + + ret = svc_get_prev_boot_status(&boot_status); + if (ret != BL_OK || boot_status) { + printk(BIOS_ERR, "PSPFW failure in previous boot: %d:%#8x\n", ret, boot_status); + vbnv_init(); + vb2api_previous_boot_fail(ctx, VB2_RECOVERY_FW_VENDOR_BLOB, + boot_status ? (int)boot_status : ret); + } +} + /* * Save workbuf (and soon memory console and timestamps) to the bootloader to pass * back to coreboot. @@ -288,6 +308,8 @@ void Main(void) verstage_mainboard_init(); post_code(POSTCODE_VERSTAGE_MAIN); + if (CONFIG(SEPARATE_SIGNED_PSPFW)) + report_prev_boot_status_to_vboot(); vboot_run_logic();