diff options
author | Joel Kitching <kitching@google.com> | 2019-05-21 12:20:38 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-28 21:10:45 -0700 |
commit | de2cae6b4d6ae864f2c90e6be73f683bad5f2f2f (patch) | |
tree | 023d1581f9054c6a54b9631be45f5277b721a23c /tests/vboot_display_tests.c | |
parent | 236bfb0bc3bd0aa37bd06702c25993446f9b6dba (diff) | |
download | vboot-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_display_tests.c')
-rw-r--r-- | tests/vboot_display_tests.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c index 16ccd36e..3d65825e 100644 --- a/tests/vboot_display_tests.c +++ b/tests/vboot_display_tests.c @@ -69,8 +69,6 @@ static void ResetMocks(void) sd = vb2_get_sd(&ctx); sd->vbsd = shared; - sd->gbb = (struct vb2_gbb_header *)gbb_data; - sd->gbb_size = sizeof(gbb_data); memset(&shared_data, 0, sizeof(shared_data)); VbSharedDataInit(shared, sizeof(shared_data)); @@ -79,6 +77,35 @@ static void ResetMocks(void) } /* 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) +{ + uint8_t *rptr; + uint32_t rsize; + + switch(index) { + case VB2_RES_GBB: + rptr = (uint8_t *)&gbb_data; + rsize = sizeof(gbb_data); + break; + default: + return VB2_ERROR_EX_READ_RESOURCE_INDEX; + } + + if (offset > rsize || offset + size > rsize) + return VB2_ERROR_EX_READ_RESOURCE_SIZE; + + memcpy(buf, rptr + offset, size); + return VB2_SUCCESS; +} VbError_t VbExGetLocalizationCount(uint32_t *count) { @@ -116,22 +143,17 @@ static void DebugInfoTest(void) TEST_EQ(strcmp(hwid, "Test HWID"), 0, "HWID"); ResetMocks(); - sd->gbb_size = 0; - VbGbbReadHWID(&ctx, hwid, sizeof(hwid)); - TEST_EQ(strcmp(hwid, "{INVALID}"), 0, "HWID bad gbb"); - - ResetMocks(); - sd->gbb->hwid_size = 0; + gbb->hwid_size = 0; VbGbbReadHWID(&ctx, hwid, sizeof(hwid)); TEST_EQ(strcmp(hwid, "{INVALID}"), 0, "HWID missing"); ResetMocks(); - sd->gbb->hwid_offset = sd->gbb_size + 1; + gbb->hwid_offset = sizeof(gbb_data) + 1; VbGbbReadHWID(&ctx, hwid, sizeof(hwid)); TEST_EQ(strcmp(hwid, "{INVALID}"), 0, "HWID past end"); ResetMocks(); - sd->gbb->hwid_size = sd->gbb_size; + gbb->hwid_size = sizeof(gbb_data); VbGbbReadHWID(&ctx, hwid, sizeof(hwid)); TEST_EQ(strcmp(hwid, "{INVALID}"), 0, "HWID overflow"); |