diff options
author | Ting Shen <phoenixshen@google.com> | 2018-11-06 16:17:42 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-11-09 10:00:10 +0000 |
commit | 697ba9e3a5f6f56f2822175c9de738ef0d851c6f (patch) | |
tree | daad4afbc3d2a64d03f41b184435510917ecd353 | |
parent | 64d7369976b88b21d8d8a860252023776a2f119e (diff) | |
download | vboot-697ba9e3a5f6f56f2822175c9de738ef0d851c6f.tar.gz |
vboot: conditionally build alt os feature
CQ-DEPEND=CL:1322689
BUG=b:118998724
TEST=Run following commands with and without campfire USE flag:
emerge-eve vboot_reference
cros_run_unit_tests --board eve --packages vboot_reference
BRANCH=eve-campfire
Change-Id: I4d65ee86919e8fc7a9c8157f9910d68fdc11e671
Signed-off-by: Ting Shen <phoenixshen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/1319532
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | firmware/lib/include/vboot_kernel.h | 2 | ||||
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 8 | ||||
-rw-r--r-- | firmware/lib/vboot_ui.c | 2 | ||||
-rw-r--r-- | tests/vboot_api_kernel2_tests.c | 5 | ||||
-rw-r--r-- | tests/vboot_api_kernel4_tests.c | 26 |
6 files changed, 44 insertions, 3 deletions
@@ -161,6 +161,10 @@ CC ?= gcc CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall ${WERROR} ${DEBUG_FLAGS} endif +ifneq (${ALT_OS},) +CFLAGS += -DALT_OS +endif + ifneq (${CUSTOM_MUSIC},) CFLAGS += -DCUSTOM_MUSIC endif diff --git a/firmware/lib/include/vboot_kernel.h b/firmware/lib/include/vboot_kernel.h index ba2f51b0..0e131a7c 100644 --- a/firmware/lib/include/vboot_kernel.h +++ b/firmware/lib/include/vboot_kernel.h @@ -82,10 +82,12 @@ VbError_t VbBootDeveloperMenu(struct vb2_context *ctx, VbCommonParams *cparams); */ VbError_t VbBootRecoveryMenu(struct vb2_context *ctx, VbCommonParams *cparams); +#ifdef ALT_OS /** * Handle an Alt OS-mode boot. */ VbError_t VbBootAltOS(struct vb2_context *ctx, VbCommonParams *cparams); +#endif /* ALT_OS */ /** * Return the current FWMP flags. Valid only inside VbSelectAndLoadKernel(). diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 4145e3d0..2647255a 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -425,6 +425,7 @@ VbError_t vb2_post_ec_sync_hooks(struct vb2_context *ctx, return VBERROR_SUCCESS; } +#ifdef ALT_OS int VbAltOSForceChromeOS(void) { return 0; } @@ -519,6 +520,7 @@ VbError_t VbCheckAltOS(struct vb2_context *ctx, VbCommonParams *cparams, return VBERROR_SUCCESS; } +#endif /* ALT_OS */ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, VbSelectAndLoadKernelParams *kparams) @@ -530,11 +532,13 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, if (retval) goto VbSelectAndLoadKernel_exit; +#ifdef ALT_OS /* * Determine whether the EC is in RO or RW. This information * will be used later on in Alt OS boot flow. */ int trusted_ec = VbExTrustEC(0); +#endif /* ALT_OS */ /* * Do EC software sync if necessary. This has UI, but it's just a @@ -548,6 +552,7 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, if (retval) goto VbSelectAndLoadKernel_exit; +#ifdef ALT_OS /* * Check whether confirmation screen or picker screen need to be * shown for Alt OS. Ignore return value, and in the case of failure, @@ -556,6 +561,7 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, retval = VbCheckAltOS(&ctx, cparams, trusted_ec); if (retval == VBERROR_VGA_OPROM_MISMATCH) goto VbSelectAndLoadKernel_exit; +#endif /* ALT_OS */ /* Select boot path */ if (shared->recovery_reason) { @@ -572,12 +578,14 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, else retval = VbBootDeveloper(&ctx, cparams); VbExEcEnteringMode(0, VB_EC_DEVELOPER); +#ifdef ALT_OS } else if (shared->flags & VBSD_ALT_OS_CONFIRM_ENABLE || shared->flags & VBSD_ALT_OS_SHOW_PICKER) { /* Alt OS boot. This has UI. */ retval = VbBootAltOS(&ctx, cparams); /* Report as normal mode to the EC. */ VbExEcEnteringMode(0, VB_EC_NORMAL); +#endif /* ALT_OS */ } else { /* Normal boot */ retval = VbBootNormal(&ctx, cparams); diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index d037e7fc..59008ac1 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -153,6 +153,7 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams, return -1; } +#ifdef ALT_OS VbError_t vb2_alt_os_picker(struct vb2_context *ctx, VbCommonParams *cparams, uint32_t timeout_msec, int *index) { @@ -249,6 +250,7 @@ VbError_t VbBootAltOS(struct vb2_context *ctx, VbCommonParams *cparams) VbError_t retval = vb2_alt_os_ui(ctx, cparams); return retval; } +#endif /* ALT_OS */ static const char dev_disable_msg[] = "Developer mode is disabled on this device by system policy.\n" diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c index 44c53c92..c1bf9787 100644 --- a/tests/vboot_api_kernel2_tests.c +++ b/tests/vboot_api_kernel2_tests.c @@ -748,7 +748,7 @@ static void VbBootRecTest(void) printf("...done.\n"); } - +#ifdef ALT_OS static void VbBootAltOSTest(void) { printf("Testing VbBootAltOS()...\n"); @@ -772,6 +772,7 @@ static void VbBootAltOSTest(void) printf("...done.\n"); } +#endif /* ALT_OS */ int main(void) @@ -780,7 +781,9 @@ int main(void) VbBootTest(); VbBootDevTest(); VbBootRecTest(); +#ifdef ALT_OS VbBootAltOSTest(); +#endif /* ALT_OS */ return gTestSuccess ? 0 : 255; } diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index 1edea80a..fad74f8d 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -293,8 +293,11 @@ static void VbSlkTest(void) // todo: rkr/w/l fail ignored if recovery - /* Boot alt OS */ - uint32_t oprom_needed; + /* + * Boot Alt OS. + * Also make sure when ALT_OS not defined, Alt OS flags should not + * affect normal boot flow. + */ /* * Enable request without OPROM @@ -312,9 +315,14 @@ static void VbSlkTest(void) gah_retval = 1; VbNvSet(&vnc, VBNV_ENABLE_ALT_OS_REQUEST, 1); VbNvTeardown(&vnc); +#ifdef ALT_OS + uint32_t oprom_needed; test_slk(VBERROR_VGA_OPROM_MISMATCH, 0, "Alt OS doesn't request OPROM"); VbNvGet(&vnc, VBNV_OPROM_NEEDED, &oprom_needed); TEST_EQ(oprom_needed, 1, "Alt OS doesn't request OPROM"); +#else + test_slk(0, 0, "Normal"); +#endif /* * Enable request with OPROM @@ -333,8 +341,13 @@ static void VbSlkTest(void) gaf_val |= ALT_OS_HOTKEY; VbNvSet(&vnc, VBNV_ENABLE_ALT_OS_REQUEST, 1); VbNvTeardown(&vnc); +#ifdef ALT_OS vbboot_retval = -4; test_slk(VBERROR_SIMULATED, 0, "Alt OS enable bad"); +#else + vbboot_retval = -1; + test_slk(VBERROR_SIMULATED, 0, "Normal"); +#endif /* * Enabled with OPROM @@ -351,8 +364,13 @@ static void VbSlkTest(void) shared->flags |= VBSD_OPROM_MATTERS; shared->flags |= VBSD_OPROM_LOADED; gaf_val |= ALT_OS_ENABLE; +#ifdef ALT_OS vbboot_retval = -4; test_slk(VBERROR_SIMULATED, 0, "Alt OS boot bad"); +#else + vbboot_retval = -1; + test_slk(VBERROR_SIMULATED, 0, "Normal"); +#endif /* * Disable request without OPROM @@ -371,8 +389,12 @@ static void VbSlkTest(void) VbNvSet(&vnc, VBNV_DISABLE_ALT_OS_REQUEST, 1); VbNvTeardown(&vnc); vbboot_retval = -1; +#ifdef ALT_OS test_slk(VBERROR_SIMULATED, 0, "Alt OS incorrect boot after disable"); TEST_FALSE(saf_val & ALT_OS_ENABLE, "Alt OS doesn't disable"); +#else + test_slk(VBERROR_SIMULATED, 0, "Normal"); +#endif } int main(void) |