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

Unified Diff: firmware/lib/vboot_firmware.c

Issue 6626045: Pass VbSharedData between LoadFirmware() and LoadKernel() (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Fixes from code review. Created 9 years, 9 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 | « firmware/lib/vboot_common.c ('k') | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: firmware/lib/vboot_firmware.c
diff --git a/firmware/lib/vboot_firmware.c b/firmware/lib/vboot_firmware.c
index bbae0952872dcd929dc5d063e929f4e3d10fd705..2f358522a92c2cb5c4956d3ce1bea2369b1cbda6 100644
--- a/firmware/lib/vboot_firmware.c
+++ b/firmware/lib/vboot_firmware.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -6,6 +6,7 @@
* (Firmware portion)
*/
+#include "gbb_header.h"
#include "load_firmware_fw.h"
#include "rollback_index.h"
#include "utility.h"
@@ -39,8 +40,9 @@ int LoadFirmwareSetup(void) {
int LoadFirmware(LoadFirmwareParams* params) {
-
- VbPublicKey* root_key = (VbPublicKey*)params->firmware_root_key_blob;
+ VbSharedDataHeader* shared = (VbSharedDataHeader*)params->shared_data_blob;
+ GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)params->gbb_data;
+ VbPublicKey* root_key;
VbLoadFirmwareInternal* lfi;
VbNvContext* vnc = params->nv_context;
@@ -64,16 +66,19 @@ int LoadFirmware(LoadFirmwareParams* params) {
/* Setup NV storage */
VbNvSetup(vnc);
- if (params->kernel_sign_key_size < sizeof(VbPublicKey)) {
- VBDEBUG(("Kernel sign key buffer too small\n"));
+ /* Initialize shared data structure. */
+ if (0 != VbSharedDataInit(shared, params->shared_data_size)) {
+ VBDEBUG(("Shared data init error\n"));
+ recovery = VBNV_RECOVERY_RO_SHARED_DATA;
goto LoadFirmwareExit;
}
- /* Must have a root key */
- if (!root_key) {
- VBDEBUG(("No root key\n"));
+ /* Must have a root key from the GBB */
+ if (!gbb) {
+ VBDEBUG(("No GBB\n"));
goto LoadFirmwareExit;
}
+ root_key = (VbPublicKey*)((uint8_t*)gbb + gbb->rootkey_offset);
/* Parse flags */
is_dev = (params->boot_flags & BOOT_FLAG_DEVELOPER ? 1 : 0);
@@ -235,21 +240,13 @@ int LoadFirmware(LoadFirmwareParams* params) {
/* If we're still here, the firmware is valid. */
VBDEBUG(("Firmware %d is valid.\n", index));
if (-1 == good_index) {
- VbPublicKey *kdest = (VbPublicKey*)params->kernel_sign_key_blob;
-
- /* Copy the kernel sign key blob into the destination buffer */
- PublicKeyInit(kdest, (uint8_t*)(kdest + 1),
- (params->kernel_sign_key_size - sizeof(VbPublicKey)));
-
- if (0 != PublicKeyCopy(kdest, &preamble->kernel_subkey)) {
- VBDEBUG(("Kernel subkey too big for buffer.\n"));
+ /* Save the key we actually used */
+ if (0 != VbSharedDataSetKernelKey(shared, &preamble->kernel_subkey)) {
+ VBDEBUG(("Unable to save kernel subkey to shared data.\n"));
continue; /* The firmware signature was good, but the public
* key was bigger that the caller can handle. */
}
- /* Save the key size we actually used */
- params->kernel_sign_key_size = kdest->key_offset + kdest->key_size;
-
/* Save the good index, now that we're sure we can actually use
* this firmware. That's the one we'll boot. */
good_index = index;
@@ -314,6 +311,10 @@ LoadFirmwareExit:
recovery : VBNV_RECOVERY_NOT_REQUESTED);
VbNvTeardown(vnc);
+ /* Note that we don't reduce params->shared_data_size to shared->data_used,
+ * since we want to leave space for LoadKernel() to add to the shared data
+ * buffer. */
+
return retval;
}
« no previous file with comments | « firmware/lib/vboot_common.c ('k') | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698