Add VB_INIT_FLAG_SW_WP_ENABLED to VbInit() input flags.

We need to know not only whether the HW WP pin is asserted, but whether the
flash chip has configured its software protection registers to actually
protect anything. This flag can be used to indicate that.

BUG=chrome-os-partner:13265
BRANCH=link
TEST=none

This just adds the flag. Nothing actually sets the flag yet, so there's
nothing to test.

Change-Id: Icba9945fb56eb3a4681486c630cbbdc9232485ef
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31642
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Bill Richardson
2012-08-28 15:00:51 -07:00
committed by Gerrit
parent 1d053f6e23
commit 9dc62178c9
6 changed files with 24 additions and 3 deletions

View File

@@ -181,6 +181,9 @@ typedef struct VbCommonParams {
#define VB_INIT_FLAG_EC_SOFTWARE_SYNC 0x00000200 #define VB_INIT_FLAG_EC_SOFTWARE_SYNC 0x00000200
/* EC on this platform is slow to update. */ /* EC on this platform is slow to update. */
#define VB_INIT_FLAG_EC_SLOW_UPDATE 0x00000400 #define VB_INIT_FLAG_EC_SLOW_UPDATE 0x00000400
/* Software write protect was enabled at boot time. This is separate from the
* HW write protect. Both must be set for flash write protection to work. */
#define VB_INIT_FLAG_SW_WP_ENABLED 0x00000800
/* Output flags for VbInitParams.out_flags. Used to indicate /* Output flags for VbInitParams.out_flags. Used to indicate
* potential boot paths and configuration to the calling firmware * potential boot paths and configuration to the calling firmware

View File

@@ -237,6 +237,8 @@ typedef struct VbKernelPreambleHeader {
#define VBSD_EC_SOFTWARE_SYNC 0x00000800 #define VBSD_EC_SOFTWARE_SYNC 0x00000800
/* VbInit() was told that the EC firmware is slow to update */ /* VbInit() was told that the EC firmware is slow to update */
#define VBSD_EC_SLOW_UPDATE 0x00001000 #define VBSD_EC_SLOW_UPDATE 0x00001000
/* Firmware software write protect was enabled at boot time */
#define VBSD_BOOT_FIRMWARE_SW_WP_ENABLED 0x00002000
/* Supported flags by header version. It's ok to add new flags while keeping /* Supported flags by header version. It's ok to add new flags while keeping
* struct version 2 as long as flag-NOT-present is the correct value for * struct version 2 as long as flag-NOT-present is the correct value for

View File

@@ -56,6 +56,8 @@ VbError_t VbInit(VbCommonParams* cparams, VbInitParams* iparams) {
shared->flags |= VBSD_BOOT_REC_SWITCH_ON; shared->flags |= VBSD_BOOT_REC_SWITCH_ON;
if (iparams->flags & VB_INIT_FLAG_WP_ENABLED) if (iparams->flags & VB_INIT_FLAG_WP_ENABLED)
shared->flags |= VBSD_BOOT_FIRMWARE_WP_ENABLED; shared->flags |= VBSD_BOOT_FIRMWARE_WP_ENABLED;
if (iparams->flags & VB_INIT_FLAG_SW_WP_ENABLED)
shared->flags |= VBSD_BOOT_FIRMWARE_SW_WP_ENABLED;
if (iparams->flags & VB_INIT_FLAG_S3_RESUME) if (iparams->flags & VB_INIT_FLAG_S3_RESUME)
shared->flags |= VBSD_BOOT_S3_RESUME; shared->flags |= VBSD_BOOT_S3_RESUME;
if (iparams->flags & VB_INIT_FLAG_RO_NORMAL_SUPPORT) if (iparams->flags & VB_INIT_FLAG_RO_NORMAL_SUPPORT)

View File

@@ -38,7 +38,8 @@ typedef enum VdatIntField {
VDAT_INT_DEVSW_BOOT, /* Dev switch position at boot */ VDAT_INT_DEVSW_BOOT, /* Dev switch position at boot */
VDAT_INT_DEVSW_VIRTUAL, /* Dev switch is virtual */ VDAT_INT_DEVSW_VIRTUAL, /* Dev switch is virtual */
VDAT_INT_RECSW_BOOT, /* Recovery switch position at boot */ VDAT_INT_RECSW_BOOT, /* Recovery switch position at boot */
VDAT_INT_WPSW_BOOT, /* WP switch position at boot */ VDAT_INT_HW_WPSW_BOOT, /* Hardware WP switch position at boot */
VDAT_INT_SW_WPSW_BOOT, /* Flash chip's WP setting at boot */
VDAT_INT_FW_VERSION_TPM, /* Current firmware version in TPM */ VDAT_INT_FW_VERSION_TPM, /* Current firmware version in TPM */
VDAT_INT_KERNEL_VERSION_TPM, /* Current kernel version in TPM */ VDAT_INT_KERNEL_VERSION_TPM, /* Current kernel version in TPM */
@@ -364,9 +365,12 @@ int GetVdatInt(VdatIntField field) {
case VDAT_INT_RECSW_BOOT: case VDAT_INT_RECSW_BOOT:
value = (sh->flags & VBSD_BOOT_REC_SWITCH_ON ? 1 : 0); value = (sh->flags & VBSD_BOOT_REC_SWITCH_ON ? 1 : 0);
break; break;
case VDAT_INT_WPSW_BOOT: case VDAT_INT_HW_WPSW_BOOT:
value = (sh->flags & VBSD_BOOT_FIRMWARE_WP_ENABLED ? 1 : 0); value = (sh->flags & VBSD_BOOT_FIRMWARE_WP_ENABLED ? 1 : 0);
break; break;
case VDAT_INT_SW_WPSW_BOOT:
value = (sh->flags & VBSD_BOOT_FIRMWARE_SW_WP_ENABLED ? 1 : 0);
break;
case VDAT_INT_RECOVERY_REASON: case VDAT_INT_RECOVERY_REASON:
value = sh->recovery_reason; value = sh->recovery_reason;
break; break;
@@ -432,7 +436,9 @@ int VbGetSystemPropertyInt(const char* name) {
} else if (!strcasecmp(name, "recoverysw_boot")) { } else if (!strcasecmp(name, "recoverysw_boot")) {
value = GetVdatInt(VDAT_INT_RECSW_BOOT); value = GetVdatInt(VDAT_INT_RECSW_BOOT);
} else if (!strcasecmp(name, "wpsw_boot")) { } else if (!strcasecmp(name, "wpsw_boot")) {
value = GetVdatInt(VDAT_INT_WPSW_BOOT); value = GetVdatInt(VDAT_INT_HW_WPSW_BOOT);
} else if (!strcasecmp(name, "sw_wpsw_boot")) {
value = GetVdatInt(VDAT_INT_SW_WPSW_BOOT);
} else if (!strcasecmp(name,"vdat_flags")) { } else if (!strcasecmp(name,"vdat_flags")) {
value = GetVdatInt(VDAT_INT_FLAGS); value = GetVdatInt(VDAT_INT_FLAGS);
} else if (!strcasecmp(name,"tpm_fwver")) { } else if (!strcasecmp(name,"tpm_fwver")) {

View File

@@ -143,6 +143,12 @@ static void VbInitTest(void) {
TestVbInit(0, 0, "Flags test WP"); TestVbInit(0, 0, "Flags test WP");
TEST_EQ(shared->flags, VBSD_BOOT_FIRMWARE_WP_ENABLED, " shared flags WP"); TEST_EQ(shared->flags, VBSD_BOOT_FIRMWARE_WP_ENABLED, " shared flags WP");
ResetMocks();
iparams.flags = VB_INIT_FLAG_SW_WP_ENABLED;
TestVbInit(0, 0, "Flags test SW WP");
TEST_EQ(shared->flags, VBSD_BOOT_FIRMWARE_SW_WP_ENABLED,
" shared flags SW WP");
ResetMocks(); ResetMocks();
iparams.flags = VB_INIT_FLAG_RO_NORMAL_SUPPORT; iparams.flags = VB_INIT_FLAG_RO_NORMAL_SUPPORT;
TestVbInit(0, 0, " flags test RO normal"); TestVbInit(0, 0, " flags test RO normal");

View File

@@ -70,6 +70,8 @@ const Param sys_param_list[] = {
{"ro_fwid", IS_STRING, "Read-only firmware ID"}, {"ro_fwid", IS_STRING, "Read-only firmware ID"},
{"savedmem_base", 0, "RAM debug data area physical address", "0x%08x"}, {"savedmem_base", 0, "RAM debug data area physical address", "0x%08x"},
{"savedmem_size", 0, "RAM debug data area size in bytes"}, {"savedmem_size", 0, "RAM debug data area size in bytes"},
{"sw_wpsw_boot", 0,
"Firmware write protect software setting enabled at boot"},
{"tpm_fwver", 0, "Firmware version stored in TPM", "0x%08x"}, {"tpm_fwver", 0, "Firmware version stored in TPM", "0x%08x"},
{"tpm_kernver", 0, "Kernel version stored in TPM", "0x%08x"}, {"tpm_kernver", 0, "Kernel version stored in TPM", "0x%08x"},
{"tried_fwb", 0, "Tried firmware B before A this boot"}, {"tried_fwb", 0, "Tried firmware B before A this boot"},