security/vboot: Remove selected_region from struct vboot_working_data
Since we already have pre-RAM cache for FMAP (CB:36657), calling
load_firmware() multiple times is no longer a problem. This patch
replaces vboot_get_selected_region() usage with vboot_locate_firmware(),
which locates the firmware by reading from the CBMEM cache.
In addition, returning false from vboot_is_slot_selected() implies the
recovery path was requested, i.e., vb2_shared_data.recovery_reason was
set. Therefore, we simply remove the vboot_is_slot_selected() check from
vboot_check_recovery_request().
BRANCH=none
BUG=chromium:1021452
TEST=emerge-kukui coreboot
Change-Id: I27cb1a2175beb189053fc3e44b17b60aba474bb0
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36845
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/src/security/vboot/vboot_logic.c b/src/security/vboot/vboot_logic.c
index 71371cd..6ee4d94 100644
--- a/src/security/vboot/vboot_logic.c
+++ b/src/security/vboot/vboot_logic.c
@@ -35,11 +35,6 @@
#define TODO_BLOCK_SIZE 1024
-static int is_slot_a(struct vb2_context *ctx)
-{
- return !(ctx->flags & VB2_CONTEXT_FW_SLOT_B);
-}
-
/* exports */
void vb2ex_printf(const char *func, const char *fmt, ...)
@@ -70,7 +65,7 @@
name = "GBB";
break;
case VB2_RES_FW_VBLOCK:
- if (is_slot_a(ctx))
+ if (vboot_is_firmware_slot_a(ctx))
name = "VBLOCK_A";
else
name = "VBLOCK_B";
@@ -256,19 +251,6 @@
return VB2_SUCCESS;
}
-static int locate_firmware(struct vb2_context *ctx,
- struct region_device *fw_main)
-{
- const char *name;
-
- if (is_slot_a(ctx))
- name = "FW_MAIN_A";
- else
- name = "FW_MAIN_B";
-
- return fmap_locate_area_as_rdev(name, fw_main);
-}
-
/**
* Save non-volatile and/or secure data if needed.
*/
@@ -417,7 +399,7 @@
}
printk(BIOS_INFO, "Phase 4\n");
- rv = locate_firmware(ctx, &fw_main);
+ rv = vboot_locate_firmware(ctx, &fw_main);
if (rv)
die_with_post_code(POST_INVALID_ROM,
"Failed to read FMAP to locate firmware");
@@ -468,8 +450,8 @@
}
}
- printk(BIOS_INFO, "Slot %c is selected\n", is_slot_a(ctx) ? 'A' : 'B');
- vboot_set_selected_region(region_device_region(&fw_main));
+ printk(BIOS_INFO, "Slot %c is selected\n",
+ vboot_is_firmware_slot_a(ctx) ? 'A' : 'B');
verstage_main_exit:
/* If CBMEM is not up yet, let the ROMSTAGE_CBMEM_INIT_HOOK take care