security/vboot: Drop CAR_GLOBAL_MIGRATION support
Change-Id: I9dee03da028b9111b685e325368815a86e444a47 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37028 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
7255610d9f
commit
344e86bb3b
|
@ -25,7 +25,7 @@
|
|||
#include <security/vboot/symbols.h>
|
||||
#include <security/vboot/vboot_common.h>
|
||||
|
||||
static struct vb2_context *vboot_ctx CAR_GLOBAL;
|
||||
static struct vb2_context *vboot_ctx;
|
||||
|
||||
struct vboot_working_data *vboot_get_working_data(void)
|
||||
{
|
||||
|
@ -50,20 +50,19 @@ static inline void *vboot_get_workbuf(struct vboot_working_data *wd)
|
|||
|
||||
struct vb2_context *vboot_get_context(void)
|
||||
{
|
||||
struct vb2_context **vboot_ctx_ptr = car_get_var_ptr(&vboot_ctx);
|
||||
struct vboot_working_data *wd;
|
||||
|
||||
/* Return if context has already been initialized/restored. */
|
||||
if (*vboot_ctx_ptr)
|
||||
return *vboot_ctx_ptr;
|
||||
if (vboot_ctx)
|
||||
return vboot_ctx;
|
||||
|
||||
wd = vboot_get_working_data();
|
||||
|
||||
/* Restore context from a previous stage. */
|
||||
if (vboot_logic_executed()) {
|
||||
assert(vb2api_reinit(vboot_get_workbuf(wd),
|
||||
vboot_ctx_ptr) == VB2_SUCCESS);
|
||||
return *vboot_ctx_ptr;
|
||||
&vboot_ctx) == VB2_SUCCESS);
|
||||
return vboot_ctx;
|
||||
}
|
||||
|
||||
assert(verification_should_run());
|
||||
|
@ -78,10 +77,10 @@ struct vb2_context *vboot_get_context(void)
|
|||
/* Initialize vb2_shared_data and friends. */
|
||||
assert(vb2api_init(vboot_get_workbuf(wd),
|
||||
VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE -
|
||||
wd->buffer_offset,
|
||||
vboot_ctx_ptr) == VB2_SUCCESS);
|
||||
wd->buffer_offset,
|
||||
&vboot_ctx) == VB2_SUCCESS);
|
||||
|
||||
return *vboot_ctx_ptr;
|
||||
return vboot_ctx;
|
||||
}
|
||||
|
||||
int vboot_locate_firmware(const struct vb2_context *ctx,
|
||||
|
@ -116,7 +115,7 @@ static void vboot_migrate_cbmem(int unused)
|
|||
vb2api_relocate(vboot_get_workbuf(wd_cbmem),
|
||||
vboot_get_workbuf(wd_preram),
|
||||
cbmem_size - wd_cbmem->buffer_offset,
|
||||
car_get_var_ptr(&vboot_ctx));
|
||||
&vboot_ctx);
|
||||
}
|
||||
ROMSTAGE_CBMEM_INIT_HOOK(vboot_migrate_cbmem)
|
||||
#else
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define __VBOOT_MISC_H__
|
||||
|
||||
#include <assert.h>
|
||||
#include <arch/early_variables.h>
|
||||
#include <security/vboot/vboot_common.h>
|
||||
|
||||
struct vb2_context;
|
||||
|
@ -112,7 +111,7 @@ static inline int vboot_logic_executed(void)
|
|||
need to check a global to see if verfication has run. */
|
||||
if (verification_should_run() ||
|
||||
(verstage_should_load() && CONFIG(VBOOT_RETURN_FROM_VERSTAGE)))
|
||||
return car_get_var(vboot_executed);
|
||||
return vboot_executed;
|
||||
|
||||
if (CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)) {
|
||||
/* All other stages are "after the bootblock" */
|
||||
|
|
|
@ -13,32 +13,13 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <arch/early_variables.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include <security/vboot/vbnv.h>
|
||||
#include <security/vboot/vbnv_layout.h>
|
||||
|
||||
static int vbnv_initialized CAR_GLOBAL;
|
||||
static uint8_t vbnv[VBOOT_VBNV_BLOCK_SIZE] CAR_GLOBAL;
|
||||
|
||||
/* Wrappers for accessing the variables marked as CAR_GLOBAL. */
|
||||
static inline int is_vbnv_initialized(void)
|
||||
{
|
||||
return car_get_var(vbnv_initialized);
|
||||
}
|
||||
|
||||
static inline uint8_t *vbnv_data_addr(int index)
|
||||
{
|
||||
uint8_t *vbnv_arr = car_get_var_ptr(vbnv);
|
||||
|
||||
return &vbnv_arr[index];
|
||||
}
|
||||
|
||||
static inline uint8_t vbnv_data(int index)
|
||||
{
|
||||
return *vbnv_data_addr(index);
|
||||
}
|
||||
static int vbnv_initialized;
|
||||
static uint8_t vbnv[VBOOT_VBNV_BLOCK_SIZE];
|
||||
|
||||
/* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. */
|
||||
static uint8_t crc8_vbnv(const uint8_t *data, int len)
|
||||
|
@ -66,9 +47,9 @@ void vbnv_reset(uint8_t *vbnv_copy)
|
|||
/* Read VBNV data into cache. */
|
||||
static void vbnv_setup(void)
|
||||
{
|
||||
if (!is_vbnv_initialized()) {
|
||||
read_vbnv(vbnv_data_addr(0));
|
||||
car_set_var(vbnv_initialized, 1);
|
||||
if (!vbnv_initialized) {
|
||||
read_vbnv(vbnv);
|
||||
vbnv_initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +98,7 @@ void save_vbnv(const uint8_t *vbnv_copy)
|
|||
save_vbnv_flash(vbnv_copy);
|
||||
|
||||
/* Clear initialized flag to force cached data to be updated */
|
||||
car_set_var(vbnv_initialized, 0);
|
||||
vbnv_initialized = 0;
|
||||
}
|
||||
|
||||
/* Save a recovery reason into VBNV. */
|
||||
|
@ -137,14 +118,14 @@ void set_recovery_mode_into_vbnv(int recovery_reason)
|
|||
int get_recovery_mode_from_vbnv(void)
|
||||
{
|
||||
vbnv_setup();
|
||||
return vbnv_data(RECOVERY_OFFSET);
|
||||
return vbnv[RECOVERY_OFFSET];
|
||||
}
|
||||
|
||||
/* Read the USB Device Controller(UDC) enable flag from VBNV. */
|
||||
int vbnv_udc_enable_flag(void)
|
||||
{
|
||||
vbnv_setup();
|
||||
return (vbnv_data(DEV_FLAGS_OFFSET) & DEV_ENABLE_UDC) ? 1 : 0;
|
||||
return (vbnv[DEV_FLAGS_OFFSET] & DEV_ENABLE_UDC) ? 1 : 0;
|
||||
}
|
||||
|
||||
void vbnv_init(uint8_t *vbnv_copy)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <arch/early_variables.h>
|
||||
#include <commonlib/region.h>
|
||||
#include <console/console.h>
|
||||
#include <fmap.h>
|
||||
|
@ -41,7 +40,7 @@ struct vbnv_flash_ctx {
|
|||
/* Cache of the current nvdata */
|
||||
uint8_t cache[BLOB_SIZE];
|
||||
};
|
||||
static struct vbnv_flash_ctx vbnv_flash CAR_GLOBAL;
|
||||
static struct vbnv_flash_ctx vbnv_flash;
|
||||
|
||||
/*
|
||||
* This code assumes that flash is erased to 1-bits, and write operations can
|
||||
|
@ -60,7 +59,7 @@ static inline int can_overwrite(uint8_t current, uint8_t new)
|
|||
|
||||
static int init_vbnv(void)
|
||||
{
|
||||
struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash);
|
||||
struct vbnv_flash_ctx *ctx = &vbnv_flash;
|
||||
struct region_device *rdev = &ctx->vbnv_dev;
|
||||
uint8_t buf[BLOB_SIZE];
|
||||
uint8_t empty_blob[BLOB_SIZE];
|
||||
|
@ -116,7 +115,7 @@ static int init_vbnv(void)
|
|||
|
||||
static int erase_nvram(void)
|
||||
{
|
||||
struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash);
|
||||
struct vbnv_flash_ctx *ctx = &vbnv_flash;
|
||||
const struct region_device *rdev = &ctx->vbnv_dev;
|
||||
|
||||
if (rdev_eraseat(rdev, 0, region_device_sz(rdev)) < 0) {
|
||||
|
@ -130,7 +129,7 @@ static int erase_nvram(void)
|
|||
|
||||
void read_vbnv_flash(uint8_t *vbnv_copy)
|
||||
{
|
||||
struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash);
|
||||
struct vbnv_flash_ctx *ctx = &vbnv_flash;
|
||||
|
||||
if (!ctx->initialized)
|
||||
if (init_vbnv())
|
||||
|
@ -141,7 +140,7 @@ void read_vbnv_flash(uint8_t *vbnv_copy)
|
|||
|
||||
void save_vbnv_flash(const uint8_t *vbnv_copy)
|
||||
{
|
||||
struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash);
|
||||
struct vbnv_flash_ctx *ctx = &vbnv_flash;
|
||||
int new_offset;
|
||||
int i;
|
||||
const struct region_device *rdev = &ctx->vbnv_dev;
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <arch/early_variables.h>
|
||||
#include <boot_device.h>
|
||||
#include <cbfs.h>
|
||||
#include <console/console.h>
|
||||
#include <ec/google/chromeec/ec.h>
|
||||
|
@ -34,14 +32,14 @@ _Static_assert(!CONFIG(VBOOT_RETURN_FROM_VERSTAGE) ||
|
|||
CONFIG(VBOOT_SEPARATE_VERSTAGE),
|
||||
"return from verstage only makes sense for separate verstages");
|
||||
|
||||
int vboot_executed CAR_GLOBAL;
|
||||
int vboot_executed;
|
||||
|
||||
void vboot_run_logic(void)
|
||||
{
|
||||
if (verification_should_run()) {
|
||||
/* Note: this path is not used for VBOOT_RETURN_FROM_VERSTAGE */
|
||||
verstage_main();
|
||||
car_set_var(vboot_executed, 1);
|
||||
vboot_executed = 1;
|
||||
} else if (verstage_should_load()) {
|
||||
struct cbfsf file;
|
||||
struct prog verstage =
|
||||
|
@ -68,7 +66,7 @@ void vboot_run_logic(void)
|
|||
if (!CONFIG(VBOOT_RETURN_FROM_VERSTAGE))
|
||||
return;
|
||||
|
||||
car_set_var(vboot_executed, 1);
|
||||
vboot_executed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue