summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/security/vboot/bootmode.c14
-rw-r--r--src/security/vboot/common.c74
-rw-r--r--src/security/vboot/misc.h34
-rw-r--r--src/security/vboot/vboot_crtm.c2
-rw-r--r--src/security/vboot/vboot_handoff.c2
-rw-r--r--src/security/vboot/vboot_loader.c8
-rw-r--r--src/security/vboot/vboot_logic.c6
7 files changed, 78 insertions, 62 deletions
diff --git a/src/security/vboot/bootmode.c b/src/security/vboot/bootmode.c
index fb1fc461b8..3fb693d4bc 100644
--- a/src/security/vboot/bootmode.c
+++ b/src/security/vboot/bootmode.c
@@ -23,23 +23,23 @@
#include <security/vboot/vbnv.h>
#include <security/vboot/vboot_common.h>
-static int vb2_get_recovery_reason_shared_data(void)
+static int vboot_get_recovery_reason_shared_data(void)
{
/* Shared data does not exist for Ramstage and Post-CAR stage. */
if (ENV_RAMSTAGE || ENV_POSTCAR)
return 0;
- struct vb2_shared_data *sd = vb2_get_shared_data();
+ struct vb2_shared_data *sd = vboot_get_shared_data();
assert(sd);
return sd->recovery_reason;
}
-void vb2_save_recovery_reason_vbnv(void)
+void vboot_save_recovery_reason_vbnv(void)
{
if (!CONFIG(VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT))
return;
- int reason = vb2_get_recovery_reason_shared_data();
+ int reason = vboot_get_recovery_reason_shared_data();
if (!reason)
return;
@@ -128,9 +128,9 @@ int vboot_check_recovery_request(void)
* verification is already complete and no slot was selected
* i.e. recovery path was requested.
*/
- if (vboot_possibly_executed() && vb2_logic_executed() &&
- !vb2_is_slot_selected())
- return vb2_get_recovery_reason_shared_data();
+ if (vboot_possibly_executed() && vboot_logic_executed() &&
+ !vboot_is_slot_selected())
+ return vboot_get_recovery_reason_shared_data();
return 0;
}
diff --git a/src/security/vboot/common.c b/src/security/vboot/common.c
index ade1b2c415..496ab782ab 100644
--- a/src/security/vboot/common.c
+++ b/src/security/vboot/common.c
@@ -36,7 +36,7 @@ struct selected_region {
* by the vboot2 core. Keep the struct CPU architecture agnostic as it crosses
* stage boundaries.
*/
-struct vb2_working_data {
+struct vboot_working_data {
struct selected_region selected_region;
/* offset of the buffer from the start of this struct */
uint32_t buffer_offset;
@@ -44,7 +44,7 @@ struct vb2_working_data {
};
/* TODO(kitching): Use VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE instead. */
-static size_t vb2_working_data_size(void)
+static size_t vboot_working_data_size(void)
{
if (CONFIG(VBOOT_STARTS_IN_ROMSTAGE))
return 12 * KiB;
@@ -56,64 +56,64 @@ static size_t vb2_working_data_size(void)
die("impossible!");
}
-static struct vb2_working_data * const vb2_get_working_data(void)
+static struct vboot_working_data * const vboot_get_working_data(void)
{
- struct vb2_working_data *wd = NULL;
+ struct vboot_working_data *wd = NULL;
if (cbmem_possibly_online())
wd = cbmem_find(CBMEM_ID_VBOOT_WORKBUF);
if (wd == NULL && CONFIG(VBOOT_STARTS_IN_BOOTBLOCK) &&
preram_symbols_available())
- wd = (struct vb2_working_data *)_vboot2_work;
+ wd = (struct vboot_working_data *)_vboot2_work;
assert(wd != NULL);
return wd;
}
-void vb2_init_work_context(struct vb2_context *ctx)
+void vboot_init_work_context(struct vb2_context *ctx)
{
- struct vb2_working_data *wd;
+ struct vboot_working_data *wd;
/* First initialize the working data struct. */
- wd = vb2_get_working_data();
- memset(wd, 0, sizeof(struct vb2_working_data));
+ wd = vboot_get_working_data();
+ memset(wd, 0, sizeof(struct vboot_working_data));
/*
* vboot prefers 16-byte alignment. This takes away 16 bytes
* from the VBOOT2_WORK region, but the vboot devs said that's okay.
*/
wd->buffer_offset = ALIGN_UP(sizeof(*wd), 16);
- wd->buffer_size = vb2_working_data_size() - wd->buffer_offset;
+ wd->buffer_size = vboot_working_data_size() - wd->buffer_offset;
/* Initialize the vb2_context. */
memset(ctx, 0, sizeof(*ctx));
- ctx->workbuf = (void *)vb2_get_shared_data();
+ ctx->workbuf = (void *)vboot_get_shared_data();
ctx->workbuf_size = wd->buffer_size;
}
-void vb2_finalize_work_context(struct vb2_context *ctx)
+void vboot_finalize_work_context(struct vb2_context *ctx)
{
/*
- * Shrink buffer_size so that vb2_migrate_cbmem knows how much
- * of vb2_working_data needs to be copied into CBMEM (if applicable),
- * and so that downstream users know how much of the workbuf is
- * currently used.
+ * Shrink buffer_size so that vboot_migrate_cbmem knows how
+ * much of vboot_working_data needs to be copied into CBMEM
+ * (if applicable), and so that downstream users know how much
+ * of the workbuf is currently used.
*/
- vb2_get_working_data()->buffer_size = ctx->workbuf_used;
+ vboot_get_working_data()->buffer_size = ctx->workbuf_used;
}
-struct vb2_shared_data *vb2_get_shared_data(void)
+struct vb2_shared_data *vboot_get_shared_data(void)
{
- struct vb2_working_data *wd = vb2_get_working_data();
+ struct vboot_working_data *wd = vboot_get_working_data();
return (void *)((uintptr_t)wd + wd->buffer_offset);
}
-int vb2_get_selected_region(struct region *region)
+int vboot_get_selected_region(struct region *region)
{
const struct selected_region *reg =
- &vb2_get_working_data()->selected_region;
+ &vboot_get_working_data()->selected_region;
if (reg == NULL)
return -1;
@@ -127,9 +127,10 @@ int vb2_get_selected_region(struct region *region)
return 0;
}
-void vb2_set_selected_region(const struct region *region)
+void vboot_set_selected_region(const struct region *region)
{
- struct selected_region *reg = &vb2_get_working_data()->selected_region;
+ struct selected_region *reg =
+ &vboot_get_working_data()->selected_region;
assert(reg != NULL);
@@ -137,9 +138,10 @@ void vb2_set_selected_region(const struct region *region)
reg->size = region_sz(region);
}
-int vb2_is_slot_selected(void)
+int vboot_is_slot_selected(void)
{
- struct selected_region *reg = &vb2_get_working_data()->selected_region;
+ struct selected_region *reg =
+ &vboot_get_working_data()->selected_region;
assert(reg != NULL);
@@ -151,29 +153,29 @@ int vb2_is_slot_selected(void)
* For platforms that do not employ VBOOT_STARTS_IN_ROMSTAGE, vboot
* verification occurs before CBMEM is brought online, using pre-RAM.
* In order to make vboot data structures available downstream, copy
- * vb2_working_data from SRAM/CAR into CBMEM on platforms where this
+ * vboot_working_data from SRAM/CAR into CBMEM on platforms where this
* memory later becomes unavailable.
*/
-static void vb2_migrate_cbmem(int unused)
+static void vboot_migrate_cbmem(int unused)
{
- const struct vb2_working_data *wd_preram =
- (struct vb2_working_data *)_vboot2_work;
+ const struct vboot_working_data *wd_preram =
+ (struct vboot_working_data *)_vboot2_work;
size_t cbmem_size = wd_preram->buffer_offset + wd_preram->buffer_size;
- struct vb2_working_data *wd_cbmem =
+ struct vboot_working_data *wd_cbmem =
cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size);
printk(BIOS_DEBUG,
- "VBOOT: copying vb2_working_data (%zu bytes) to CBMEM...\n",
+ "VBOOT: copying vboot_working_data (%zu bytes) to CBMEM...\n",
cbmem_size);
memcpy(wd_cbmem, wd_preram, cbmem_size);
assert(wd_cbmem != NULL);
}
-ROMSTAGE_CBMEM_INIT_HOOK(vb2_migrate_cbmem)
+ROMSTAGE_CBMEM_INIT_HOOK(vboot_migrate_cbmem)
#elif CONFIG(VBOOT_STARTS_IN_ROMSTAGE)
-static void vb2_setup_cbmem(int unused)
+static void vboot_setup_cbmem(int unused)
{
- struct vb2_working_data *wd_cbmem =
- cbmem_add(CBMEM_ID_VBOOT_WORKBUF, vb2_working_data_size());
+ struct vboot_working_data *wd_cbmem =
+ cbmem_add(CBMEM_ID_VBOOT_WORKBUF, vboot_working_data_size());
assert(wd_cbmem != NULL);
}
-ROMSTAGE_CBMEM_INIT_HOOK(vb2_setup_cbmem)
+ROMSTAGE_CBMEM_INIT_HOOK(vboot_setup_cbmem)
#endif
diff --git a/src/security/vboot/misc.h b/src/security/vboot/misc.h
index f1dff614c9..24e349d804 100644
--- a/src/security/vboot/misc.h
+++ b/src/security/vboot/misc.h
@@ -21,18 +21,32 @@
struct vb2_context;
struct vb2_shared_data;
-void vboot_fill_handoff(void);
-
-void vb2_init_work_context(struct vb2_context *ctx);
-void vb2_finalize_work_context(struct vb2_context *ctx);
-struct vb2_shared_data *vb2_get_shared_data(void);
+/*
+ * Source: security/vboot/common.c
+ */
+void vboot_init_work_context(struct vb2_context *ctx);
+void vboot_finalize_work_context(struct vb2_context *ctx);
+struct vb2_shared_data *vboot_get_shared_data(void);
/* Returns 0 on success. < 0 on failure. */
-int vb2_get_selected_region(struct region *region);
-void vb2_set_selected_region(const struct region *region);
-int vb2_is_slot_selected(void);
-int vb2_logic_executed(void);
+int vboot_get_selected_region(struct region *region);
+
+void vboot_set_selected_region(const struct region *region);
+int vboot_is_slot_selected(void);
+
+/*
+ * Source: security/vboot/vboot_handoff.c
+ */
+void vboot_fill_handoff(void);
-void vb2_save_recovery_reason_vbnv(void);
+/*
+ * Source: security/vboot/vboot_loader.c
+ */
+int vboot_logic_executed(void);
+
+/*
+ * Source: security/vboot/bootmode.c
+ */
+void vboot_save_recovery_reason_vbnv(void);
#endif /* __VBOOT_MISC_H__ */
diff --git a/src/security/vboot/vboot_crtm.c b/src/security/vboot/vboot_crtm.c
index 6aa5103f60..f4a6d7519f 100644
--- a/src/security/vboot/vboot_crtm.c
+++ b/src/security/vboot/vboot_crtm.c
@@ -162,7 +162,7 @@ uint32_t vboot_measure_cbfs_hook(struct cbfsf *fh, const char *name)
struct region_device rdev;
char tcpa_metadata[TCPA_PCR_HASH_NAME];
- if (!vb2_logic_executed())
+ if (!vboot_logic_executed())
return 0;
cbfsf_file_type(fh, &cbfs_type);
diff --git a/src/security/vboot/vboot_handoff.c b/src/security/vboot/vboot_handoff.c
index 2bb26a8974..e64775ea13 100644
--- a/src/security/vboot/vboot_handoff.c
+++ b/src/security/vboot/vboot_handoff.c
@@ -141,7 +141,7 @@ void vboot_fill_handoff(void)
struct vboot_handoff *vh;
struct vb2_shared_data *sd;
- sd = vb2_get_shared_data();
+ sd = vboot_get_shared_data();
sd->workbuf_hash_offset = 0;
sd->workbuf_hash_size = 0;
diff --git a/src/security/vboot/vboot_loader.c b/src/security/vboot/vboot_loader.c
index dd8c15c68f..e0facc10d7 100644
--- a/src/security/vboot/vboot_loader.c
+++ b/src/security/vboot/vboot_loader.c
@@ -63,7 +63,7 @@ static int verstage_should_load(void)
static int vboot_executed CAR_GLOBAL;
-int vb2_logic_executed(void)
+int vboot_logic_executed(void)
{
/* If we are in a stage that would load the verstage or execute the
vboot logic directly, we store the answer in a global. */
@@ -91,7 +91,7 @@ static void vboot_prepare(void)
/* Note: this path is not used for VBOOT_RETURN_FROM_VERSTAGE */
verstage_main();
car_set_var(vboot_executed, 1);
- vb2_save_recovery_reason_vbnv();
+ vboot_save_recovery_reason_vbnv();
} else if (verstage_should_load()) {
struct cbfsf file;
struct prog verstage =
@@ -138,10 +138,10 @@ static int vboot_locate(struct cbfs_props *props)
struct region selected_region;
/* Don't honor vboot results until the vboot logic has run. */
- if (!vb2_logic_executed())
+ if (!vboot_logic_executed())
return -1;
- if (vb2_get_selected_region(&selected_region))
+ if (vboot_get_selected_region(&selected_region))
return -1;
props->offset = region_offset(&selected_region);
diff --git a/src/security/vboot/vboot_logic.c b/src/security/vboot/vboot_logic.c
index d5bfa89191..0b5763bfe3 100644
--- a/src/security/vboot/vboot_logic.c
+++ b/src/security/vboot/vboot_logic.c
@@ -297,7 +297,7 @@ void verstage_main(void)
timestamp_add_now(TS_START_VBOOT);
/* Set up context and work buffer */
- vb2_init_work_context(&ctx);
+ vboot_init_work_context(&ctx);
/* Initialize and read nvdata from non-volatile storage. */
vbnv_init(ctx.nvdata);
@@ -437,7 +437,7 @@ void verstage_main(void)
}
printk(BIOS_INFO, "Slot %c is selected\n", is_slot_a(&ctx) ? 'A' : 'B');
- vb2_set_selected_region(region_device_region(&fw_main));
- vb2_finalize_work_context(&ctx);
+ vboot_set_selected_region(region_device_region(&fw_main));
+ vboot_finalize_work_context(&ctx);
timestamp_add_now(TS_END_VBOOT);
}