vboot: make vboot workbuf available to payload

Create a new cbtable entry called VBOOT_WORKBUF for
storing a pointer to the vboot workbuf within the
vboot_working_data structure.

BUG=b:124141368, b:124192753
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
BRANCH=none

Change-Id: Id68f43c282939d9e1b419e927a14fe8baa290d91
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31887
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Joel Kitching 2019-03-13 18:10:52 +08:00 committed by Patrick Georgi
parent 55fb6b4d0d
commit 8d0f59935d
7 changed files with 57 additions and 27 deletions

View File

@ -202,6 +202,7 @@ struct cb_gpios {
#define CB_TAG_VBNV 0x0019 #define CB_TAG_VBNV 0x0019
#define CB_TAG_VBOOT_HANDOFF 0x0020 #define CB_TAG_VBOOT_HANDOFF 0x0020
#define CB_TAG_VBOOT_WORKBUF 0x0034
#define CB_TAG_DMA 0x0022 #define CB_TAG_DMA 0x0022
#define CB_TAG_RAM_OOPS 0x0023 #define CB_TAG_RAM_OOPS 0x0023
#define CB_TAG_MTC 0x002b #define CB_TAG_MTC 0x002b

View File

@ -97,6 +97,8 @@ struct sysinfo_t {
void *vboot_handoff; void *vboot_handoff;
u32 vboot_handoff_size; u32 vboot_handoff_size;
void *vboot_workbuf;
uint32_t vboot_workbuf_size;
#if CONFIG(LP_ARCH_X86) #if CONFIG(LP_ARCH_X86)
int x86_rom_var_mtrr_index; int x86_rom_var_mtrr_index;

View File

@ -86,6 +86,14 @@ static void cb_parse_vboot_handoff(unsigned char *ptr, struct sysinfo_t *info)
info->vboot_handoff_size = vbho->range_size; info->vboot_handoff_size = vbho->range_size;
} }
static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info)
{
struct lb_range *vbwb = (struct lb_range *)ptr;
info->vboot_workbuf = (void *)(uintptr_t)vbwb->range_start;
info->vboot_workbuf_size = vbwb->range_size;
}
static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info) static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
{ {
struct lb_range *vbnv = (struct lb_range *)ptr; struct lb_range *vbnv = (struct lb_range *)ptr;
@ -355,6 +363,9 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
case CB_TAG_VBOOT_HANDOFF: case CB_TAG_VBOOT_HANDOFF:
cb_parse_vboot_handoff(ptr, info); cb_parse_vboot_handoff(ptr, info);
break; break;
case CB_TAG_VBOOT_WORKBUF:
cb_parse_vboot_workbuf(ptr, info);
break;
case CB_TAG_MAC_ADDRS: case CB_TAG_MAC_ADDRS:
cb_parse_mac_addresses(ptr, info); cb_parse_mac_addresses(ptr, info);
break; break;

View File

@ -292,6 +292,7 @@ struct lb_gpios {
#define LB_TAG_VBNV 0x0019 #define LB_TAG_VBNV 0x0019
#define LB_TAB_VBOOT_HANDOFF 0x0020 #define LB_TAB_VBOOT_HANDOFF 0x0020
#define LB_TAB_VBOOT_WORKBUF 0x0034
#define LB_TAB_DMA 0x0022 #define LB_TAB_DMA 0x0022
#define LB_TAG_RAM_OOPS 0x0023 #define LB_TAG_RAM_OOPS 0x0023
#define LB_TAG_MTC 0x002b #define LB_TAG_MTC 0x002b

View File

@ -32,6 +32,7 @@
#include <cbmem.h> #include <cbmem.h>
#include <bootmem.h> #include <bootmem.h>
#include <spi_flash.h> #include <spi_flash.h>
#include <security/vboot/misc.h>
#include <security/vboot/vbnv_layout.h> #include <security/vboot/vbnv_layout.h>
#if CONFIG(USE_OPTION_TABLE) #if CONFIG(USE_OPTION_TABLE)
#include <option_table.h> #include <option_table.h>
@ -206,8 +207,8 @@ static void lb_vbnv(struct lb_header *header)
vbnv->range_size = VBOOT_VBNV_BLOCK_SIZE; vbnv->range_size = VBOOT_VBNV_BLOCK_SIZE;
#endif #endif
} }
#endif /* CONFIG_CHROMEOS */
#if CONFIG(VBOOT)
static void lb_vboot_handoff(struct lb_header *header) static void lb_vboot_handoff(struct lb_header *header)
{ {
void *addr; void *addr;
@ -223,10 +224,18 @@ static void lb_vboot_handoff(struct lb_header *header)
vbho->range_start = (intptr_t)addr; vbho->range_start = (intptr_t)addr;
vbho->range_size = size; vbho->range_size = size;
} }
#else
static inline void lb_vboot_handoff(struct lb_header *header) {} static void lb_vboot_workbuf(struct lb_header *header)
#endif /* CONFIG_VBOOT */ {
#endif /* CONFIG_CHROMEOS */ struct lb_range *vbwb;
struct vboot_working_data *wd = vboot_get_working_data();
vbwb = (struct lb_range *)lb_new_record(header);
vbwb->tag = LB_TAB_VBOOT_WORKBUF;
vbwb->size = sizeof(*vbwb);
vbwb->range_start = (uintptr_t)wd + wd->buffer_offset;
vbwb->range_size = wd->buffer_size;
}
__weak uint32_t board_id(void) { return UNDEFINED_STRAPPING_ID; } __weak uint32_t board_id(void) { return UNDEFINED_STRAPPING_ID; }
__weak uint32_t ram_code(void) { return UNDEFINED_STRAPPING_ID; } __weak uint32_t ram_code(void) { return UNDEFINED_STRAPPING_ID; }
@ -535,11 +544,16 @@ static uintptr_t write_coreboot_table(uintptr_t rom_table_end)
/* pass along VBNV offsets in CMOS */ /* pass along VBNV offsets in CMOS */
lb_vbnv(head); lb_vbnv(head);
/* pass along the vboot_handoff address. */
lb_vboot_handoff(head);
#endif #endif
if (CONFIG(VBOOT)) {
/* pass along the vboot_handoff address. */
lb_vboot_handoff(head);
/* pass along the vboot workbuf address. */
lb_vboot_workbuf(head);
}
/* Add strapping IDs if available */ /* Add strapping IDs if available */
lb_board_id(head); lb_board_id(head);
lb_ram_code(head); lb_ram_code(head);

