vboot2: add a flag to indicate firmware was selected by vboot2

TEST=Done manually on Nyan:
  localhost ~ # sudo /tmp/crossystem fw_vboot2
  0
  localhost ~ # sudo /tmp/crossystem fw_vboot2=1
  localhost ~ # sudo /tmp/crossystem fw_vboot2
  0
  # reboot with vboot2 firmware
  localhost ~ # /tmp/crossystem fw_vboot2
  1

BUG=none
BRANCH=none
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>

Change-Id: I6ed553c48bdfebf07393f6f5f46832a60971314a
Reviewed-on: https://chromium-review.googlesource.com/205664
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
Daisuke Nojiri
2014-06-25 12:11:03 -07:00
committed by chrome-internal-fetch
parent 4cb5497984
commit d11086caf0
3 changed files with 20 additions and 12 deletions

View File

@@ -236,31 +236,33 @@ typedef struct VbKernelPreambleHeader {
* the firmware. If this flag is not present, it just used the hash of the * the firmware. If this flag is not present, it just used the hash of the
* kernel keyblock. * kernel keyblock.
*/ */
#define VBSD_KERNEL_KEY_VERIFIED 0x00000002 #define VBSD_KERNEL_KEY_VERIFIED 0x00000002
/* LoadFirmware() was told the developer switch was on */ /* LoadFirmware() was told the developer switch was on */
#define VBSD_LF_DEV_SWITCH_ON 0x00000004 #define VBSD_LF_DEV_SWITCH_ON 0x00000004
/* LoadFirmware() is requesting the read only normal/dev code path */ /* LoadFirmware() is requesting the read only normal/dev code path */
#define VBSD_LF_USE_RO_NORMAL 0x00000008 #define VBSD_LF_USE_RO_NORMAL 0x00000008
/* Developer switch was enabled at boot time */ /* Developer switch was enabled at boot time */
#define VBSD_BOOT_DEV_SWITCH_ON 0x00000010 #define VBSD_BOOT_DEV_SWITCH_ON 0x00000010
/* Recovery switch was enabled at boot time */ /* Recovery switch was enabled at boot time */
#define VBSD_BOOT_REC_SWITCH_ON 0x00000020 #define VBSD_BOOT_REC_SWITCH_ON 0x00000020
/* Firmware write protect was enabled at boot time */ /* Firmware write protect was enabled at boot time */
#define VBSD_BOOT_FIRMWARE_WP_ENABLED 0x00000040 #define VBSD_BOOT_FIRMWARE_WP_ENABLED 0x00000040
/* Boot is a S3->S0 resume, not a S5->S0 normal boot */ /* Boot is a S3->S0 resume, not a S5->S0 normal boot */
#define VBSD_BOOT_S3_RESUME 0x00000100 #define VBSD_BOOT_S3_RESUME 0x00000100
/* Read-only firmware supports the normal/developer code path */ /* Read-only firmware supports the normal/developer code path */
#define VBSD_BOOT_RO_NORMAL_SUPPORT 0x00000200 #define VBSD_BOOT_RO_NORMAL_SUPPORT 0x00000200
/* VbInit() was told that the system has a virtual dev-switch */ /* VbInit() was told that the system has a virtual dev-switch */
#define VBSD_HONOR_VIRT_DEV_SWITCH 0x00000400 #define VBSD_HONOR_VIRT_DEV_SWITCH 0x00000400
/* VbInit() was told the system supports EC software sync */ /* VbInit() was told the system supports EC software sync */
#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 */ /* Firmware software write protect was enabled at boot time */
#define VBSD_BOOT_FIRMWARE_SW_WP_ENABLED 0x00002000 #define VBSD_BOOT_FIRMWARE_SW_WP_ENABLED 0x00002000
/* VbInit() was told that the recovery button is a virtual one */ /* VbInit() was told that the recovery button is a virtual one */
#define VBSD_BOOT_REC_SWITCH_VIRTUAL 0x00004000 #define VBSD_BOOT_REC_SWITCH_VIRTUAL 0x00004000
/* Firmware used vboot2 for firmware selection */
#define VBSD_BOOT_FIRMWARE_VBOOT2 0x00008000
/* /*
* 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

View File

@@ -47,7 +47,8 @@ typedef enum VdatIntField {
VDAT_INT_TRIED_FIRMWARE_B, /* Tried firmware B due to fwb_tries */ VDAT_INT_TRIED_FIRMWARE_B, /* Tried firmware B due to fwb_tries */
VDAT_INT_KERNEL_KEY_VERIFIED, /* Kernel key verified using VDAT_INT_KERNEL_KEY_VERIFIED, /* Kernel key verified using
* signature, not just hash */ * signature, not just hash */
VDAT_INT_RECOVERY_REASON /* Recovery reason for current boot */ VDAT_INT_RECOVERY_REASON, /* Recovery reason for current boot */
VDAT_INT_FW_BOOT2 /* Firmware selection by vboot2 */
} VdatIntField; } VdatIntField;
@@ -395,6 +396,8 @@ int GetVdatInt(VdatIntField field) {
case VDAT_INT_KERNEL_VERSION_TPM: case VDAT_INT_KERNEL_VERSION_TPM:
value = (int)sh->kernel_version_tpm; value = (int)sh->kernel_version_tpm;
break; break;
case VDAT_INT_FW_BOOT2:
value = (sh->flags & VBSD_BOOT_FIRMWARE_VBOOT2 ? 1 : 0);
default: default:
break; break;
} }
@@ -459,6 +462,8 @@ int VbGetSystemPropertyInt(const char* name) {
value = VbGetNvStorage(VBNV_CLEAR_TPM_OWNER_DONE); value = VbGetNvStorage(VBNV_CLEAR_TPM_OWNER_DONE);
} else if (!strcasecmp(name,"fwb_tries")) { } else if (!strcasecmp(name,"fwb_tries")) {
value = VbGetNvStorage(VBNV_TRY_B_COUNT); value = VbGetNvStorage(VBNV_TRY_B_COUNT);
} else if (!strcasecmp(name,"fw_vboot2")) {
value = GetVdatInt(VDAT_INT_FW_BOOT2);
} else if (!strcasecmp(name,"fwupdate_tries")) { } else if (!strcasecmp(name,"fwupdate_tries")) {
value = VbGetNvStorage(VBNV_KERNEL_FIELD); value = VbGetNvStorage(VBNV_KERNEL_FIELD);
if (value != -1) if (value != -1)

View File

@@ -53,6 +53,7 @@ const Param sys_param_list[] = {
{"ecfw_act", IS_STRING, "Active EC firmware"}, {"ecfw_act", IS_STRING, "Active EC firmware"},
{"fmap_base", 0, "Main firmware flashmap physical address", "0x%08x"}, {"fmap_base", 0, "Main firmware flashmap physical address", "0x%08x"},
{"fwb_tries", CAN_WRITE, "Try firmware B count (writable)"}, {"fwb_tries", CAN_WRITE, "Try firmware B count (writable)"},
{"fw_vboot2", 0, "1 if firmware was selected by vboot2 or 0 otherwise"},
{"fwid", IS_STRING, "Active firmware ID"}, {"fwid", IS_STRING, "Active firmware ID"},
{"fwupdate_tries", CAN_WRITE, {"fwupdate_tries", CAN_WRITE,
"Times to try OS firmware update (writable, inside kern_nv)"}, "Times to try OS firmware update (writable, inside kern_nv)"},