From c8e4ff7c15e6bf5992a578b66bec47d69cde3bea Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 10 Nov 2011 13:31:39 -0800 Subject: Add flag to GBB to allow loading PCI Option ROMs As shipped, H2C only loads the option ROM for the built-in video, and that only when it needs display the BIOS warning screens. By setting a flag in the GBB, you can allow all option ROMs to be loaded: Note that we'll never enable this ourselves (and there's a factory test to ensure that*) because it executes non-verified code. But if a customer wants to void their warranty and set this flag in the read-only flash so they can install and use other PCI devices, they should be able to do so. BUG=chrome-os-partner:6148 TEST=none The only way to test this is to use a BIOS that was compiled with serial debugging enabled, so there's nothing for QA to do. If you have such a BIOS, you can see the difference like so: flashrom -r oldbios.bin gbb_utility -s --flags=2 oldbios.bin newbios.bin flashrom -w newbios.bin When bit 1 of the GBB flags is 0, you'll see these lines in the serial output: LoadOpRomImage-->GetSystemConfigurationTable Status = Success LoadOpRomImage-->GetH2cBootMode Status = Success When bit 1 of the GBB flags is 1, you'll see these lines in the serial output: LoadOpRomImage-->GetSystemConfigurationTable Status = Success LoadOpRomImage-->GetH2cBootMode Status = Success LoadOpRomImage-->PCI OpRom on 1.0.0 is allowed!!! This happens in any boot mode (normal, developer, recovery). -- *The factory test for GBB zero flags is gft_clear_gbb_flags.sh, in src/platform/factory_test_tools Change-Id: I31a10cc9d562b4b83669ca8a114b60e87ae28b0a Reviewed-on: https://gerrit.chromium.org/gerrit/11505 Tested-by: Bill Richardson Reviewed-by: Gaurav Shah Reviewed-by: Randall Spangler --- firmware/include/gbb_header.h | 8 +++++++- firmware/include/vboot_api.h | 2 ++ firmware/lib/vboot_api_init.c | 7 ++++++- tests/vboot_api_init_tests.c | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/firmware/include/gbb_header.h b/firmware/include/gbb_header.h index c9d2909c..6a0b65fb 100644 --- a/firmware/include/gbb_header.h +++ b/firmware/include/gbb_header.h @@ -33,8 +33,14 @@ #define GBB_HWID_MAX_SIZE 256 /* Flags for .flags field */ -/* Reduce the dev screen delay to 2 sec from 30 sec */ +/* Reduce the dev screen delay to 2 sec from 30 sec to speedup factory. */ #define GBB_FLAG_DEV_SCREEN_SHORT_DELAY 0x00000001 +/* BIOS should load option ROMs from arbitrary PCI devices. We'll never enable + * this ourselves because it executes non-verified code, but if a customer wants + * to void their warranty and set this flag in the read-only flash, they should + * be able to do so. + */ +#define GBB_FLAG_LOAD_OPTION_ROMS 0x00000002 #ifdef __cplusplus extern "C" { diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 2703e05b..ffc0c412 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -184,6 +184,8 @@ typedef struct VbCommonParams { #define VB_INIT_OUT_ENABLE_USB_STORAGE 0x00000008 /* If this is a S3 resume, do a debug reset boot instead */ #define VB_INIT_OUT_S3_DEBUG_BOOT 0x00000010 +/* BIOS should load any PCI option ROMs it finds, not just internal video */ +#define VB_INIT_OUT_ENABLE_OPROM 0x00000020 /* Data only used by VbInit() */ diff --git a/firmware/lib/vboot_api_init.c b/firmware/lib/vboot_api_init.c index 2a6b7d0b..7fa488ae 100644 --- a/firmware/lib/vboot_api_init.c +++ b/firmware/lib/vboot_api_init.c @@ -16,6 +16,7 @@ VbError_t VbInit(VbCommonParams* cparams, VbInitParams* iparams) { VbSharedDataHeader* shared = (VbSharedDataHeader*)cparams->shared_data_blob; + GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)cparams->gbb_data; VbNvContext vnc; VbError_t retval = VBERROR_SUCCESS; uint32_t recovery = VBNV_RECOVERY_NOT_REQUESTED; @@ -106,7 +107,11 @@ VbError_t VbInit(VbCommonParams* cparams, VbInitParams* iparams) { VB_INIT_OUT_ENABLE_USB_STORAGE); } - /* Copy current recovery reason to shared data */ + /* Allow BIOS to load arbitrary option ROMs? */ + if (gbb->flags & GBB_FLAG_LOAD_OPTION_ROMS) + iparams->out_flags |= VB_INIT_OUT_ENABLE_OPROM; + + /* copy current recovery reason to shared data */ shared->recovery_reason = (uint8_t)recovery; /* If this is a S3 resume, resume the TPM */ diff --git a/tests/vboot_api_init_tests.c b/tests/vboot_api_init_tests.c index 0e1d0311..22010c63 100644 --- a/tests/vboot_api_init_tests.c +++ b/tests/vboot_api_init_tests.c @@ -8,6 +8,7 @@ #include #include +#include "gbb_header.h" #include "host_common.h" #include "rollback_index.h" #include "test_common.h" @@ -24,12 +25,20 @@ static VbSharedDataHeader* shared = (VbSharedDataHeader*)shared_data; static uint64_t mock_timer; static int rollback_s3_retval; static int nv_write_called; +static GoogleBinaryBlockHeader gbb; + /* Reset mock data (for use before each test) */ static void ResetMocks(void) { Memset(&cparams, 0, sizeof(cparams)); cparams.shared_data_size = sizeof(shared_data); cparams.shared_data_blob = shared_data; + cparams.gbb_data = &gbb; + + Memset(&gbb, 0, sizeof(gbb)); + gbb.major_version = GBB_MAJOR_VER; + gbb.minor_version = GBB_MINOR_VER; + gbb.flags = 0; Memset(&iparams, 0, sizeof(iparams)); -- cgit v1.2.1