Joel Kitching has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31886
Change subject: vboot: rename symbols for better consistency ......................................................................
vboot: rename symbols for better consistency
Symbols prefixed with vb2_ should be reserved for internal vboot library use.
Anything outside of that may choose some other prefix. Here, we choose vboot_ instead.
Also, add some documentation to security/vboot/misc.h, which provides headers for a number of different C files.
BUG=b:124141368 TEST=Build and deploy to eve TEST=util/lint/checkpatch.pl -g origin/master..HEAD TEST=util/abuild/abuild -B -e -y -c 50 -p none -x TEST=make clean && make test-abuild BRANCH=none
Change-Id: I5d9154fd2d5df25ee254bd5ce4a173afaa6588be Signed-off-by: Joel Kitching kitching@google.com --- M src/security/vboot/bootmode.c M src/security/vboot/common.c M src/security/vboot/misc.h M src/security/vboot/vboot_handoff.c M src/security/vboot/vboot_loader.c M src/security/vboot/vboot_logic.c 6 files changed, 77 insertions(+), 61 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/31886/1
diff --git a/src/security/vboot/bootmode.c b/src/security/vboot/bootmode.c index fb1fc46..3fb693d 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 @@ * 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 ade1b2c..496ab78 100644 --- a/src/security/vboot/common.c +++ b/src/security/vboot/common.c @@ -36,7 +36,7 @@ * 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 @@ };
/* 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 @@ 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 @@ 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 @@ 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 @@ * 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 f1dff61..24e349d 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 vb2_save_recovery_reason_vbnv(void); +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); + +/* + * 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_handoff.c b/src/security/vboot/vboot_handoff.c index 2bb26a8..e64775e 100644 --- a/src/security/vboot/vboot_handoff.c +++ b/src/security/vboot/vboot_handoff.c @@ -141,7 +141,7 @@ 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 dd8c15c..e0facc1 100644 --- a/src/security/vboot/vboot_loader.c +++ b/src/security/vboot/vboot_loader.c @@ -63,7 +63,7 @@
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 @@ /* 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 @@ 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 d5bfa89..0b5763b 100644 --- a/src/security/vboot/vboot_logic.c +++ b/src/security/vboot/vboot_logic.c @@ -297,7 +297,7 @@ 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 @@ }
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); }
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31886 )
Change subject: vboot: rename symbols for better consistency ......................................................................
Patch Set 1: Code-Review+2
LGTM but you need to rebase.
Hello Randall Spangler, Aaron Durbin, Simon Glass, Julius Werner, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/31886
to look at the new patch set (#2).
Change subject: vboot: rename symbols for better consistency ......................................................................
vboot: rename symbols for better consistency
Symbols prefixed with vb2_ should be reserved for internal vboot library use.
Anything outside of that may choose some other prefix. Here, we choose vboot_ instead.
Also, add some documentation to security/vboot/misc.h, which provides headers for a number of different C files.
BUG=b:124141368 TEST=Build and deploy to eve TEST=util/lint/checkpatch.pl -g origin/master..HEAD TEST=util/abuild/abuild -B -e -y -c 50 -p none -x TEST=make clean && make test-abuild BRANCH=none
Change-Id: I5d9154fd2d5df25ee254bd5ce4a173afaa6588be Signed-off-by: Joel Kitching kitching@google.com --- M src/security/vboot/bootmode.c M src/security/vboot/common.c M src/security/vboot/misc.h M src/security/vboot/vboot_crtm.c M src/security/vboot/vboot_handoff.c M src/security/vboot/vboot_loader.c M src/security/vboot/vboot_logic.c 7 files changed, 78 insertions(+), 62 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/31886/2
Joel Kitching has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31886 )
Change subject: vboot: rename symbols for better consistency ......................................................................
Patch Set 2: Code-Review+1
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31886 )
Change subject: vboot: rename symbols for better consistency ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/31886 )
Change subject: vboot: rename symbols for better consistency ......................................................................
vboot: rename symbols for better consistency
Symbols prefixed with vb2_ should be reserved for internal vboot library use.
Anything outside of that may choose some other prefix. Here, we choose vboot_ instead.
Also, add some documentation to security/vboot/misc.h, which provides headers for a number of different C files.
BUG=b:124141368 TEST=Build and deploy to eve TEST=util/lint/checkpatch.pl -g origin/master..HEAD TEST=util/abuild/abuild -B -e -y -c 50 -p none -x TEST=make clean && make test-abuild BRANCH=none
Change-Id: I5d9154fd2d5df25ee254bd5ce4a173afaa6588be Signed-off-by: Joel Kitching kitching@google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/31886 Reviewed-by: Julius Werner jwerner@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/security/vboot/bootmode.c M src/security/vboot/common.c M src/security/vboot/misc.h M src/security/vboot/vboot_crtm.c M src/security/vboot/vboot_handoff.c M src/security/vboot/vboot_loader.c M src/security/vboot/vboot_logic.c 7 files changed, 78 insertions(+), 62 deletions(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved Joel Kitching: Looks good to me, but someone else must approve
diff --git a/src/security/vboot/bootmode.c b/src/security/vboot/bootmode.c index fb1fc46..3fb693d 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 @@ * 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 ade1b2c..496ab78 100644 --- a/src/security/vboot/common.c +++ b/src/security/vboot/common.c @@ -36,7 +36,7 @@ * 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 @@ };
/* 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 @@ 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 @@ 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 @@ 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 @@ * 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 f1dff61..24e349d 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 vb2_save_recovery_reason_vbnv(void); +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); + +/* + * 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 6aa5103..f4a6d75 100644 --- a/src/security/vboot/vboot_crtm.c +++ b/src/security/vboot/vboot_crtm.c @@ -162,7 +162,7 @@ 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 2bb26a8..e64775e 100644 --- a/src/security/vboot/vboot_handoff.c +++ b/src/security/vboot/vboot_handoff.c @@ -141,7 +141,7 @@ 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 dd8c15c..e0facc1 100644 --- a/src/security/vboot/vboot_loader.c +++ b/src/security/vboot/vboot_loader.c @@ -63,7 +63,7 @@
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 @@ /* 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 @@ 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 d5bfa89..0b5763b 100644 --- a/src/security/vboot/vboot_logic.c +++ b/src/security/vboot/vboot_logic.c @@ -297,7 +297,7 @@ 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 @@ }
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); }