summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2011-03-15 15:28:31 -0700
committerRandall Spangler <rspangler@chromium.org>2011-03-15 15:28:31 -0700
commit99ca3466ba097cceacaff0129e9060578a8fcb20 (patch)
treef6f60435a4db154e11a802b5b21a1920b53abcfa
parentbc7a84d9a1bef3fb8c1e2709033f6c9777599fe9 (diff)
downloadvboot-99ca3466ba097cceacaff0129e9060578a8fcb20.tar.gz
LoadFirmware() and LoadKernel() handling for test errors
Change-Id: Icecfcab8f5cc30e80da7a2d77a1b1729f5094fee R=wfrichar@chromium.org BUG=13107 TEST=make && make runtests Review URL: http://codereview.chromium.org/6673048
-rw-r--r--firmware/include/vboot_nvstorage.h7
-rw-r--r--firmware/lib/vboot_firmware.c26
-rw-r--r--firmware/lib/vboot_kernel.c24
3 files changed, 57 insertions, 0 deletions
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h
index 98377056..350a789e 100644
--- a/firmware/include/vboot_nvstorage.h
+++ b/firmware/include/vboot_nvstorage.h
@@ -116,6 +116,13 @@ typedef enum VbNvParam {
#define VBNV_RECOVERY_US_UNSPECIFIED 0xFF
+/* Function codes for VBNV_TEST_ERROR_FUNC */
+#define VBNV_TEST_ERROR_LOAD_FIRMWARE_SETUP 1
+#define VBNV_TEST_ERROR_LOAD_FIRMWARE 2
+#define VBNV_TEST_ERROR_LOAD_KERNEL 3
+#define VBNV_TEST_ERROR_S3_RESUME 4
+
+
/* Initialize the NV storage library. This must be called before any
* other functions in this library. Returns 0 if success, non-zero if
* error.
diff --git a/firmware/lib/vboot_firmware.c b/firmware/lib/vboot_firmware.c
index 2f358522..bfe91866 100644
--- a/firmware/lib/vboot_firmware.c
+++ b/firmware/lib/vboot_firmware.c
@@ -34,6 +34,7 @@ void UpdateFirmwareBodyHash(LoadFirmwareParams* params,
int LoadFirmwareSetup(void) {
+ /* TODO: handle test errors (requires passing in VbNvContext) */
/* TODO: start initializing the TPM */
return LOAD_FIRMWARE_SUCCESS;
}
@@ -50,6 +51,7 @@ int LoadFirmware(LoadFirmwareParams* params) {
uint32_t tpm_version = 0;
uint64_t lowest_version = 0xFFFFFFFF;
uint32_t status;
+ uint32_t test_err = 0;
int good_index = -1;
int is_dev;
int index;
@@ -73,6 +75,27 @@ int LoadFirmware(LoadFirmwareParams* params) {
goto LoadFirmwareExit;
}
+ /* Handle test errors */
+ VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
+ if (VBNV_TEST_ERROR_LOAD_FIRMWARE == test_err) {
+ /* Get error code */
+ VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err);
+ /* Clear test params so we don't repeat the error */
+ VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0);
+ VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0);
+ /* Handle error codes */
+ switch (test_err) {
+ case LOAD_FIRMWARE_RECOVERY:
+ recovery = VBNV_RECOVERY_RO_TEST_LF;
+ goto LoadFirmwareExit;
+ case LOAD_FIRMWARE_REBOOT:
+ retval = test_err;
+ goto LoadFirmwareExit;
+ default:
+ break;
+ }
+ }
+
/* Must have a root key from the GBB */
if (!gbb) {
VBDEBUG(("No GBB\n"));
@@ -320,6 +343,9 @@ LoadFirmwareExit:
int S3Resume(void) {
+
+ /* TODO: handle test errors (requires passing in VbNvContext) */
+
/* Resume the TPM */
uint32_t status = RollbackS3Resume();
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index ee2890cf..faa9c48a 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -135,6 +135,7 @@ int LoadKernel(LoadKernelParams* params) {
uint64_t lowest_version = 0xFFFFFFFF;
int rec_switch, dev_switch;
BootMode boot_mode;
+ uint32_t test_err = 0;
uint32_t status;
/* TODO: differentiate between finding an invalid kernel (found_partitions>0)
@@ -156,6 +157,29 @@ int LoadKernel(LoadKernelParams* params) {
goto LoadKernelExit;
}
+ /* Handle test errors */
+ VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
+ if (VBNV_TEST_ERROR_LOAD_KERNEL == test_err) {
+ /* Get error code */
+ VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err);
+ /* Clear test params so we don't repeat the error */
+ VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0);
+ VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0);
+ /* Handle error codes */
+ switch (test_err) {
+ case LOAD_KERNEL_RECOVERY:
+ recovery = VBNV_RECOVERY_RW_TEST_LK;
+ goto LoadKernelExit;
+ case LOAD_KERNEL_NOT_FOUND:
+ case LOAD_KERNEL_INVALID:
+ case LOAD_KERNEL_REBOOT:
+ retval = test_err;
+ goto LoadKernelExit;
+ default:
+ break;
+ }
+ }
+
/* Initialization */
blba = params->bytes_per_lba;
kbuf_sectors = KBUF_SIZE / blba;