diff options
author | Joel Kitching <kitching@google.com> | 2019-05-29 16:25:05 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-07 20:09:43 +0000 |
commit | efd0dc23e855c8ec5a4cd4e0bb08b4ae1e40bfb3 (patch) | |
tree | 7dc12209dcbace8a8c17de3e09e2c54bbb409075 | |
parent | 40c35a022fc9ff9a2be0f394be45747e8f767931 (diff) | |
download | vboot-efd0dc23e855c8ec5a4cd4e0bb08b4ae1e40bfb3.tar.gz |
vboot: check display init when entering normal mode
In order to simplify code which uses VB2_NV_DISPLAY_REQUEST,
centralize disabling this NVRAM flag to a function called at
the start of VbBootNormal. Also disable VB2_NV_DIAG_REQUEST
here, since display init is enabled for this request as well.
BUG=b:124141368, chromium:948592, chromium:967298, b:133175864
TEST=make clean && make runtests
BRANCH=none
Change-Id: I8aa7c44671ada23c0500cd8a0c5d7f737298bb11
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1634451
Commit-Queue: Jason Clinton <jclinton@chromium.org>
Tested-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 30 | ||||
-rw-r--r-- | tests/vboot_api_kernel2_tests.c | 14 | ||||
-rw-r--r-- | tests/vboot_detach_menu_tests.c | 11 |
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(); |