View File

@ -25,24 +25,6 @@
#include <security/vboot/symbols.h> #include <security/vboot/symbols.h>
#include <security/vboot/vboot_common.h> #include <security/vboot/vboot_common.h>
struct selected_region {
uint32_t offset;
uint32_t size;
};
/*
* this is placed at the start of the vboot work buffer. selected_region is used
* for the verstage to return the location of the selected slot. buffer is used
* by the vboot2 core. Keep the struct CPU architecture agnostic as it crosses
* stage boundaries.
*/
struct vboot_working_data {
struct selected_region selected_region;
/* offset of the buffer from the start of this struct */
uint32_t buffer_offset;
uint32_t buffer_size;
};
/* TODO(kitching): Use VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE instead. */ /* TODO(kitching): Use VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE instead. */
static size_t vboot_working_data_size(void) static size_t vboot_working_data_size(void)
{ {
@ -56,7 +38,7 @@ static size_t vboot_working_data_size(void)
die("impossible!"); die("impossible!");
} }
static struct vboot_working_data * const vboot_get_working_data(void) struct vboot_working_data * const vboot_get_working_data(void)
{ {
struct vboot_working_data *wd = NULL; struct vboot_working_data *wd = NULL;

View File

@ -21,9 +21,28 @@
struct vb2_context; struct vb2_context;
struct vb2_shared_data; struct vb2_shared_data;
struct selected_region {
uint32_t offset;
uint32_t size;
};
/*
* this is placed at the start of the vboot work buffer. selected_region is used
* for the verstage to return the location of the selected slot. buffer is used
* by the vboot2 core. Keep the struct CPU architecture agnostic as it crosses
* stage boundaries.
*/
struct vboot_working_data {
struct selected_region selected_region;
/* offset of the buffer from the start of this struct */
uint32_t buffer_offset;
uint32_t buffer_size;
};
/* /*
* Source: security/vboot/common.c * Source: security/vboot/common.c
*/ */
struct vboot_working_data * const vboot_get_working_data(void);
void vboot_init_work_context(struct vb2_context *ctx); void vboot_init_work_context(struct vb2_context *ctx);
void vboot_finalize_work_context(struct vb2_context *ctx); void vboot_finalize_work_context(struct vb2_context *ctx);
struct vb2_shared_data *vboot_get_shared_data(void); struct vb2_shared_data *vboot_get_shared_data(void);