mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
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>
This commit is contained in:
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
@@ -47,11 +47,6 @@ typedef enum VbNvParam {
|
|||||||
VBNV_LOCALIZATION_INDEX,
|
VBNV_LOCALIZATION_INDEX,
|
||||||
/* Field reserved for kernel/user-mode use; 32-bit value. */
|
/* Field reserved for kernel/user-mode use; 32-bit value. */
|
||||||
VBNV_KERNEL_FIELD,
|
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. */
|
/* Allow booting from USB in developer mode. 0=no, 1=yes. */
|
||||||
VBNV_DEV_BOOT_USB,
|
VBNV_DEV_BOOT_USB,
|
||||||
/* Only boot Google-signed images in developer mode. 0=no, 1=yes. */
|
/* Only boot Google-signed images in developer mode. 0=no, 1=yes. */
|
||||||
@@ -130,13 +125,6 @@ typedef enum VbNvParam {
|
|||||||
#define VBNV_RECOVERY_US_UNSPECIFIED 0xFF
|
#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
|
/* Initialize the NV storage library. This must be called before any
|
||||||
* other functions in this library. Returns 0 if success, non-zero if
|
* other functions in this library. Returns 0 if success, non-zero if
|
||||||
* error.
|
* error.
|
||||||
|
|||||||
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*
|
*
|
||||||
@@ -42,7 +42,6 @@ int LoadFirmware(VbCommonParams* cparams, VbSelectFirmwareParams* fparams,
|
|||||||
|
|
||||||
uint32_t try_b_count;
|
uint32_t try_b_count;
|
||||||
uint32_t lowest_version = 0xFFFFFFFF;
|
uint32_t lowest_version = 0xFFFFFFFF;
|
||||||
uint32_t test_err = 0;
|
|
||||||
int good_index = -1;
|
int good_index = -1;
|
||||||
int is_dev;
|
int is_dev;
|
||||||
int index;
|
int index;
|
||||||
@@ -56,22 +55,6 @@ int LoadFirmware(VbCommonParams* cparams, VbSelectFirmwareParams* fparams,
|
|||||||
|
|
||||||
VBDEBUG(("LoadFirmware started...\n"));
|
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 */
|
/* Must have a root key from the GBB */
|
||||||
if (!gbb) {
|
if (!gbb) {
|
||||||
VBDEBUG(("No GBB\n"));
|
VBDEBUG(("No GBB\n"));
|
||||||
|
|||||||
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*
|
*
|
||||||
@@ -139,7 +139,6 @@ VbError_t LoadKernel(LoadKernelParams* params) {
|
|||||||
uint32_t lowest_version = LOWEST_TPM_VERSION;
|
uint32_t lowest_version = LOWEST_TPM_VERSION;
|
||||||
int rec_switch, dev_switch;
|
int rec_switch, dev_switch;
|
||||||
BootMode boot_mode;
|
BootMode boot_mode;
|
||||||
uint32_t test_err = 0;
|
|
||||||
uint32_t require_official_os = 0;
|
uint32_t require_official_os = 0;
|
||||||
|
|
||||||
VbError_t retval = VBERROR_UNKNOWN;
|
VbError_t retval = VBERROR_UNKNOWN;
|
||||||
@@ -184,23 +183,6 @@ VbError_t LoadKernel(LoadKernelParams* params) {
|
|||||||
shcall->sector_count = params->ending_lba + 1;
|
shcall->sector_count = params->ending_lba + 1;
|
||||||
shared->lk_call_count++;
|
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 */
|
/* Initialization */
|
||||||
blba = params->bytes_per_lba;
|
blba = params->bytes_per_lba;
|
||||||
kbuf_sectors = KBUF_SIZE / blba;
|
kbuf_sectors = KBUF_SIZE / blba;
|
||||||
|
|||||||
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
@@ -32,11 +32,6 @@
|
|||||||
#define DEV_BOOT_USB_MASK 0x01
|
#define DEV_BOOT_USB_MASK 0x01
|
||||||
#define DEV_BOOT_SIGNED_ONLY_MASK 0x02
|
#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 KERNEL_FIELD_OFFSET 11
|
||||||
#define CRC_OFFSET 15
|
#define CRC_OFFSET 15
|
||||||
|
|
||||||
@@ -112,15 +107,6 @@ int VbNvGet(VbNvContext* context, VbNvParam param, uint32_t* dest) {
|
|||||||
| (raw[KERNEL_FIELD_OFFSET + 3] << 24));
|
| (raw[KERNEL_FIELD_OFFSET + 3] << 24));
|
||||||
return 0;
|
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:
|
case VBNV_DEV_BOOT_USB:
|
||||||
*dest = (raw[DEV_FLAGS_OFFSET] & DEV_BOOT_USB_MASK ? 1 : 0);
|
*dest = (raw[DEV_FLAGS_OFFSET] & DEV_BOOT_USB_MASK ? 1 : 0);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -200,17 +186,6 @@ int VbNvSet(VbNvContext* context, VbNvParam param, uint32_t value) {
|
|||||||
raw[KERNEL_FIELD_OFFSET + 3] = (uint8_t)(value >> 24);
|
raw[KERNEL_FIELD_OFFSET + 3] = (uint8_t)(value >> 24);
|
||||||
break;
|
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:
|
case VBNV_DEV_BOOT_USB:
|
||||||
if (value)
|
if (value)
|
||||||
raw[DEV_FLAGS_OFFSET] |= DEV_BOOT_USB_MASK;
|
raw[DEV_FLAGS_OFFSET] |= DEV_BOOT_USB_MASK;
|
||||||
|
|||||||
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
@@ -363,10 +363,6 @@ int VbGetSystemPropertyInt(const char* name) {
|
|||||||
value = VbGetNvStorage(VBNV_KERNEL_FIELD);
|
value = VbGetNvStorage(VBNV_KERNEL_FIELD);
|
||||||
} else if (!strcasecmp(name,"nvram_cleared")) {
|
} else if (!strcasecmp(name,"nvram_cleared")) {
|
||||||
value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET);
|
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")) {
|
} else if (!strcasecmp(name,"recovery_request")) {
|
||||||
value = VbGetNvStorage(VBNV_RECOVERY_REQUEST);
|
value = VbGetNvStorage(VBNV_RECOVERY_REQUEST);
|
||||||
} else if (!strcasecmp(name,"dbg_reset")) {
|
} else if (!strcasecmp(name,"dbg_reset")) {
|
||||||
@@ -443,10 +439,6 @@ int VbSetSystemPropertyInt(const char* name, int value) {
|
|||||||
if (!strcasecmp(name,"nvram_cleared")) {
|
if (!strcasecmp(name,"nvram_cleared")) {
|
||||||
/* Can only clear this flag; it's set inside the NV storage library. */
|
/* Can only clear this flag; it's set inside the NV storage library. */
|
||||||
return VbSetNvStorage(VBNV_KERNEL_SETTINGS_RESET, 0);
|
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")) {
|
} else if (!strcasecmp(name,"recovery_request")) {
|
||||||
return VbSetNvStorage(VBNV_RECOVERY_REQUEST, value);
|
return VbSetNvStorage(VBNV_RECOVERY_REQUEST, value);
|
||||||
} else if (!strcasecmp(name,"dbg_reset")) {
|
} else if (!strcasecmp(name,"dbg_reset")) {
|
||||||
|
|||||||
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*
|
*
|
||||||
@@ -186,14 +186,6 @@ static void TestLoadFirmware(VbError_t expected_retval,
|
|||||||
static void LoadFirmwareTest(void) {
|
static void LoadFirmwareTest(void) {
|
||||||
uint32_t u;
|
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 */
|
/* Require GBB */
|
||||||
ResetMocks();
|
ResetMocks();
|
||||||
cparams.gbb_data = NULL;
|
cparams.gbb_data = NULL;
|
||||||
|
|||||||
@@ -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
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*
|
*
|
||||||
@@ -29,8 +29,6 @@ static VbNvField nvfields[] = {
|
|||||||
{VBNV_RECOVERY_REQUEST, 0, 0x42, 0xED, "recovery request"},
|
{VBNV_RECOVERY_REQUEST, 0, 0x42, 0xED, "recovery request"},
|
||||||
{VBNV_LOCALIZATION_INDEX, 0, 0x69, 0xB0, "localization index"},
|
{VBNV_LOCALIZATION_INDEX, 0, 0x69, 0xB0, "localization index"},
|
||||||
{VBNV_KERNEL_FIELD, 0, 0x12345678, 0xFEDCBA98, "kernel field"},
|
{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_USB, 0, 1, 0, "dev boot usb"},
|
||||||
{VBNV_DEV_BOOT_SIGNED_ONLY, 0, 1, 0, "dev boot custom"},
|
{VBNV_DEV_BOOT_SIGNED_ONLY, 0, 1, 0, "dev boot custom"},
|
||||||
{0, 0, 0, 0, NULL}
|
{0, 0, 0, 0, NULL}
|
||||||
|
|||||||
Reference in New Issue
Block a user