summaryrefslogtreecommitdiff
path: root/firmware/lib/region-init.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 /firmware/lib/region-init.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 'firmware/lib/region-init.c')
-rw-r--r--firmware/lib/region-init.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/firmware/lib/region-init.c b/firmware/lib/region-init.c
index e34a3d15..9e3c2bc3 100644
--- a/firmware/lib/region-init.c
+++ b/firmware/lib/region-init.c
@@ -20,22 +20,14 @@
static VbError_t VbGbbReadData(struct vb2_context *ctx,
uint32_t offset, uint32_t size, void *buf)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
-
- /* This is the old API, for backwards compatibility */
- if (!sd->gbb)
- return VBERROR_INVALID_GBB;
-
- if (offset + size > sd->gbb_size)
+ if (vb2ex_read_resource(ctx, VB2_RES_GBB, offset, buf, size))
return VBERROR_INVALID_GBB;
-
- memcpy(buf, ((uint8_t *)sd->gbb) + offset, size);
return VBERROR_SUCCESS;
}
VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid, uint32_t max_size)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
if (!max_size)
return VBERROR_INVALID_PARAMETER;
@@ -44,18 +36,18 @@ VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid, uint32_t max_size)
if (!ctx)
return VBERROR_INVALID_GBB;
- if (0 == sd->gbb->hwid_size) {
+ if (0 == gbb->hwid_size) {
VB2_DEBUG("VbHWID(): invalid hwid size\n");
return VBERROR_SUCCESS; /* oddly enough! */
}
- if (sd->gbb->hwid_size > max_size) {
+ if (gbb->hwid_size > max_size) {
VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n");
return VBERROR_INVALID_PARAMETER;
}
- return VbGbbReadData(ctx, sd->gbb->hwid_offset,
- sd->gbb->hwid_size, hwid);
+ return VbGbbReadData(ctx, gbb->hwid_offset,
+ gbb->hwid_size, hwid);
}
static VbError_t VbGbbReadKey(struct vb2_context *ctx, uint32_t offset,
@@ -86,14 +78,14 @@ static VbError_t VbGbbReadKey(struct vb2_context *ctx, uint32_t offset,
VbError_t VbGbbReadRootKey(struct vb2_context *ctx, VbPublicKey **keyp)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
- return VbGbbReadKey(ctx, sd->gbb->rootkey_offset, keyp);
+ return VbGbbReadKey(ctx, gbb->rootkey_offset, keyp);
}
VbError_t VbGbbReadRecoveryKey(struct vb2_context *ctx, VbPublicKey **keyp)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
- return VbGbbReadKey(ctx, sd->gbb->recovery_key_offset, keyp);
+ return VbGbbReadKey(ctx, gbb->recovery_key_offset, keyp);
}