summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2020-04-16 13:18:52 +0800
committerCommit Bot <commit-bot@chromium.org>2020-04-17 12:52:37 +0000
commit297ea05cf12ce31156f8648983431332b50c995c (patch)
tree43b6b669e042e2609bcb54a836afe5b98f38f848 /firmware
parent860328536239e78ec33c1c7132ac0e98121f07eb (diff)
downloadvboot-297ea05cf12ce31156f8648983431332b50c995c.tar.gz
vboot: remove VBERROR_TPM_SET_BOOT_MODE_STATE error code
Since secdata and nvdata get/set functions no longer return error codes, and instead use VB2_ASSERT and VB2_DIE to abort on failure, vb2_enable_developer_mode no longer has any error code to return. Change the function return type to void, and remove checks around the function call. As a result, VBERROR_TPM_SET_BOOT_MODE_STATE becomes unused and we may remove it. Finally, move the USB_BOOT_ON_DEV logic (enable USB boot when on transition to dev mode) into vb2_enable_developer_mode. Also add unit tests. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I286d9343c4c751ff24bf4c149a26fbe5306e383a Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2152212 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/2misc.c7
-rw-r--r--firmware/2lib/include/2misc.h3
-rw-r--r--firmware/2lib/include/2return_codes.h2
-rw-r--r--firmware/lib/vboot_ui_legacy_clamshell.c7
-rw-r--r--firmware/lib/vboot_ui_legacy_menu.c9
5 files changed, 7 insertions, 21 deletions
diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c
index de4b4241..5411ad1e 100644
--- a/firmware/2lib/2misc.c
+++ b/firmware/2lib/2misc.c
@@ -375,7 +375,7 @@ vb2_error_t vb2_select_fw_slot(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-vb2_error_t vb2_enable_developer_mode(struct vb2_context *ctx)
+void vb2_enable_developer_mode(struct vb2_context *ctx)
{
uint32_t flags;
@@ -385,9 +385,10 @@ vb2_error_t vb2_enable_developer_mode(struct vb2_context *ctx)
flags |= VB2_SECDATA_FIRMWARE_FLAG_DEV_MODE;
vb2_secdata_firmware_set(ctx, VB2_SECDATA_FIRMWARE_FLAGS, flags);
- VB2_DEBUG("Mode change will take effect on next reboot\n");
+ if (USB_BOOT_ON_DEV)
+ vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
- return VB2_SUCCESS;
+ VB2_DEBUG("Mode change will take effect on next reboot\n");
}
test_mockable
diff --git a/firmware/2lib/include/2misc.h b/firmware/2lib/include/2misc.h
index 94a93d40..ccdd832a 100644
--- a/firmware/2lib/include/2misc.h
+++ b/firmware/2lib/include/2misc.h
@@ -171,9 +171,8 @@ vb2_error_t vb2_load_kernel_preamble(struct vb2_context *ctx);
* done on the next boot.
*
* @param ctx Vboot context
- * @return VB2_SUCCESS, or error code on error.
*/
-vb2_error_t vb2_enable_developer_mode(struct vb2_context *ctx);
+void vb2_enable_developer_mode(struct vb2_context *ctx);
/**
* Check whether recovery is allowed or not.
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index c03ba7ac..3a303be1 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -40,8 +40,6 @@ enum vb2_return_code {
* vboot1-style errors
* TODO: deprecate these once they have all moved over to vboot2 style
*/
- /* Unable to set boot mode state in TPM */
- VBERROR_TPM_SET_BOOT_MODE_STATE = 0x10006,
/* Calling firmware needs to perform a reboot. */
VBERROR_REBOOT_REQUIRED = 0x10007,
/* Calling firmware requested shutdown via VbExIsShutdownRequested() */
diff --git a/firmware/lib/vboot_ui_legacy_clamshell.c b/firmware/lib/vboot_ui_legacy_clamshell.c
index c510d58f..a759b931 100644
--- a/firmware/lib/vboot_ui_legacy_clamshell.c
+++ b/firmware/lib/vboot_ui_legacy_clamshell.c
@@ -499,12 +499,7 @@ static vb2_error_t recovery_ui(struct vb2_context *ctx)
VB_CONFIRM_MUST_TRUST_KEYBOARD;
switch (VbUserConfirms(ctx, vbc_flags)) {
case 1:
- VB2_DEBUG("Enabling dev-mode...\n");
- 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 (USB_BOOT_ON_DEV)
- vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
+ vb2_enable_developer_mode(ctx);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
case -1:
VB2_DEBUG("Shutdown requested\n");
diff --git a/firmware/lib/vboot_ui_legacy_menu.c b/firmware/lib/vboot_ui_legacy_menu.c
index 48eaabe9..66e4c9c7 100644
--- a/firmware/lib/vboot_ui_legacy_menu.c
+++ b/firmware/lib/vboot_ui_legacy_menu.c
@@ -358,15 +358,8 @@ static vb2_error_t to_dev_action(struct vb2_context *ctx)
!vb2_allow_recovery(ctx))
return VBERROR_KEEP_LOOPING;
- VB2_DEBUG("Enabling dev-mode...\n");
- if (VB2_SUCCESS != vb2_enable_developer_mode(ctx))
- return VBERROR_TPM_SET_BOOT_MODE_STATE;
+ vb2_enable_developer_mode(ctx);
- /* This was meant for headless devices, shouldn't really matter here. */
- if (USB_BOOT_ON_DEV)
- vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
-
- VB2_DEBUG("Reboot so it will take effect\n");
return VBERROR_REBOOT_REQUIRED;
}