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>
diff --git a/src/security/vboot/vboot_loader.c b/src/security/vboot/vboot_loader.c
index 7cda690..70e6685 100644
--- a/src/security/vboot/vboot_loader.c
+++ b/src/security/vboot/vboot_loader.c
@@ -31,6 +31,12 @@
struct vb2_hash *metadata_hash = 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)) {
ctx = vboot_get_context();
vb2_error_t rv = vb2api_get_metadata_hash(ctx, &metadata_hash);
@@ -38,12 +44,6 @@
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);
if (err && err != CB_CBFS_CACHE_FULL) {
if (CONFIG(VBOOT_CBFS_INTEGRATION)) {