diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index cbfc7bf91b..2eb0da32dd 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -162,6 +162,10 @@ struct sysinfo_t { uint32_t cbfs_ro_mcache_size; uintptr_t cbfs_rw_mcache_offset; uint32_t cbfs_rw_mcache_size; + + /* pvmfw buffer location */ + uintptr_t pvmfw; + uint32_t pvmfw_size; }; extern struct sysinfo_t lib_sysinfo; diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index 7873426473..7a9f997054 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -268,6 +268,10 @@ static void cb_parse_cbmem_entry(void *ptr, struct sysinfo_t *info) case CBMEM_ID_CSE_INFO: info->cse_info = cbmem_entry->address; break; + case CBMEM_ID_PVMFW: + info->pvmfw = cbmem_entry->address; + info->pvmfw_size = cbmem_entry->entry_size; + break; default: break; } diff --git a/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h b/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h index 7873d5856f..4cf1f09a84 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h +++ b/src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h @@ -90,6 +90,7 @@ #define CBMEM_ID_CSE_INFO 0x4553435F #define CBMEM_ID_CSE_BP_INFO 0x42455343 #define CBMEM_ID_AMD_OPENSIL 0x4153494C +#define CBMEM_ID_PVMFW 0x666d7670 #define CBMEM_ID_TO_NAME_TABLE \ { CBMEM_ID_ACPI, "ACPI " }, \ @@ -172,5 +173,6 @@ { CBMEM_ID_AMD_MP2, "AMD MP2 BUFFER"},\ { CBMEM_ID_CSE_INFO, "CSE SPECIFIC INFO"},\ { CBMEM_ID_CSE_BP_INFO, "CSE BP INFO"}, \ - { CBMEM_ID_AMD_OPENSIL, "OPENSIL DATA"} + { CBMEM_ID_AMD_OPENSIL, "OPENSIL DATA"}, \ + { CBMEM_ID_PVMFW, "PVMFW "} #endif /* _CBMEM_ID_H_ */ diff --git a/src/vendorcode/google/Kconfig b/src/vendorcode/google/Kconfig index b24c554147..a846336c0b 100644 --- a/src/vendorcode/google/Kconfig +++ b/src/vendorcode/google/Kconfig @@ -37,3 +37,18 @@ config MAINBOARD_HAS_GOOGLE_STRAUSS_KEYBOARD config ACPI_FNKEY_GEN_SCANCODE default 94 if MAINBOARD_HAS_GOOGLE_STRAUSS_KEYBOARD + +config GOOGLE_PVMFW_CBMEM + bool "Enable reserving memory for pvmfw using cbmem" + default n + help + Select this config to enable allocating a region for Android protected + virtual machine firmware within cbmem. The region shall be filled by + the payload and the purpose is to just reserve the memory. + cbmem is used to make sure that the region won't overlap with other + reserved regions or device regions. + +config GOOGLE_PVMFW_CBMEM_SIZE + hex "Size of the pvmfw buffer to be reserved using cbmem" + depends on GOOGLE_PVMFW_CBMEM + default 0x400000 diff --git a/src/vendorcode/google/Makefile.mk b/src/vendorcode/google/Makefile.mk index c9e83897ff..32bb90ff74 100644 --- a/src/vendorcode/google/Makefile.mk +++ b/src/vendorcode/google/Makefile.mk @@ -4,3 +4,4 @@ subdirs-$(CONFIG_CHROMEOS) += chromeos ramstage-$(CONFIG_GOOGLE_DSM_CALIB) += dsm_calib.c ramstage-$(CONFIG_GOOGLE_SMBIOS_MAINBOARD_VERSION) += smbios.c +ramstage-$(CONFIG_GOOGLE_PVMFW_CBMEM) += pvmfw_cbmem.c diff --git a/src/vendorcode/google/pvmfw_cbmem.c b/src/vendorcode/google/pvmfw_cbmem.c new file mode 100644 index 0000000000..15b0710645 --- /dev/null +++ b/src/vendorcode/google/pvmfw_cbmem.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +static void add_pvmfw_cbmem(void *unused) +{ + (void)unused; + void *pvmfw; + + pvmfw = cbmem_add(CBMEM_ID_PVMFW, CONFIG_GOOGLE_PVMFW_CBMEM_SIZE); + if (!pvmfw) + printk(BIOS_ERR, "Failed to add pvmfw info to CBMEM\n"); +} + +BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, add_pvmfw_cbmem, NULL);