summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-12-19 13:51:25 +0800
committerCommit Bot <commit-bot@chromium.org>2019-12-24 14:05:27 +0000
commitd9ddac88c99d8df5b7dde618e43807f3c0dd6080 (patch)
tree195b4f616f23d92703c7a34d2fb33253dde6a521
parent1df08718b7c18a0454240f78bdb80359116fc295 (diff)
downloadvboot-d9ddac88c99d8df5b7dde618e43807f3c0dd6080.tar.gz
vboot: change USB_BOOT_ON_DEV to use build flag
Instead of calling VbExGetSwitches to essentially retrieve a compile-time config value from depthcharge, send this config value to vboot_reference as a build flag. Add a test based on the value of USB_BOOT_ON_DEV. BUG=b:124141368, chromium:1035761 TEST=make clean && make runtests TEST=Add CONFIG_USB_BOOT_ON_DEV to defconfig and flash to device Switch to dev mode and confirm dev_boot_usb with crossystem BRANCH=none Change-Id: I70a2e3fcd8c5cc252ca3d0eed81490a08503d7b3 Cq-Depend: chromium:1975346 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1975450 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
-rw-r--r--Makefile7
-rw-r--r--firmware/include/vboot_api.h2
-rw-r--r--firmware/lib/vboot_ui.c11
-rw-r--r--firmware/lib/vboot_ui_menu.c2
-rw-r--r--tests/vboot_api_kernel2_tests.c2
5 files changed, 12 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 26cfc6d6..c6cceb1d 100644
--- a/Makefile
+++ b/Makefile
@@ -183,6 +183,13 @@ ifneq (${TPM2_MODE},)
CFLAGS += -DTPM2_MODE
endif
+# Enable USB boot when switching to dev mode
+ifneq ($(filter-out 0,${USB_BOOT_ON_DEV}),)
+CFLAGS += -DUSB_BOOT_ON_DEV=1
+else
+CFLAGS += -DUSB_BOOT_ON_DEV=0
+endif
+
# Some tests need to be disabled when using mocked_secdata_tpm.
ifneq (${MOCK_TPM},)
CFLAGS += -DMOCK_TPM
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index f893aadc..d7c2eee2 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -50,8 +50,6 @@ typedef struct VbSharedDataHeader VbSharedDataHeader;
/* Flags for VbExGetSwitches() */
/* Report if user is currently present (typically via power button) */
#define VB_SWITCH_FLAG_PHYS_PRESENCE_PRESSED 0x00000004
-/* Allow USB boot on transition to dev */
-#define VB_SWITCH_FLAG_ALLOW_USB_BOOT 0x00004000
/*
* We use disk handles rather than indices. Using indices causes problems if
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index b0c67d22..c48478d8 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -35,12 +35,6 @@ void vb2_init_ui(void)
power_button_state = POWER_BUTTON_HELD_SINCE_BOOT;
}
-static void VbAllowUsbBoot(struct vb2_context *ctx)
-{
- VB2_DEBUG(".");
- vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
-}
-
/**
* Checks GBB flags against VbExIsShutdownRequested() shutdown request to
* determine if a shutdown is required.
@@ -877,9 +871,8 @@ static vb2_error_t recovery_ui(struct vb2_context *ctx)
if (VB2_SUCCESS != vb2_enable_developer_mode(ctx))
return VBERROR_TPM_SET_BOOT_MODE_STATE;
VB2_DEBUG("Reboot so it will take effect\n");
- if (VbExGetSwitches
- (VB_SWITCH_FLAG_ALLOW_USB_BOOT))
- VbAllowUsbBoot(ctx);
+ if (USB_BOOT_ON_DEV)
+ vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
case -1:
VB2_DEBUG("Shutdown requested\n");
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index aa3f2a91..f74f6d50 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -364,7 +364,7 @@ static vb2_error_t to_dev_action(struct vb2_context *ctx)
return VBERROR_TPM_SET_BOOT_MODE_STATE;
/* This was meant for headless devices, shouldn't really matter here. */
- if (VbExGetSwitches(VB_SWITCH_FLAG_ALLOW_USB_BOOT))
+ if (USB_BOOT_ON_DEV)
vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
VB2_DEBUG("Reboot so it will take effect\n");
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index 2d490681..712fa707 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -1120,6 +1120,8 @@ static void VbBootRecTestGpio(uint32_t first, uint32_t second, uint32_t third,
TEST_EQ(VbBootRecovery(ctx), VBERROR_EC_REBOOT_TO_RO_REQUIRED,
msg);
TEST_EQ(virtdev_set, 1, " virtual dev mode on");
+ TEST_EQ(vb2_nv_get(ctx, VB2_NV_DEV_BOOT_USB), !!USB_BOOT_ON_DEV,
+ " NV_DEV_BOOT_USB enabled");
} else {
TEST_EQ(VbBootRecovery(ctx), VBERROR_SHUTDOWN_REQUESTED, msg);
TEST_EQ(virtdev_set, 0, " virtual dev mode off");