diff options
author | Duncan Laurie <dlaurie@google.com> | 2019-05-22 17:24:54 -0700 |
---|---|---|
committer | Duncan Laurie <dlaurie@google.com> | 2019-05-23 00:37:48 +0000 |
commit | a32d2df033257f50602e8b2ede0e9e67395a7059 (patch) | |
tree | 56c6617b0ad8465cc324015068f26e1a1bcd6f75 | |
parent | 5c4d3e6396e25be57df602844cf209fecc74b078 (diff) | |
download | vboot-a32d2df033257f50602e8b2ede0e9e67395a7059.tar.gz |
Revert "vboot: deprecate v1 GoogleBinaryBlockHeader struct"
This reverts commit e0a46a061ca3fefed75785f5bdf772a7e1697d8e.
BUG=none
TEST=none
Change-Id: Icd4aa273ac696fc30fd01d561bfbe35b9871a7eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1626763
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Commit-Queue: Duncan Laurie <dlaurie@google.com>
Tested-by: Duncan Laurie <dlaurie@google.com>
29 files changed, 131 insertions, 106 deletions
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c index c8491551..c486d570 100644 --- a/firmware/lib/ec_sync.c +++ b/firmware/lib/ec_sync.c @@ -12,6 +12,7 @@ #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 e34a3d15..ef676873 100644 --- a/firmware/lib/region-init.c +++ b/firmware/lib/region-init.c @@ -12,6 +12,7 @@ #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 2be3e938..77dc3366 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -14,6 +14,7 @@ #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 d735cb41..c43becec 100644 --- a/firmware/lib/vboot_display.c +++ b/firmware/lib/vboot_display.c @@ -13,6 +13,7 @@ #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 7195bdb0..57ab53d4 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -17,6 +17,7 @@ #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 14508a63..e06d5f6b 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -14,6 +14,7 @@ #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" @@ -78,7 +79,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 & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN) + if (sd->gbb_flags & GBB_FLAG_DISABLE_LID_SHUTDOWN) shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED; return shutdown_request; @@ -618,7 +619,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 & - VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) { + 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 42494772..505a4caa 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -12,6 +12,7 @@ #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 84531c4a..02f4757f 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -16,6 +16,7 @@ #include <unistd.h> #include "futility.h" +#include "gbb_header.h" static void print_help(int argc, char *argv[]) { @@ -98,19 +99,18 @@ static void opt_has_arg(const char *name, int val) static int errorcnt; #define GBB_SEARCH_STRIDE 4 -static struct vb2_gbb_header *FindGbbHeader(uint8_t *ptr, size_t size) +static GoogleBinaryBlockHeader *FindGbbHeader(uint8_t *ptr, size_t size) { size_t i; - struct vb2_gbb_header *tmp, *gbb_header = NULL; + GoogleBinaryBlockHeader *tmp, *gbb_header = NULL; int count = 0; for (i = 0; i <= size - GBB_SEARCH_STRIDE; i += GBB_SEARCH_STRIDE) { - if (0 != memcmp(ptr + i, VB2_GBB_SIGNATURE, - VB2_GBB_SIGNATURE_SIZE)) + if (0 != memcmp(ptr + i, GBB_SIGNATURE, GBB_SIGNATURE_SIZE)) continue; /* Found something. See if it's any good. */ - tmp = (struct vb2_gbb_header *) (ptr + i); + tmp = (GoogleBinaryBlockHeader *) (ptr + i); if (futil_valid_gbb_header(tmp, size - i, NULL)) if (!count++) gbb_header = tmp; @@ -132,12 +132,12 @@ static struct vb2_gbb_header *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 = EXPECTED_VB2_GBB_HEADER_SIZE; + size_t size = GBB_HEADER_SIZE; int i = 0; /* Danger Will Robinson! four entries ==> four paramater blocks */ uint32_t val[] = { 0, 0, 0, 0 }; uint8_t *buf; - struct vb2_gbb_header *gbb; + GoogleBinaryBlockHeader *gbb; sizes = strdup(desc); if (!sizes) { @@ -173,14 +173,14 @@ static uint8_t *create_gbb(const char *desc, off_t *sizeptr) *sizeptr = 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 = (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->flags = 0; - i = EXPECTED_VB2_GBB_HEADER_SIZE; + i = 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; - struct vb2_gbb_header *gbb; + GoogleBinaryBlockHeader *gbb; uint8_t *gbb_base; int i; diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c index c458eef6..8b6b2520 100644 --- a/futility/cmd_sign.c +++ b/futility/cmd_sign.c @@ -22,6 +22,7 @@ #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 2e24b75f..0b45be18 100644 --- a/futility/file_type.c +++ b/futility/file_type.c @@ -16,6 +16,7 @@ #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 a04c044b..d79e76f8 100644 --- a/futility/file_type_bios.c +++ b/futility/file_type_bios.c @@ -14,6 +14,7 @@ #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" @@ -51,7 +52,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) { - struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)buf; + GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)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 1de17f7f..9a1ac6dc 100644 --- a/futility/futility.h +++ b/futility/futility.h @@ -9,6 +9,7 @@ #include "2common.h" #include "vboot_common.h" +#include "gbb_header.h" #include "host_key.h" /* This program */ @@ -104,24 +105,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(struct vb2_gbb_header *gbb, uint32_t len); +int futil_looks_like_gbb(GoogleBinaryBlockHeader *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(struct vb2_gbb_header *gbb, uint32_t len, +int futil_valid_gbb_header(GoogleBinaryBlockHeader *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(struct vb2_gbb_header *gbb); +void update_hwid_digest(GoogleBinaryBlockHeader *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(struct vb2_gbb_header *gbb, +int print_hwid_digest(GoogleBinaryBlockHeader *gbb, const char *banner, const char *footer); /* Copies a file or dies with an error message */ @@ -129,11 +130,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 struct vb2_gbb_header *gbb); + const GoogleBinaryBlockHeader *gbb); /* Verify ryu root key header */ int verify_ryu_root_header(uint8_t *ptr, size_t size, - const struct vb2_gbb_header *gbb); + const GoogleBinaryBlockHeader *gbb); /* Possible file operation errors */ enum futil_file_err { diff --git a/futility/misc.c b/futility/misc.c index 82385c1a..333360a8 100644 --- a/futility/misc.c +++ b/futility/misc.c @@ -28,6 +28,7 @@ #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; @@ -62,28 +63,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) { - struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)buf; + GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)buf; - if (memcmp(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE)) + if (memcmp(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE)) return FILE_TYPE_UNKNOWN; - if (gbb->major_version > VB2_GBB_MAJOR_VER) + if (gbb->major_version > GBB_MAJOR_VER) return FILE_TYPE_UNKNOWN; - if (sizeof(struct vb2_gbb_header) > len) + if (sizeof(GoogleBinaryBlockHeader) > len) return FILE_TYPE_UNKNOWN; /* close enough */ return FILE_TYPE_GBB; } -int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len, +int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len, uint32_t *maxlen_ptr) { - if (len < sizeof(struct vb2_gbb_header)) + if (len < sizeof(GoogleBinaryBlockHeader)) return 0; - if (memcmp(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE)) + if (memcmp(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE)) return 0; - if (gbb->major_version != VB2_GBB_MAJOR_VER) + if (gbb->major_version != GBB_MAJOR_VER) return 0; /* Check limits first, to help identify problems */ @@ -100,10 +101,9 @@ int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len, *maxlen_ptr = maxlen; } - if (gbb->header_size != EXPECTED_VB2_GBB_HEADER_SIZE || - gbb->header_size > len) + if (gbb->header_size != GBB_HEADER_SIZE || gbb->header_size > len) return 0; - if (gbb->hwid_offset < EXPECTED_VB2_GBB_HEADER_SIZE) + if (gbb->hwid_offset < GBB_HEADER_SIZE) return 0; if (gbb->hwid_offset + gbb->hwid_size > len) return 0; @@ -113,16 +113,16 @@ int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len, if (!is_null_terminated(s, gbb->hwid_size)) return 0; } - if (gbb->rootkey_offset < EXPECTED_VB2_GBB_HEADER_SIZE) + if (gbb->rootkey_offset < GBB_HEADER_SIZE) return 0; if (gbb->rootkey_offset + gbb->rootkey_size > len) return 0; - if (gbb->bmpfv_offset < EXPECTED_VB2_GBB_HEADER_SIZE) + if (gbb->bmpfv_offset < GBB_HEADER_SIZE) return 0; if (gbb->bmpfv_offset + gbb->bmpfv_size > len) return 0; - if (gbb->recovery_key_offset < EXPECTED_VB2_GBB_HEADER_SIZE) + if (gbb->recovery_key_offset < 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(struct vb2_gbb_header *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(struct vb2_gbb_header *gbb, +int print_hwid_digest(GoogleBinaryBlockHeader *gbb, const char *banner, const char *footer) { printf("%s", banner); @@ -169,7 +169,7 @@ int print_hwid_digest(struct vb2_gbb_header *gbb, /* Deprecated. Use futil_set_gbb_hwid in future. */ /* For GBB v1.2 and later, update the hwid_digest field. */ -void update_hwid_digest(struct vb2_gbb_header *gbb) +void update_hwid_digest(GoogleBinaryBlockHeader *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 48aef431..1865b75c 100644 --- a/futility/ryu_root_header.c +++ b/futility/ryu_root_header.c @@ -19,6 +19,7 @@ #include "2common.h" #include "2sha.h" #include "futility.h" +#include "gbb_header.h" #define SEARCH_STRIDE 4 @@ -96,7 +97,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 struct vb2_gbb_header *gbb) + const GoogleBinaryBlockHeader *gbb) { const uint8_t *gbb_base = (const uint8_t *)gbb; @@ -108,7 +109,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 struct vb2_gbb_header *gbb) + const GoogleBinaryBlockHeader *gbb) { struct vb2_ryu_root_key_hash *hash; @@ -130,7 +131,7 @@ int fill_ryu_root_header(uint8_t *ptr, size_t size, } int verify_ryu_root_header(uint8_t *ptr, size_t size, - const struct vb2_gbb_header *gbb) + const GoogleBinaryBlockHeader *gbb) { uint8_t digest[VB2_SHA256_DIGEST_SIZE] = {0}; diff --git a/futility/updater.c b/futility/updater.c index 859dedee..8dad7d41 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -955,7 +955,12 @@ 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; - if (!futil_valid_gbb_header(gbb_header, section.size, NULL)) { + /* + * 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)) { 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 d4e3cedf..5a9aee7f 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/2lib/include/2gbb_flags.h +# Values from vboot_reference/firmware/include/gbb_header.h GBBFLAGS_DESCRIPTION_PREFIX=" Defined flags (some values may be not supported by all systems): " GBBFLAGS_LIST=" - 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 + 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 " GBBFLAGS_DESCRIPTION_SUFFIX=" diff --git a/scripts/image_signing/make_dev_firmware.sh b/scripts/image_signing/make_dev_firmware.sh index 767dc22c..136b18fb 100755 --- a/scripts/image_signing/make_dev_firmware.sh +++ b/scripts/image_signing/make_dev_firmware.sh @@ -377,8 +377,7 @@ 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: VB2_GBB_FLAG_FORCE_DEV_BOOT_USB | - # VB2_GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK + # 0x30: GBB_FLAG_FORCE_DEV_BOOT_USB | 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 45764048..fb043460 100644 --- a/tests/ec_sync_tests.c +++ b/tests/ec_sync_tests.c @@ -14,6 +14,7 @@ #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 1d69d44d..91756ac3 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 "2struct.h" +#include "gbb_header.h" #include "test_common.h" int main(int argc, char *argv[]) { - TEST_EQ(sizeof(struct vb2_gbb_header), - EXPECTED_VB2_GBB_HEADER_SIZE, - "sizeof(struct vb2_gbb_header)"); + TEST_EQ(sizeof(GoogleBinaryBlockHeader), + GBB_HEADER_SIZE, + "sizeof(GoogleBinaryBlockHeader)"); TEST_EQ(0, 0, "Not Really A"); diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c index ccd4c617..286972c2 100644 --- a/tests/vboot_api_devmode_tests.c +++ b/tests/vboot_api_devmode_tests.c @@ -15,6 +15,7 @@ #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 3203bf05..2d0a7ab5 100644 --- a/tests/vboot_api_kernel2_tests.c +++ b/tests/vboot_api_kernel2_tests.c @@ -13,6 +13,7 @@ #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 a4bc6bec..fdf51da6 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -14,6 +14,7 @@ #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" @@ -32,7 +33,7 @@ static VbCommonParams cparams; static VbSelectAndLoadKernelParams kparams; static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data; -static struct vb2_gbb_header gbb; +static GoogleBinaryBlockHeader gbb; static uint32_t rkr_version; static uint32_t new_version; @@ -56,8 +57,8 @@ static void ResetMocks(void) memset(&kparams, 0, sizeof(kparams)); memset(&gbb, 0, sizeof(gbb)); - gbb.major_version = VB2_GBB_MAJOR_VER; - gbb.minor_version = VB2_GBB_MINOR_VER; + gbb.major_version = GBB_MAJOR_VER; + gbb.minor_version = GBB_MINOR_VER; gbb.flags = 0; /* ctx.workbuf will be initialized by VbSelectAndLoadKernel. */ @@ -211,7 +212,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 |= VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC; + gbb.flags |= 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 a0f89466..8d3281be 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 "2struct.h" +#include "gbb_header.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 struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)gbb_buf; +static GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)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 = VB2_GBB_MAJOR_VER; - gbb->minor_version = VB2_GBB_MINOR_VER; + gbb->major_version = GBB_MAJOR_VER; + gbb->minor_version = 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 = VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; + gbb->flags = 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 = VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; + gbb->flags = 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 = VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP; + gbb->flags = 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 fc0d3893..92f6dcc9 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -13,6 +13,7 @@ #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 05785848..bf71a5f4 100644 --- a/tests/vboot_detach_menu_tests.c +++ b/tests/vboot_detach_menu_tests.c @@ -13,6 +13,7 @@ #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" @@ -279,8 +280,8 @@ static void VbBootDevTest(void) /* Proceed to legacy after timeout if GBB flag set */ ResetMocksForDeveloper(); - sd->gbb_flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY | - VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY; + sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY | + GBB_FLAG_FORCE_DEV_BOOT_LEGACY; TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "default legacy GBB"); TEST_EQ(vbexlegacy_called, 1, " try legacy"); @@ -465,7 +466,7 @@ static void VbBootDevTest(void) /* ENTER functionality is unaffected by GBB flag in detachable UI. */ ResetMocksForDeveloper(); - sd->gbb_flags |= VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM; + sd->gbb_flags |= 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"); @@ -520,7 +521,7 @@ static void VbBootDevTest(void) /* Tonorm ignored if GBB forces dev switch on */ ResetMocksForDeveloper(); shared->flags |= VBSD_BOOT_DEV_SWITCH_ON; - sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON; + sd->gbb_flags |= 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; @@ -581,7 +582,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 |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY; + sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY; TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "Ctrl+D"); TEST_EQ(vbexlegacy_called, 0, " not legacy"); @@ -621,7 +622,7 @@ static void VbBootDevTest(void) /* Ctrl+L boots legacy if enabled by GBB flag */ ResetMocksForDeveloper(); - sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY; + sd->gbb_flags |= 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, @@ -736,7 +737,7 @@ static void VbBootDevTest(void) /* Ctrl+U enabled via GBB */ ResetMocksForDeveloper(); - sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_USB; + sd->gbb_flags |= 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"); @@ -1360,7 +1361,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 |= VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY; + sd->gbb_flags |= 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 16ccd36e..986bb270 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(struct vb2_gbb_header)]; -static struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)gbb_data; +static char gbb_data[4096 + sizeof(GoogleBinaryBlockHeader)]; +static GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)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 = VB2_GBB_MAJOR_VER; - gbb->minor_version = VB2_GBB_MINOR_VER; + gbb->major_version = GBB_MAJOR_VER; + gbb->minor_version = GBB_MINOR_VER; gbb->flags = 0; - gbb_used = sizeof(struct vb2_gbb_header); + gbb_used = sizeof(GoogleBinaryBlockHeader); 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 4fd78a82..e94c5b73 100644 --- a/tests/vboot_kernel_tests.c +++ b/tests/vboot_kernel_tests.c @@ -19,6 +19,7 @@ #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" @@ -59,8 +60,8 @@ static int verify_data_fail; static int unpack_key_fail; static int gpt_flag_external; -static uint8_t gbb_data[sizeof(struct vb2_gbb_header) + 2048]; -static struct vb2_gbb_header *gbb = (struct vb2_gbb_header*)gbb_data; +static uint8_t gbb_data[sizeof(GoogleBinaryBlockHeader) + 2048]; +static GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader*)gbb_data; static VbExDiskHandle_t handle; static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; static VbSharedDataHeader *shared = (VbSharedDataHeader *)shared_data; @@ -138,8 +139,8 @@ static void ResetMocks(void) gpt_flag_external = 0; memset(gbb, 0, sizeof(*gbb)); - gbb->major_version = VB2_GBB_MAJOR_VER; - gbb->minor_version = VB2_GBB_MINOR_VER; + gbb->major_version = GBB_MAJOR_VER; + gbb->minor_version = 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 f1c850fe..49d6d43a 100644 --- a/utility/include/gbb_utility.h +++ b/utility/include/gbb_utility.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "gbb_header.h" namespace vboot_reference { @@ -35,7 +36,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 vb2_gbb_header. + // properties, following the order described in GoogleBinaryBlockHeader. // return true on success. bool create_new(const std::vector<uint32_t> &create_param); @@ -80,7 +81,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, - struct vb2_gbb_header *phdr) const; + GoogleBinaryBlockHeader *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; @@ -89,7 +90,7 @@ class GoogleBinaryBlockUtil { bool find_property(PROPINDEX i, uint32_t *poffset, uint32_t *psize, const char **pname) const; - struct vb2_gbb_header header_; // copy of GBB header from image + GoogleBinaryBlockHeader 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 331e57ad..6606c425 100644 --- a/utility/load_kernel_test.c +++ b/utility/load_kernel_test.c @@ -17,6 +17,7 @@ #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" @@ -85,7 +86,7 @@ int main(int argc, char* argv[]) { uint64_t key_size; uint8_t* key_blob = NULL; VbSharedDataHeader* shared; - struct vb2_gbb_header* gbb; + GoogleBinaryBlockHeader* gbb; VbError_t rv; int c, argsleft; int errorcnt = 0; @@ -159,13 +160,13 @@ int main(int argc, char* argv[]) { } /* Initialize the GBB */ - uint32_t gbb_size = sizeof(struct vb2_gbb_header) + key_size; - gbb = (struct vb2_gbb_header*)malloc(gbb_size); + uint32_t gbb_size = sizeof(GoogleBinaryBlockHeader) + key_size; + gbb = (GoogleBinaryBlockHeader*)malloc(gbb_size); memset(gbb, 0, gbb_size); - 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); + 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); /* Fill in the given key, if any, for both root and recovery */ if (key_blob) { gbb->rootkey_offset = gbb->header_size; |