summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/lib/vboot_api_kernel.c30
-rw-r--r--tests/vboot_api_kernel2_tests.c14
-rw-r--r--tests/vboot_detach_menu_tests.c11
3 files changed, 47 insertions, 8 deletions
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index d5dda055..e32c9500 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -151,6 +151,31 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags)
return retval;
}
+/**
+ * Reset any NVRAM requests.
+ *
+ * @param ctx Vboot context
+ * @return 1 if a reboot is required, 0 otherwise.
+ */
+static int vb2_reset_nv_requests(struct vb2_context *ctx)
+{
+ int need_reboot = 0;
+
+ if (vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST)) {
+ VB2_DEBUG("Unset display request (undo display init)\n");
+ vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 0);
+ need_reboot = 1;
+ }
+
+ if (vb2_nv_get(ctx, VB2_NV_DIAG_REQUEST)) {
+ VB2_DEBUG("Unset diagnostic request (undo display init)\n");
+ vb2_nv_set(ctx, VB2_NV_DIAG_REQUEST, 0);
+ need_reboot = 1;
+ }
+
+ return need_reboot;
+}
+
VbError_t VbBootNormal(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
@@ -161,6 +186,11 @@ VbError_t VbBootNormal(struct vb2_context *ctx)
/* Boot from fixed disk only */
VB2_DEBUG("Entering\n");
+ if (vb2_reset_nv_requests(ctx)) {
+ VB2_DEBUG("Normal mode: reboot to reset NVRAM requests\n");
+ return VBERROR_REBOOT_REQUIRED;
+ }
+
VbError_t rv = VbTryLoadKernel(ctx, VB_DISK_FLAG_FIXED);
VB2_DEBUG("Checking if TPM kernel version needs advancing\n");
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index fcace7a1..66de74aa 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -466,6 +466,20 @@ static void VbBootTest(void)
VbExEcEnteringMode(0, VB_EC_NORMAL);
TEST_EQ(VbBootNormal(&ctx), 1002, "VbBootNormal()");
TEST_EQ(VbGetMode(), VB_EC_NORMAL, "vboot_mode normal");
+
+ ResetMocks();
+ vb2_nv_set(&ctx, VB2_NV_DISPLAY_REQUEST, 1);
+ TEST_EQ(VbBootNormal(&ctx), VBERROR_REBOOT_REQUIRED,
+ "VbBootNormal() reboot to reset NVRAM display request");
+ TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISPLAY_REQUEST), 0,
+ " display request reset");
+
+ ResetMocks();
+ vb2_nv_set(&ctx, VB2_NV_DIAG_REQUEST, 1);
+ TEST_EQ(VbBootNormal(&ctx), VBERROR_REBOOT_REQUIRED,
+ "VbBootNormal() reboot to reset NVRAM diag request");
+ TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DIAG_REQUEST), 0,
+ " diag request reset");
}
static void VbBootDevTest(void)
diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c
index 6949bedb..4d618659 100644
--- a/tests/vboot_detach_menu_tests.c
+++ b/tests/vboot_detach_menu_tests.c
@@ -255,13 +255,9 @@ uint32_t SetVirtualDevMode(int val)
/* Tests */
-static void VbBootTest(void)
-{
- ResetMocks();
- VbExEcEnteringMode(0, VB_EC_NORMAL);
- TEST_EQ(VbBootNormal(&ctx), vbtlk_retval_fixed, "VbBootNormal()");
- TEST_EQ(VbGetMode(), VB_EC_NORMAL, "vboot_mode normal");
-}
+/*
+ * VbBootNormal tests: Please see VbBootTest in vboot_api_kernel2_tests.c
+ */
static void VbBootDevTest(void)
{
@@ -2337,7 +2333,6 @@ static void VbNavigationTest(void)
int main(void)
{
- VbBootTest();
VbBootDevTest();
VbBootRecTest();
VbTestLanguageMenu();