diff options
-rw-r--r-- | firmware/2lib/2misc.c | 26 | ||||
-rw-r--r-- | firmware/2lib/2nvstorage.c | 4 | ||||
-rw-r--r-- | firmware/2lib/2recovery_reasons.c | 4 | ||||
-rw-r--r-- | firmware/2lib/2stub.c | 2 | ||||
-rw-r--r-- | firmware/2lib/2ui.c | 4 | ||||
-rw-r--r-- | firmware/2lib/2ui_screens.c | 48 | ||||
-rw-r--r-- | firmware/2lib/include/2api.h | 29 | ||||
-rw-r--r-- | firmware/2lib/include/2gbb_flags.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2misc.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2nvstorage.h | 2 | ||||
-rw-r--r-- | firmware/2lib/include/2recovery_reasons.h | 4 | ||||
-rw-r--r-- | firmware/2lib/include/2secdata.h | 2 | ||||
-rw-r--r-- | firmware/2lib/include/2ui.h | 2 | ||||
-rw-r--r-- | firmware/include/vboot_api.h | 27 | ||||
-rw-r--r-- | firmware/stub/vboot_api_stub.c | 2 | ||||
-rw-r--r-- | host/lib/crossystem.c | 22 | ||||
-rwxr-xr-x | scripts/image_signing/gbb_flags_common.sh | 4 | ||||
-rw-r--r-- | tests/vb2_misc_tests.c | 68 | ||||
-rw-r--r-- | tests/vb2_nvstorage_tests.c | 2 | ||||
-rw-r--r-- | tests/vb2_ui_action_tests.c | 79 | ||||
-rw-r--r-- | tests/vb2_ui_tests.c | 57 | ||||
-rw-r--r-- | utility/crossystem.c | 16 |
22 files changed, 213 insertions, 203 deletions
diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c index ec460b32..13cd35a2 100644 --- a/firmware/2lib/2misc.c +++ b/firmware/2lib/2misc.c @@ -250,7 +250,7 @@ vb2_error_t vb2_check_dev_switch(struct vb2_context *ctx) * developer mode. */ vb2_nv_set(ctx, VB2_NV_DEV_BOOT_EXTERNAL, 0); - vb2_nv_set(ctx, VB2_NV_DEV_BOOT_LEGACY, 0); + vb2_nv_set(ctx, VB2_NV_DEV_BOOT_ALTFW, 0); vb2_nv_set(ctx, VB2_NV_DEV_BOOT_SIGNED_ONLY, 0); vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, 0); } @@ -527,8 +527,8 @@ enum vb2_dev_default_boot_target vb2api_get_dev_default_boot_target( { struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); - if (gbb->flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) - return VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY; + if (gbb->flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_ALTFW) + return VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW; switch (vb2_nv_get(ctx, VB2_NV_DEV_DEFAULT_BOOT)) { case VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL: @@ -536,9 +536,9 @@ enum vb2_dev_default_boot_target vb2api_get_dev_default_boot_target( return VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL; break; - case VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY: - if (vb2_dev_boot_legacy_allowed(ctx)) - return VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY; + case VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW: + if (vb2_dev_boot_altfw_allowed(ctx)) + return VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW; break; } @@ -555,14 +555,14 @@ int vb2_dev_boot_allowed(struct vb2_context *ctx) return 1; } -int vb2_dev_boot_legacy_allowed(struct vb2_context *ctx) +int vb2_dev_boot_altfw_allowed(struct vb2_context *ctx) { struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); - return vb2_nv_get(ctx, VB2_NV_DEV_BOOT_LEGACY) || - (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY) || + return vb2_nv_get(ctx, VB2_NV_DEV_BOOT_ALTFW) || + (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_ALTFW) || vb2_secdata_fwmp_get_flag(ctx, - VB2_SECDATA_FWMP_DEV_ENABLE_LEGACY); + VB2_SECDATA_FWMP_DEV_ENABLE_ALTFW); } int vb2_dev_boot_external_allowed(struct vb2_context *ctx) @@ -660,9 +660,9 @@ char *vb2api_get_debug_info(struct vb2_context *ctx) i = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_EXTERNAL); DEBUG_INFO_APPEND("\ndev_boot_usb: %d", i); - /* Add dev_boot_legacy flag */ - i = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_LEGACY); - DEBUG_INFO_APPEND("\ndev_boot_legacy: %d", i); + /* Add dev_boot_altfw flag */ + i = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_ALTFW); + DEBUG_INFO_APPEND("\ndev_boot_altfw: %d", i); /* Add dev_default_boot flag */ i = vb2_nv_get(ctx, VB2_NV_DEV_DEFAULT_BOOT); diff --git a/firmware/2lib/2nvstorage.c b/firmware/2lib/2nvstorage.c index c3cdca5e..1cd5ba25 100644 --- a/firmware/2lib/2nvstorage.c +++ b/firmware/2lib/2nvstorage.c @@ -145,7 +145,7 @@ uint32_t vb2_nv_get(struct vb2_context *ctx, enum vb2_nv_param param) case VB2_NV_DEV_BOOT_EXTERNAL: return GETBIT(VB2_NV_OFFS_DEV, VB2_NV_DEV_FLAG_EXTERNAL); - case VB2_NV_DEV_BOOT_LEGACY: + case VB2_NV_DEV_BOOT_ALTFW: return GETBIT(VB2_NV_OFFS_DEV, VB2_NV_DEV_FLAG_LEGACY); case VB2_NV_DEV_BOOT_SIGNED_ONLY: @@ -331,7 +331,7 @@ void vb2_nv_set(struct vb2_context *ctx, SETBIT(VB2_NV_OFFS_DEV, VB2_NV_DEV_FLAG_EXTERNAL); break; - case VB2_NV_DEV_BOOT_LEGACY: + case VB2_NV_DEV_BOOT_ALTFW: SETBIT(VB2_NV_OFFS_DEV, VB2_NV_DEV_FLAG_LEGACY); break; diff --git a/firmware/2lib/2recovery_reasons.c b/firmware/2lib/2recovery_reasons.c index 093ef863..8c43dcef 100644 --- a/firmware/2lib/2recovery_reasons.c +++ b/firmware/2lib/2recovery_reasons.c @@ -152,8 +152,8 @@ const char *vb2_get_recovery_reason_string(uint8_t code) return "Recovery hash space lock error in RO firmware"; /* 0x60 */ case VB2_RECOVERY_TPM_DISABLE_FAILED: return "Failed to disable TPM before running untrusted code"; - /* 0x61 */ case VB2_RECOVERY_ALTFW_HASH_FAILED: - return "Verification of alternative firmware payload failed"; + /* 0x61 */ case VB2_RECOVERY_ALTFW_HASH_MISMATCH: + return "Verification of alternate bootloader payload failed"; /* 0x62 */ case VB2_RECOVERY_SECDATA_FWMP_INIT: return "FWMP secure NVRAM (TPM) initialization error"; /* 0x63 */ case VB2_RECOVERY_CR50_BOOT_MODE: diff --git a/firmware/2lib/2stub.c b/firmware/2lib/2stub.c index d26ee745..79fcf717 100644 --- a/firmware/2lib/2stub.c +++ b/firmware/2lib/2stub.c @@ -223,7 +223,7 @@ uint32_t vb2ex_get_locale_count(void) } __attribute__((weak)) -uint32_t vb2ex_get_bootloader_count(void) +uint32_t vb2ex_get_altfw_count(void) { return 0; } diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c index 10de1760..80d0568d 100644 --- a/firmware/2lib/2ui.c +++ b/firmware/2lib/2ui.c @@ -422,8 +422,8 @@ vb2_error_t developer_action(struct vb2_ui_context *ui) if (ui->key == VB_KEY_CTRL('D') || (DETACHABLE && ui->key == VB_BUTTON_VOL_DOWN_LONG_PRESS)) return vb2_ui_developer_mode_boot_internal_action(ui); - if (ui->key == VB_KEY_CTRL('L')) - return vb2_ui_developer_mode_boot_alternate_action(ui); + if (ui->key == VB_KEY_CTRL('L')) /* L for aLtfw (formerly Legacy) */ + return vb2_ui_developer_mode_boot_altfw_action(ui); if (ui->key == '\t') return vb2_ui_screen_change(ui, VB2_SCREEN_DEBUG_INFO); diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c index 4aeeda14..a3ee41a5 100644 --- a/firmware/2lib/2ui_screens.c +++ b/firmware/2lib/2ui_screens.c @@ -681,7 +681,7 @@ static const struct vb2_screen_info recovery_disk_step3_screen = { #define DEVELOPER_MODE_ITEM_RETURN_TO_SECURE 1 #define DEVELOPER_MODE_ITEM_BOOT_INTERNAL 2 #define DEVELOPER_MODE_ITEM_BOOT_EXTERNAL 3 -#define DEVELOPER_MODE_ITEM_SELECT_BOOTLOADER 4 +#define DEVELOPER_MODE_ITEM_SELECT_ALTFW 4 vb2_error_t developer_mode_init(struct vb2_ui_context *ui) { @@ -703,18 +703,18 @@ vb2_error_t developer_mode_init(struct vb2_ui_context *ui) DEVELOPER_MODE_ITEM_BOOT_EXTERNAL); /* Don't show "Select alternate bootloader" button if not allowed. */ - if (!vb2_dev_boot_legacy_allowed(ui->ctx)) + if (!vb2_dev_boot_altfw_allowed(ui->ctx)) VB2_SET_BIT(ui->state->hidden_item_mask, - DEVELOPER_MODE_ITEM_SELECT_BOOTLOADER); + DEVELOPER_MODE_ITEM_SELECT_ALTFW); /* Choose the default selection. */ switch (default_boot) { case VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL: ui->state->selected_item = DEVELOPER_MODE_ITEM_BOOT_EXTERNAL; break; - case VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY: + case VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW: ui->state->selected_item = - DEVELOPER_MODE_ITEM_SELECT_BOOTLOADER; + DEVELOPER_MODE_ITEM_SELECT_ALTFW; break; default: ui->state->selected_item = DEVELOPER_MODE_ITEM_BOOT_INTERNAL; @@ -831,9 +831,9 @@ static const struct vb2_menu_item developer_mode_items[] = { .text = "Boot from external disk", .action = vb2_ui_developer_mode_boot_external_action, }, - [DEVELOPER_MODE_ITEM_SELECT_BOOTLOADER] = { + [DEVELOPER_MODE_ITEM_SELECT_ALTFW] = { .text = "Select alternate bootloader", - .target = VB2_SCREEN_DEVELOPER_SELECT_BOOTLOADER, + .target = VB2_SCREEN_DEVELOPER_SELECT_ALTFW, }, ADVANCED_OPTIONS_ITEM, POWER_OFF_ITEM, @@ -929,7 +929,7 @@ static const struct vb2_screen_info developer_invalid_disk_screen = { }; /******************************************************************************/ -/* VB2_SCREEN_DEVELOPER_SELECT_BOOTLOADER */ +/* VB2_SCREEN_DEVELOPER_SELECT_ALTFW */ static const struct vb2_menu_item developer_select_bootloader_items_before[] = { LANGUAGE_SELECT_ITEM, @@ -943,7 +943,7 @@ static const struct vb2_menu_item developer_select_bootloader_items_after[] = { static vb2_error_t developer_select_bootloader_init(struct vb2_ui_context *ui) { if (get_menu(ui)->num_items == 0) { - ui->error_code = VB2_UI_ERROR_NO_BOOTLOADER; + ui->error_code = VB2_UI_ERROR_ALTFW_EMPTY; return vb2_ui_screen_back(ui); } /* Select the first bootloader. */ @@ -952,40 +952,40 @@ static vb2_error_t developer_select_bootloader_init(struct vb2_ui_context *ui) return VB2_REQUEST_UI_CONTINUE; } -vb2_error_t vb2_ui_developer_mode_boot_alternate_action( +vb2_error_t vb2_ui_developer_mode_boot_altfw_action( struct vb2_ui_context *ui) { - uint32_t altfw_num; + uint32_t altfw_id; const size_t menu_before_len = ARRAY_SIZE(developer_select_bootloader_items_before); if (!(ui->ctx->flags & VB2_CONTEXT_DEVELOPER_MODE) || !vb2_dev_boot_allowed(ui->ctx) || - !vb2_dev_boot_legacy_allowed(ui->ctx)) { + !vb2_dev_boot_altfw_allowed(ui->ctx)) { VB2_DEBUG("ERROR: Dev mode alternate bootloader not allowed\n"); - ui->error_code = VB2_UI_ERROR_ALTERNATE_BOOT_DISABLED; + ui->error_code = VB2_UI_ERROR_ALTFW_DISABLED; return VB2_REQUEST_UI_CONTINUE; } - if (vb2ex_get_bootloader_count() == 0) { + if (vb2ex_get_altfw_count() == 0) { VB2_DEBUG("ERROR: No alternate bootloader was found\n"); - ui->error_code = VB2_UI_ERROR_NO_BOOTLOADER; + ui->error_code = VB2_UI_ERROR_ALTFW_EMPTY; return VB2_REQUEST_UI_CONTINUE; } if (ui->key == VB_KEY_CTRL('L')) { - altfw_num = 0; + altfw_id = 0; VB2_DEBUG("Try booting from default bootloader\n"); } else { - altfw_num = ui->state->selected_item - menu_before_len + 1; - VB2_DEBUG("Try booting from bootloader #%u\n", altfw_num); + altfw_id = ui->state->selected_item - menu_before_len + 1; + VB2_DEBUG("Try booting from bootloader #%u\n", altfw_id); } - /* VbExLegacy will not return if successful */ - VbExLegacy(altfw_num); + /* vb2ex_run_altfw will not return if successful */ + vb2ex_run_altfw(altfw_id); VB2_DEBUG("ERROR: Alternate bootloader failed\n"); - ui->error_code = VB2_UI_ERROR_ALTERNATE_BOOT_FAILED; + ui->error_code = VB2_UI_ERROR_ALTFW_FAILED; return VB2_REQUEST_UI_CONTINUE; } @@ -1002,7 +1002,7 @@ static const struct vb2_menu *get_bootloader_menu(struct vb2_ui_context *ui) if (ui->bootloader_menu.num_items > 0) return &ui->bootloader_menu; - num_bootloaders = vb2ex_get_bootloader_count(); + num_bootloaders = vb2ex_get_altfw_count(); if (num_bootloaders == 0) { VB2_DEBUG("ERROR: No bootloader was found\n"); return NULL; @@ -1024,7 +1024,7 @@ static const struct vb2_menu *get_bootloader_menu(struct vb2_ui_context *ui) for (i = 0; i < num_bootloaders; i++) { items[i + menu_before_len].text = "Some bootloader"; items[i + menu_before_len].action = - vb2_ui_developer_mode_boot_alternate_action; + vb2_ui_developer_mode_boot_altfw_action; } /* Copy postfix items to the end. */ @@ -1039,7 +1039,7 @@ static const struct vb2_menu *get_bootloader_menu(struct vb2_ui_context *ui) } static const struct vb2_screen_info developer_select_bootloader_screen = { - .id = VB2_SCREEN_DEVELOPER_SELECT_BOOTLOADER, + .id = VB2_SCREEN_DEVELOPER_SELECT_ALTFW, .name = "Select alternate bootloader", .init = developer_select_bootloader_init, .get_menu = get_bootloader_menu, diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index 5ea06e2f..2b7fce4a 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -875,8 +875,8 @@ enum vb2_dev_default_boot_target { /* Default to boot from external disk. */ VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL = 1, - /* Default to boot legacy OS. */ - VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY = 2, + /* Default to boot altfw. */ + VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW = 2, }; /** @@ -1339,8 +1339,8 @@ enum vb2_screen { VB2_SCREEN_DEVELOPER_BOOT_EXTERNAL = 0x320, /* Invalid external disk inserted */ VB2_SCREEN_DEVELOPER_INVALID_DISK = 0x330, - /* Select alternate bootloader ("legacy boot") */ - VB2_SCREEN_DEVELOPER_SELECT_BOOTLOADER = 0x340, + /* Select alternate bootloader ("altfw") */ + VB2_SCREEN_DEVELOPER_SELECT_ALTFW = 0x340, /* Diagnostic tools */ VB2_SCREEN_DIAGNOSTICS = 0x400, /* Storage diagnostic screen */ @@ -1366,11 +1366,11 @@ enum vb2_ui_error { /* Untrusted confirmation */ VB2_UI_ERROR_UNTRUSTED_CONFIRMATION, /* Alternate bootloader is disabled */ - VB2_UI_ERROR_ALTERNATE_BOOT_DISABLED, - /* No bootloader was found */ - VB2_UI_ERROR_NO_BOOTLOADER, + VB2_UI_ERROR_ALTFW_DISABLED, + /* No alternate bootloader was found */ + VB2_UI_ERROR_ALTFW_EMPTY, /* Alternate bootloader failed */ - VB2_UI_ERROR_ALTERNATE_BOOT_FAILED, + VB2_UI_ERROR_ALTFW_FAILED, /* Diagnostics internal failure */ VB2_UI_ERROR_DIAGNOSTICS, }; @@ -1426,7 +1426,18 @@ uint32_t vb2ex_get_locale_count(void); * * @return Number of alternate bootloaders. 0 if none or on error. */ -uint32_t vb2ex_get_bootloader_count(void); +uint32_t vb2ex_get_altfw_count(void); + +/** + * Run alternate bootloader. + * + * @param altfw_id ID of alternate bootloader to run, where + * altfw_id <= vb2ex_get_altfw_count(). 0 for default, + * which corresponds to an alternate bootloader in + * the range 1 <= altfw_id <= vb2ex_getfw_count(). + * @return VB2_SUCCESS, or error code on error. + */ +vb2_error_t vb2ex_run_altfw(uint32_t altfw_id); /** * Delay for at least the specified number of milliseconds. diff --git a/firmware/2lib/include/2gbb_flags.h b/firmware/2lib/include/2gbb_flags.h index c1c937c9..0eff7f70 100644 --- a/firmware/2lib/include/2gbb_flags.h +++ b/firmware/2lib/include/2gbb_flags.h @@ -53,8 +53,8 @@ enum vb2_gbb_flag { /* Allow Enter key to trigger dev->tonorm screen transition */ VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM = 1 << 6, - /* Allow booting Legacy OSes in dev mode even if dev_boot_legacy=0. */ - VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY = 1 << 7, + /* Allow booting Legacy OSes in dev mode even if dev_boot_altfw=0. */ + VB2_GBB_FLAG_FORCE_DEV_BOOT_ALTFW = 1 << 7, /* * Currently running FAFT tests. May be used as a hint to disable @@ -69,7 +69,7 @@ enum vb2_gbb_flag { VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC = 1 << 9, /* Default to booting legacy OS when dev screen times out */ - VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY = 1 << 10, + VB2_GBB_FLAG_DEFAULT_DEV_BOOT_ALTFW = 1 << 10, /* Disable auxiliary firmware (auxfw) software sync */ VB2_GBB_FLAG_DISABLE_AUXFW_SOFTWARE_SYNC = 1 << 11, diff --git a/firmware/2lib/include/2misc.h b/firmware/2lib/include/2misc.h index 334b1485..3d96293b 100644 --- a/firmware/2lib/include/2misc.h +++ b/firmware/2lib/include/2misc.h @@ -224,13 +224,13 @@ int vb2_dev_boot_allowed(struct vb2_context *ctx); * Determine if booting from legacy BIOS is allowed. * * Legacy BIOS is allowed if any of these flags are set: - * VB2_NV_DEV_BOOT_LEGACY, VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY, and - * VB2_SECDATA_FWMP_DEV_ENABLE_LEGACY. + * VB2_NV_DEV_BOOT_ALTFW, VB2_GBB_FLAG_FORCE_DEV_BOOT_ALTFW, and + * VB2_SECDATA_FWMP_DEV_ENABLE_ALTFW. * * @param ctx Vboot context * @return 1 if allowed, or 0 otherwise. */ -int vb2_dev_boot_legacy_allowed(struct vb2_context *ctx); +int vb2_dev_boot_altfw_allowed(struct vb2_context *ctx); /** * Determine if booting from external disk is allowed. diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h index 9de8056e..2f40b233 100644 --- a/firmware/2lib/include/2nvstorage.h +++ b/firmware/2lib/include/2nvstorage.h @@ -49,7 +49,7 @@ enum vb2_nv_param { /* Allow booting from external disk in developer mode. 0=no, 1=yes. */ VB2_NV_DEV_BOOT_EXTERNAL, /* Allow booting of legacy OSes in developer mode. 0=no, 1=yes. */ - VB2_NV_DEV_BOOT_LEGACY, + VB2_NV_DEV_BOOT_ALTFW, /* Only boot Google-signed images in developer mode. 0=no, 1=yes. */ VB2_NV_DEV_BOOT_SIGNED_ONLY, /* diff --git a/firmware/2lib/include/2recovery_reasons.h b/firmware/2lib/include/2recovery_reasons.h index e8cff424..30dbd2e3 100644 --- a/firmware/2lib/include/2recovery_reasons.h +++ b/firmware/2lib/include/2recovery_reasons.h @@ -265,8 +265,8 @@ enum vb2_nv_recovery { /* Failed to disable the TPM [prior to running untrusted code] */ VB2_RECOVERY_TPM_DISABLE_FAILED = 0x60, - /* Alt FW Failed hash verification */ - VB2_RECOVERY_ALTFW_HASH_FAILED = 0x61, + /* Verification of altfw payload failed (deprecated) */ + VB2_RECOVERY_ALTFW_HASH_MISMATCH = 0x61, /* FWMP secure data initialization error */ VB2_RECOVERY_SECDATA_FWMP_INIT = 0x62, diff --git a/firmware/2lib/include/2secdata.h b/firmware/2lib/include/2secdata.h index 5e419340..f9a0e308 100644 --- a/firmware/2lib/include/2secdata.h +++ b/firmware/2lib/include/2secdata.h @@ -181,7 +181,7 @@ enum vb2_secdata_fwmp_flags { VB2_SECDATA_FWMP_DEV_DISABLE_BOOT = (1 << 0), VB2_SECDATA_FWMP_DEV_DISABLE_RECOVERY = (1 << 1), VB2_SECDATA_FWMP_DEV_ENABLE_EXTERNAL = (1 << 2), - VB2_SECDATA_FWMP_DEV_ENABLE_LEGACY = (1 << 3), + VB2_SECDATA_FWMP_DEV_ENABLE_ALTFW = (1 << 3), VB2_SECDATA_FWMP_DEV_ENABLE_OFFICIAL_ONLY = (1 << 4), VB2_SECDATA_FWMP_DEV_USE_KEY_HASH = (1 << 5), /* CCD = case-closed debugging on cr50; flag implemented on cr50 */ diff --git a/firmware/2lib/include/2ui.h b/firmware/2lib/include/2ui.h index 2e1f3651..c5d13311 100644 --- a/firmware/2lib/include/2ui.h +++ b/firmware/2lib/include/2ui.h @@ -132,7 +132,7 @@ vb2_error_t vb2_ui_developer_mode_boot_internal_action( struct vb2_ui_context *ui); vb2_error_t vb2_ui_developer_mode_boot_external_action( struct vb2_ui_context *ui); -vb2_error_t vb2_ui_developer_mode_boot_alternate_action( +vb2_error_t vb2_ui_developer_mode_boot_altfw_action( struct vb2_ui_context *ui); /** diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 739019ad..43752e4a 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -355,33 +355,6 @@ uint32_t VbExIsShutdownRequested(void); /* Shutdown requested due to a power button being pressed. */ #define VB_SHUTDOWN_REQUEST_POWER_BUTTON 0x00000004 -enum VbAltFwIndex_t { - VB_ALTFW_DIAGNOSTIC = -1, - VB_ALTFW_DEFAULT = 0, - VB_ALTFW_FIRST = 1, - VB_ALTFW_SECOND, - VB_ALTFW_THIRD, - VB_ALTFW_FOURTH, - VB_ALTFW_FIFTH, - VB_ALTFW_SIXTH, - VB_ALTFW_SEVENTH, - VB_ALTFW_EIGHTH, - VB_ALTFW_NINTH, -}; - -/** - * Execute legacy boot option. - * - * @param altfw_num Bootloader sequence number to execute. Use - * 0 to boot the default payload, if any - * >0 (i.e., positive #) run a payload by # based in altfw/list file - * <0 (i.e., negative #) run a specific payload by name without using - * the altfw/list file. Typically payloads in this category will be - * verified before they are run. Currently these #s are defined: - * -1 diagnostic payload - */ -vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c index a0da9ae1..bc5f2fe9 100644 --- a/firmware/stub/vboot_api_stub.c +++ b/firmware/stub/vboot_api_stub.c @@ -37,7 +37,7 @@ uint32_t VbExIsShutdownRequested(void) } __attribute__((weak)) -vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num) +vb2_error_t vb2ex_run_altfw(uint32_t altfw_id) { return VB2_SUCCESS; } diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c index 67149e59..9d23091f 100644 --- a/host/lib/crossystem.c +++ b/host/lib/crossystem.c @@ -69,7 +69,7 @@ typedef enum VbBuildOption { } VbBuildOption; static const char *fw_results[] = {"unknown", "trying", "success", "failure"}; -static const char *default_boot[] = {"disk", "usb", "legacy"}; +static const char *default_boot[] = {"disk", "usb", "altfw"}; /* Masks for kern_nv usage by kernel. */ #define KERN_NV_FWUPDATE_TRIES_MASK 0x000F @@ -420,8 +420,9 @@ int VbGetSystemPropertyInt(const char *name) value = vb2_get_nv_storage(VB2_NV_BACKUP_NVRAM_REQUEST); } else if (!strcasecmp(name,"dev_boot_usb")) { value = vb2_get_nv_storage(VB2_NV_DEV_BOOT_EXTERNAL); - } else if (!strcasecmp(name,"dev_boot_legacy")) { - value = vb2_get_nv_storage(VB2_NV_DEV_BOOT_LEGACY); + } else if (!strcasecmp(name,"dev_boot_altfw") || + !strcasecmp(name,"dev_boot_legacy")) { + value = vb2_get_nv_storage(VB2_NV_DEV_BOOT_ALTFW); } else if (!strcasecmp(name,"dev_boot_signed_only")) { value = vb2_get_nv_storage(VB2_NV_DEV_BOOT_SIGNED_ONLY); } else if (!strcasecmp(name,"dev_enable_udc")) { @@ -630,9 +631,10 @@ int VbSetSystemPropertyInt(const char *name, int value) } else if (!strcasecmp(name,"dev_boot_usb")) { return vb2_set_nv_storage_with_backup( VB2_NV_DEV_BOOT_EXTERNAL, value); - } else if (!strcasecmp(name,"dev_boot_legacy")) { + } else if (!strcasecmp(name,"dev_boot_altfw") || + !strcasecmp(name,"dev_boot_legacy")) { return vb2_set_nv_storage_with_backup( - VB2_NV_DEV_BOOT_LEGACY, value); + VB2_NV_DEV_BOOT_ALTFW, value); } else if (!strcasecmp(name,"dev_boot_signed_only")) { return vb2_set_nv_storage_with_backup( VB2_NV_DEV_BOOT_SIGNED_ONLY, value); @@ -681,6 +683,16 @@ int VbSetSystemPropertyString(const char* name, const char* value) } else if (!strcasecmp(name, "dev_default_boot")) { int i; + /* "legacy" term deprecated in favour of "altfw" + (see: b/179458327) */ + if (!strcasecmp(value, "legacy")) { + fprintf(stderr, + "!!!\n" + "!!! PLEASE USE 'altfw' INSTEAD OF 'legacy'\n" + "!!!\n"); + value = "altfw"; + } + for (i = 0; i < ARRAY_SIZE(default_boot); i++) { if (!strcasecmp(value, default_boot[i])) return vb2_set_nv_storage( diff --git a/scripts/image_signing/gbb_flags_common.sh b/scripts/image_signing/gbb_flags_common.sh index 100f37d1..9577f7ac 100755 --- a/scripts/image_signing/gbb_flags_common.sh +++ b/scripts/image_signing/gbb_flags_common.sh @@ -26,10 +26,10 @@ GBBFLAGS_LIST=" 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_FORCE_DEV_BOOT_ALTFW 0x00000080 VB2_GBB_FLAG_RUNNING_FAFT 0x00000100 VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC 0x00000200 - VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400 + VB2_GBB_FLAG_DEFAULT_DEV_BOOT_ALTFW 0x00000400 VB2_GBB_FLAG_DISABLE_AUXFW_SOFTWARE_SYNC 0x00000800 VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN 0x00001000 VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY 0x00004000 diff --git a/tests/vb2_misc_tests.c b/tests/vb2_misc_tests.c index c64552c2..a7cc1155 100644 --- a/tests/vb2_misc_tests.c +++ b/tests/vb2_misc_tests.c @@ -505,14 +505,14 @@ static void dev_switch_tests(void) /* Any normal mode boot clears dev boot flags */ reset_common_data(); vb2_nv_set(ctx, VB2_NV_DEV_BOOT_EXTERNAL, 1); - vb2_nv_set(ctx, VB2_NV_DEV_BOOT_LEGACY, 1); + vb2_nv_set(ctx, VB2_NV_DEV_BOOT_ALTFW, 1); vb2_nv_set(ctx, VB2_NV_DEV_BOOT_SIGNED_ONLY, 1); vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, 1); TEST_SUCC(vb2_check_dev_switch(ctx), "dev mode off"); TEST_EQ(vb2_nv_get(ctx, VB2_NV_DEV_BOOT_EXTERNAL), 0, " cleared dev boot external"); - TEST_EQ(vb2_nv_get(ctx, VB2_NV_DEV_BOOT_LEGACY), - 0, " cleared dev boot legacy"); + TEST_EQ(vb2_nv_get(ctx, VB2_NV_DEV_BOOT_ALTFW), + 0, " cleared dev boot altfw"); TEST_EQ(vb2_nv_get(ctx, VB2_NV_DEV_BOOT_SIGNED_ONLY), 0, " cleared dev boot signed only"); TEST_EQ(vb2_nv_get(ctx, VB2_NV_DEV_DEFAULT_BOOT), @@ -892,14 +892,14 @@ static void dev_default_boot_tests(void) VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL, "no default boot, boot disk"); - /* Set boot legacy by GBB */ + /* Set boot altfw by GBB */ reset_common_data(); - gbb.flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY; + gbb.flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_ALTFW; vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL); TEST_EQ(vb2api_get_dev_default_boot_target(ctx), - VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY, - "GBB set default boot legacy"); + VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW, + "GBB set default boot altfw"); /* Boot from internal disk */ reset_common_data(); @@ -926,36 +926,36 @@ static void dev_default_boot_tests(void) VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL, "default boot external not allowed"); reset_common_data(); - vb2_nv_set(ctx, VB2_NV_DEV_BOOT_LEGACY, 1); + vb2_nv_set(ctx, VB2_NV_DEV_BOOT_ALTFW, 1); vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL); TEST_EQ(vb2api_get_dev_default_boot_target(ctx), VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL, "default boot external not allowed"); - /* Boot legacy */ + /* Boot altfw */ reset_common_data(); - vb2_nv_set(ctx, VB2_NV_DEV_BOOT_LEGACY, 1); + vb2_nv_set(ctx, VB2_NV_DEV_BOOT_ALTFW, 1); vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, - VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY); + VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW); TEST_EQ(vb2api_get_dev_default_boot_target(ctx), - VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY, - "set default boot legacy"); + VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW, + "set default boot altfw"); - /* Boot legacy not allowed */ + /* Boot altfw not allowed */ reset_common_data(); vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, - VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY); + VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW); TEST_EQ(vb2api_get_dev_default_boot_target(ctx), VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL, - "default boot legacy not allowed"); + "default boot altfw not allowed"); reset_common_data(); vb2_nv_set(ctx, VB2_NV_DEV_BOOT_EXTERNAL, 1); vb2_nv_set(ctx, VB2_NV_DEV_DEFAULT_BOOT, - VB2_DEV_DEFAULT_BOOT_TARGET_LEGACY); + VB2_DEV_DEFAULT_BOOT_TARGET_ALTFW); TEST_EQ(vb2api_get_dev_default_boot_target(ctx), VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL, - "default boot legacy not allowed"); + "default boot altfw not allowed"); } static void dev_boot_allowed_tests(void) @@ -977,34 +977,34 @@ static void dev_boot_allowed_tests(void) /* Legacy boot - not allowed by default */ reset_common_data(); - TEST_EQ(vb2_dev_boot_legacy_allowed(ctx), 0, - "dev boot legacy - not allowed by default"); + TEST_EQ(vb2_dev_boot_altfw_allowed(ctx), 0, + "dev boot altfw - not allowed by default"); /* Legacy boot - enabled by nvdata */ reset_common_data(); - vb2_nv_set(ctx, VB2_NV_DEV_BOOT_LEGACY, 1); - TEST_EQ(vb2_dev_boot_legacy_allowed(ctx), 1, - "dev boot legacy - nvdata enabled"); + vb2_nv_set(ctx, VB2_NV_DEV_BOOT_ALTFW, 1); + TEST_EQ(vb2_dev_boot_altfw_allowed(ctx), 1, + "dev boot altfw - nvdata enabled"); /* Legacy boot - enabled by FWMP */ reset_common_data(); - fwmp->flags |= VB2_SECDATA_FWMP_DEV_ENABLE_LEGACY; - TEST_EQ(vb2_dev_boot_legacy_allowed(ctx), 1, - "dev boot legacy - secdata enabled"); + fwmp->flags |= VB2_SECDATA_FWMP_DEV_ENABLE_ALTFW; + TEST_EQ(vb2_dev_boot_altfw_allowed(ctx), 1, + "dev boot altfw - secdata enabled"); /* Legacy boot - force enabled by GBB */ reset_common_data(); - gbb.flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY; - TEST_EQ(vb2_dev_boot_legacy_allowed(ctx), 1, - "dev boot legacy - GBB force enabled"); + gbb.flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_ALTFW; + TEST_EQ(vb2_dev_boot_altfw_allowed(ctx), 1, + "dev boot altfw - GBB force enabled"); /* Legacy boot - set all flags */ reset_common_data(); - vb2_nv_set(ctx, VB2_NV_DEV_BOOT_LEGACY, 1); - fwmp->flags |= VB2_SECDATA_FWMP_DEV_ENABLE_LEGACY; - gbb.flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY; - TEST_EQ(vb2_dev_boot_legacy_allowed(ctx), 1, - "dev boot legacy - all flags set"); + vb2_nv_set(ctx, VB2_NV_DEV_BOOT_ALTFW, 1); + fwmp->flags |= VB2_SECDATA_FWMP_DEV_ENABLE_ALTFW; + gbb.flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_ALTFW; + TEST_EQ(vb2_dev_boot_altfw_allowed(ctx), 1, + "dev boot altfw - all flags set"); /* External boot - not allowed by default */ reset_common_data(); diff --git a/tests/vb2_nvstorage_tests.c b/tests/vb2_nvstorage_tests.c index a49f162d..94bcfcab 100644 --- a/tests/vb2_nvstorage_tests.c +++ b/tests/vb2_nvstorage_tests.c @@ -41,7 +41,7 @@ static struct nv_field nvfields[] = { {VB2_NV_LOCALIZATION_INDEX, 0, 0x69, 0xB0, "localization index"}, {VB2_NV_KERNEL_FIELD, 0, 0x1234, 0xFEDC, "kernel field"}, {VB2_NV_DEV_BOOT_EXTERNAL, 0, 1, 0, "dev boot usb"}, - {VB2_NV_DEV_BOOT_LEGACY, 0, 1, 0, "dev boot legacy"}, + {VB2_NV_DEV_BOOT_ALTFW, 0, 1, 0, "dev boot altfw"}, {VB2_NV_DEV_BOOT_SIGNED_ONLY, 0, 1, 0, "dev boot custom"}, {VB2_NV_DEV_DEFAULT_BOOT, 0, 1, 2, "dev default boot"}, {VB2_NV_DIAG_REQUEST, 0, 1, 0, "diagnostic rom request"}, diff --git a/tests/vb2_ui_action_tests.c b/tests/vb2_ui_action_tests.c index f6f18dcc..68c41c25 100644 --- a/tests/vb2_ui_action_tests.c +++ b/tests/vb2_ui_action_tests.c @@ -65,11 +65,11 @@ static vb2_error_t mock_vbtlk_retval; static uint32_t mock_vbtlk_expected_flag; static int mock_dev_boot_allowed; -static int mock_dev_boot_legacy_allowed; +static int mock_dev_boot_altfw_allowed; -static int mock_vbexlegacy_called; -static enum VbAltFwIndex_t mock_altfw_num_last; -static uint32_t mock_bootloader_count; +static int mock_run_altfw_called; +static uint32_t mock_altfw_last; +static uint32_t mock_altfw_count; static uint32_t mock_time_ms; static const uint32_t mock_time_start_ms = 31ULL * VB2_MSEC_PER_SEC; @@ -360,12 +360,12 @@ static void reset_common_data(void) /* For dev_boot* in 2misc.h */ mock_dev_boot_allowed = 1; - mock_dev_boot_legacy_allowed = 0; + mock_dev_boot_altfw_allowed = 0; - /* For VbExLegacy */ - mock_vbexlegacy_called = 0; - mock_altfw_num_last = -100; - mock_bootloader_count = 2; + /* For vb2ex_run_altfw */ + mock_run_altfw_called = 0; + mock_altfw_last = -100; + mock_altfw_count = 2; /* For vb2ex_mtime and vb2ex_msleep */ mock_time_ms = mock_time_start_ms; @@ -492,25 +492,25 @@ int vb2_dev_boot_allowed(struct vb2_context *c) return mock_dev_boot_allowed; } -int vb2_dev_boot_legacy_allowed(struct vb2_context *c) +int vb2_dev_boot_altfw_allowed(struct vb2_context *c) { - return mock_dev_boot_legacy_allowed; + return mock_dev_boot_altfw_allowed; } -vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num) +vb2_error_t vb2ex_run_altfw(uint32_t altfw_id) { - mock_vbexlegacy_called++; - mock_altfw_num_last = altfw_num; + mock_run_altfw_called++; + mock_altfw_last = altfw_id; - if (altfw_num <= mock_bootloader_count) + if (altfw_id <= mock_altfw_count) return VB2_SUCCESS; else return VB2_ERROR_UNKNOWN; } -uint32_t vb2ex_get_bootloader_count(void) +uint32_t vb2ex_get_altfw_count(void) { - return mock_bootloader_count; + return mock_altfw_count; } uint32_t vb2ex_mtime(void) @@ -740,54 +740,59 @@ static void menu_select_tests(void) VB2_DEBUG("...done.\n"); } -static void vb2_ui_developer_mode_boot_alternate_action_tests(void) +static void vb2_ui_developer_mode_boot_altfw_action_tests(void) { VB2_DEBUG("Test developer mode boot alternate action...\n"); /* Not allowed: not in dev mode */ reset_common_data(); - mock_dev_boot_legacy_allowed = 1; - TEST_EQ(vb2_ui_developer_mode_boot_alternate_action(&mock_ui_context), + mock_dev_boot_altfw_allowed = 1; + TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context), VB2_REQUEST_UI_CONTINUE, "not allowed: not in dev mode"); - TEST_EQ(mock_vbexlegacy_called, 0, " VbExLegacy not called"); + TEST_EQ(mock_run_altfw_called, 0, + " vb2ex_run_altfw not called"); /* Not allowed: dev boot not allowed */ reset_common_data(); ctx->flags |= VB2_CONTEXT_DEVELOPER_MODE; mock_dev_boot_allowed = 0; - mock_dev_boot_legacy_allowed = 1; - TEST_EQ(vb2_ui_developer_mode_boot_alternate_action(&mock_ui_context), + mock_dev_boot_altfw_allowed = 1; + TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context), VB2_REQUEST_UI_CONTINUE, "not allowed: dev boot not allowed"); - TEST_EQ(mock_vbexlegacy_called, 0, " VbExLegacy not called"); + TEST_EQ(mock_run_altfw_called, 0, + " vb2ex_run_altfw not called"); - /* Not allowed: boot legacy not allowed */ + /* Not allowed: boot altfw not allowed */ reset_common_data(); ctx->flags |= VB2_CONTEXT_DEVELOPER_MODE; - TEST_EQ(vb2_ui_developer_mode_boot_alternate_action(&mock_ui_context), + TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context), VB2_REQUEST_UI_CONTINUE, - "not allowed: boot legacy not allowed"); - TEST_EQ(mock_vbexlegacy_called, 0, " VbExLegacy not called"); + "not allowed: boot altfw not allowed"); + TEST_EQ(mock_run_altfw_called, 0, + " vb2ex_run_altfw not called"); /* Allowed */ reset_common_data(); ctx->flags |= VB2_CONTEXT_DEVELOPER_MODE; - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; mock_ui_context.state->selected_item = 2; - TEST_EQ(vb2_ui_developer_mode_boot_alternate_action(&mock_ui_context), + TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context), VB2_REQUEST_UI_CONTINUE, "allowed"); - TEST_EQ(mock_vbexlegacy_called, 1, " VbExLegacy called once"); - TEST_EQ(mock_altfw_num_last, 2, " select bootloader #2"); + TEST_EQ(mock_run_altfw_called, 1, + " vb2ex_run_altfw called once"); + TEST_EQ(mock_altfw_last, 2, " select bootloader #2"); /* CTRL+L = default bootloader */ reset_common_data(); ctx->flags |= VB2_CONTEXT_DEVELOPER_MODE; - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; mock_ui_context.key = VB_KEY_CTRL('L'); mock_ui_context.state->selected_item = 4; /* Ignored */ - TEST_EQ(vb2_ui_developer_mode_boot_alternate_action(&mock_ui_context), + TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context), VB2_REQUEST_UI_CONTINUE, "allowed: ctrl+l"); - TEST_EQ(mock_vbexlegacy_called, 1, " VbExLegacy called once"); - TEST_EQ(mock_altfw_num_last, 0, " select bootloader #0"); + TEST_EQ(mock_run_altfw_called, 1, + " vb2ex_run_altfw called once"); + TEST_EQ(mock_altfw_last, 0, " select bootloader #0"); VB2_DEBUG("...done.\n"); } @@ -1054,7 +1059,7 @@ int main(void) menu_select_tests(); /* Screen actions */ - vb2_ui_developer_mode_boot_alternate_action_tests(); + vb2_ui_developer_mode_boot_altfw_action_tests(); /* Global actions */ manual_recovery_action_tests(); diff --git a/tests/vb2_ui_tests.c b/tests/vb2_ui_tests.c index bc950335..baac919d 100644 --- a/tests/vb2_ui_tests.c +++ b/tests/vb2_ui_tests.c @@ -74,12 +74,12 @@ static int mock_beep_total; static enum vb2_dev_default_boot_target mock_default_boot; static int mock_dev_boot_allowed; -static int mock_dev_boot_legacy_allowed; +static int mock_dev_boot_altfw_allowed; static int mock_dev_boot_external_allowed; -static int mock_vbexlegacy_called; -static enum VbAltFwIndex_t mock_altfw_num_last; -static uint32_t mock_bootloader_count; +static int mock_run_altfw_called; +static uint32_t mock_altfw_last; +static uint32_t mock_altfw_count; static vb2_error_t mock_vbtlk_retval[32]; static uint32_t mock_vbtlk_expected_flag[32]; @@ -317,13 +317,13 @@ static void reset_common_data(enum reset_type t) /* For dev_boot* in 2misc.h */ mock_default_boot = VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL; mock_dev_boot_allowed = 1; - mock_dev_boot_legacy_allowed = 0; + mock_dev_boot_altfw_allowed = 0; mock_dev_boot_external_allowed = 1; - /* For VbExLegacy */ - mock_vbexlegacy_called = 0; - mock_altfw_num_last = -100; - mock_bootloader_count = 2; + /* For vb2ex_run_altfw */ + mock_run_altfw_called = 0; + mock_altfw_last = -100; + mock_altfw_count = 2; /* For VbTryLoadKernel */ memset(mock_vbtlk_retval, 0, sizeof(mock_vbtlk_retval)); @@ -490,9 +490,9 @@ int vb2_dev_boot_allowed(struct vb2_context *c) return mock_dev_boot_allowed; } -int vb2_dev_boot_legacy_allowed(struct vb2_context *c) +int vb2_dev_boot_altfw_allowed(struct vb2_context *c) { - return mock_dev_boot_legacy_allowed; + return mock_dev_boot_altfw_allowed; } int vb2_dev_boot_external_allowed(struct vb2_context *c) @@ -500,17 +500,17 @@ int vb2_dev_boot_external_allowed(struct vb2_context *c) return mock_dev_boot_external_allowed; } -vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num) +vb2_error_t vb2ex_run_altfw(uint32_t altfw_id) { - mock_vbexlegacy_called++; - mock_altfw_num_last = altfw_num; + mock_run_altfw_called++; + mock_altfw_last = altfw_id; return VB2_SUCCESS; } -uint32_t vb2ex_get_bootloader_count(void) +uint32_t vb2ex_get_altfw_count(void) { - return mock_bootloader_count; + return mock_altfw_count; } vb2_error_t VbTryLoadKernel(struct vb2_context *c, uint32_t get_info_flags) @@ -702,20 +702,21 @@ static void developer_tests(void) TEST_EQ(vb2_developer_menu(ctx), VB2_SUCCESS, "select boot external in dev menu"); - /* Ctrl+L = boot legacy (allowed) */ + /* Ctrl+L = boot altfw (allowed) */ reset_common_data(FOR_DEVELOPER); - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; add_mock_keypress(VB_KEY_CTRL('L')); TEST_EQ(vb2_developer_menu(ctx), VB2_REQUEST_SHUTDOWN, - "ctrl+l = boot legacy"); - TEST_EQ(mock_vbexlegacy_called, 1, " VbExLegacy called"); + "ctrl+l = boot altfw"); + TEST_EQ(mock_run_altfw_called, 1, " vb2ex_run_altfw called"); - /* Ctrl+L = boot legacy (disallowed) */ + /* Ctrl+L = boot altfw (disallowed) */ reset_common_data(FOR_DEVELOPER); add_mock_keypress(VB_KEY_CTRL('L')); TEST_EQ(vb2_developer_menu(ctx), VB2_REQUEST_SHUTDOWN, - "ctrl+l = boot legacy"); - TEST_EQ(mock_vbexlegacy_called, 0, " VbExLegacy not called"); + "ctrl+l = boot altfw"); + TEST_EQ(mock_run_altfw_called, 0, + " vb2ex_run_altfw not called"); /* VB_BUTTON_VOL_UP_LONG_PRESS = boot external */ if (DETACHABLE) { @@ -1286,7 +1287,7 @@ static void developer_screen_tests(void) /* Dev mode: disabled and hidden item mask */ reset_common_data(FOR_DEVELOPER); - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_FIXED); TEST_EQ(vb2_developer_menu(ctx), VB2_SUCCESS, "dev mode screen: no disabled or hidden item"); @@ -1294,7 +1295,7 @@ static void developer_screen_tests(void) MOCK_IGNORE, MOCK_IGNORE, 0x0, 0x0, MOCK_IGNORE); reset_common_data(FOR_DEVELOPER); - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; gbb.flags |= VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON; add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_FIXED); TEST_EQ(vb2_developer_menu(ctx), VB2_SUCCESS, @@ -1305,7 +1306,7 @@ static void developer_screen_tests(void) reset_common_data(FOR_DEVELOPER); add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_FIXED); mock_dev_boot_external_allowed = 0; - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; TEST_EQ(vb2_developer_menu(ctx), VB2_SUCCESS, "dev mode screen: hide boot external"); DISPLAYED_EQ("dev mode screen", VB2_SCREEN_DEVELOPER_MODE, @@ -1364,7 +1365,7 @@ static void developer_screen_tests(void) DISPLAYED_NO_EXTRA(); reset_common_data(FOR_DEVELOPER); /* Select #2 by default */ - mock_dev_boot_legacy_allowed = 1; + mock_dev_boot_altfw_allowed = 1; /* #4: Alternate boot */ add_mock_keypress(VB_KEY_DOWN); add_mock_keypress(VB_KEY_DOWN); @@ -1372,7 +1373,7 @@ static void developer_screen_tests(void) add_mock_keypress(VB_KEY_ENTER); TEST_EQ(vb2_developer_menu(ctx), VB2_REQUEST_SHUTDOWN, "dev mode screen"); - TEST_EQ(mock_vbexlegacy_called, 1, " VbExLegacy called"); + TEST_EQ(mock_run_altfw_called, 1, " vb2ex_run_altfw called"); reset_common_data(FOR_DEVELOPER); /* Select #2 by default */ add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_FIXED); diff --git a/utility/crossystem.c b/utility/crossystem.c index 384c6717..8fdce980 100644 --- a/utility/crossystem.c +++ b/utility/crossystem.c @@ -37,13 +37,13 @@ const Param sys_param_list[] = { {"cros_debug", 0, "OS should allow debug features"}, {"dbg_reset", CAN_WRITE, "Debug reset mode request"}, {"debug_build", 0, "OS image built for debug features"}, - {"dev_boot_legacy", CAN_WRITE, "Enable developer mode boot Legacy OSes"}, + {"dev_boot_altfw", CAN_WRITE, "Enable developer mode alternate bootloader"}, {"dev_boot_signed_only", CAN_WRITE, "Enable developer mode boot only from official kernels"}, {"dev_boot_usb", CAN_WRITE, "Enable developer mode boot from external disk (USB/SD)"}, {"dev_default_boot", IS_STRING|CAN_WRITE, - "Default boot from disk, legacy or usb"}, + "Default boot from disk, altfw or usb"}, {"dev_enable_udc", CAN_WRITE, "Enable USB Device Controller"}, {"devsw_boot", 0, "Developer switch position at boot"}, {"devsw_cur", 0, "Developer switch current position"}, @@ -135,6 +135,14 @@ static const Param* FindParam(const char* name) { const Param* p; if (!name) return NULL; + /* "legacy" term deprecated in favour of "altfw" (see: b/179458327) */ + if (!strcasecmp(name, "dev_boot_legacy")) { + fprintf(stderr, + "!!!\n" + "!!! PLEASE USE 'dev_boot_altfw' INSTEAD OF 'dev_boot_legacy'\n" + "!!!\n"); + name = "dev_boot_altfw"; + } for (p = sys_param_list; p->name; p++) { if (!strcasecmp(p->name, name)) return p; @@ -308,13 +316,13 @@ int main(int argc, char* argv[]) { case PARAM_SUCCESS: break; case PARAM_ERROR_READ_ONLY: - fprintf(stderr, "Parameter %s is read-only\n", name); + fprintf(stderr, "Parameter %s is read-only\n", p->name); break; case PARAM_ERROR_INVALID_INT: fprintf(stderr, "Value %s is not a valid integer\n", value); break; default: - fprintf(stderr, "Failed to set parameter %s\n", name); + fprintf(stderr, "Failed to set parameter %s\n", p->name); break; } } else if (has_expect) |