summaryrefslogtreecommitdiff
path: root/firmware/2lib/2misc.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/2lib/2misc.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/2lib/2misc.c')
-rw-r--r--firmware/2lib/2misc.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c
index 8b6a19f8..03e0353a 100644
--- a/firmware/2lib/2misc.c
+++ b/firmware/2lib/2misc.c
@@ -14,7 +14,8 @@
#include "2sha.h"
#include "2rsa.h"
-int vb2_validate_gbb_signature(uint8_t *sig) {
+int vb2_validate_gbb_signature(uint8_t *sig)
+{
const static uint8_t sig_xor[VB2_GBB_SIGNATURE_SIZE] =
VB2_GBB_XOR_SIGNATURE;
int i;
@@ -25,6 +26,13 @@ int vb2_validate_gbb_signature(uint8_t *sig) {
return VB2_SUCCESS;
}
+test_mockable
+struct vb2_gbb_header *vb2_get_gbb(struct vb2_context *ctx)
+{
+ return (struct vb2_gbb_header *)
+ ((void *)vb2_get_sd(ctx) + vb2_get_sd(ctx)->gbb_offset);
+}
+
void vb2_workbuf_from_ctx(struct vb2_context *ctx, struct vb2_workbuf *wb)
{
vb2_workbuf_init(wb, ctx->workbuf + ctx->workbuf_used,
@@ -218,11 +226,9 @@ int vb2_fw_parse_gbb(struct vb2_context *ctx)
if (rv)
return rv;
- /* Extract the only things we care about at firmware time */
- sd->gbb_flags = gbb->flags;
- sd->gbb_rootkey_offset = gbb->rootkey_offset;
- sd->gbb_rootkey_size = gbb->rootkey_size;
- memcpy(sd->gbb_hwid_digest, gbb->hwid_digest, VB2_GBB_HWID_DIGEST_SIZE);
+ /* Keep on the work buffer permanently */
+ sd->gbb_offset = vb2_offset_of(sd, gbb);
+ ctx->workbuf_used = vb2_offset_of(ctx->workbuf, wb.buf);
return VB2_SUCCESS;
}
@@ -230,6 +236,7 @@ int vb2_fw_parse_gbb(struct vb2_context *ctx)
int vb2_check_dev_switch(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
uint32_t flags = 0;
uint32_t old_flags;
int is_dev = 0;
@@ -275,7 +282,7 @@ int vb2_check_dev_switch(struct vb2_context *ctx)
is_dev = 1;
/* Check if GBB is forcing dev mode */
- if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON)
+ if (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON)
is_dev = 1;
/* Handle whichever mode we end up in */