Remove unused test fields from VbNvStorage

Confirmed via codesearch that these fields are not used outside of
vboot_reference itself, and the only use inside vboot_reference is one
test which checked that the test error generation itself worked.

BUG=chromium-os:31668
TEST=make && make runtests

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: Ic393e126ca2853f7aaff19ffd6fcdbdb1c47689f
Reviewed-on: https://gerrit.chromium.org/gerrit/24895
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h
index 7914176..4259d40 100644
--- a/firmware/include/vboot_nvstorage.h
+++ b/firmware/include/vboot_nvstorage.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  */
@@ -47,11 +47,6 @@
   VBNV_LOCALIZATION_INDEX,
   /* Field reserved for kernel/user-mode use; 32-bit value. */
   VBNV_KERNEL_FIELD,
-  /* Verified boot API function which should generate a test error, if
-   * error number (below) is non-zero. */
-  VBNV_TEST_ERROR_FUNC,
-  /* Verified boot API error to generate for the function, if non-zero. */
-  VBNV_TEST_ERROR_NUM,
   /* Allow booting from USB in developer mode.  0=no, 1=yes. */
   VBNV_DEV_BOOT_USB,
   /* Only boot Google-signed images in developer mode.  0=no, 1=yes. */
@@ -130,13 +125,6 @@
 #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 2bc6652..3f9f64f 100644
--- a/firmware/lib/vboot_firmware.c
+++ b/firmware/lib/vboot_firmware.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  *
@@ -42,7 +42,6 @@
 
   uint32_t try_b_count;
   uint32_t lowest_version = 0xFFFFFFFF;
-  uint32_t test_err = 0;
   int good_index = -1;
   int is_dev;
   int index;
@@ -56,22 +55,6 @@
 
   VBDEBUG(("LoadFirmware started...\n"));
 
-  /* 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);
-    /* All error codes currently map to simulated error */
-    if (test_err) {
-      recovery = VBNV_RECOVERY_RO_TEST_LF;
-      retval = VBERROR_SIMULATED;
-      goto LoadFirmwareExit;
-    }
-  }
-
   /* Must have a root key from the GBB */
   if (!gbb) {
     VBDEBUG(("No GBB\n"));
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 9573e6e..1dffc7b 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  *
@@ -139,7 +139,6 @@
   uint32_t lowest_version = LOWEST_TPM_VERSION;
   int rec_switch, dev_switch;
   BootMode boot_mode;
-  uint32_t test_err = 0;
   uint32_t require_official_os = 0;
 
   VbError_t retval = VBERROR_UNKNOWN;
@@ -184,23 +183,6 @@
   shcall->sector_count = params->ending_lba + 1;
   shared->lk_call_count++;
 
-  /* 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);
-    shcall->test_error_num = (uint8_t)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);
-    /* All error codes currently map to simulated error */
-    if (test_err) {
-      recovery = VBNV_RECOVERY_RW_TEST_LK;
-      retval = VBERROR_SIMULATED;
-      goto LoadKernelExit;
-    }
-  }
-
   /* Initialization */
   blba = params->bytes_per_lba;
   kbuf_sectors = KBUF_SIZE / blba;
diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c
index de4fa3b..79a28d7 100644
--- a/firmware/lib/vboot_nvstorage.c
+++ b/firmware/lib/vboot_nvstorage.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  */
@@ -32,11 +32,6 @@
 #define DEV_BOOT_USB_MASK               0x01
 #define DEV_BOOT_SIGNED_ONLY_MASK       0x02
 
-#define FIRMWARE_FLAGS_OFFSET        5
-#define FIRMWARE_TEST_ERR_FUNC_MASK     0x38
-#define FIRMWARE_TEST_ERR_FUNC_SHIFT    3
-#define FIRMWARE_TEST_ERR_NUM_MASK      0x07
-
 #define KERNEL_FIELD_OFFSET         11
 #define CRC_OFFSET                  15
 
@@ -112,15 +107,6 @@
                | (raw[KERNEL_FIELD_OFFSET + 3] << 24));
       return 0;
 
-    case VBNV_TEST_ERROR_FUNC:
-      *dest = (raw[FIRMWARE_FLAGS_OFFSET] & FIRMWARE_TEST_ERR_FUNC_MASK)
-          >> FIRMWARE_TEST_ERR_FUNC_SHIFT;
-      return 0;
-
-    case VBNV_TEST_ERROR_NUM:
-      *dest = raw[FIRMWARE_FLAGS_OFFSET] & FIRMWARE_TEST_ERR_NUM_MASK;
-      return 0;
-
     case VBNV_DEV_BOOT_USB:
       *dest = (raw[DEV_FLAGS_OFFSET] & DEV_BOOT_USB_MASK ? 1 : 0);
       return 0;
