diff options
-rw-r--r-- | firmware/2lib/include/2recovery_reasons.h | 3 | ||||
-rw-r--r-- | firmware/include/vboot_api.h | 4 | ||||
-rw-r--r-- | firmware/include/vboot_nvstorage.h | 2 | ||||
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 13 | ||||
-rw-r--r-- | firmware/lib/vboot_display.c | 2 | ||||
-rw-r--r-- | tests/vboot_api_kernel2_tests.c | 8 | ||||
-rw-r--r-- | tests/vboot_api_kernel4_tests.c | 4 |
7 files changed, 25 insertions, 11 deletions
diff --git a/firmware/2lib/include/2recovery_reasons.h b/firmware/2lib/include/2recovery_reasons.h index 13685e62..441c58c5 100644 --- a/firmware/2lib/include/2recovery_reasons.h +++ b/firmware/2lib/include/2recovery_reasons.h @@ -220,6 +220,9 @@ enum vb2_nv_recovery { /* Fastboot mode requested by user-mode */ VB2_RECOVERY_US_FASTBOOT = 0xc3, + /* User requested recovery for training memory and rebooting. */ + VB2_RECOVERY_TRAIN_AND_REBOOT = 0xc4, + /* Unspecified/unknown error in user-mode */ VB2_RECOVERY_US_UNSPECIFIED = 0xff, }; diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index a6121e92..950c1e22 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -68,8 +68,8 @@ enum VbErrorPredefined_t { VBERROR_TPM_LOCK_FIRMWARE = 0x10005, /* Unable to set boot mode state in TPM */ VBERROR_TPM_SET_BOOT_MODE_STATE = 0x10006, - /* TPM requires reboot */ - VBERROR_TPM_REBOOT_REQUIRED = 0x10007, + /* Calling firmware needs to perform a reboot. */ + VBERROR_REBOOT_REQUIRED = 0x10007, /* Unable to set up TPM */ VBERROR_TPM_FIRMWARE_SETUP = 0x10008, /* Unable to read kernel versions from TPM */ diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h index 48f93d5a..c43f2eb4 100644 --- a/firmware/include/vboot_nvstorage.h +++ b/firmware/include/vboot_nvstorage.h @@ -290,6 +290,8 @@ typedef enum VbFwResult { #define VBNV_RECOVERY_BCB_USER_MODE 0xC2 /* Fastboot mode requested by user-mode */ #define VBNV_RECOVERY_US_FASTBOOT 0xC3 +/* User requested recovery for training memory and rebooting. */ +#define VBNV_RECOVERY_TRAIN_AND_REBOOT 0xC4 /* Unspecified/unknown error in user-mode */ #define VBNV_RECOVERY_US_UNSPECIFIED 0xFF diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 549df24f..d367f4c6 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -365,7 +365,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p) VB_SCREEN_TO_NORM_CONFIRMED, 0, &vnc); VbExSleepMs(5000); - return VBERROR_TPM_REBOOT_REQUIRED; + return VBERROR_REBOOT_REQUIRED; case -1: VBDEBUG(("%s() - shutdown requested\n", __func__)); return VBERROR_SHUTDOWN_REQUESTED; @@ -437,7 +437,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p) VB_SCREEN_TO_NORM_CONFIRMED, 0, &vnc); VbExSleepMs(5000); - return VBERROR_TPM_REBOOT_REQUIRED; + return VBERROR_REBOOT_REQUIRED; case -1: VBDEBUG(("%s() - shutdown requested\n", __func__)); @@ -667,7 +667,7 @@ VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p) if (VbExGetSwitches (VB_INIT_FLAG_ALLOW_USB_BOOT)) VbAllowUsbBoot(); - return VBERROR_TPM_REBOOT_REQUIRED; + return VBERROR_REBOOT_REQUIRED; case -1: VBDEBUG(("%s() - Shutdown requested\n", __func__)); @@ -1218,7 +1218,12 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, #endif /* Select boot path */ - if (shared->recovery_reason) { + if (shared->recovery_reason == VBNV_RECOVERY_TRAIN_AND_REBOOT) { + /* Reboot requested by user recovery code. */ + VBDEBUG(("Reboot requested by user (recovery_reason=%d).\n", + shared->recovery_reason)); + retval = VBERROR_REBOOT_REQUIRED; + } else if (shared->recovery_reason) { /* Recovery boot */ p.boot_flags |= BOOT_FLAG_RECOVERY; retval = VbBootRecovery(cparams, &p); diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c index adbeaa9f..e4720046 100644 --- a/firmware/lib/vboot_display.c +++ b/firmware/lib/vboot_display.c @@ -539,6 +539,8 @@ const char *RecoveryReasonString(uint8_t code) return "User-mode requested recovery via BCB"; case VBNV_RECOVERY_US_FASTBOOT: return "User-mode requested fastboot mode"; + case VBNV_RECOVERY_TRAIN_AND_REBOOT: + return "User-mode requested DRAM train and reboot"; case VBNV_RECOVERY_US_UNSPECIFIED: return "Unspecified/unknown error in user-mode"; } diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c index 8a566367..433933ba 100644 --- a/tests/vboot_api_kernel2_tests.c +++ b/tests/vboot_api_kernel2_tests.c @@ -360,7 +360,7 @@ static void VbBootDevTest(void) shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON; mock_keypress[0] = ' '; mock_keypress[1] = '\r'; - TEST_EQ(VbBootDeveloper(&cparams, &lkp), VBERROR_TPM_REBOOT_REQUIRED, + TEST_EQ(VbBootDeveloper(&cparams, &lkp), VBERROR_REBOOT_REQUIRED, "Space = tonorm"); TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_WARNING, " warning screen"); @@ -398,7 +398,7 @@ static void VbBootDevTest(void) gbb.flags |= GBB_FLAG_ENTER_TRIGGERS_TONORM; mock_keypress[0] = '\r'; mock_keypress[1] = '\r'; - TEST_EQ(VbBootDeveloper(&cparams, &lkp), VBERROR_TPM_REBOOT_REQUIRED, + TEST_EQ(VbBootDeveloper(&cparams, &lkp), VBERROR_REBOOT_REQUIRED, "Enter = tonorm"); /* Tonorm ignored if GBB forces dev switch on */ @@ -502,7 +502,7 @@ static void VbBootDevTest(void) VbApiKernelGetFwmp()->flags |= FWMP_DEV_DISABLE_BOOT; mock_keypress[0] = '\x1b'; /* Just causes TONORM again */ mock_keypress[1] = '\r'; - TEST_EQ(VbBootDeveloper(&cparams, &lkp), VBERROR_TPM_REBOOT_REQUIRED, + TEST_EQ(VbBootDeveloper(&cparams, &lkp), VBERROR_REBOOT_REQUIRED, "FWMP dev disabled"); TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_TO_NORM, " tonorm screen"); @@ -690,7 +690,7 @@ static void VbBootRecTest(void) mock_keypress[0] = 0x04; mock_keypress[1] = '\r'; mock_keyflags[1] = VB_KEY_FLAG_TRUSTED_KEYBOARD; - TEST_EQ(VbBootRecovery(&cparams, &lkp), VBERROR_TPM_REBOOT_REQUIRED, + TEST_EQ(VbBootRecovery(&cparams, &lkp), VBERROR_REBOOT_REQUIRED, "Ctrl+D todev confirm"); TEST_EQ(virtdev_set, 1, " virtual dev mode on"); diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index 2672c4e7..401c61d5 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -244,7 +244,9 @@ static void VbSlkTest(void) rkr_retval = rkw_retval = rkl_retval = VBERROR_SIMULATED; test_slk(0, 0, "Recovery ignore TPM errors"); - + ResetMocks(); + shared->recovery_reason = VBNV_RECOVERY_TRAIN_AND_REBOOT; + test_slk(VBERROR_REBOOT_REQUIRED, 0, "Recovery train and reboot"); // todo: rkr/w/l fail ignored if recovery |