From 43f6cab881dc0ed52fe08e6c2c64239fde11996b Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Fri, 10 May 2019 12:17:18 +0800 Subject: vboot: update display init to use vboot2 code As per go/vboot2-oprom-cleanup, use vboot2 SD flag DISPLAY_AVAILABLE, instead of the old vboot1 flags OPROM_MATTERS and OPROM_LOADED. Remove instances of "OPROM" and update with correct nomenclature. Update code and tests for EC software sync and diagnostic menu to use vboot2 display init model. OPROM_MATTERS and OPROM_LOADED are now deprecated, and will be removed when no references remain in depthcharge and coreboot. Deprecate VBERROR_DISPLAY_INIT_MISMATCH (previously OPROM_MISMATCH) and return VBERROR_REBOOT_REQUIRED directly when needed. BUG=b:124141368, b:124192753, chromium:948529 TEST=Build image for eve, force EC update, check that the "critical update" screen shows TEST=make clean && make runtests BRANCH=none Change-Id: I889872f886230f8559d5cce09d0de194da3fcc38 Signed-off-by: Joel Kitching Reviewed-on: https://chromium-review.googlesource.com/1605641 Commit-Ready: ChromeOS CL Exonerator Bot Tested-by: Joel Kitching Reviewed-by: Julius Werner --- firmware/2lib/2api.c | 2 +- firmware/2lib/2nvstorage.c | 8 ++--- firmware/2lib/include/2nvstorage.h | 15 ++++----- firmware/2lib/include/2nvstorage_fields.h | 2 +- firmware/include/vboot_api.h | 5 +-- firmware/include/vboot_struct.h | 6 ++-- firmware/lib/ec_sync.c | 2 +- firmware/lib/ec_sync_all.c | 54 ++++++++++++++----------------- firmware/lib/vboot_api_kernel.c | 43 +++++++++++++----------- firmware/lib/vboot_ui.c | 4 +-- host/lib/crossystem.c | 8 ++--- tests/ec_sync_tests.c | 37 +++++++++++++++++++++ tests/vb2_api_tests.c | 4 +-- tests/vb2_nvstorage_tests.c | 2 +- tests/vboot_api_kernel2_tests.c | 22 +++++++------ tests/vboot_api_kernel4_tests.c | 32 ++++++++++-------- utility/crossystem.c | 2 +- 17 files changed, 147 insertions(+), 101 deletions(-) diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c index 1556c997..ada229a5 100644 --- a/firmware/2lib/2api.c +++ b/firmware/2lib/2api.c @@ -106,7 +106,7 @@ int vb2api_fw_phase1(struct vb2_context *ctx) * above by vb2_check_dev_switch. */ if (!(ctx->flags & VB2_CONTEXT_DISPLAY_INIT) && - (vb2_nv_get(ctx, VB2_NV_OPROM_NEEDED) || + (vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST) || sd->flags & VB2_SD_FLAG_DEV_MODE_ENABLED || sd->recovery_reason)) ctx->flags |= VB2_CONTEXT_DISPLAY_INIT; diff --git a/firmware/2lib/2nvstorage.c b/firmware/2lib/2nvstorage.c index b1669d09..95d2f6e7 100644 --- a/firmware/2lib/2nvstorage.c +++ b/firmware/2lib/2nvstorage.c @@ -176,8 +176,8 @@ uint32_t vb2_nv_get(struct vb2_context *ctx, enum vb2_nv_param param) case VB2_NV_DISABLE_DEV_REQUEST: return GETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_DISABLE_DEV); - case VB2_NV_OPROM_NEEDED: - return GETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_OPROM_NEEDED); + case VB2_NV_DISPLAY_REQUEST: + return GETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_DISPLAY_REQUEST); case VB2_NV_BACKUP_NVRAM_REQUEST: return GETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_BACKUP_NVRAM); @@ -377,8 +377,8 @@ void vb2_nv_set(struct vb2_context *ctx, SETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_DISABLE_DEV); break; - case VB2_NV_OPROM_NEEDED: - SETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_OPROM_NEEDED); + case VB2_NV_DISPLAY_REQUEST: + SETBIT(VB2_NV_OFFS_BOOT, VB2_NV_BOOT_DISPLAY_REQUEST); break; case VB2_NV_BACKUP_NVRAM_REQUEST: diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h index 3efa29b6..b51cb6fa 100644 --- a/firmware/2lib/include/2nvstorage.h +++ b/firmware/2lib/include/2nvstorage.h @@ -67,15 +67,12 @@ enum vb2_nv_param { * virtual. */ VB2_NV_DISABLE_DEV_REQUEST, - /* - * Set and cleared by vboot to request that the video Option ROM be - * loaded at boot time, so that BIOS screens can be displayed. 0=no, - * 1=yes. - */ - VB2_NV_OPROM_NEEDED, - /* TODO(chromium:948529): VB2_NV_OPROM_NEEDED is being renamed to - VB2_NV_DISPLAY_REQUEST. */ - VB2_NV_DISPLAY_REQUEST = VB2_NV_OPROM_NEEDED, + /* Set and cleared by vboot to request that display be initialized + at boot time, so that BIOS screens can be displayed. 0=no, 1=yes. */ + VB2_NV_DISPLAY_REQUEST, + /* TODO(chromium:948529): Remove VB2_NV_OPROM_NEEDED when unused. + Renamed to VB2_NV_DISPLAY_REQUEST (above). */ + VB2_NV_OPROM_NEEDED = VB2_NV_DISPLAY_REQUEST, /* Request that the firmware clear the TPM owner on the next boot. */ VB2_NV_CLEAR_TPM_OWNER_REQUEST, /* Flag that TPM owner was cleared on request. */ diff --git a/firmware/2lib/include/2nvstorage_fields.h b/firmware/2lib/include/2nvstorage_fields.h index f8e3693a..11a9f8fb 100644 --- a/firmware/2lib/include/2nvstorage_fields.h +++ b/firmware/2lib/include/2nvstorage_fields.h @@ -75,7 +75,7 @@ enum vb2_nv_offset { /* Fields in VB2_NV_OFFS_BOOT */ #define VB2_NV_BOOT_TRY_COUNT_MASK 0x0f #define VB2_NV_BOOT_BACKUP_NVRAM 0x10 -#define VB2_NV_BOOT_OPROM_NEEDED 0x20 +#define VB2_NV_BOOT_DISPLAY_REQUEST 0x20 #define VB2_NV_BOOT_DISABLE_DEV 0x40 #define VB2_NV_BOOT_DEBUG_RESET 0x80 diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index c5b382ac..38c5cbda 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -118,8 +118,9 @@ enum VbErrorPredefined_t { VBERROR_EC_REBOOT_TO_SWITCH_RW = 0x1001A, /* Developer has requested a BIOS shell */ VBERROR_BIOS_SHELL_REQUESTED = 0x10020, - /* Need VGA and don't have it, or vice-versa */ - VBERROR_VGA_OPROM_MISMATCH = 0x10021, + /* Need initialized display and don't have it, or vice-versa. + Deprecated; should use VBERROR_REBOOT_REQUIRED instead. */ + VBERROR_DEPRECATED_DISPLAY_INIT_MISMATCH = 0x10021, /* Need EC to reboot to read-only code */ VBERROR_EC_REBOOT_TO_RO_REQUIRED = 0x10022, /* Invalid region read parameters */ diff --git a/firmware/include/vboot_struct.h b/firmware/include/vboot_struct.h index 9c8a3587..ab063475 100644 --- a/firmware/include/vboot_struct.h +++ b/firmware/include/vboot_struct.h @@ -243,9 +243,11 @@ typedef struct VbKernelPreambleHeader { #define VBSD_BOOT_REC_SWITCH_VIRTUAL 0x00004000 /* Firmware used vboot2 for firmware selection */ #define VBSD_BOOT_FIRMWARE_VBOOT2 0x00008000 -/* Firmware needs VGA Option ROM to display screens */ +/* Firmware needs VGA Option ROM to display screens + Deprecated; see chromium:948529 */ #define VBSD_OPROM_MATTERS 0x00010000 -/* Firmware has loaded the VGA Option ROM */ +/* Firmware has loaded the VGA Option ROM + Deprecated; see chromium:948529 */ #define VBSD_OPROM_LOADED 0x00020000 /* Don't try for boot failures */ #define VBSD_NOFAIL_BOOT 0x00040000 diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c index b72403db..c486d570 100644 --- a/firmware/lib/ec_sync.c +++ b/firmware/lib/ec_sync.c @@ -257,7 +257,7 @@ static VbError_t sync_one_ec(struct vb2_context *ctx, int devidx) VB2_DEBUG("Rebooting to jump to new EC-RW\n"); /* Since we're rebooting, ec_sync_all won't be given a * chance to clear the flag. Need to clear it here. */ - vb2_nv_set(ctx, VB2_NV_OPROM_NEEDED, 0); + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 0); return VBERROR_EC_REBOOT_TO_SWITCH_RW; } } diff --git a/firmware/lib/ec_sync_all.c b/firmware/lib/ec_sync_all.c index 6c3fe74f..fca9f9b4 100644 --- a/firmware/lib/ec_sync_all.c +++ b/firmware/lib/ec_sync_all.c @@ -17,24 +17,22 @@ #include "vboot_display.h" #include "vboot_kernel.h" -static VbError_t ec_sync_unload_oprom(struct vb2_context *ctx, - VbSharedDataHeader *shared, - int need_wait_screen) +static VbError_t ec_sync_disable_display(struct vb2_context *ctx, + int need_wait_screen) { /* - * Reboot to unload VGA Option ROM if: - * - we displayed the wait screen - * - the system has slow EC update flag set - * - the VGA Option ROM was needed and loaded - * - the system is NOT in developer mode (that'll also need the ROM) + * Reboot to disable display initialization + * - we displayed the EC wait screen (otherwise we may be interfering + * with some other vboot feature requesting display initialization) + * - vboot requested display to be initialized on this boot + * - the system is NOT in developer mode (which will also need display) */ if (need_wait_screen && - (shared->flags & VBSD_OPROM_MATTERS) && - (shared->flags & VBSD_OPROM_LOADED) && - !(shared->flags & VBSD_BOOT_DEV_SWITCH_ON)) { - VB2_DEBUG("Reboot to unload VGA Option ROM\n"); - vb2_nv_set(ctx, VB2_NV_OPROM_NEEDED, 0); - return VBERROR_VGA_OPROM_MISMATCH; + vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST) && + !(vb2_get_sd(ctx)->vbsd->flags & VBSD_BOOT_DEV_SWITCH_ON)) { + VB2_DEBUG("Reboot to undo display initialization\n"); + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 0); + return VBERROR_REBOOT_REQUIRED; } return VBERROR_SUCCESS; } @@ -42,7 +40,6 @@ static VbError_t ec_sync_unload_oprom(struct vb2_context *ctx, VbError_t ec_sync_all(struct vb2_context *ctx) { struct vb2_shared_data *sd = vb2_get_sd(ctx); - VbSharedDataHeader *shared = sd->vbsd; VbAuxFwUpdateSeverity_t fw_update; VbError_t rv; @@ -56,25 +53,24 @@ VbError_t ec_sync_all(struct vb2_context *ctx) (fw_update == VB_AUX_FW_SLOW_UPDATE); /* - * Check if we need to reboot to load the VGA Option ROM before we can + * Check if we need to reboot to initialize the display before we can * display the WAIT screen. * * Do this before we check if ec_sync_phase1() requires a reboot for * some other reason, since there's no reason to reboot twice. */ - int reboot_for_oprom = (need_wait_screen && - shared->flags & VBSD_OPROM_MATTERS && - !(shared->flags & VBSD_OPROM_LOADED)); - if (reboot_for_oprom) { - VB2_DEBUG("Reboot to load VGA Option ROM\n"); - vb2_nv_set(ctx, VB2_NV_OPROM_NEEDED, 1); + int reboot_for_display = (need_wait_screen && + !(sd->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE)); + if (reboot_for_display) { + VB2_DEBUG("Reboot to initialize display\n"); + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1); } - /* Reboot if phase 1 needed it, or if we need to load VGA Option ROM */ + /* Reboot if phase 1 needed it, or if we need to initialize display */ if (phase1_rv) return VBERROR_EC_REBOOT_TO_RO_REQUIRED; - if (reboot_for_oprom) - return VBERROR_VGA_OPROM_MISMATCH; + if (reboot_for_display) + return VBERROR_REBOOT_REQUIRED; /* Display the wait screen if we need it */ if (need_wait_screen) { @@ -90,16 +86,16 @@ VbError_t ec_sync_all(struct vb2_context *ctx) /* * Do Aux FW software sync and protect devices tunneled through the EC. * Aux FW update may request RO reboot to force EC cold reset so also - * unload the option ROM if needed to prevent a second reboot. + * disable display request if needed to prevent a second reboot. */ rv = ec_sync_update_aux_fw(ctx); if (rv) { - ec_sync_unload_oprom(ctx, shared, need_wait_screen); + ec_sync_disable_display(ctx, need_wait_screen); return rv; } - /* Reboot to unload VGA Option ROM if needed */ - rv = ec_sync_unload_oprom(ctx, shared, need_wait_screen); + /* Reboot to disable display initialization if needed */ + rv = ec_sync_disable_display(ctx, need_wait_screen); if (rv) return rv; diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 038622bf..77dc3366 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -399,25 +399,32 @@ VbError_t VbSelectAndLoadKernel( retval = VbBootRecovery(ctx); VbExEcEnteringMode(0, VB_EC_RECOVERY); } else if (DIAGNOSTIC_UI && vb2_nv_get(ctx, VB2_NV_DIAG_REQUEST)) { - struct vb2_shared_data *sd = vb2_get_sd(ctx); - if (sd->vbsd->flags & VBSD_OPROM_MATTERS) - vb2_nv_set(ctx, VB2_NV_OPROM_NEEDED, 0); - vb2_nv_set(ctx, VB2_NV_DIAG_REQUEST, 0); - - /* - * Diagnostic boot. This has a UI but only power button - * is used for input so no detachable-specific UI is needed. - * This mode is also 1-shot so it's placed before developer - * mode. - */ - retval = VbBootDiagnostic(ctx); - /* - * The diagnostic menu should either boot a rom, or - * return either of reboot or shutdown. The following - * check is a safety precaution. - */ - if (!retval) { + /* If display is unavailable and was not requested, request it + and reboot. This is not a normal state. */ + if (!(vb2_get_sd(ctx)->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE) && + !vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST)) { + VB2_DEBUG("ERROR: Diagnostic mode needs a display " + "request; rebooting\n"); + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1); retval = VBERROR_REBOOT_REQUIRED; + } else { + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 0); + vb2_nv_set(ctx, VB2_NV_DIAG_REQUEST, 0); + + /* + * Diagnostic boot. This has a UI but only power button + * is used for input so no detachable-specific UI is + * needed. This mode is also 1-shot so it's placed + * before developer mode. + */ + retval = VbBootDiagnostic(ctx); + /* + * The diagnostic menu should either boot a rom, or + * return either of reboot or shutdown. The following + * check is a safety precaution. + */ + if (!retval) + retval = VBERROR_REBOOT_REQUIRED; } } else if (ctx->flags & VB2_CONTEXT_DEVELOPER_MODE) { if (kparams->inflags & VB_SALK_INFLAGS_VENDOR_DATA_SETTABLE) diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index 60afadc9..e06d5f6b 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -393,8 +393,8 @@ static VbError_t vb2_check_diagnostic_key(struct vb2_context *ctx, uint32_t key) { if (DIAGNOSTIC_UI && (key == VB_KEY_CTRL('C') || key == VB_KEY_F(12))) { VB2_DEBUG("Diagnostic mode requested, rebooting\n"); - if (vb2_get_sd(ctx)->vbsd->flags & VBSD_OPROM_MATTERS) - vb2_nv_set(ctx, VB2_NV_OPROM_NEEDED, 1); + if (!(vb2_get_sd(ctx)->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE)) + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1); vb2_nv_set(ctx, VB2_NV_DIAG_REQUEST, 1); return VBERROR_REBOOT_REQUIRED; diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c index 994d4796..1eb540a3 100644 --- a/host/lib/crossystem.c +++ b/host/lib/crossystem.c @@ -514,8 +514,8 @@ int VbGetSystemPropertyInt(const char *name) value = vb2_get_nv_storage(VB2_NV_DEV_BOOT_FASTBOOT_FULL_CAP); } else if (!strcasecmp(name,"dev_enable_udc")) { value = vb2_get_nv_storage(VB2_NV_DEV_ENABLE_UDC); - } else if (!strcasecmp(name,"oprom_needed")) { - value = vb2_get_nv_storage(VB2_NV_OPROM_NEEDED); + } else if (!strcasecmp(name,"display_request")) { + value = vb2_get_nv_storage(VB2_NV_DISPLAY_REQUEST); } else if (!strcasecmp(name,"recovery_subcode")) { value = vb2_get_nv_storage(VB2_NV_RECOVERY_SUBCODE); } else if (!strcasecmp(name,"wipeout_request")) { @@ -662,8 +662,8 @@ int VbSetSystemPropertyInt(const char *name, int value) } else if (!strcasecmp(name,"fwb_tries") || !strcasecmp(name,"fw_try_count")) { return vb2_set_nv_storage(VB2_NV_TRY_COUNT, value); - } else if (!strcasecmp(name,"oprom_needed")) { - return vb2_set_nv_storage(VB2_NV_OPROM_NEEDED, value); + } else if (!strcasecmp(name,"display_request")) { + return vb2_set_nv_storage(VB2_NV_DISPLAY_REQUEST, value); } else if (!strcasecmp(name,"wipeout_request")) { /* Can only clear this flag, set only by firmware. */ return vb2_set_nv_storage(VB2_NV_REQ_WIPEOUT, 0); diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c index 571eef67..fb043460 100644 --- a/tests/ec_sync_tests.c +++ b/tests/ec_sync_tests.c @@ -74,6 +74,7 @@ static void ResetMocks(void) sd = vb2_get_sd(&ctx); sd->vbsd = shared; + sd->flags |= VB2_SD_FLAG_DISPLAY_AVAILABLE; memset(&shared_data, 0, sizeof(shared_data)); VbSharedDataInit(shared, sizeof(shared_data)); @@ -302,12 +303,15 @@ static void VbSoftwareSyncTest(void) ResetMocks(); vb2_nv_set(&ctx, VB2_NV_TRY_RO_SYNC, 1); mock_ec_ro_hash[0]++; + vb2_nv_set(&ctx, VB2_NV_DISPLAY_REQUEST, 1); test_ssync(0, 0, "rw update not needed"); TEST_EQ(ec_rw_protected, 1, " ec rw protected"); TEST_EQ(ec_run_image, 1, " ec run image"); TEST_EQ(ec_rw_updated, 0, " ec rw not updated"); TEST_EQ(ec_ro_protected, 1, " ec ro protected"); TEST_EQ(ec_ro_updated, 1, " ec ro updated"); + TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), 1, + " DISPLAY_REQUEST left untouched"); ResetMocks(); mock_ec_rw_hash[0]++; @@ -350,6 +354,33 @@ static void VbSoftwareSyncTest(void) test_ssync(0, 0, "Slow update"); TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen"); + ResetMocks(); + mock_ec_rw_hash[0]++; + ctx.flags |= VB2_CONTEXT_EC_SYNC_SLOW; + sd->flags &= ~VB2_SD_FLAG_DISPLAY_AVAILABLE; + test_ssync(VBERROR_REBOOT_REQUIRED, 0, + "Slow update - reboot for display"); + + ResetMocks(); + mock_ec_rw_hash[0]++; + ctx.flags |= VB2_CONTEXT_EC_SYNC_SLOW; + vb2_nv_set(&ctx, VB2_NV_DISPLAY_REQUEST, 1); + test_ssync(VBERROR_REBOOT_REQUIRED, 0, + "Slow update with display request"); + TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen"); + TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), 0, + " DISPLAY_REQUEST disabled"); + + ResetMocks(); + mock_ec_rw_hash[0]++; + ctx.flags |= VB2_CONTEXT_EC_SYNC_SLOW; + vb2_nv_set(&ctx, VB2_NV_DISPLAY_REQUEST, 0); + test_ssync(VBERROR_SUCCESS, 0, + "Slow update without display request (no reboot needed)"); + TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen"); + TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), 0, + " DISPLAY_REQUEST still disabled"); + /* RW cases, no update */ ResetMocks(); mock_in_rw = 1; @@ -434,6 +465,12 @@ static void VbSoftwareSyncTest(void) TEST_EQ(ec_aux_fw_update_req, 1, " aux fw update requested"); TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected"); + ResetMocks(); + ec_aux_fw_mock_severity = VB_AUX_FW_SLOW_UPDATE; + sd->flags &= ~VB2_SD_FLAG_DISPLAY_AVAILABLE; + test_ssync(VBERROR_REBOOT_REQUIRED, 0, + "Slow auxiliary FW update needed - reboot for display"); + ResetMocks(); ec_aux_fw_mock_severity = VB_AUX_FW_SLOW_UPDATE; test_ssync(VBERROR_SUCCESS, 0, diff --git a/tests/vb2_api_tests.c b/tests/vb2_api_tests.c index 8c31c2ec..d45f7451 100644 --- a/tests/vb2_api_tests.c +++ b/tests/vb2_api_tests.c @@ -258,8 +258,8 @@ static void phase1_tests(void) 0, " display available SD flag"); reset_common_data(FOR_MISC); - vb2_nv_set(&cc, VB2_NV_OPROM_NEEDED, 1); - TEST_SUCC(vb2api_fw_phase1(&cc), "phase1 with OPROM_NEEDED"); + vb2_nv_set(&cc, VB2_NV_DISPLAY_REQUEST, 1); + TEST_SUCC(vb2api_fw_phase1(&cc), "phase1 with DISPLAY_REQUEST"); TEST_NEQ(cc.flags & VB2_CONTEXT_DISPLAY_INIT, 0, " display init context flag"); TEST_NEQ(sd->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE, diff --git a/tests/vb2_nvstorage_tests.c b/tests/vb2_nvstorage_tests.c index 2dbc9950..52c14d4e 100644 --- a/tests/vb2_nvstorage_tests.c +++ b/tests/vb2_nvstorage_tests.c @@ -54,7 +54,7 @@ static struct nv_field nvfields[] = { {VB2_NV_CLEAR_TPM_OWNER_DONE, 0, 1, 0, "clear tpm owner done"}, {VB2_NV_TPM_REQUESTED_REBOOT, 0, 1, 0, "tpm requested reboot"}, {VB2_NV_REQ_WIPEOUT, 0, 1, 0, "request wipeout"}, - {VB2_NV_OPROM_NEEDED, 0, 1, 0, "oprom needed"}, + {VB2_NV_DISPLAY_REQUEST, 0, 1, 0, "oprom needed"}, {VB2_NV_BACKUP_NVRAM_REQUEST, 0, 1, 0, "backup nvram request"}, {VB2_NV_FASTBOOT_UNLOCK_IN_FW, 0, 1, 0, "fastboot unlock in fw"}, {VB2_NV_BOOT_ON_AC_DETECT, 0, 1, 0, "boot on ac detect"}, diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c index cb2471f4..2d0a7ab5 100644 --- a/tests/vboot_api_kernel2_tests.c +++ b/tests/vboot_api_kernel2_tests.c @@ -98,6 +98,7 @@ static void ResetMocks(void) sd = vb2_get_sd(&ctx); sd->vbsd = shared; + sd->flags |= VB2_SD_FLAG_DISPLAY_AVAILABLE; audio_looping_calls_left = 30; vbtlk_retval = 1000; @@ -1343,7 +1344,7 @@ static void VbBootRecTest(void) VBERROR_TPM_SET_BOOT_MODE_STATE, "Ctrl+D todev failure"); - /* Test Diagnostic Mode via Ctrl-C when no oprom needed */ + /* Test Diagnostic Mode via Ctrl-C - display available */ ResetMocks(); shared->flags = VBSD_BOOT_REC_SWITCH_ON; trust_ec = 1; @@ -1363,14 +1364,15 @@ static void VbBootRecTest(void) TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DIAG_REQUEST), DIAGNOSTIC_UI, " todiag is updated for Ctrl-C"); - TEST_EQ(vb2_nv_get(&ctx, VB2_NV_OPROM_NEEDED), 0, - " todiag doesn't update for unneeded opom"); + TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), 0, + " todiag doesn't set unneeded DISPLAY_REQUEST"); TEST_EQ(screens_displayed[0], VB_SCREEN_RECOVERY_INSERT, " insert screen"); - /* Test Diagnostic Mode via F12 - oprom needed */ + /* Test Diagnostic Mode via F12 - display disabled */ ResetMocks(); - shared->flags = VBSD_BOOT_REC_SWITCH_ON | VBSD_OPROM_MATTERS; + shared->flags = VBSD_BOOT_REC_SWITCH_ON; + sd->flags &= ~VB2_SD_FLAG_DISPLAY_AVAILABLE; trust_ec = 1; vbtlk_retval = VBERROR_NO_DISK_FOUND - VB_DISK_FLAG_REMOVABLE; MockGpioAfter(100, GPIO_SHUTDOWN); @@ -1387,12 +1389,12 @@ static void VbBootRecTest(void) "F12 todiag - disabled"); TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DIAG_REQUEST), DIAGNOSTIC_UI, " todiag is updated for F12"); - TEST_EQ(vb2_nv_get(&ctx, VB2_NV_OPROM_NEEDED), DIAGNOSTIC_UI, - " todiag updates opom, if need"); + TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), DIAGNOSTIC_UI, + " todiag sets DISPLAY_REQUEST if needed"); TEST_EQ(screens_displayed[0], VB_SCREEN_RECOVERY_INSERT, " insert screen"); - /* Test Diagnostic Mode via Ctrl-C OS broken */ + /* Test Diagnostic Mode via Ctrl-C OS broken - display available */ ResetMocks(); shared->flags = 0; MockGpioAfter(100, GPIO_SHUTDOWN); @@ -1409,8 +1411,8 @@ static void VbBootRecTest(void) "Ctrl+C todiag os broken - disabled"); TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DIAG_REQUEST), DIAGNOSTIC_UI, " todiag is updated for Ctrl-C"); - TEST_EQ(vb2_nv_get(&ctx, VB2_NV_OPROM_NEEDED), 0, - " todiag doesn't update for unneeded opom"); + TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), 0, + " todiag doesn't set unneeded DISPLAY_REQUEST"); TEST_EQ(screens_displayed[0], VB_SCREEN_OS_BROKEN, " os broken screen"); diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index adad4131..fdf51da6 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -28,6 +28,7 @@ static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE]; static struct vb2_context ctx; static struct vb2_context ctx_nvram_backend; +static struct vb2_shared_data *sd; static VbCommonParams cparams; static VbSelectAndLoadKernelParams kparams; static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE]; @@ -65,6 +66,8 @@ static void ResetMocks(void) ctx.workbuf = workbuf; ctx.workbuf_size = sizeof(workbuf); vb2_init_context(&ctx); + sd = vb2_get_sd(&ctx); + sd->flags |= VB2_SD_FLAG_DISPLAY_AVAILABLE; /* * ctx_nvram_backend is only used as an NVRAM backend (see @@ -271,26 +274,27 @@ static void VbSlkTest(void) ResetMocks(); mock_switches[1] = VB_SWITCH_FLAG_PHYS_PRESENCE_PRESSED; vb2_nv_set(&ctx_nvram_backend, VB2_NV_DIAG_REQUEST, 1); - vb2_nv_set(&ctx_nvram_backend, VB2_NV_OPROM_NEEDED, 1); + vb2_nv_set(&ctx_nvram_backend, VB2_NV_DISPLAY_REQUEST, 1); vbboot_retval = -4; - test_slk(VBERROR_SIMULATED, 0, "Normal boot with diag"); - TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_DIAG_REQUEST), 0, - " diag not requested"); - TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_OPROM_NEEDED), 1, - " oprom still needed"); + test_slk(VBERROR_SIMULATED, 0, + "Normal boot with diag - display available"); + TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_DIAG_REQUEST), + 0, " diag not requested"); + TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_DISPLAY_REQUEST), + 0, " DISPLAY_REQUEST disabled"); ResetMocks(); mock_switches[1] = VB_SWITCH_FLAG_PHYS_PRESENCE_PRESSED; vb2_nv_set(&ctx_nvram_backend, VB2_NV_DIAG_REQUEST, 1); - vb2_nv_set(&ctx_nvram_backend, VB2_NV_OPROM_NEEDED, 1); - shared->flags |= VBSD_OPROM_MATTERS; + vb2_nv_set(&ctx_nvram_backend, VB2_NV_DISPLAY_REQUEST, 0); + sd->flags &= ~VB2_SD_FLAG_DISPLAY_AVAILABLE; vbboot_retval = -4; - test_slk(VBERROR_SIMULATED, 0, - "Normal boot with diag and oprom"); - TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_DIAG_REQUEST), 0, - " diag not requested"); - TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_OPROM_NEEDED), 0, - " oprom not needed"); + test_slk(VBERROR_REBOOT_REQUIRED, 0, + "Normal boot with diag - display unavailable"); + TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_DIAG_REQUEST), + 1, " diag requested"); + TEST_EQ(vb2_nv_get(&ctx_nvram_backend, VB2_NV_DISPLAY_REQUEST), + 1, " DISPLAY_REQUEST needed"); } /* Boot dev */ diff --git a/utility/crossystem.c b/utility/crossystem.c index 3093f2a8..00846a67 100644 --- a/utility/crossystem.c +++ b/utility/crossystem.c @@ -78,7 +78,7 @@ const Param sys_param_list[] = { {"mainfw_act", IS_STRING, "Active main firmware"}, {"mainfw_type", IS_STRING, "Active main firmware type"}, {"nvram_cleared", CAN_WRITE, "Have NV settings been lost? Write 0 to clear"}, - {"oprom_needed", CAN_WRITE, "Should we load the VGA Option ROM at boot?"}, + {"display_request", CAN_WRITE, "Should we initialize the display at boot?"}, {"phase_enforcement", 0, "Board should have full security settings applied"}, {"recovery_reason", 0, "Recovery mode reason for current boot"}, -- cgit v1.2.1