summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/lib/include/rollback_index.h (renamed from firmware/include/rollback_index.h)6
-rw-r--r--firmware/lib/vboot_kernel.c31
-rw-r--r--firmware/version.c2
3 files changed, 21 insertions, 18 deletions
diff --git a/firmware/include/rollback_index.h b/firmware/lib/include/rollback_index.h
index b1366dd4..d60a1701 100644
--- a/firmware/include/rollback_index.h
+++ b/firmware/lib/include/rollback_index.h
@@ -73,7 +73,8 @@ Call from LoadKernel()
/* These functions are callable from LoadFirmware(). They cannot use
* global variables. */
-/* Setup must be called. */
+/* Setup must be called. Pass developer_mode=nonzero if in developer
+ * mode. */
uint32_t RollbackFirmwareSetup(int developer_mode,
uint16_t* key_version, uint16_t* version);
/* Write may be called if the versions change */
@@ -85,7 +86,8 @@ uint32_t RollbackFirmwareLock(void);
* variables. */
/* Recovery may be called. If it is, this is the first time a
* rollback function has been called this boot, so it needs to know if
- * we're in developer mode. */
+ * we're in developer mode. Pass developer_mode=nonzero if in developer
+ * mode. */
uint32_t RollbackKernelRecovery(int developer_mode);
/* Read and write may be called if not in developer mode. If called in
* recovery mode, these are ignored and/or return 0 versions. */
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 5533f11c..e6658d75 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -124,10 +124,9 @@ int LoadKernel(LoadKernelParams* params) {
uint16_t tpm_kernel_version = 0;
uint64_t lowest_key_version = 0xFFFF;
uint64_t lowest_kernel_version = 0xFFFF;
- int is_dev = ((BOOT_FLAG_DEVELOPER & params->boot_flags) &&
- !(BOOT_FLAG_RECOVERY & params->boot_flags));
- int is_normal = (!(BOOT_FLAG_DEVELOPER & params->boot_flags) &&
- !(BOOT_FLAG_RECOVERY & params->boot_flags));
+ int is_dev = (BOOT_FLAG_DEVELOPER & params->boot_flags);
+ int is_rec = (BOOT_FLAG_RECOVERY & params->boot_flags);
+ int is_normal = (!is_dev && !is_rec);
/* Clear output params in case we fail */
params->partition_number = 0;
@@ -135,11 +134,11 @@ int LoadKernel(LoadKernelParams* params) {
params->bootloader_size = 0;
/* Let the TPM know if we're in recovery mode */
- if (BOOT_FLAG_RECOVERY & params->boot_flags) {
- if (0 != RollbackKernelRecovery(BOOT_FLAG_DEVELOPER & params->boot_flags
- ? 1 : 0)) {
+ if (is_rec) {
+ if (0 != RollbackKernelRecovery(is_dev ? 1 : 0)) {
VBDEBUG(("Error setting up TPM for recovery kernel\n"));
- return LOAD_KERNEL_RECOVERY;
+ /* Ignore return code, since we need to boot recovery mode to
+ * fix the TPM. */
}
}
@@ -150,7 +149,7 @@ int LoadKernel(LoadKernelParams* params) {
VBDEBUG(("Unable to get kernel versions from TPM\n"));
return LOAD_KERNEL_RECOVERY;
}
- } else if (is_dev) {
+ } else if (is_dev && !is_rec) {
/* In developer mode, we ignore the kernel subkey, and just use
* the SHA-512 hash to verify the key block. */
kernel_subkey = NULL;
@@ -205,14 +204,14 @@ int LoadKernel(LoadKernelParams* params) {
/* Check the key block flags against the current boot mode */
if (!(key_block->key_block_flags &&
- ((BOOT_FLAG_DEVELOPER & params->boot_flags) ?
- KEY_BLOCK_FLAG_DEVELOPER_1 : KEY_BLOCK_FLAG_DEVELOPER_0))) {
+ (is_dev ? KEY_BLOCK_FLAG_DEVELOPER_1 :
+ KEY_BLOCK_FLAG_DEVELOPER_0))) {
VBDEBUG(("Developer flag mismatch.\n"));
continue;
}
if (!(key_block->key_block_flags &&
- ((BOOT_FLAG_RECOVERY & params->boot_flags) ?
- KEY_BLOCK_FLAG_RECOVERY_1 : KEY_BLOCK_FLAG_RECOVERY_0))) {
+ (is_rec ? KEY_BLOCK_FLAG_RECOVERY_1 :
+ KEY_BLOCK_FLAG_RECOVERY_0))) {
VBDEBUG(("Recovery flag mismatch.\n"));
continue;
}
@@ -374,10 +373,12 @@ int LoadKernel(LoadKernelParams* params) {
}
}
- /* Lock the kernel versions, since we're about to boot the kernel */
+ /* Lock the kernel versions */
if (0 != RollbackKernelLock()) {
VBDEBUG(("Error locking kernel versions.\n"));
- return LOAD_KERNEL_RECOVERY;
+ /* Don't reboot to recovery mode if we're already there */
+ if (!is_rec)
+ return LOAD_KERNEL_RECOVERY;
}
/* Success! */
diff --git a/firmware/version.c b/firmware/version.c
index f3ff0eda..faadabaa 100644
--- a/firmware/version.c
+++ b/firmware/version.c
@@ -1 +1 @@
-char* VbootVersion = "VBOOv=8078f71c";
+char* VbootVersion = "VBOOv=c6976ffa";