vboot: Fix reboot loop in recovery with VBOOT_CBFS_INTEGRATION

After first recovery request coreboot would get stuck in bootloop with
VB2_RECOVERY_PREAMBLE as recovery reason due to not checking whether
coreboot is alread in recovery mode, and calling failing code.

Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Change-Id: Idc947a1d150ff6487cf973b36bf4f0af41daa220
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73091
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
This commit is contained in:
Jakub Czapiga 2023-02-17 17:08:17 +01:00 committed by Eric Lai
parent 03fbf06ffd
commit 5f9dafe5ff
1 changed files with 6 additions and 6 deletions

View File

@ -31,6 +31,12 @@ static void after_verstage(void)
struct vb2_hash *metadata_hash = NULL; struct vb2_hash *metadata_hash = NULL;
struct vb2_context *ctx = NULL; struct vb2_context *ctx = NULL;
vboot_executed = 1; /* Mark verstage execution complete. */
const struct cbfs_boot_device *cbd = vboot_get_cbfs_boot_device();
if (!cbd) /* Can't initialize RW CBFS in recovery mode. */
return;
if (CONFIG(VBOOT_CBFS_INTEGRATION)) { if (CONFIG(VBOOT_CBFS_INTEGRATION)) {
ctx = vboot_get_context(); ctx = vboot_get_context();
vb2_error_t rv = vb2api_get_metadata_hash(ctx, &metadata_hash); vb2_error_t rv = vb2api_get_metadata_hash(ctx, &metadata_hash);
@ -38,12 +44,6 @@ static void after_verstage(void)
vboot_fail_and_reboot(ctx, VB2_RECOVERY_FW_PREAMBLE, rv); vboot_fail_and_reboot(ctx, VB2_RECOVERY_FW_PREAMBLE, rv);
} }
vboot_executed = 1; /* Mark verstage execution complete. */
const struct cbfs_boot_device *cbd = vboot_get_cbfs_boot_device();
if (!cbd) /* Can't initialize RW CBFS in recovery mode. */
return;
enum cb_err err = cbfs_init_boot_device(cbd, metadata_hash); enum cb_err err = cbfs_init_boot_device(cbd, metadata_hash);
if (err && err != CB_CBFS_CACHE_FULL) { if (err && err != CB_CBFS_CACHE_FULL) {
if (CONFIG(VBOOT_CBFS_INTEGRATION)) { if (CONFIG(VBOOT_CBFS_INTEGRATION)) {