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

Side by Side Diff: firmware/lib/vboot_firmware.c

Issue 6673048: LoadFirmware() and LoadKernel() handling for test errors (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: post merge 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « firmware/include/vboot_nvstorage.h ('k') | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * High-level firmware API for loading and verifying rewritable firmware. 5 * High-level firmware API for loading and verifying rewritable firmware.
6 * (Firmware portion) 6 * (Firmware portion)
7 */ 7 */
8 8
9 #include "gbb_header.h" 9 #include "gbb_header.h"
10 #include "load_firmware_fw.h" 10 #include "load_firmware_fw.h"
(...skipping 16 matching lines...) Expand all
27 uint8_t* data, uint64_t size) { 27 uint8_t* data, uint64_t size) {
28 VbLoadFirmwareInternal* lfi = 28 VbLoadFirmwareInternal* lfi =
29 (VbLoadFirmwareInternal*)params->load_firmware_internal; 29 (VbLoadFirmwareInternal*)params->load_firmware_internal;
30 30
31 DigestUpdate(&lfi->body_digest_context, data, size); 31 DigestUpdate(&lfi->body_digest_context, data, size);
32 lfi->body_size_accum += size; 32 lfi->body_size_accum += size;
33 } 33 }
34 34
35 35
36 int LoadFirmwareSetup(void) { 36 int LoadFirmwareSetup(void) {
37 /* TODO: handle test errors (requires passing in VbNvContext) */
37 /* TODO: start initializing the TPM */ 38 /* TODO: start initializing the TPM */
38 return LOAD_FIRMWARE_SUCCESS; 39 return LOAD_FIRMWARE_SUCCESS;
39 } 40 }
40 41
41 42
42 int LoadFirmware(LoadFirmwareParams* params) { 43 int LoadFirmware(LoadFirmwareParams* params) {
43 VbSharedDataHeader* shared = (VbSharedDataHeader*)params->shared_data_blob; 44 VbSharedDataHeader* shared = (VbSharedDataHeader*)params->shared_data_blob;
44 GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)params->gbb_data; 45 GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)params->gbb_data;
45 VbPublicKey* root_key; 46 VbPublicKey* root_key;
46 VbLoadFirmwareInternal* lfi; 47 VbLoadFirmwareInternal* lfi;
47 VbNvContext* vnc = params->nv_context; 48 VbNvContext* vnc = params->nv_context;
48 49
49 uint32_t try_b_count; 50 uint32_t try_b_count;
50 uint32_t tpm_version = 0; 51 uint32_t tpm_version = 0;
51 uint64_t lowest_version = 0xFFFFFFFF; 52 uint64_t lowest_version = 0xFFFFFFFF;
52 uint32_t status; 53 uint32_t status;
54 uint32_t test_err = 0;
53 int good_index = -1; 55 int good_index = -1;
54 int is_dev; 56 int is_dev;
55 int index; 57 int index;
56 int i; 58 int i;
57 59
58 int retval = LOAD_FIRMWARE_RECOVERY; 60 int retval = LOAD_FIRMWARE_RECOVERY;
59 int recovery = VBNV_RECOVERY_RO_UNSPECIFIED; 61 int recovery = VBNV_RECOVERY_RO_UNSPECIFIED;
60 62
61 /* Clear output params in case we fail */ 63 /* Clear output params in case we fail */
62 params->firmware_index = 0; 64 params->firmware_index = 0;
63 65
64 VBDEBUG(("LoadFirmware started...\n")); 66 VBDEBUG(("LoadFirmware started...\n"));
65 67
66 /* Setup NV storage */ 68 /* Setup NV storage */
67 VbNvSetup(vnc); 69 VbNvSetup(vnc);
68 70
69 /* Initialize shared data structure. */ 71 /* Initialize shared data structure. */
70 if (0 != VbSharedDataInit(shared, params->shared_data_size)) { 72 if (0 != VbSharedDataInit(shared, params->shared_data_size)) {
71 VBDEBUG(("Shared data init error\n")); 73 VBDEBUG(("Shared data init error\n"));
72 recovery = VBNV_RECOVERY_RO_SHARED_DATA; 74 recovery = VBNV_RECOVERY_RO_SHARED_DATA;
73 goto LoadFirmwareExit; 75 goto LoadFirmwareExit;
74 } 76 }
75 77
78 /* Handle test errors */
79 VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
80 if (VBNV_TEST_ERROR_LOAD_FIRMWARE == test_err) {
81 /* Get error code */
82 VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err);
83 /* Clear test params so we don't repeat the error */
84 VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0);
85 VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0);
86 /* Handle error codes */
87 switch (test_err) {
88 case LOAD_FIRMWARE_RECOVERY:
89 recovery = VBNV_RECOVERY_RO_TEST_LF;
90 goto LoadFirmwareExit;
91 case LOAD_FIRMWARE_REBOOT:
92 retval = test_err;
93 goto LoadFirmwareExit;
94 default:
95 break;
96 }
97 }
98
76 /* Must have a root key from the GBB */ 99 /* Must have a root key from the GBB */
77 if (!gbb) { 100 if (!gbb) {
78 VBDEBUG(("No GBB\n")); 101 VBDEBUG(("No GBB\n"));
79 goto LoadFirmwareExit; 102 goto LoadFirmwareExit;
80 } 103 }
81 root_key = (VbPublicKey*)((uint8_t*)gbb + gbb->rootkey_offset); 104 root_key = (VbPublicKey*)((uint8_t*)gbb + gbb->rootkey_offset);
82 105
83 /* Parse flags */ 106 /* Parse flags */
84 is_dev = (params->boot_flags & BOOT_FLAG_DEVELOPER ? 1 : 0); 107 is_dev = (params->boot_flags & BOOT_FLAG_DEVELOPER ? 1 : 0);
85 108
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 336
314 /* Note that we don't reduce params->shared_data_size to shared->data_used, 337 /* Note that we don't reduce params->shared_data_size to shared->data_used,
315 * since we want to leave space for LoadKernel() to add to the shared data 338 * since we want to leave space for LoadKernel() to add to the shared data
316 * buffer. */ 339 * buffer. */
317 340
318 return retval; 341 return retval;
319 } 342 }
320 343
321 344
322 int S3Resume(void) { 345 int S3Resume(void) {
346
347 /* TODO: handle test errors (requires passing in VbNvContext) */
348
323 /* Resume the TPM */ 349 /* Resume the TPM */
324 uint32_t status = RollbackS3Resume(); 350 uint32_t status = RollbackS3Resume();
325 351
326 /* If we can't resume, just do a full reboot. No need to go to recovery 352 /* If we can't resume, just do a full reboot. No need to go to recovery
327 * mode here, since if the TPM is really broken we'll catch it on the 353 * mode here, since if the TPM is really broken we'll catch it on the
328 * next boot. */ 354 * next boot. */
329 if (status == TPM_SUCCESS) 355 if (status == TPM_SUCCESS)
330 return LOAD_FIRMWARE_SUCCESS; 356 return LOAD_FIRMWARE_SUCCESS;
331 else 357 else
332 return LOAD_FIRMWARE_REBOOT; 358 return LOAD_FIRMWARE_REBOOT;
333 } 359 }
OLDNEW
« no previous file with comments | « firmware/include/vboot_nvstorage.h ('k') | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698