Furquan Shaikh (furquan@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15868
-gerrit
commit 697194daeb61f8e0459f1ff7185d87a643fc7f46 Author: Furquan Shaikh furquan@google.com Date: Mon Jul 25 13:02:36 2016 -0700
bootmode: Get rid of CONFIG_BOOTMODE_STRAPS
With VBOOT_VERIFY_FIRMWARE separated from CHROMEOS, move recovery and developer mode check funcitons to vboot. Thus, get rid of the BOOTMODE_STRAPS option which controlled these functions under src/lib.
BUG=chrome-os-partner:44531
Change-Id: Ia2571026ce8976856add01095cc6be415d2be22e Signed-off-by: Furquan Shaikh furquan@google.com --- src/Kconfig | 4 - src/device/pci_device.c | 4 +- src/drivers/intel/fsp1_1/raminit.c | 5 +- src/drivers/intel/fsp1_1/romstage.c | 3 +- src/drivers/intel/fsp2_0/memory_init.c | 5 +- src/ec/google/chromeec/ec.c | 11 +- src/include/bootmode.h | 9 -- src/lib/bootmode.c | 18 --- src/mainboard/google/cyan/chromeos.c | 2 +- src/mainboard/google/rambi/chromeos.c | 5 +- src/mainboard/google/stout/ec.c | 2 +- src/mainboard/google/stout/romstage.c | 2 +- src/mainboard/google/veyron_rialto/mainboard.c | 4 +- src/mainboard/intel/strago/chromeos.c | 2 +- src/northbridge/intel/haswell/gma.c | 3 +- src/northbridge/intel/haswell/raminit.c | 5 +- src/northbridge/intel/sandybridge/raminit_mrc.c | 3 +- src/soc/intel/baytrail/romstage/raminit.c | 4 +- src/soc/intel/broadwell/igd.c | 3 +- src/soc/intel/broadwell/romstage/raminit.c | 3 +- src/soc/intel/common/mrc_cache.c | 6 +- src/soc/intel/skylake/igd.c | 3 +- src/soc/intel/skylake/romstage/romstage.c | 3 +- src/southbridge/intel/bd82x6x/me_8.x.c | 2 +- src/southbridge/intel/fsp_bd82x6x/me_8.x.c | 2 +- src/vendorcode/google/chromeos/Kconfig | 1 - src/vendorcode/google/chromeos/elog.c | 4 +- src/vendorcode/google/chromeos/gnvs.c | 6 +- src/vendorcode/google/vboot2/Makefile.inc | 10 +- src/vendorcode/google/vboot2/bootmode.c | 173 ++++++++++++++++++++++++ src/vendorcode/google/vboot2/recovery.c | 157 --------------------- src/vendorcode/google/vboot2/vboot_common.h | 4 + 32 files changed, 237 insertions(+), 231 deletions(-)
diff --git a/src/Kconfig b/src/Kconfig index 1cc0bfa..c73c655 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -512,10 +512,6 @@ config MMCONF_SUPPORT bool default n
-config BOOTMODE_STRAPS - bool - default n - source "src/console/Kconfig"
config HAVE_ACPI_RESUME diff --git a/src/device/pci_device.c b/src/device/pci_device.c index 5cd0053..ddc8179 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -669,8 +669,8 @@ static int should_run_oprom(struct device *dev) /* Don't run VGA option ROMs, unless we have to print * something on the screen before the kernel is loaded. */ - should_run = !IS_ENABLED(CONFIG_BOOTMODE_STRAPS) || - developer_mode_enabled() || recovery_mode_enabled(); + should_run = !IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) || + vboot_developer_mode_enabled() || vboot_recovery_mode_enabled();
#if CONFIG_CHROMEOS if (!should_run) diff --git a/src/drivers/intel/fsp1_1/raminit.c b/src/drivers/intel/fsp1_1/raminit.c index 3eee2da..c5423f2 100644 --- a/src/drivers/intel/fsp1_1/raminit.c +++ b/src/drivers/intel/fsp1_1/raminit.c @@ -24,7 +24,7 @@ #include <soc/intel/common/mma.h> #include <string.h> #include <timestamp.h> -#include <bootmode.h> +#include <vendorcode/google/vboot2/vboot_common.h>
void raminit(struct romstage_params *params) { @@ -288,7 +288,8 @@ void raminit(struct romstage_params *params) if (mrc_hob == NULL) printk(BIOS_DEBUG, "Memory Configuration Data Hob not present\n"); - else if (!recovery_mode_enabled()) { + else if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + !vboot_recovery_mode_enabled()) { /* Do not save MRC data in recovery path */ pei_ptr->data_to_save = GET_GUID_HOB_DATA(mrc_hob); pei_ptr->data_to_save_size = ALIGN( diff --git a/src/drivers/intel/fsp1_1/romstage.c b/src/drivers/intel/fsp1_1/romstage.c index c1b1ca5..128152d 100644 --- a/src/drivers/intel/fsp1_1/romstage.c +++ b/src/drivers/intel/fsp1_1/romstage.c @@ -122,7 +122,8 @@ void romstage_common(struct romstage_params *params) params->pei_data->saved_data_size = 0; params->pei_data->saved_data = NULL; if (!params->pei_data->disable_saved_data) { - if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + vboot_recovery_mode_enabled()) { /* Recovery mode does not use MRC cache */ printk(BIOS_DEBUG, "Recovery mode: not using MRC cache.\n"); diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c index 8afa6d7..f673a5a 100644 --- a/src/drivers/intel/fsp2_0/memory_init.c +++ b/src/drivers/intel/fsp2_0/memory_init.c @@ -14,7 +14,6 @@ #include <arch/io.h> #include <arch/cpu.h> #include <arch/symbols.h> -#include <bootmode.h> #include <cbfs.h> #include <cbmem.h> #include <console/console.h> @@ -28,6 +27,7 @@ #include <string.h> #include <symbols.h> #include <timestamp.h> +#include <vendorcode/google/vboot2/vboot_common.h>
typedef asmlinkage enum fsp_status (*fsp_memory_init_fn) (void *raminit_upd, void **hob_list); @@ -109,7 +109,8 @@ static void fsp_fill_mrc_cache(struct FSPM_ARCH_UPD *arch_upd, bool s3wake, return;
/* Don't use saved training data when recovery mode is enabled. */ - if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + vboot_recovery_mode_enabled()) { printk(BIOS_DEBUG, "Recovery mode. Not using MRC cache.\n"); return; } diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 1a381d7..62a7221 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -16,7 +16,6 @@ #include <stdint.h> #include <string.h> #include <console/console.h> -#include <bootmode.h> #include <arch/io.h> #include <delay.h> #include <halt.h> @@ -24,6 +23,7 @@ #include <elog.h> #include <rtc.h> #include <stdlib.h> +#include <vendorcode/google/vboot2/vboot_common.h>
#include "chip.h" #include "ec.h" @@ -207,7 +207,7 @@ void google_chromeec_early_init(void) google_chromeec_early_pd_init();
/* If in recovery ensure EC is running RO firmware. */ - if (recovery_mode_enabled()) + if (vboot_recovery_mode_enabled()) google_chromeec_check_ec_image(EC_IMAGE_RO); } } @@ -246,7 +246,7 @@ void google_chromeec_check_pd_image(int expected_type) void google_chromeec_early_pd_init(void) { /* If in recovery ensure PD is running RO firmware. */ - if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_CHROMEOS) && vboot_recovery_mode_enabled()) { google_chromeec_check_pd_image(EC_IMAGE_RO); } } @@ -496,6 +496,9 @@ void google_chromeec_init(void) struct chromeec_command cec_cmd; struct ec_response_get_version cec_resp = {{0}};
+ if (!IS_ENABLED(CONFIG_CHROMEOS)) + return; + printk(BIOS_DEBUG, "Google Chrome EC: Initializing keyboard.\n");
google_chromeec_hello(); @@ -521,7 +524,7 @@ void google_chromeec_init(void) }
if (cec_cmd.cmd_code || - (recovery_mode_enabled() && + (vboot_recovery_mode_enabled() && (cec_resp.current_image != EC_IMAGE_RO))) { struct ec_params_reboot_ec reboot_ec; /* Reboot the EC and make it come back in RO mode */ diff --git a/src/include/bootmode.h b/src/include/bootmode.h index 9feb5af..21aa386 100644 --- a/src/include/bootmode.h +++ b/src/include/bootmode.h @@ -26,18 +26,9 @@ int clear_recovery_mode_switch(void); int get_wipeout_mode_switch(void); int get_lid_switch(void);
- /* Return 1 if display initialization is required. 0 if not. */ int display_init_required(void); int gfx_get_init_done(void); void gfx_set_init_done(int done);
-#if CONFIG_BOOTMODE_STRAPS -int developer_mode_enabled(void); -int recovery_mode_enabled(void); -#else -static inline int recovery_mode_enabled(void) { return 0; } -static inline int developer_mode_enabled(void) { return 0; } -#endif - #endif /* __BOOTMODE_H__ */ diff --git a/src/lib/bootmode.c b/src/lib/bootmode.c index c6c29ac..dcee2d1 100644 --- a/src/lib/bootmode.c +++ b/src/lib/bootmode.c @@ -17,24 +17,6 @@ #include <bootmode.h> #include <vendorcode/google/chromeos/chromeos.h>
-#if CONFIG_BOOTMODE_STRAPS -int developer_mode_enabled(void) -{ - if (get_developer_mode_switch()) - return 1; -#if CONFIG_VBOOT_VERIFY_FIRMWARE - if (vboot_handoff_check_developer_flag()) - return 1; -#endif - return 0; -} - -int recovery_mode_enabled(void) -{ - return !!vboot_check_recovery_request(); -} -#endif /* CONFIG_BOOTMODE_STRAPS */ - #if ENV_RAMSTAGE static int gfx_init_done = -1;
diff --git a/src/mainboard/google/cyan/chromeos.c b/src/mainboard/google/cyan/chromeos.c index a038d1f..757db5f 100644 --- a/src/mainboard/google/cyan/chromeos.c +++ b/src/mainboard/google/cyan/chromeos.c @@ -40,7 +40,7 @@ void fill_lb_gpios(struct lb_gpios *gpios) { struct lb_gpio chromeos_gpios[] = { {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, - {-1, ACTIVE_HIGH, recovery_mode_enabled(), "recovery"}, + {-1, ACTIVE_HIGH, vboot_recovery_mode_enabled(), "recovery"}, {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, {-1, ACTIVE_HIGH, 0, "power"}, diff --git a/src/mainboard/google/rambi/chromeos.c b/src/mainboard/google/rambi/chromeos.c index f2a2ab7..329c90f 100644 --- a/src/mainboard/google/rambi/chromeos.c +++ b/src/mainboard/google/rambi/chromeos.c @@ -14,11 +14,12 @@ */
#include <string.h> -#include <bootmode.h> #include <arch/io.h> +#include <bootmode.h> #include <device/device.h> #include <device/pci.h> #include <soc/gpio.h> +#include <vendorcode/google/vboot2/vboot_common.h>
#if CONFIG_EC_GOOGLE_CHROMEEC #include "ec.h" @@ -35,7 +36,7 @@ void fill_lb_gpios(struct lb_gpios *gpios) { struct lb_gpio chromeos_gpios[] = { {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, - {-1, ACTIVE_HIGH, recovery_mode_enabled(), "recovery"}, + {-1, ACTIVE_HIGH, vboot_recovery_mode_enabled(), "recovery"}, {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, {-1, ACTIVE_HIGH, 0, "power"}, diff --git a/src/mainboard/google/stout/ec.c b/src/mainboard/google/stout/ec.c index 019f046..3e5f2d0 100644 --- a/src/mainboard/google/stout/ec.c +++ b/src/mainboard/google/stout/ec.c @@ -39,7 +39,7 @@ void stout_ec_init(void) /* * Important: get_recovery_mode_switch() must be called in EC init. */ - if (IS_ENABLED(CONFIG_BOOTMODE_STRAPS)) + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE)) get_recovery_mode_switch();
/* Unmute */ diff --git a/src/mainboard/google/stout/romstage.c b/src/mainboard/google/stout/romstage.c index 8348e4f..3c4cefa 100644 --- a/src/mainboard/google/stout/romstage.c +++ b/src/mainboard/google/stout/romstage.c @@ -119,7 +119,7 @@ void rcba_config(void) static void early_ec_init(void) { u8 ec_status = ec_read(EC_STATUS_REG); - int rec_mode = IS_ENABLED(CONFIG_BOOTMODE_STRAPS) && + int rec_mode = IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && get_recovery_mode_switch();
if (((ec_status & 0x3) == EC_IN_RO_MODE) || diff --git a/src/mainboard/google/veyron_rialto/mainboard.c b/src/mainboard/google/veyron_rialto/mainboard.c index ebcaa2a..82c7b78 100644 --- a/src/mainboard/google/veyron_rialto/mainboard.c +++ b/src/mainboard/google/veyron_rialto/mainboard.c @@ -34,6 +34,7 @@ #include <symbols.h> #include <vbe.h> #include <vendorcode/google/chromeos/chromeos.h> +#include <vendorcode/google/vboot2/vboot_common.h>
#include "board.h"
@@ -90,7 +91,8 @@ static void mainboard_init(device_t dev)
/* If recovery mode is detected, reduce frequency and voltage to reduce * heat in case machine is left unattended. chrome-os-partner:41201. */ - if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + vboot_recovery_mode_enabled()) { printk(BIOS_DEBUG, "Reducing APLL freq for recovery mode.\n"); rkclk_configure_cpu(APLL_600_MHZ); rk808_configure_buck(1, 900); diff --git a/src/mainboard/intel/strago/chromeos.c b/src/mainboard/intel/strago/chromeos.c index 2cc092d..0e072f0 100644 --- a/src/mainboard/intel/strago/chromeos.c +++ b/src/mainboard/intel/strago/chromeos.c @@ -39,7 +39,7 @@ void fill_lb_gpios(struct lb_gpios *gpios) { struct lb_gpio chromeos_gpios[] = { {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, - {-1, ACTIVE_HIGH, recovery_mode_enabled(), "recovery"}, + {-1, ACTIVE_HIGH, vboot_recovery_mode_enabled(), "recovery"}, {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, {-1, ACTIVE_HIGH, 0, "power"}, diff --git a/src/northbridge/intel/haswell/gma.c b/src/northbridge/intel/haswell/gma.c index 4449ffc..7d7d45b 100644 --- a/src/northbridge/intel/haswell/gma.c +++ b/src/northbridge/intel/haswell/gma.c @@ -457,7 +457,8 @@ static void gma_func0_init(struct device *dev) dp.panel_power_cycle_delay = conf->gpu_panel_power_cycle_delay;
#if IS_ENABLED(CONFIG_CHROMEOS) - init_fb = developer_mode_enabled() || recovery_mode_enabled(); + init_fb = vboot_developer_mode_enabled() || + vboot_recovery_mode_enabled(); #endif lightup_ok = panel_lightup(&dp, init_fb); gfx_set_init_done(1); diff --git a/src/northbridge/intel/haswell/raminit.c b/src/northbridge/intel/haswell/raminit.c index 464f7c8..ab09792 100644 --- a/src/northbridge/intel/haswell/raminit.c +++ b/src/northbridge/intel/haswell/raminit.c @@ -14,7 +14,6 @@ */
#include <console/console.h> -#include <bootmode.h> #include <string.h> #include <arch/io.h> #include <cbmem.h> @@ -25,6 +24,7 @@ #include <northbridge/intel/common/mrc_cache.h> #include <pc80/mc146818rtc.h> #include <device/pci_def.h> +#include <vendorcode/google/vboot2/vboot_common.h> #include "raminit.h" #include "pei_data.h" #include "haswell.h" @@ -121,7 +121,8 @@ void sdram_initialize(struct pei_data *pei_data) * Do not pass MRC data in for recovery mode boot, * Always pass it in for S3 resume. */ - if (!recovery_mode_enabled() || pei_data->boot_mode == 2) + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + (!vboot_recovery_mode_enabled() || pei_data->boot_mode == 2)) prepare_mrc_cache(pei_data);
/* If MRC data is not found we cannot continue S3 resume. */ diff --git a/src/northbridge/intel/sandybridge/raminit_mrc.c b/src/northbridge/intel/sandybridge/raminit_mrc.c index 8754e42..1d5650d 100644 --- a/src/northbridge/intel/sandybridge/raminit_mrc.c +++ b/src/northbridge/intel/sandybridge/raminit_mrc.c @@ -200,7 +200,8 @@ void sdram_initialize(struct pei_data *pei_data) * Do not pass MRC data in for recovery mode boot, * Always pass it in for S3 resume. */ - if (!recovery_mode_enabled() || pei_data->boot_mode == 2) + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + !vboot_recovery_mode_enabled() || pei_data->boot_mode == 2) prepare_mrc_cache(pei_data);
/* If MRC data is not found we cannot continue S3 resume. */ diff --git a/src/soc/intel/baytrail/romstage/raminit.c b/src/soc/intel/baytrail/romstage/raminit.c index d45b9ea..5cb0cd5 100644 --- a/src/soc/intel/baytrail/romstage/raminit.c +++ b/src/soc/intel/baytrail/romstage/raminit.c @@ -16,7 +16,6 @@ #include <stddef.h> #include <arch/acpi.h> #include <arch/io.h> -#include <bootmode.h> #include <cbfs.h> #include <cbmem.h> #include <console/console.h> @@ -31,6 +30,7 @@ #include <soc/romstage.h> #include <ec/google/chromeec/ec.h> #include <ec/google/chromeec/ec_commands.h> +#include <vendorcode/google/vboot2/vboot_common.h>
static void reset_system(void) { @@ -123,7 +123,7 @@ void raminit(struct mrc_params *mp, int prev_sleep_state) if (!mp->io_hole_mb) mp->io_hole_mb = 2048;
- if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && vboot_recovery_mode_enabled()) { printk(BIOS_DEBUG, "Recovery mode: not using MRC cache.\n"); } else if (!mrc_cache_get_current(&cache)) { mp->saved_data_size = cache->size; diff --git a/src/soc/intel/broadwell/igd.c b/src/soc/intel/broadwell/igd.c index 599a95c..b068748 100644 --- a/src/soc/intel/broadwell/igd.c +++ b/src/soc/intel/broadwell/igd.c @@ -487,7 +487,8 @@ static void igd_init(struct device *dev) /* Wait for any configured pre-graphics delay */ if (!acpi_is_wakeup_s3()) { #if IS_ENABLED(CONFIG_CHROMEOS) - if (developer_mode_enabled() || recovery_mode_enabled() || + if (vboot_developer_mode_enabled() || + vboot_recovery_mode_enabled() || vboot_wants_oprom()) mdelay(CONFIG_PRE_GRAPHICS_DELAY); #else diff --git a/src/soc/intel/broadwell/romstage/raminit.c b/src/soc/intel/broadwell/romstage/raminit.c index 488b231..d0b52f3 100644 --- a/src/soc/intel/broadwell/romstage/raminit.c +++ b/src/soc/intel/broadwell/romstage/raminit.c @@ -48,7 +48,8 @@ void raminit(struct pei_data *pei_data)
broadwell_fill_pei_data(pei_data);
- if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + vboot_recovery_mode_enabled()) { /* Recovery mode does not use MRC cache */ printk(BIOS_DEBUG, "Recovery mode: not using MRC cache.\n"); } else if (!mrc_cache_get_current(&cache)) { diff --git a/src/soc/intel/common/mrc_cache.c b/src/soc/intel/common/mrc_cache.c index b6f6654..938a8f6 100644 --- a/src/soc/intel/common/mrc_cache.c +++ b/src/soc/intel/common/mrc_cache.c @@ -14,12 +14,13 @@ */
#include <string.h> -#include <bootmode.h> #include <bootstate.h> #include <console/console.h> #include <cbmem.h> #include <fmap.h> #include <ip_checksum.h> +#include <vendorcode/google/vboot2/vboot_common.h> + #include "mrc_cache.h" #include "nvm.h"
@@ -304,7 +305,8 @@ static void update_mrc_cache(void *unused) return; }
- if (recovery_mode_enabled()) { + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + vboot_recovery_mode_enabled()) { mrc_cache_erase(®ion); printk(BIOS_DEBUG, "In recovery mode. Skipping MRC update.\n"); return; diff --git a/src/soc/intel/skylake/igd.c b/src/soc/intel/skylake/igd.c index 4bb597c..5a7f577 100644 --- a/src/soc/intel/skylake/igd.c +++ b/src/soc/intel/skylake/igd.c @@ -90,7 +90,8 @@ static void igd_init(struct device *dev) /* Wait for any configured pre-graphics delay */ if (!acpi_is_wakeup_s3()) { #if IS_ENABLED(CONFIG_CHROMEOS) - if (developer_mode_enabled() || recovery_mode_enabled() || + if (vboot_developer_mode_enabled() || + vboot_recovery_mode_enabled() || vboot_wants_oprom()) mdelay(CONFIG_PRE_GRAPHICS_DELAY); #else diff --git a/src/soc/intel/skylake/romstage/romstage.c b/src/soc/intel/skylake/romstage/romstage.c index 8375ccd..31ba4b4 100644 --- a/src/soc/intel/skylake/romstage/romstage.c +++ b/src/soc/intel/skylake/romstage/romstage.c @@ -100,7 +100,8 @@ void soc_memory_init_params(struct romstage_params *params, upd->IedSize = CONFIG_IED_REGION_SIZE; upd->ProbelessTrace = config->ProbelessTrace; upd->EnableTraceHub = config->EnableTraceHub; - if (recovery_mode_enabled()) + if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && + vboot_recovery_mode_enabled()) upd->SaGv = 0; /* Disable SaGv in recovery mode. */ else upd->SaGv = config->SaGv; diff --git a/src/southbridge/intel/bd82x6x/me_8.x.c b/src/southbridge/intel/bd82x6x/me_8.x.c index 410e6b8..4dbe8ed 100644 --- a/src/southbridge/intel/bd82x6x/me_8.x.c +++ b/src/southbridge/intel/bd82x6x/me_8.x.c @@ -710,7 +710,7 @@ static void intel_me_init(device_t dev) /* * Unlock ME in recovery mode. */ - if (recovery_mode_enabled()) { + if (vboot_recovery_mode_enabled()) { /* Unlock ME flash region */ mkhi_hmrfpo_enable();
diff --git a/src/southbridge/intel/fsp_bd82x6x/me_8.x.c b/src/southbridge/intel/fsp_bd82x6x/me_8.x.c index 522858b..e29d86b 100644 --- a/src/southbridge/intel/fsp_bd82x6x/me_8.x.c +++ b/src/southbridge/intel/fsp_bd82x6x/me_8.x.c @@ -709,7 +709,7 @@ static void intel_me_init(device_t dev) /* * Unlock ME in recovery mode. */ - if (recovery_mode_enabled()) { + if (vboot_recovery_mode_enabled()) { /* Unlock ME flash region */ mkhi_hmrfpo_enable();
diff --git a/src/vendorcode/google/chromeos/Kconfig b/src/vendorcode/google/chromeos/Kconfig index 3809bb8..a3cd11d 100644 --- a/src/vendorcode/google/chromeos/Kconfig +++ b/src/vendorcode/google/chromeos/Kconfig @@ -25,7 +25,6 @@ config CHROMEOS select TPM2 if MAINBOARD_HAS_TPM2 select TPM_INIT_FAILURE_IS_FATAL if PC80_SYSTEM && LPC_TPM select SKIP_TPM_STARTUP_ON_NORMAL_BOOT if PC80_SYSTEM && LPC_TPM - select BOOTMODE_STRAPS select ELOG if SPI_FLASH select COLLECT_TIMESTAMPS select VBOOT_VERIFY_FIRMWARE diff --git a/src/vendorcode/google/chromeos/elog.c b/src/vendorcode/google/chromeos/elog.c index bd207dc..d820021 100644 --- a/src/vendorcode/google/chromeos/elog.c +++ b/src/vendorcode/google/chromeos/elog.c @@ -24,10 +24,10 @@
void elog_add_boot_reason(void) { - if (developer_mode_enabled()) { + if (vboot_developer_mode_enabled()) { elog_add_event(ELOG_TYPE_CROS_DEVELOPER_MODE); printk(BIOS_DEBUG, "%s: Logged dev mode boot\n", __func__); - } else if (recovery_mode_enabled()) { + } else if (vboot_recovery_mode_enabled()) { u8 reason = 0; #if CONFIG_VBOOT_VERIFY_FIRMWARE struct vboot_handoff *vbho = cbmem_find(CBMEM_ID_VBOOT_HANDOFF); diff --git a/src/vendorcode/google/chromeos/gnvs.c b/src/vendorcode/google/chromeos/gnvs.c index c7dfecc..4025b00 100644 --- a/src/vendorcode/google/chromeos/gnvs.c +++ b/src/vendorcode/google/chromeos/gnvs.c @@ -52,10 +52,10 @@ void chromeos_init_vboot(chromeos_acpi_t *chromeos) #endif
#if CONFIG_ELOG - if (developer_mode_enabled() || - (vboot_wants_oprom() && !recovery_mode_enabled())) + if (vboot_developer_mode_enabled() || + (vboot_wants_oprom() && !vboot_recovery_mode_enabled())) elog_add_event(ELOG_TYPE_CROS_DEVELOPER_MODE); - if (recovery_mode_enabled()) { + if (vboot_recovery_mode_enabled()) { int reason = get_recovery_mode_from_vbnv(); #if CONFIG_VBOOT_VERIFY_FIRMWARE if (vboot_handoff && !reason) { diff --git a/src/vendorcode/google/vboot2/Makefile.inc b/src/vendorcode/google/vboot2/Makefile.inc index 8fb1bc6..c2e24b5 100644 --- a/src/vendorcode/google/vboot2/Makefile.inc +++ b/src/vendorcode/google/vboot2/Makefile.inc @@ -28,11 +28,11 @@ romstage-y += vboot_common.c ramstage-y += vboot_common.c postcar-y += vboot_common.c
-bootblock-y += recovery.c -romstage-y += recovery.c -ramstage-y += recovery.c -verstage-y += recovery.c -postcar-y += recovery.c +bootblock-y += bootmode.c +romstage-y += bootmode.c +ramstage-y += bootmode.c +verstage-y += bootmode.c +postcar-y += bootmode.c
bootblock-y += common.c libverstage-y += vboot_logic.c diff --git a/src/vendorcode/google/vboot2/bootmode.c b/src/vendorcode/google/vboot2/bootmode.c new file mode 100644 index 0000000..a351f98 --- /dev/null +++ b/src/vendorcode/google/vboot2/bootmode.c @@ -0,0 +1,173 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2016 Google Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <assert.h> +#include <bootmode.h> +#include <bootstate.h> +#include <rules.h> +#include <string.h> +#include <vb2_api.h> +#include <vendorcode/google/chromeos/vbnv.h> + +#include "misc.h" +#include "vboot_common.h" + +static int vb2_get_recovery_reason_shared_data(void) +{ + /* Shared data does not exist for Ramstage and Post-CAR stage. */ + if (ENV_RAMSTAGE || ENV_POSTCAR) + return 0; + + struct vb2_shared_data *sd = vb2_get_shared_data(); + assert(sd); + return sd->recovery_reason; +} + +void vb2_save_recovery_reason_vbnv(void) +{ + if (!IS_ENABLED(CONFIG_VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT)) + return; + + int reason = vb2_get_recovery_reason_shared_data(); + if (!reason) + return; + + set_recovery_mode_into_vbnv(reason); +} + +static void vb2_clear_recovery_reason_vbnv(void *unused) +{ + if (!IS_ENABLED(CONFIG_VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT)) + return; + + set_recovery_mode_into_vbnv(0); +} + +/* + * Recovery reason stored in VBNV needs to be cleared before the state of VBNV + * is backed-up anywhere or jumping to the payload (whichever occurs + * first). Currently, vbnv_cmos.c backs up VBNV on POST_DEVICE. Thus, we need to + * make sure that the stored recovery reason is cleared off before that + * happens. + * IMPORTANT: Any reboot occurring after BS_DEV_INIT state will cause loss of + * recovery reason on reboot. Until now, we have seen reboots occuring on x86 + * only in FSP stages which run before BS_DEV_INIT. + */ +BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, + vb2_clear_recovery_reason_vbnv, NULL); + +/* + * Returns 0 for the stages where we know that cbmem does not come online. + * Even if this function returns 1 for romstage, depending upon the point in + * bootup, cbmem might not actually be online. + */ +static int cbmem_possibly_online(void) +{ + if (ENV_BOOTBLOCK) + return 0; + + if (ENV_VERSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK)) + return 0; + + return 1; +} + +/* + * Returns 1 if vboot is being used and currently in a stage which might have + * already executed vboot verification. + */ +static int vboot_possibly_executed(void) +{ + if (!IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE)) + return 0; + + if (IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK)) { + if (ENV_BOOTBLOCK && IS_ENABLED(CONFIG_SEPARATE_VERSTAGE)) + return 0; + return 1; + } + + if (IS_ENABLED(CONFIG_VBOOT_STARTS_IN_ROMSTAGE)) { + if (ENV_BOOTBLOCK) + return 0; + return 1; + } + + return 0; +} + +/* + * vb2_check_recovery_request looks up different components to identify if there + * is a recovery request and returns appropriate reason code: + * 1. Checks if recovery mode is initiated by EC. If yes, returns + * VB2_RECOVERY_RO_MANUAL. + * 2. If CONFIG_CHROMEOS is enabled, checks if recovery request is present in + * VBNV and returns the code read from it. + * 3. Checks recovery request in handoff for stages post-cbmem. + * 4. For non-CBMEM stages, check if vboot verification is done and look-up + * selected region to identify if vboot_refence library has requested recovery + * path. If yes, return the reason code from shared data. + * 5. If nothing applies, return 0 indicating no recovery request. + */ +int vboot_check_recovery_request(void) +{ + int reason = 0; + + /* EC-initiated recovery. */ + if (get_recovery_mode_switch()) + return VB2_RECOVERY_RO_MANUAL; + + /* Recovery request in VBNV. */ + if (IS_ENABLED(CONFIG_CHROMEOS) && + (reason = get_recovery_mode_from_vbnv()) != 0) + return reason; + + /* + * Check recovery flag in vboot_handoff for stages post CBMEM coming + * online. Since for some stages there is no way to know if cbmem has + * already come online, try looking up handoff anyways. If it fails, + * flow will fallback to looking up shared data. + */ + if (cbmem_possibly_online() && + ((reason = vboot_handoff_get_recovery_reason()) != 0)) + return reason; + + /* + * For stages where CBMEM might not be online, identify if vboot + * verification is already complete and no slot was selected + * i.e. recovery path was requested. + */ + if (vboot_possibly_executed() && vb2_logic_executed() && + !vb2_is_slot_selected()) + return vb2_get_recovery_reason_shared_data(); + + return 0; +} + +int vboot_recovery_mode_enabled(void) +{ + return !!vboot_check_recovery_request(); +} + +int vboot_developer_mode_enabled(void) +{ + if (get_developer_mode_switch()) + return 1; + + if (cbmem_possibly_online() && vboot_handoff_check_developer_flag()) + return 1; + + return 0; +} diff --git a/src/vendorcode/google/vboot2/recovery.c b/src/vendorcode/google/vboot2/recovery.c deleted file mode 100644 index 3966db4..0000000 --- a/src/vendorcode/google/vboot2/recovery.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright 2016 Google Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include <assert.h> -#include <bootmode.h> -#include <bootstate.h> -#include <rules.h> -#include <string.h> -#include <vb2_api.h> -#include <vendorcode/google/chromeos/vbnv.h> - -#include "misc.h" -#include "vboot_common.h" - -static int vb2_get_recovery_reason_shared_data(void) -{ - /* Shared data does not exist for Ramstage and Post-CAR stage. */ - if (ENV_RAMSTAGE || ENV_POSTCAR) - return 0; - - struct vb2_shared_data *sd = vb2_get_shared_data(); - assert(sd); - return sd->recovery_reason; -} - -void vb2_save_recovery_reason_vbnv(void) -{ - if (!IS_ENABLED(CONFIG_VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT)) - return; - - int reason = vb2_get_recovery_reason_shared_data(); - if (!reason) - return; - - set_recovery_mode_into_vbnv(reason); -} - -static void vb2_clear_recovery_reason_vbnv(void *unused) -{ - if (!IS_ENABLED(CONFIG_VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT)) - return; - - set_recovery_mode_into_vbnv(0); -} - -/* - * Recovery reason stored in VBNV needs to be cleared before the state of VBNV - * is backed-up anywhere or jumping to the payload (whichever occurs - * first). Currently, vbnv_cmos.c backs up VBNV on POST_DEVICE. Thus, we need to - * make sure that the stored recovery reason is cleared off before that - * happens. - * IMPORTANT: Any reboot occurring after BS_DEV_INIT state will cause loss of - * recovery reason on reboot. Until now, we have seen reboots occuring on x86 - * only in FSP stages which run before BS_DEV_INIT. - */ -BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, - vb2_clear_recovery_reason_vbnv, NULL); - -/* - * Returns 0 for the stages where we know that cbmem does not come online. - * Even if this function returns 1 for romstage, depending upon the point in - * bootup, cbmem might not actually be online. - */ -static int cbmem_possibly_online(void) -{ - if (ENV_BOOTBLOCK) - return 0; - - if (ENV_VERSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK)) - return 0; - - return 1; -} - -/* - * Returns 1 if vboot is being used and currently in a stage which might have - * already executed vboot verification. - */ -static int vboot_possibly_executed(void) -{ - if (!IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE)) - return 0; - - if (IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK)) { - if (ENV_BOOTBLOCK && IS_ENABLED(CONFIG_SEPARATE_VERSTAGE)) - return 0; - return 1; - } - - if (IS_ENABLED(CONFIG_VBOOT_STARTS_IN_ROMSTAGE)) { - if (ENV_BOOTBLOCK) - return 0; - return 1; - } - - return 0; -} - -/* - * vb2_check_recovery_request looks up different components to identify if there - * is a recovery request and returns appropriate reason code: - * 1. Checks if recovery mode is initiated by EC. If yes, returns - * VB2_RECOVERY_RO_MANUAL. - * 2. If CONFIG_CHROMEOS is enabled, checks if recovery request is present in - * VBNV and returns the code read from it. - * 3. Checks recovery request in handoff for stages post-cbmem. - * 4. For non-CBMEM stages, check if vboot verification is done and look-up - * selected region to identify if vboot_refence library has requested recovery - * path. If yes, return the reason code from shared data. - * 5. If nothing applies, return 0 indicating no recovery request. - */ -int vboot_check_recovery_request(void) -{ - int reason = 0; - - /* EC-initiated recovery. */ - if (get_recovery_mode_switch()) - return VB2_RECOVERY_RO_MANUAL; - - /* Recovery request in VBNV. */ - if (IS_ENABLED(CONFIG_CHROMEOS) && - (reason = get_recovery_mode_from_vbnv()) != 0) - return reason; - - /* - * Check recovery flag in vboot_handoff for stages post CBMEM coming - * online. Since for some stages there is no way to know if cbmem has - * already come online, try looking up handoff anyways. If it fails, - * flow will fallback to looking up shared data. - */ - if (cbmem_possibly_online() && - ((reason = vboot_handoff_get_recovery_reason()) != 0)) - return reason; - - /* - * For stages where CBMEM might not be online, identify if vboot - * verification is already complete and no slot was selected - * i.e. recovery path was requested. - */ - if (vboot_possibly_executed() && vb2_logic_executed() && - !vb2_is_slot_selected()) - return vb2_get_recovery_reason_shared_data(); - - return 0; -} diff --git a/src/vendorcode/google/vboot2/vboot_common.h b/src/vendorcode/google/vboot2/vboot_common.h index 249d83a..993ad32 100644 --- a/src/vendorcode/google/vboot2/vboot_common.h +++ b/src/vendorcode/google/vboot2/vboot_common.h @@ -101,4 +101,8 @@ void verstage_main(void); void verstage(void); void verstage_mainboard_init(void);
+/* Check boot modes */ +int vboot_developer_mode_enabled(void); +int vboot_recovery_mode_enabled(void); + #endif /* VBOOT_COMMON_H */