From b7d1f03e368b146d11eab511cd6a573a528bc728 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Tue, 3 Feb 2015 16:28:31 -0800 Subject: [PATCH] kernel flags: Pass back kernel premable flags in kparams Kernel preamble flags are set by the signer for passing hints about the image. Read these flags from the preamble and pass it back to the caller in kparams structure. BUG=chrome-os-partner:35861 BRANCH=None TEST=Compiles and boots to kernel prompt for both CrOS image and bootimg. Change-Id: I07a8b974dcf3ab5cd93d26a752c989d268c8da99 Signed-off-by: Furquan Shaikh Reviewed-on: https://chromium-review.googlesource.com/245951 Reviewed-by: Bill Richardson Tested-by: Furquan Shaikh Reviewed-by: Randall Spangler Commit-Queue: Furquan Shaikh --- firmware/include/vboot_api.h | 2 ++ firmware/lib/include/load_kernel_fw.h | 2 ++ firmware/lib/vboot_api_kernel.c | 2 ++ firmware/lib/vboot_kernel.c | 3 +++ 4 files changed, 9 insertions(+) diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index af61eedd08..9c040c067b 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -335,6 +335,8 @@ typedef struct VbSelectAndLoadKernelParams { uint32_t bootloader_size; /* UniquePartitionGuid for boot partition */ uint8_t partition_guid[16]; + /* Flags passed in by signer */ + uint32_t flags; /* * TODO: in H2C, all that pretty much just gets passed to the * bootloader as KernelBootloaderOptions, though the disk handle is diff --git a/firmware/lib/include/load_kernel_fw.h b/firmware/lib/include/load_kernel_fw.h index 46081912d8..da418a3327 100644 --- a/firmware/lib/include/load_kernel_fw.h +++ b/firmware/lib/include/load_kernel_fw.h @@ -70,6 +70,8 @@ typedef struct LoadKernelParams { uint64_t bootloader_size; /* UniquePartitionGuid for boot partition */ uint8_t partition_guid[16]; + /* Flags passed in by signer */ + uint32_t flags; } LoadKernelParams; /** diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index d394d5ccbd..4769089ef1 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -984,6 +984,7 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, kparams->partition_number = 0; kparams->bootloader_address = 0; kparams->bootloader_size = 0; + kparams->flags = 0; Memset(kparams->partition_guid, 0, sizeof(kparams->partition_guid)); cparams->bmp = NULL; @@ -1152,6 +1153,7 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams, kparams->partition_number = (uint32_t)p.partition_number; kparams->bootloader_address = p.bootloader_address; kparams->bootloader_size = (uint32_t)p.bootloader_size; + kparams->flags = p.flags; Memcpy(kparams->partition_guid, p.partition_guid, sizeof(kparams->partition_guid)); diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 08b8a23ba1..9ea054c3ee 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -67,6 +67,7 @@ VbError_t LoadKernel(LoadKernelParams *params, VbCommonParams *cparams) params->partition_number = 0; params->bootloader_address = 0; params->bootloader_size = 0; + params->flags = 0; /* Calculate switch positions and boot mode */ rec_switch = (BOOT_FLAG_RECOVERY & params->boot_flags ? 1 : 0); @@ -437,6 +438,8 @@ VbError_t LoadKernel(LoadKernelParams *params, VbCommonParams *cparams) */ params->bootloader_address = preamble->bootloader_address; params->bootloader_size = preamble->bootloader_size; + if (VbKernelHasFlags(preamble) == VBOOT_SUCCESS) + params->flags = preamble->flags; /* Update GPT to note this is the kernel we're trying */ GptUpdateKernelEntry(&gpt, GPT_UPDATE_ENTRY_TRY);