@@ -200,17 +186,6 @@
       raw[KERNEL_FIELD_OFFSET + 3] = (uint8_t)(value >> 24);
       break;
 
-    case VBNV_TEST_ERROR_FUNC:
-      raw[FIRMWARE_FLAGS_OFFSET] &= ~FIRMWARE_TEST_ERR_FUNC_MASK;
-      raw[FIRMWARE_FLAGS_OFFSET] |= (value << FIRMWARE_TEST_ERR_FUNC_SHIFT)
-          & FIRMWARE_TEST_ERR_FUNC_MASK;
-      break;
-
-    case VBNV_TEST_ERROR_NUM:
-      raw[FIRMWARE_FLAGS_OFFSET] &= ~FIRMWARE_TEST_ERR_NUM_MASK;
-      raw[FIRMWARE_FLAGS_OFFSET] |= (value & FIRMWARE_TEST_ERR_NUM_MASK);
-      break;
-
     case VBNV_DEV_BOOT_USB:
       if (value)
         raw[DEV_FLAGS_OFFSET] |= DEV_BOOT_USB_MASK;
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index a834979..d80f843 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  */
@@ -363,10 +363,6 @@
     value = VbGetNvStorage(VBNV_KERNEL_FIELD);
   } else if (!strcasecmp(name,"nvram_cleared")) {
     value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET);
-  } else if (!strcasecmp(name,"vbtest_errfunc")) {
-    value = VbGetNvStorage(VBNV_TEST_ERROR_FUNC);
-  } else if (!strcasecmp(name,"vbtest_errno")) {
-    value = VbGetNvStorage(VBNV_TEST_ERROR_NUM);
   } else if (!strcasecmp(name,"recovery_request")) {
     value = VbGetNvStorage(VBNV_RECOVERY_REQUEST);
   } else if (!strcasecmp(name,"dbg_reset")) {
@@ -443,10 +439,6 @@
   if (!strcasecmp(name,"nvram_cleared")) {
     /* Can only clear this flag; it's set inside the NV storage library. */
     return VbSetNvStorage(VBNV_KERNEL_SETTINGS_RESET, 0);
-  } else if (!strcasecmp(name,"vbtest_errfunc")) {
-    return VbSetNvStorage(VBNV_TEST_ERROR_FUNC, value);
-  } else if (!strcasecmp(name,"vbtest_errno")) {
-    return VbSetNvStorage(VBNV_TEST_ERROR_NUM, value);
   } else if (!strcasecmp(name,"recovery_request")) {
     return VbSetNvStorage(VBNV_RECOVERY_REQUEST, value);
   } else if (!strcasecmp(name,"dbg_reset")) {
diff --git a/tests/vboot_firmware_tests.c b/tests/vboot_firmware_tests.c
index 940e5ea..7a02322 100644
--- a/tests/vboot_firmware_tests.c
+++ b/tests/vboot_firmware_tests.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  *
@@ -186,14 +186,6 @@
 static void LoadFirmwareTest(void) {
   uint32_t u;
 
-  /* Test error should cause abort */
-  ResetMocks();
-  VbNvSet(&vnc, VBNV_TEST_ERROR_FUNC, VBNV_TEST_ERROR_LOAD_FIRMWARE);
-  VbNvSet(&vnc, VBNV_TEST_ERROR_NUM, 1);
-  TestLoadFirmware(VBERROR_SIMULATED, VBNV_RECOVERY_RO_TEST_LF,
-                   "Simulated error");
-  TEST_EQ(shared->firmware_index, 0xFF, "Error means no firmware index");
-
   /* Require GBB */
   ResetMocks();
   cparams.gbb_data = NULL;
diff --git a/tests/vboot_nvstorage_test.c b/tests/vboot_nvstorage_test.c
index d3f431e..46219df 100644
--- a/tests/vboot_nvstorage_test.c
+++ b/tests/vboot_nvstorage_test.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
  *
@@ -29,8 +29,6 @@
   {VBNV_RECOVERY_REQUEST, 0, 0x42, 0xED, "recovery request"},
   {VBNV_LOCALIZATION_INDEX, 0, 0x69, 0xB0, "localization index"},
   {VBNV_KERNEL_FIELD, 0, 0x12345678, 0xFEDCBA98, "kernel field"},
-  {VBNV_TEST_ERROR_FUNC, 0, 1, 7, "verified boot test error func"},
-  {VBNV_TEST_ERROR_NUM, 0, 3, 6, "verified boot test error number"},
   {VBNV_DEV_BOOT_USB, 0, 1, 0, "dev boot usb"},
   {VBNV_DEV_BOOT_SIGNED_ONLY, 0, 1, 0, "dev boot custom"},
   {0, 0, 0, 0, NULL}