Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: src/platform/vboot_reference/vboot_firmware/lib/load_kernel_fw.c

Issue 2561001: Fix LoadKernel() (Closed) Base URL: ssh://gitrw.chromium.org/chromiumos
Patch Set: Make requested changes. Rename bootloader start to bootloader address. Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform/vboot_reference/vboot_firmware/lib/kernel_image_fw.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/vboot_reference/vboot_firmware/lib/load_kernel_fw.c
diff --git a/src/platform/vboot_reference/vboot_firmware/lib/load_kernel_fw.c b/src/platform/vboot_reference/vboot_firmware/lib/load_kernel_fw.c
index dec92d199a4c69d2c2acffff434e3ee536df186c..ba515a275a90fcea82f4c0da6e52efc2b04f689d 100644
--- a/src/platform/vboot_reference/vboot_firmware/lib/load_kernel_fw.c
+++ b/src/platform/vboot_reference/vboot_firmware/lib/load_kernel_fw.c
@@ -18,6 +18,7 @@
// TODO: for testing
#include <stdio.h>
+#include <inttypes.h> /* For PRIu64 macro */
#include "cgptlib_internal.h"
/* TODO: Remove this terrible hack which fakes partition attributes
@@ -28,11 +29,10 @@ void FakePartitionAttributes(GptData* gpt) {
GptEntry* e;
int i;
printf("Hacking partition attributes...\n");
- printf("Note that GUIDs below have first 3 fields endian-swapped\n");
for (i = 0, e = entries; i < 12; i++, e++) {
- printf("%2d %08x %04x %04x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ printf("%2d %08x %04x %04x %02x %02x %02x %02x %02x %02x %02x %02x",
i,
e->type.u.Uuid.time_low,
e->type.u.Uuid.time_mid,
@@ -46,6 +46,8 @@ void FakePartitionAttributes(GptData* gpt) {
e->type.u.Uuid.node[4],
e->type.u.Uuid.node[5]
);
+ printf(" %8" PRIu64 " %8" PRIu64"\n", e->starting_lba,
+ e->ending_lba - e->starting_lba + 1);
if (!IsKernelEntry(e))
continue;
printf("Hacking attributes for kernel partition %d\n", i);
@@ -144,6 +146,11 @@ int LoadKernel(LoadKernelParams* params) {
uint16_t lowest_kernel_version = 0xFFFF;
KernelImage *kim = NULL;
+ /* Clear output params in case we fail */
+ params->partition_number = 0;
+ params->bootloader_address = 0;
+ params->bootloader_size = 0;
+
/* Read current kernel key index from TPM. Assumes TPM is already
* initialized. */
/* TODO: Is that a safe assumption? Normally, SetupTPM() would be called
@@ -161,8 +168,6 @@ int LoadKernel(LoadKernelParams* params) {
if (0 != AllocAndReadGptData(&gpt))
break;
- fprintf(stderr, "RRS1\n");
-
/* Initialize GPT library */
if (GPT_SUCCESS != GptInit(&gpt))
break;
@@ -180,15 +185,11 @@ int LoadKernel(LoadKernelParams* params) {
if (!kim)
break;
- fprintf(stderr, "RRS2\n");
-
/* Loop over candidate kernel partitions */
while (GPT_SUCCESS == GptNextKernelEntry(&gpt, &part_start, &part_size)) {
RSAPublicKey *kernel_sign_key = NULL;
int kernel_start, kernel_sectors;
- fprintf(stderr, "RRS3\n");
-
/* Found at least one kernel partition. */
found_partition = 1;
@@ -198,8 +199,6 @@ int LoadKernel(LoadKernelParams* params) {
if (0 != BootDeviceReadLBA(part_start, kbuf_sectors, kbuf))
continue;
- fprintf(stderr, "RRS4\n");
-
/* Verify the kernel header and preamble */
if (VERIFY_KERNEL_SUCCESS != VerifyKernelHeader(
params->header_sign_key_blob,
@@ -211,7 +210,17 @@ int LoadKernel(LoadKernelParams* params) {
continue;
}
- fprintf(stderr, "RRS5\n");
+ printf("Kernel header:\n");
+ printf("header version: %d\n", kim->header_version);
+ printf("header len: %d\n", kim->header_len);
+ printf("firmware sign alg: %d\n", kim->firmware_sign_algorithm);
+ printf("kernel sign alg: %d\n", kim->kernel_sign_algorithm);
+ printf("kernel key version: %d\n", kim->kernel_key_version);
+ printf("kernel version: %d\n", kim->kernel_version);
+ printf("kernel len: %" PRIu64 "\n", kim->kernel_len);
+ printf("bootloader addr: %" PRIu64 "\n", kim->bootloader_offset);
+ printf("bootloader size: %" PRIu64 "\n", kim->bootloader_size);
+ printf("padded header size: %" PRIu64 "\n", kim->padded_header_size);
/* Check for rollback of key version */
if (kim->kernel_key_version < tpm_kernel_key_version) {
@@ -270,8 +279,7 @@ int LoadKernel(LoadKernelParams* params) {
if (-1 == good_partition) {
good_partition = gpt.current_kernel;
params->partition_number = gpt.current_kernel;
- params->bootloader_start = (uint8_t*)params->kernel_buffer +
- kim->bootloader_offset;
+ params->bootloader_address = kim->bootloader_offset;
params->bootloader_size = kim->bootloader_size;
/* If the good partition's key version is the same as the tpm, then
« no previous file with comments | « src/platform/vboot_reference/vboot_firmware/lib/kernel_image_fw.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698