Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/79737?usp=email )
Change subject: vendorcode/google/chromeos: API to read factory config ......................................................................
vendorcode/google/chromeos: API to read factory config
This code leverages the TPM vendor-specific function tlcl_ti50_get_factory_config() to fetch the device's factory configuration.
Note: this implementation is specific for chromeos devices with Ti50 devices.
BUG=b:317880956 TEST=Able to retrieve the factory config from google/screebo.
Change-Id: I34f47c9a94972534cda656ef624ef12ed5ddeb06 Signed-off-by: Subrata Banik subratabanik@google.com --- M src/vendorcode/google/chromeos/Makefile.inc M src/vendorcode/google/chromeos/chromeos.h A src/vendorcode/google/chromeos/ti50_misc_cmd.c 3 files changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/37/79737/1
diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc index fbfd7a4..80c863b 100644 --- a/src/vendorcode/google/chromeos/Makefile.inc +++ b/src/vendorcode/google/chromeos/Makefile.inc @@ -9,6 +9,7 @@ ramstage-$(CONFIG_HAVE_REGULATORY_DOMAIN) += wrdd.c ramstage-$(CONFIG_USE_SAR) += sar.c ramstage-$(CONFIG_TPM_GOOGLE) += cr50_enable_update.c +ramstage-$(CONFIG_TPM_GOOGLE_TI50) += ti50_misc_cmd.c
romstage-$(CONFIG_CHROMEOS_CSE_BOARD_RESET_OVERRIDE) += cse_board_reset.c ramstage-$(CONFIG_CHROMEOS_CSE_BOARD_RESET_OVERRIDE) += cse_board_reset.c diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h index cab855d..321ae655 100644 --- a/src/vendorcode/google/chromeos/chromeos.h +++ b/src/vendorcode/google/chromeos/chromeos.h @@ -26,6 +26,11 @@ void cbmem_add_vpd_calibration_data(void); void chromeos_set_me_hash(u32*, int); void chromeos_set_ramoops(void *ram_oops, size_t size); +/* + * The factory config space is a one-time programmable info page. + * For the unprovisioned one, the read will be 0x0. + */ +uint8_t chromeos_get_factory_config(void);
/* * Declaration for mainboards to use to generate ACPI-specific ChromeOS needs. diff --git a/src/vendorcode/google/chromeos/ti50_misc_cmd.c b/src/vendorcode/google/chromeos/ti50_misc_cmd.c new file mode 100644 index 0000000..91a412e --- /dev/null +++ b/src/vendorcode/google/chromeos/ti50_misc_cmd.c @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <security/tpm/tss.h> +#include <vendorcode/google/chromeos/chromeos.h> + +uint8_t chromeos_get_factory_config(void) +{ + /* Initialize TPM driver. */ + tpm_result_t rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "tlcl_lib_init() failed: %#x\n", rc); + return 0; + } + + uint64_t factory_config; + + rc = tlcl_ti50_get_factory_config(&factory_config); + + if (rc == TPM_CB_NO_SUCH_COMMAND) { + printk(BIOS_INFO, + "Ti50 does not support Factory Config command\n"); + return 0; + } + + return factory_config; +}