summaryrefslogtreecommitdiff
path: root/tests/vboot_kernel_tests.c
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-05-21 12:20:38 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-05-28 21:10:45 -0700
commitde2cae6b4d6ae864f2c90e6be73f683bad5f2f2f (patch)
tree023d1581f9054c6a54b9631be45f5277b721a23c /tests/vboot_kernel_tests.c
parent236bfb0bc3bd0aa37bd06702c25993446f9b6dba (diff)
downloadvboot-de2cae6b4d6ae864f2c90e6be73f683bad5f2f2f.tar.gz
vboot: save GBB header in workbuf during firmware verification
Since GBB header will be needed for subsequent GBB reads later on (in kernel verification stage), and since GBB header is relatively small (128 bytes), save the full GBB header onto workbuf during firmware verification stage, and store an offset pointer to it in vb2_shared_data. vb2_gbb_header object may be accessed via the vb2_get_gbb function. Additionally, update functions in firmware/lib/region-init.c to read GBB data from flash, rather than using cparams passed in by depthcharge, which is slated for deprecation. BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I6e6218231299ce3a5b383663bc3480b20f929840 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1585500 Reviewed-on: https://chromium-review.googlesource.com/1627430 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'tests/vboot_kernel_tests.c')
-rw-r--r--tests/vboot_kernel_tests.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c
index 4fd78a82..1711ceed 100644
--- a/tests/vboot_kernel_tests.c
+++ b/tests/vboot_kernel_tests.c
@@ -59,8 +59,7 @@ static int verify_data_fail;
static int unpack_key_fail;
static int gpt_flag_external;
-static uint8_t gbb_data[sizeof(struct vb2_gbb_header) + 2048];
-static struct vb2_gbb_header *gbb = (struct vb2_gbb_header*)gbb_data;
+static struct vb2_gbb_header gbb;
static VbExDiskHandle_t handle;
static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE];
static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data;
@@ -137,10 +136,10 @@ static void ResetMocks(void)
gpt_flag_external = 0;
- memset(gbb, 0, sizeof(*gbb));
- gbb->major_version = VB2_GBB_MAJOR_VER;
- gbb->minor_version = VB2_GBB_MINOR_VER;
- gbb->flags = 0;
+ memset(&gbb, 0, sizeof(gbb));
+ gbb.major_version = VB2_GBB_MAJOR_VER;
+ gbb.minor_version = VB2_GBB_MINOR_VER;
+ gbb.flags = 0;
memset(&shared_data, 0, sizeof(shared_data));
VbSharedDataInit(shared, sizeof(shared_data));
@@ -181,13 +180,25 @@ static void ResetMocks(void)
struct vb2_shared_data *sd = vb2_get_sd(&ctx);
sd->vbsd = shared;
- sd->gbb = (struct vb2_gbb_header *)gbb_data;
- sd->gbb_size = sizeof(gbb_data);
// TODO: more workbuf fields - flags, secdata, secdatak
}
/* Mocks */
+struct vb2_gbb_header *vb2_get_gbb(struct vb2_context *c)
+{
+ return &gbb;
+}
+
+int vb2ex_read_resource(struct vb2_context *c,
+ enum vb2_resource_index index,
+ uint32_t offset,
+ void *buf,
+ uint32_t size)
+{
+ memset(buf, 0, size);
+ return VB2_SUCCESS;
+}
VbError_t VbExDiskRead(VbExDiskHandle_t h, uint64_t lba_start,
uint64_t lba_count, void *buffer)