summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-06-13 14:16:16 +0800
committerCommit Bot <commit-bot@chromium.org>2019-06-14 21:44:50 +0000
commit5306ca28f4c077cb3e1dac0e0e7bbb35ef37687c (patch)
treefd8f4c254fdd868683c5f3c35f54d2741af6c6a3
parentde5b8dff95811ba0bbe27c7f5cb7bb0269eab761 (diff)
downloadvboot-5306ca28f4c077cb3e1dac0e0e7bbb35ef37687c.tar.gz
vboot: export offset and type of GBB struct flags member
Export information about vb2_gbb_header's flags member: * vb2_gbb_flags_t * VB2_GBB_FLAGS_OFFSET BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I2923156edd06df02751ccded5dcbb5bf8fe0207d Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1657503 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Auto-Submit: Joel Kitching <kitching@chromium.org>
-rw-r--r--firmware/2lib/include/2constants.h9
-rw-r--r--firmware/2lib/include/2struct.h13
2 files changed, 16 insertions, 6 deletions
diff --git a/firmware/2lib/include/2constants.h b/firmware/2lib/include/2constants.h
index 76e7f22e..4dadd8b6 100644
--- a/firmware/2lib/include/2constants.h
+++ b/firmware/2lib/include/2constants.h
@@ -65,6 +65,13 @@
#define VB2_WORKBUF_ALIGN __BIGGEST_ALIGNMENT__
/* Maximum length of a HWID in bytes, counting terminating null. */
-#define VB2_GBB_HWID_MAX_SIZE 256
+#define VB2_GBB_HWID_MAX_SIZE 256
+
+/* Type and offset of flags member in vb2_gbb_header struct. */
+#define VB2_GBB_FLAGS_OFFSET 12
+#ifndef __ASSEMBLER__
+#include <stdint.h>
+typedef uint32_t vb2_gbb_flags_t;
+#endif
#endif /* VBOOT_REFERENCE_2CONSTANTS_H_ */
diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h
index 2ca30142..52783b6a 100644
--- a/firmware/2lib/include/2struct.h
+++ b/firmware/2lib/include/2struct.h
@@ -15,9 +15,9 @@
#ifndef VBOOT_REFERENCE_VBOOT_2STRUCT_H_
#define VBOOT_REFERENCE_VBOOT_2STRUCT_H_
-#include <stdint.h>
+#include "2constants.h"
#include "2crypto.h"
-#include "2gbb_flags.h"
+#include "2sysincludes.h"
/*
* Key block flags.
@@ -250,7 +250,7 @@ struct vb2_gbb_header {
uint32_t header_size; /* Size of GBB header in bytes */
/* Flags (see enum vb2_gbb_flag in 2gbb_flags.h) */
- uint32_t flags;
+ vb2_gbb_flags_t flags;
/* Offsets (from start of header) and sizes (in bytes) of components */
uint32_t hwid_offset; /* HWID */
@@ -265,13 +265,16 @@ struct vb2_gbb_header {
/* Added in version 1.2 */
uint8_t hwid_digest[VB2_GBB_HWID_DIGEST_SIZE]; /* SHA-256 of HWID */
- /* Pad to match EXPECETED_VB2_GBB_HEADER_SIZE. Initialize to 0. */
+ /* Pad to match EXPECTED_VB2_GBB_HEADER_SIZE. Initialize to 0. */
uint8_t pad[48];
} __attribute__((packed));
-/* The GBB is used outside of vboot_reference, so this size is important. */
#define EXPECTED_VB2_GBB_HEADER_SIZE 128
+/* VB2_GBB_FLAGS_OFFSET exposed in 2constants.h */
+_Static_assert(VB2_GBB_FLAGS_OFFSET == offsetof(struct vb2_gbb_header, flags),
+ "VB2_GBB_FLAGS_OFFSET set incorrectly");
+
/*
* Root key hash for Ryu devices only. Contains the hash of the root key.
* This will be embedded somewhere inside the RO part of the firmware, so that