diff options
author | Joel Kitching <kitching@google.com> | 2019-04-25 18:31:14 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-17 18:36:48 -0700 |
commit | 27e3e9fcba98dba576322273a34bd0cbbb639e81 (patch) | |
tree | 208694afb44812fd666551682bffe95c96856d48 | |
parent | 719968c47a6220b3e660e4f72cbc2a56750eec00 (diff) | |
download | vboot-27e3e9fcba98dba576322273a34bd0cbbb639e81.tar.gz |
vboot: deprecate v1 GoogleBinaryBlockHeader struct
Deprecate internal usage of GoogleBinaryBlockHeader struct in
favour of vb2_gbb_header struct. Keep the v1 struct around until
we remove references in other repos.
BUG=b:124141368, chromium:954774
TEST=make clean && make runtests
BRANCH=none
Change-Id: I396d2e624bd5dcac9c461cc86e8175e8f7692d26
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1583826
Commit-Ready: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
29 files changed, 106 insertions, 131 deletions
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c index c486d570..c8491551 100644 --- a/firmware/lib/ec_sync.c +++ b/firmware/lib/ec_sync.c @@ -12,7 +12,6 @@ #include "sysincludes.h" #include "ec_sync.h" -#include "gbb_header.h" #include "vboot_api.h" #include "vboot_common.h" #include "vboot_kernel.h" diff --git a/firmware/lib/region-init.c b/firmware/lib/region-init.c index ef676873..e34a3d15 100644 --- a/firmware/lib/region-init.c +++ b/firmware/lib/region-init.c @@ -12,7 +12,6 @@ #include "sysincludes.h" #include "gbb_access.h" -#include "gbb_header.h" #include "load_kernel_fw.h" #include "utility.h" #include "vboot_api.h" diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 77dc3366..2be3e938 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -14,7 +14,6 @@ #include "2rsa.h" #include "ec_sync.h" #include "gbb_access.h" -#include "gbb_header.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "utility.h" diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c index c43becec..d735cb41 100644 --- a/firmware/lib/vboot_display.c +++ b/firmware/lib/vboot_display.c @@ -13,7 +13,6 @@ #include "2nvstorage.h" #include "2sha.h" #include "gbb_access.h" -#include "gbb_header.h" #include "utility.h" #include "vboot_api.h" #include "vboot_common.h" diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 57ab53d4..7195bdb0 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -17,7 +17,6 @@ #include "cgptlib.h" #include "cgptlib_internal.h" #include "gbb_access.h" -#include "gbb_header.h" #include "gpt_misc.h" #include "load_kernel_fw.h" #include "rollback_index.h" diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index e06d5f6b..14508a63 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -14,7 +14,6 @@ #include "2rsa.h" #include "ec_sync.h" #include "gbb_access.h" -#include "gbb_header.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "tlcl.h" @@ -79,7 +78,7 @@ static int VbWantShutdown(struct vb2_context *ctx, uint32_t key) shutdown_request |= VB_SHUTDOWN_REQUEST_POWER_BUTTON; /* If desired, ignore shutdown request due to lid closure. */ - if (sd->gbb_flags & GBB_FLAG_DISABLE_LID_SHUTDOWN) + if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN) shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED; return shutdown_request; @@ -619,7 +618,7 @@ static VbError_t vb2_developer_ui(struct vb2_context *ctx) if (shared->flags & VBSD_BOOT_DEV_SWITCH_ON) { /* Stop the countdown while we go ask... */ if (sd->gbb_flags & - GBB_FLAG_FORCE_DEV_SWITCH_ON) { + VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) { /* * TONORM won't work (only for * non-shipping devices). diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 505a4caa..42494772 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -12,7 +12,6 @@ #include "2rsa.h" #include "ec_sync.h" #include "gbb_access.h" -#include "gbb_header.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "utility.h" diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c index 02f4757f..84531c4a 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -16,7 +16,6 @@ #include <unistd.h> #include "futility.h" -#include "gbb_header.h" static void print_help(int argc, char *argv[]) { @@ -99,18 +98,19 @@ static void opt_has_arg(const char *name, int val) static int errorcnt; #define GBB_SEARCH_STRIDE 4 -static GoogleBinaryBlockHeader *FindGbbHeader(uint8_t *ptr, size_t size) +static struct vb2_gbb_header *FindGbbHeader(uint8_t *ptr, size_t size) { size_t i; - GoogleBinaryBlockHeader *tmp, *gbb_header = NULL; + struct vb2_gbb_header *tmp, *gbb_header = NULL; int count = 0; for (i = 0; i <= size - GBB_SEARCH_STRIDE; i += GBB_SEARCH_STRIDE) { - if (0 != memcmp(ptr + i, GBB_SIGNATURE, GBB_SIGNATURE_SIZE)) + if (0 != memcmp(ptr + i, VB2_GBB_SIGNATURE, + VB2_GBB_SIGNATURE_SIZE)) continue; /* Found something. See if it's any good. */ - tmp = (GoogleBinaryBlockHeader *) (ptr + i); + tmp = (struct vb2_gbb_header *) (ptr + i); if (futil_valid_gbb_header(tmp, size - i, NULL)) if (!count++) gbb_header = tmp; @@ -132,12 +132,12 @@ static GoogleBinaryBlockHeader *FindGbbHeader(uint8_t *ptr, size_t size) static uint8_t *create_gbb(const char *desc, off_t *sizeptr) { char *str, *sizes, *param, *e = NULL; - size_t size = GBB_HEADER_SIZE; + size_t size = EXPECTED_VB2_GBB_HEADER_SIZE; int i = 0; /* Danger Will Robinson! four entries ==> four paramater blocks */ uint32_t val[] = { 0, 0, 0, 0 }; uint8_t *buf; - GoogleBinaryBlockHeader *gbb; + struct vb2_gbb_header *gbb; sizes = strdup(desc); if (!sizes) { @@ -173,14 +173,14 @@ static uint8_t *create_gbb(const char *desc, off_t *sizeptr) *sizeptr = size; } - gbb = (GoogleBinaryBlockHeader *) buf; - memcpy(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE); - gbb->major_version = GBB_MAJOR_VER; - gbb->minor_version = GBB_MINOR_VER; - gbb->header_size = GBB_HEADER_SIZE; + gbb = (struct vb2_gbb_header *) buf; + memcpy(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE); + gbb->major_version = VB2_GBB_MAJOR_VER; + gbb->minor_version = VB2_GBB_MINOR_VER; + gbb->header_size = EXPECTED_VB2_GBB_HEADER_SIZE; gbb->flags = 0; - i = GBB_HEADER_SIZE; + i = EXPECTED_VB2_GBB_HEADER_SIZE; gbb->hwid_offset = i; gbb->hwid_size = val[0]; i += val[0]; @@ -371,7 +371,7 @@ static int do_gbb(int argc, char *argv[]) uint8_t *inbuf = NULL; off_t filesize; uint8_t *outbuf = NULL; - GoogleBinaryBlockHeader *gbb; + struct vb2_gbb_header *gbb; uint8_t *gbb_base; int i; diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c index 8b6b2520..c458eef6 100644 --- a/futility/cmd_sign.c +++ b/futility/cmd_sign.c @@ -22,7 +22,6 @@ #include "fmap.h" #include "futility.h" #include "futility_options.h" -#include "gbb_header.h" #include "host_common.h" #include "host_key2.h" #include "kernel_blob.h" diff --git a/futility/file_type.c b/futility/file_type.c index 0b45be18..2e24b75f 100644 --- a/futility/file_type.c +++ b/futility/file_type.c @@ -16,7 +16,6 @@ #include "file_type.h" #include "futility.h" -#include "gbb_header.h" /* Description and functions to handle each file type */ struct futil_file_type_s { diff --git a/futility/file_type_bios.c b/futility/file_type_bios.c index d79e76f8..a04c044b 100644 --- a/futility/file_type_bios.c +++ b/futility/file_type_bios.c @@ -14,7 +14,6 @@ #include "file_type_bios.h" #include "futility.h" #include "futility_options.h" -#include "gbb_header.h" #include "host_common.h" #include "vb1_helper.h" #include "vb2_common.h" @@ -52,7 +51,7 @@ static void fmap_limit_area(FmapAreaHeader *ah, uint32_t len) int ft_show_gbb(const char *name, uint8_t *buf, uint32_t len, void *data) { - GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)buf; + struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)buf; struct bios_state_s *state = (struct bios_state_s *)data; int retval = 0; uint32_t maxlen = 0; diff --git a/futility/futility.h b/futility/futility.h index 9a1ac6dc..1de17f7f 100644 --- a/futility/futility.h +++ b/futility/futility.h @@ -9,7 +9,6 @@ #include "2common.h" #include "vboot_common.h" -#include "gbb_header.h" #include "host_key.h" /* This program */ @@ -105,24 +104,24 @@ extern const struct futil_cmd_t *const futil_cmds[]; extern int debugging_enabled; /* Returns true if this looks enough like a GBB header to proceed. */ -int futil_looks_like_gbb(GoogleBinaryBlockHeader *gbb, uint32_t len); +int futil_looks_like_gbb(struct vb2_gbb_header *gbb, uint32_t len); /* * Returns true if the gbb header is valid (and optionally updates *maxlen). * This doesn't verify the contents, though. */ -int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len, +int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len, uint32_t *maxlen); /* Sets the HWID string field inside a GBB header. */ int futil_set_gbb_hwid(struct vb2_gbb_header *gbb, const char *hwid); /* For GBB v1.2 and later, update the hwid_digest */ -void update_hwid_digest(GoogleBinaryBlockHeader *gbb); +void update_hwid_digest(struct vb2_gbb_header *gbb); /* For GBB v1.2 and later, print the stored digest of the HWID (and whether * it's correct). Return true if it is correct. */ -int print_hwid_digest(GoogleBinaryBlockHeader *gbb, +int print_hwid_digest(struct vb2_gbb_header *gbb, const char *banner, const char *footer); /* Copies a file or dies with an error message */ @@ -130,11 +129,11 @@ void futil_copy_file_or_die(const char *infile, const char *outfile); /* Update ryu root key header in the image */ int fill_ryu_root_header(uint8_t *ptr, size_t size, - const GoogleBinaryBlockHeader *gbb); + const struct vb2_gbb_header *gbb); /* Verify ryu root key header */ int verify_ryu_root_header(uint8_t *ptr, size_t size, - const GoogleBinaryBlockHeader *gbb); + const struct vb2_gbb_header *gbb); /* Possible file operation errors */ enum futil_file_err { diff --git a/futility/misc.c b/futility/misc.c index 333360a8..82385c1a 100644 --- a/futility/misc.c +++ b/futility/misc.c @@ -28,7 +28,6 @@ #include "cgptlib_internal.h" #include "file_type.h" #include "futility.h" -#include "gbb_header.h" /* Default is to support everything we can */ enum vboot_version vboot_version = VBOOT_VERSION_ALL; @@ -63,28 +62,28 @@ static inline uint32_t max(uint32_t a, uint32_t b) enum futil_file_type ft_recognize_gbb(uint8_t *buf, uint32_t len) { - GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)buf; + struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)buf; - if (memcmp(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE)) + if (memcmp(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE)) return FILE_TYPE_UNKNOWN; - if (gbb->major_version > GBB_MAJOR_VER) + if (gbb->major_version > VB2_GBB_MAJOR_VER) return FILE_TYPE_UNKNOWN; - if (sizeof(GoogleBinaryBlockHeader) > len) + if (sizeof(struct vb2_gbb_header) > len) return FILE_TYPE_UNKNOWN; /* close enough */ return FILE_TYPE_GBB; } -int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len, +int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len, uint32_t *maxlen_ptr) { - if (len < sizeof(GoogleBinaryBlockHeader)) + if (len < sizeof(struct vb2_gbb_header)) return 0; - if (memcmp(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE)) + if (memcmp(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE)) return 0; - if (gbb->major_version != GBB_MAJOR_VER) + if (gbb->major_version != VB2_GBB_MAJOR_VER) return 0; /* Check limits first, to help identify problems */ @@ -101,9 +100,10 @@ int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len, *maxlen_ptr = maxlen; } - if (gbb->header_size != GBB_HEADER_SIZE || gbb->header_size > len) + if (gbb->header_size != EXPECTED_VB2_GBB_HEADER_SIZE || + gbb->header_size > len) return 0; - if (gbb->hwid_offset < GBB_HEADER_SIZE) + if (gbb->hwid_offset < EXPECTED_VB2_GBB_HEADER_SIZE) return 0; if (gbb->hwid_offset + gbb->hwid_size > len) return 0; @@ -113,16 +113,16 @@ int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len, if (!is_null_terminated(s, gbb->hwid_size)) return 0; } - if (gbb->rootkey_offset < GBB_HEADER_SIZE) + if (gbb->rootkey_offset < EXPECTED_VB2_GBB_HEADER_SIZE) return 0; if (gbb->rootkey_offset + gbb->rootkey_size > len) return 0; - if (gbb->bmpfv_offset < GBB_HEADER_SIZE) + if (gbb->bmpfv_offset < EXPECTED_VB2_GBB_HEADER_SIZE) return 0; if (gbb->bmpfv_offset + gbb->bmpfv_size > len) return 0; - if (gbb->recovery_key_offset < GBB_HEADER_SIZE) + if (gbb->recovery_key_offset < EXPECTED_VB2_GBB_HEADER_SIZE) return 0; if (gbb->recovery_key_offset + gbb->recovery_key_size > len) return 0; @@ -133,7 +133,7 @@ int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len, /* For GBB v1.2 and later, print the stored digest of the HWID (and whether * it's correct). Return true if it is correct. */ -int print_hwid_digest(GoogleBinaryBlockHeader *gbb, +int print_hwid_digest(struct vb2_gbb_header *gbb, const char *banner, const char *footer) { printf("%s", banner); @@ -169,7 +169,7 @@ int print_hwid_digest(GoogleBinaryBlockHeader *gbb, /* Deprecated. Use futil_set_gbb_hwid in future. */ /* For GBB v1.2 and later, update the hwid_digest field. */ -void update_hwid_digest(GoogleBinaryBlockHeader *gbb) +void update_hwid_digest(struct vb2_gbb_header *gbb) { /* There isn't one for v1.1 and earlier */ if (gbb->minor_version < 2) diff --git a/futility/ryu_root_header.c b/futility/ryu_root_header.c index 1865b75c..48aef431 100644 --- a/futility/ryu_root_header.c +++ b/futility/ryu_root_header.c @@ -19,7 +19,6 @@ #include "2common.h" #include "2sha.h" #include "futility.h" -#include "gbb_header.h" #define SEARCH_STRIDE 4 @@ -97,7 +96,7 @@ static struct vb2_ryu_root_key_hash *find_ryu_root_header(uint8_t *ptr, } static void calculate_root_key_hash(uint8_t *digest, size_t digest_size, - const GoogleBinaryBlockHeader *gbb) + const struct vb2_gbb_header *gbb) { const uint8_t *gbb_base = (const uint8_t *)gbb; @@ -109,7 +108,7 @@ static void calculate_root_key_hash(uint8_t *digest, size_t digest_size, } int fill_ryu_root_header(uint8_t *ptr, size_t size, - const GoogleBinaryBlockHeader *gbb) + const struct vb2_gbb_header *gbb) { struct vb2_ryu_root_key_hash *hash; @@ -131,7 +130,7 @@ int fill_ryu_root_header(uint8_t *ptr, size_t size, } int verify_ryu_root_header(uint8_t *ptr, size_t size, - const GoogleBinaryBlockHeader *gbb) + const struct vb2_gbb_header *gbb) { uint8_t digest[VB2_SHA256_DIGEST_SIZE] = {0}; diff --git a/futility/updater.c b/futility/updater.c index 8dad7d41..859dedee 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -955,12 +955,7 @@ const struct vb2_gbb_header *find_gbb(const struct firmware_image *image) find_firmware_section(§ion, image, FMAP_RO_GBB); gbb_header = (struct vb2_gbb_header *)section.data; - /* - * futil_valid_gbb_header needs v1 header (GoogleBinaryBlockHeader) - * but that should be compatible with vb2_gbb_header - */ - if (!futil_valid_gbb_header((GoogleBinaryBlockHeader *)gbb_header, - section.size, NULL)) { + if (!futil_valid_gbb_header(gbb_header, section.size, NULL)) { ERROR("Cannot find GBB in image: %s.\n", image->file_name); return NULL; } diff --git a/scripts/image_signing/gbb_flags_common.sh b/scripts/image_signing/gbb_flags_common.sh index 5a9aee7f..d4e3cedf 100644 --- a/scripts/image_signing/gbb_flags_common.sh +++ b/scripts/image_signing/gbb_flags_common.sh @@ -13,29 +13,29 @@ load_shflags || exit 1 # Globals # ---------------------------------------------------------------------------- -# Values from vboot_reference/firmware/include/gbb_header.h +# Values from vboot_reference/firmware/2lib/include/2gbb_flags.h GBBFLAGS_DESCRIPTION_PREFIX=" Defined flags (some values may be not supported by all systems): " GBBFLAGS_LIST=" - GBB_FLAG_DEV_SCREEN_SHORT_DELAY 0x00000001 - GBB_FLAG_LOAD_OPTION_ROMS 0x00000002 - GBB_FLAG_ENABLE_ALTERNATE_OS 0x00000004 - GBB_FLAG_FORCE_DEV_SWITCH_ON 0x00000008 - GBB_FLAG_FORCE_DEV_BOOT_USB 0x00000010 - GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK 0x00000020 - GBB_FLAG_ENTER_TRIGGERS_TONORM 0x00000040 - GBB_FLAG_FORCE_DEV_BOOT_LEGACY 0x00000080 - GBB_FLAG_FAFT_KEY_OVERIDE 0x00000100 - GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC 0x00000200 - GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400 - GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC 0x00000800 - GBB_FLAG_DISABLE_LID_SHUTDOWN 0x00001000 - GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP 0x00002000 - GBB_FLAG_FORCE_MANUAL_RECOVERY 0x00004000 - GBB_FLAG_DISABLE_FWMP 0x00008000 - GBB_FLAG_ENABLE_UDC 0x00010000 + VB2_GBB_FLAG_DEV_SCREEN_SHORT_DELAY 0x00000001 + VB2_GBB_FLAG_LOAD_OPTION_ROMS 0x00000002 + VB2_GBB_FLAG_ENABLE_ALTERNATE_OS 0x00000004 + VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON 0x00000008 + VB2_GBB_FLAG_FORCE_DEV_BOOT_USB 0x00000010 + VB2_GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK 0x00000020 + VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM 0x00000040 + VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY 0x00000080 + VB2_GBB_FLAG_FAFT_KEY_OVERIDE 0x00000100 + VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC 0x00000200 + VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400 + VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC 0x00000800 + VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN 0x00001000 + VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP 0x00002000 + VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY 0x00004000 + VB2_GBB_FLAG_DISABLE_FWMP 0x00008000 + VB2_GBB_FLAG_ENABLE_UDC 0x00010000 " GBBFLAGS_DESCRIPTION_SUFFIX=" diff --git a/scripts/image_signing/make_dev_firmware.sh b/scripts/image_signing/make_dev_firmware.sh index 136b18fb..767dc22c 100755 --- a/scripts/image_signing/make_dev_firmware.sh +++ b/scripts/image_signing/make_dev_firmware.sh @@ -377,7 +377,8 @@ main() { debug_msg "Decide new GBB flags from: $old_gbb_flags" [ -z "$old_gbb_flags" ] && die "Cannot find GBB flags. (message: $(cat "${EXEC_LOG}"))" - # 0x30: GBB_FLAG_FORCE_DEV_BOOT_USB | GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK + # 0x30: VB2_GBB_FLAG_FORCE_DEV_BOOT_USB | + # VB2_GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK local new_gbb_flags="$((old_gbb_flags | 0x30))" debug_msg "Replace GBB parts (futility gbb allows changing on-the-fly)" diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c index fb043460..45764048 100644 --- a/tests/ec_sync_tests.c +++ b/tests/ec_sync_tests.c @@ -14,7 +14,6 @@ #include "2misc.h" #include "2nvstorage.h" #include "ec_sync.h" -#include "gbb_header.h" #include "host_common.h" #include "load_kernel_fw.h" #include "rollback_index.h" diff --git a/tests/futility/test_not_really.c b/tests/futility/test_not_really.c index 91756ac3..1d69d44d 100644 --- a/tests/futility/test_not_really.c +++ b/tests/futility/test_not_really.c @@ -4,14 +4,14 @@ * found in the LICENSE file. */ #include <stdio.h> -#include "gbb_header.h" +#include "2struct.h" #include "test_common.h" int main(int argc, char *argv[]) { - TEST_EQ(sizeof(GoogleBinaryBlockHeader), - GBB_HEADER_SIZE, - "sizeof(GoogleBinaryBlockHeader)"); + TEST_EQ(sizeof(struct vb2_gbb_header), + EXPECTED_VB2_GBB_HEADER_SIZE, + "sizeof(struct vb2_gbb_header)"); TEST_EQ(0, 0, "Not Really A"); diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c index 286972c2..ccd4c617 100644 --- a/tests/vboot_api_devmode_tests.c +++ b/tests/vboot_api_devmode_tests.c @@ -15,7 +15,6 @@ #include "2misc.h" #include "2nvstorage.h" #include "crc32.h" -#include "gbb_header.h" #include "host_common.h" #include "load_kernel_fw.h" #include "rollback_index.h" diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c index 2d0a7ab5..3203bf05 100644 --- a/tests/vboot_api_kernel2_tests.c +++ b/tests/vboot_api_kernel2_tests.c @@ -13,7 +13,6 @@ #include "2api.h" #include "2misc.h" #include "2nvstorage.h" -#include "gbb_header.h" #include "host_common.h" #include "load_kernel_fw.h" #include "rollback_index.h" diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index fdf51da6..a4bc6bec 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -14,7 +14,6 @@ #include "2misc.h" #include "2nvstorage.h" #include "ec_sync.h" -#include "gbb_header.h" #include "host_common.h" #include "load_kernel_fw.h" #include "rollback_index.h" @@ -33,7 +32,7 @@ static VbCommonParams cparams; static VbSelectAndLoadKernelParams kparams; static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data; -static GoogleBinaryBlockHeader gbb; +static struct vb2_gbb_header gbb; static uint32_t rkr_version; static uint32_t new_version; @@ -57,8 +56,8 @@ static void ResetMocks(void) memset(&kparams, 0, sizeof(kparams)); memset(&gbb, 0, sizeof(gbb)); - gbb.major_version = GBB_MAJOR_VER; - gbb.minor_version = GBB_MINOR_VER; + gbb.major_version = VB2_GBB_MAJOR_VER; + gbb.minor_version = VB2_GBB_MINOR_VER; gbb.flags = 0; /* ctx.workbuf will be initialized by VbSelectAndLoadKernel. */ @@ -212,7 +211,7 @@ static void VbSlkTest(void) /* Same if shared->flags asks for sync, but it's overridden by GBB */ ResetMocks(); shared->flags |= VBSD_EC_SOFTWARE_SYNC; - gbb.flags |= GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC; + gbb.flags |= VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC; test_slk(0, 0, "EC sync disabled by GBB"); /* Rollback kernel version */ diff --git a/tests/vboot_api_kernel5_tests.c b/tests/vboot_api_kernel5_tests.c index 8d3281be..a0f89466 100644 --- a/tests/vboot_api_kernel5_tests.c +++ b/tests/vboot_api_kernel5_tests.c @@ -16,7 +16,7 @@ #include "2misc.h" #include "2nvstorage.h" #include "2rsa.h" -#include "gbb_header.h" +#include "2struct.h" #include "host_common.h" #include "load_kernel_fw.h" #include "test_common.h" @@ -35,7 +35,7 @@ static VbSelectAndLoadKernelParams kparams; static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data; static uint8_t gbb_buf[4096]; -static GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)gbb_buf; +static struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)gbb_buf; static uint8_t kernel_buffer[80000]; static int key_block_verify_fail; /* 0=ok, 1=sig, 2=hash */ @@ -62,8 +62,8 @@ static void ResetMocks(void) memset(&kparams, 0, sizeof(kparams)); memset(gbb_buf, 0, sizeof(gbb_buf)); - gbb->major_version = GBB_MAJOR_VER; - gbb->minor_version = GBB_MINOR_VER; + gbb->major_version = VB2_GBB_MAJOR_VER; + gbb->minor_version = VB2_GBB_MINOR_VER; gbb->flags = 0; gbb->rootkey_offset = sizeof(*gbb); gbb->rootkey_size = sizeof(VbPublicKey); @@ -234,7 +234,7 @@ static void VerifyMemoryBootImageTest(void) /* Key Block Hash Failure */ ResetMocks(); shared->flags = VBSD_BOOT_DEV_SWITCH_ON; - gbb->flags = GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; + gbb->flags = VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; key_block_verify_fail = 1; TEST_EQ(VbVerifyMemoryBootImage(&ctx, &cparams, &kparams, kernel_buffer, kernel_buffer_size), @@ -267,7 +267,7 @@ static void VerifyMemoryBootImageTest(void) kbh.key_block_flags = KEY_BLOCK_FLAG_DEVELOPER_0 | KEY_BLOCK_FLAG_RECOVERY_1; copy_kbh(); - gbb->flags = GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; + gbb->flags = VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; shared->flags = VBSD_BOOT_DEV_SWITCH_ON; TEST_EQ(VbVerifyMemoryBootImage(&ctx, &cparams, &kparams, kernel_buffer, kernel_buffer_size), @@ -280,7 +280,7 @@ static void VerifyMemoryBootImageTest(void) KEY_BLOCK_FLAG_RECOVERY_0; copy_kbh(); shared->flags = VBSD_BOOT_DEV_SWITCH_ON; - gbb->flags = GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; + gbb->flags = VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; TEST_EQ(VbVerifyMemoryBootImage(&ctx, &cparams, &kparams, kernel_buffer, kernel_buffer_size), VBERROR_SUCCESS, diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c index 92f6dcc9..fc0d3893 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -13,7 +13,6 @@ #include "2sysincludes.h" #include "2common.h" #include "2nvstorage.h" -#include "gbb_header.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "test_common.h" diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c index bf71a5f4..05785848 100644 --- a/tests/vboot_detach_menu_tests.c +++ b/tests/vboot_detach_menu_tests.c @@ -13,7 +13,6 @@ #include "2api.h" #include "2misc.h" #include "2nvstorage.h" -#include "gbb_header.h" #include "host_common.h" #include "load_kernel_fw.h" #include "rollback_index.h" @@ -280,8 +279,8 @@ static void VbBootDevTest(void) /* Proceed to legacy after timeout if GBB flag set */ ResetMocksForDeveloper(); - sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY | - GBB_FLAG_FORCE_DEV_BOOT_LEGACY; + sd->gbb_flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY | + VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY; TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "default legacy GBB"); TEST_EQ(vbexlegacy_called, 1, " try legacy"); @@ -466,7 +465,7 @@ static void VbBootDevTest(void) /* ENTER functionality is unaffected by GBB flag in detachable UI. */ ResetMocksForDeveloper(); - sd->gbb_flags |= GBB_FLAG_ENTER_TRIGGERS_TONORM; + sd->gbb_flags |= VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM; mock_keypress[0] = VB_KEY_ENTER; TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SHUTDOWN_REQUESTED, "dev warning menu: ENTER unaffected by GBB"); @@ -521,7 +520,7 @@ static void VbBootDevTest(void) /* Tonorm ignored if GBB forces dev switch on */ ResetMocksForDeveloper(); shared->flags |= VBSD_BOOT_DEV_SWITCH_ON; - sd->gbb_flags |= GBB_FLAG_FORCE_DEV_SWITCH_ON; + sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON; mock_keypress[0] = VB_BUTTON_VOL_UP_SHORT_PRESS; mock_keypress[1] = VB_BUTTON_POWER_SHORT_PRESS; mock_keypress[2] = VB_BUTTON_POWER_SHORT_PRESS; @@ -582,7 +581,7 @@ static void VbBootDevTest(void) /* Ctrl+D doesn't boot legacy even if GBB flag is set */ ResetMocksForDeveloper(); mock_keypress[0] = VB_KEY_CTRL('D'); - sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY; + sd->gbb_flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY; TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "Ctrl+D"); TEST_EQ(vbexlegacy_called, 0, " not legacy"); @@ -622,7 +621,7 @@ static void VbBootDevTest(void) /* Ctrl+L boots legacy if enabled by GBB flag */ ResetMocksForDeveloper(); - sd->gbb_flags |= GBB_FLAG_FORCE_DEV_BOOT_LEGACY; + sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY; mock_keypress[0] = VB_KEY_CTRL('L'); mock_keypress[1] = VB_BUTTON_POWER_SHORT_PRESS; TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, @@ -737,7 +736,7 @@ static void VbBootDevTest(void) /* Ctrl+U enabled via GBB */ ResetMocksForDeveloper(); - sd->gbb_flags |= GBB_FLAG_FORCE_DEV_BOOT_USB; + sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_USB; mock_keypress[0] = VB_KEY_CTRL('U'); vbtlk_retval[0] = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE; TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SUCCESS, "Ctrl+U force USB"); @@ -1361,7 +1360,7 @@ static void VbBootRecTest(void) /* go to INSERT if forced by GBB flag */ ResetMocks(); vbtlk_retval[0] = VBERROR_NO_DISK_FOUND - VB_DISK_FLAG_REMOVABLE; - sd->gbb_flags |= GBB_FLAG_FORCE_MANUAL_RECOVERY; + sd->gbb_flags |= VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY; TEST_EQ(VbBootRecoveryMenu(&ctx), VBERROR_SHUTDOWN_REQUESTED, "Shutdown requested in INSERT forced by GBB flag"); TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0, " no recovery"); diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c index 986bb270..16ccd36e 100644 --- a/tests/vboot_display_tests.c +++ b/tests/vboot_display_tests.c @@ -14,8 +14,8 @@ #include "2common.h" #include "2misc.h" #include "2nvstorage.h" +#include "2struct.h" #include "gbb_access.h" -#include "gbb_header.h" #include "host_common.h" #include "test_common.h" #include "vboot_common.h" @@ -25,8 +25,8 @@ /* Mock data */ static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data; -static char gbb_data[4096 + sizeof(GoogleBinaryBlockHeader)]; -static GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)gbb_data; +static char gbb_data[4096 + sizeof(struct vb2_gbb_header)]; +static struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)gbb_data; static char debug_info[4096]; static struct vb2_context ctx; struct vb2_shared_data *sd; @@ -40,10 +40,10 @@ static void ResetMocks(void) int gbb_used; memset(gbb_data, 0, sizeof(gbb_data)); - gbb->major_version = GBB_MAJOR_VER; - gbb->minor_version = GBB_MINOR_VER; + gbb->major_version = VB2_GBB_MAJOR_VER; + gbb->minor_version = VB2_GBB_MINOR_VER; gbb->flags = 0; - gbb_used = sizeof(GoogleBinaryBlockHeader); + gbb_used = sizeof(struct vb2_gbb_header); gbb->hwid_offset = gbb_used; strcpy(gbb_data + gbb->hwid_offset, "Test HWID"); diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c index e94c5b73..4fd78a82 100644 --- a/tests/vboot_kernel_tests.c +++ b/tests/vboot_kernel_tests.c @@ -19,7 +19,6 @@ #include "cgptlib.h" #include "cgptlib_internal.h" #include "crc32.h" -#include "gbb_header.h" #include "gpt.h" #include "host_common.h" #include "load_kernel_fw.h" @@ -60,8 +59,8 @@ static int verify_data_fail; static int unpack_key_fail; static int gpt_flag_external; -static uint8_t gbb_data[sizeof(GoogleBinaryBlockHeader) + 2048]; -static GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader*)gbb_data; +static uint8_t gbb_data[sizeof(struct vb2_gbb_header) + 2048]; +static struct vb2_gbb_header *gbb = (struct vb2_gbb_header*)gbb_data; static VbExDiskHandle_t handle; static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data; @@ -139,8 +138,8 @@ static void ResetMocks(void) gpt_flag_external = 0; memset(gbb, 0, sizeof(*gbb)); - gbb->major_version = GBB_MAJOR_VER; - gbb->minor_version = GBB_MINOR_VER; + gbb->major_version = VB2_GBB_MAJOR_VER; + gbb->minor_version = VB2_GBB_MINOR_VER; gbb->flags = 0; memset(&shared_data, 0, sizeof(shared_data)); diff --git a/utility/include/gbb_utility.h b/utility/include/gbb_utility.h index 49d6d43a..f1c850fe 100644 --- a/utility/include/gbb_utility.h +++ b/utility/include/gbb_utility.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "gbb_header.h" namespace vboot_reference { @@ -36,7 +35,7 @@ class GoogleBinaryBlockUtil { bool save_to_file(const char *filename); // create a new GBB blob by providing a list of reserved data size for each - // properties, following the order described in GoogleBinaryBlockHeader. + // properties, following the order described in vb2_gbb_header. // return true on success. bool create_new(const std::vector<uint32_t> &create_param); @@ -81,7 +80,7 @@ class GoogleBinaryBlockUtil { // load and check header structure from image by given offset. // return true if a valid GBB header is loaded into *phdr. bool load_gbb_header(const std::string &image, long offset, - GoogleBinaryBlockHeader *phdr) const; + struct vb2_gbb_header *phdr) const; // find the size, offset, and name information for given property. // return true if the offset and size are assign to *poffset and *psize; @@ -90,7 +89,7 @@ class GoogleBinaryBlockUtil { bool find_property(PROPINDEX i, uint32_t *poffset, uint32_t *psize, const char **pname) const; - GoogleBinaryBlockHeader header_; // copy of GBB header from image + struct vb2_gbb_header header_; // copy of GBB header from image std::string file_content_; // complete image file content long header_offset_; // offset to GBB header in file_content_ bool is_valid_gbb; // if we are holding a valid GBB diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c index 6606c425..331e57ad 100644 --- a/utility/load_kernel_test.c +++ b/utility/load_kernel_test.c @@ -17,7 +17,6 @@ #include "2sysincludes.h" #include "2api.h" #include "2misc.h" -#include "gbb_header.h" #include "host_common.h" #include "load_kernel_fw.h" #include "rollback_index.h" @@ -86,7 +85,7 @@ int main(int argc, char* argv[]) { uint64_t key_size; uint8_t* key_blob = NULL; VbSharedDataHeader* shared; - GoogleBinaryBlockHeader* gbb; + struct vb2_gbb_header* gbb; VbError_t rv; int c, argsleft; int errorcnt = 0; @@ -160,13 +159,13 @@ int main(int argc, char* argv[]) { } /* Initialize the GBB */ - uint32_t gbb_size = sizeof(GoogleBinaryBlockHeader) + key_size; - gbb = (GoogleBinaryBlockHeader*)malloc(gbb_size); + uint32_t gbb_size = sizeof(struct vb2_gbb_header) + key_size; + gbb = (struct vb2_gbb_header*)malloc(gbb_size); memset(gbb, 0, gbb_size); - memcpy(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE); - gbb->major_version = GBB_MAJOR_VER; - gbb->minor_version = GBB_MINOR_VER; - gbb->header_size = sizeof(GoogleBinaryBlockHeader); + memcpy(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE); + gbb->major_version = VB2_GBB_MAJOR_VER; + gbb->minor_version = VB2_GBB_MINOR_VER; + gbb->header_size = sizeof(struct vb2_gbb_header); /* Fill in the given key, if any, for both root and recovery */ if (key_blob) { gbb->rootkey_offset = gbb->header_size; |