Enable TPM in developer mode again.

Also fix a few comments, and make extra debugging work when compiled
in firmware.

BUG=none
TEST=make && make runtests; all pass

Review URL: http://codereview.chromium.org/3007036
This commit is contained in:
Randall Spangler
2010-08-05 15:13:14 -07:00
parent 97a122817d
commit 63dffcb52b
5 changed files with 59 additions and 80 deletions

View File

@@ -152,16 +152,12 @@ int LoadKernel(LoadKernelParams* params) {
params->bootloader_address = 0;
params->bootloader_size = 0;
if (!is_dev) {
/* TODO: should use the TPM all the time; for now, only use when
* not in developer mode. */
/* Let the TPM know if we're in recovery mode */
if (is_rec) {
if (0 != RollbackKernelRecovery(is_dev ? 1 : 0)) {
VBDEBUG(("Error setting up TPM for recovery kernel\n"));
/* Ignore return code, since we need to boot recovery mode to
* fix the TPM. */
}
/* Let the TPM know if we're in recovery mode */
if (is_rec) {
if (0 != RollbackKernelRecovery(is_dev)) {
VBDEBUG(("Error setting up TPM for recovery kernel\n"));
/* Ignore return code, since we need to boot recovery mode to
* fix the TPM. */
}
}
@@ -350,6 +346,8 @@ int LoadKernel(LoadKernelParams* params) {
good_partition = gpt.current_kernel + 1;
params->partition_number = gpt.current_kernel + 1;
GetCurrentKernelUniqueGuid(&gpt, &params->partition_guid);
/* TODO: GetCurrentKernelUniqueGuid() should take a destination size, or
* the dest should be a struct, so we know it's big enough. */
params->bootloader_address = preamble->bootloader_address;
params->bootloader_size = preamble->bootloader_size;
/* If we're in developer or recovery mode, there's no rollback
@@ -400,24 +398,20 @@ int LoadKernel(LoadKernelParams* params) {
(uint16_t)lowest_kernel_version);
if (0 != status) {
VBDEBUG(("Error writing kernel versions to TPM.\n"));
return (status == TPM_E_MUST_REBOOT ?
LOAD_KERNEL_REBOOT : LOAD_KERNEL_RECOVERY);
return (status == TPM_E_MUST_REBOOT ?
LOAD_KERNEL_REBOOT : LOAD_KERNEL_RECOVERY);
}
}
}
if (!is_dev) {
/* TODO: should use the TPM all the time; for now, only use when
* not in developer mode. */
/* Lock the kernel versions */
status = RollbackKernelLock();
if (0 != status) {
VBDEBUG(("Error locking kernel versions.\n"));
/* Don't reboot to recovery mode if we're already there */
if (!is_rec)
return (status == TPM_E_MUST_REBOOT ?
LOAD_KERNEL_REBOOT : LOAD_KERNEL_RECOVERY);
}
/* Lock the kernel versions */
status = RollbackKernelLock();
if (0 != status) {
VBDEBUG(("Error locking kernel versions.\n"));
/* Don't reboot to recovery mode if we're already there */
if (!is_rec)
return (status == TPM_E_MUST_REBOOT ?
LOAD_KERNEL_REBOOT : LOAD_KERNEL_RECOVERY);
}
/* Success! */