summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2021-08-27 13:26:32 +0800
committerCommit Bot <commit-bot@chromium.org>2021-08-31 09:38:56 +0000
commit243b51f740583a1661f2d8209906e87a822cd832 (patch)
tree1ede8522e60ca29ef3937ceeee2f0888a4a8061d
parent44826c7a47c4ee1300ae46d031ca81ffad596d09 (diff)
downloadvboot-243b51f740583a1661f2d8209906e87a822cd832.tar.gz
vboot/ui: Show error box on internal boot failure
CL:2917623 changes the behavior when failing to boot from internal disk in developer UI. However, it causes the device to potentially enter a reboot loop (b/197216832). Instead of either triggering recovery or returning an error from the UI loop, change the behavior to showing an error message in a dialog box and staying in the UI. This is similar to the behavior when booting from an invalid external disk, where an error screen will be shown to the user. Add VB2_UI_ERROR_INTERNAL_BOOT_FAILED to vb2_ui_error enum. BUG=b:197216832, b:197911901 TEST=make runtests BRANCH=none Cq-Depend: chromium:3123160 Change-Id: Ic5ace55fc8b93ba0836e5722b7c5011fd490c35e Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3124395 Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/2lib/2ui_screens.c11
-rw-r--r--firmware/2lib/include/2api.h2
-rw-r--r--tests/vb2_ui_tests.c5
3 files changed, 14 insertions, 4 deletions
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index a2ad2b63..d6ee6839 100644
--- a/firmware/2lib/2ui_screens.c
+++ b/firmware/2lib/2ui_screens.c
@@ -727,14 +727,21 @@ vb2_error_t developer_mode_init(struct vb2_ui_context *ui)
vb2_error_t vb2_ui_developer_mode_boot_internal_action(
struct vb2_ui_context *ui)
{
+ vb2_error_t rv;
+
if (!(ui->ctx->flags & VB2_CONTEXT_DEVELOPER_MODE) ||
!(ui->ctx->flags & VB2_CONTEXT_DEV_BOOT_ALLOWED)) {
VB2_DEBUG("ERROR: Dev mode internal boot not allowed\n");
return VB2_SUCCESS;
}
- VB2_TRY(VbTryLoadKernel(ui->ctx, VB_DISK_FLAG_FIXED));
- return VB2_REQUEST_UI_EXIT;
+ rv = VbTryLoadKernel(ui->ctx, VB_DISK_FLAG_FIXED);
+ if (rv == VB2_SUCCESS)
+ return VB2_REQUEST_UI_EXIT;
+
+ VB2_DEBUG("ERROR: Failed to boot from internal disk: %#x\n", rv);
+ ui->error_beep = 1;
+ return set_ui_error(ui, VB2_UI_ERROR_INTERNAL_BOOT_FAILED);
}
vb2_error_t vb2_ui_developer_mode_boot_external_action(
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index b973417d..6144c84b 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -1456,6 +1456,8 @@ enum vb2_ui_error {
VB2_UI_ERROR_UNTRUSTED_CONFIRMATION,
/* To-norm not allowed */
VB2_UI_ERROR_TO_NORM_NOT_ALLOWED,
+ /* Internal boot failed */
+ VB2_UI_ERROR_INTERNAL_BOOT_FAILED,
/* External boot is disabled */
VB2_UI_ERROR_EXTERNAL_BOOT_DISABLED,
/* Alternate bootloader is disabled */
diff --git a/tests/vb2_ui_tests.c b/tests/vb2_ui_tests.c
index 54f76037..948c6af5 100644
--- a/tests/vb2_ui_tests.c
+++ b/tests/vb2_ui_tests.c
@@ -635,8 +635,9 @@ static void developer_tests(void)
/* If fail to load internal disk, don't boot */
reset_common_data(FOR_DEVELOPER);
add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_FIXED);
- TEST_EQ(vb2_developer_menu(ctx), VB2_ERROR_LK_NO_DISK_FOUND,
- "if fail to load internal disk, don't boot");
+ TEST_NEQ(vb2_developer_menu(ctx), VB2_SUCCESS,
+ "if fail to load internal disk, don't boot");
+ TEST_EQ(mock_calls_until_shutdown, 0, " loop forever");
/* Select boot internal in dev menu */
reset_common_data(FOR_DEVELOPER);