From f9af26618973c3d8b938ad65f555ddcd31efeb45 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Wed, 7 Aug 2024 16:18:03 +0200 Subject: util/amdfwtool: add support to specify RPMC NVRAM region Add support to specify the base and size of the replay-protected monotonic counter (RPMC) non-volatile storage area in the SPI flash. A later patch will use this to tell amdfwtool about the location and size of the corresponding FMAP section. This code is ported from github.com/teslamotors/coreboot/tree/tesla-4.12-amd Signed-off-by: Felix Held Change-Id: Idafa7d9bf64125bcabd9b47e77147bcffee739e2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83812 Reviewed-by: Marshall Dawson Reviewed-by: Martin Roth Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) Reviewed-by: Karthik Ramasubramanian --- util/amdfwtool/amdfwtool.c | 3 ++- util/amdfwtool/opts.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 1dac476a2a..1fe9923696 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -1011,7 +1011,8 @@ static void integrate_psp_firmwares(context *ctx, pspdir->entries[count].addr = fw_table[i].other; pspdir->entries[count].address_mode = 0; count++; - } else if (fw_table[i].type == AMD_FW_PSP_NVRAM) { + } else if (fw_table[i].type == AMD_FW_PSP_NVRAM || + fw_table[i].type == AMD_RPMC_NVRAM) { if (fw_table[i].filename == NULL) { if (fw_table[i].size == 0) continue; diff --git a/util/amdfwtool/opts.c b/util/amdfwtool/opts.c index 511ffd02db..62bbc97ae5 100644 --- a/util/amdfwtool/opts.c +++ b/util/amdfwtool/opts.c @@ -68,6 +68,8 @@ enum { LONGOPT_BIOS_SIG = 259, LONGOPT_NVRAM_BASE = 260, LONGOPT_NVRAM_SIZE = 261, + LONGOPT_RPMC_NVRAM_BASE = 262, + LONGOPT_RPMC_NVRAM_SIZE = 263, }; static const char optstring[] = {AMDFW_OPT_CONFIG, ':', @@ -87,6 +89,8 @@ static struct option long_options[] = { {"nvram", required_argument, 0, AMDFW_OPT_NVRAM }, {"nvram-base", required_argument, 0, LONGOPT_NVRAM_BASE }, {"nvram-size", required_argument, 0, LONGOPT_NVRAM_SIZE }, + {"rpmc-nvram-base", required_argument, 0, LONGOPT_RPMC_NVRAM_BASE }, + {"rpmc-nvram-size", required_argument, 0, LONGOPT_RPMC_NVRAM_SIZE }, {"soft-fuse", required_argument, 0, AMDFW_OPT_FUSE }, {"token-unlock", no_argument, 0, AMDFW_OPT_UNLOCK }, {"whitelist", required_argument, 0, AMDFW_OPT_WHITELIST }, @@ -150,6 +154,8 @@ static void usage(void) printf("--token-unlock Set token unlock\n"); printf("--nvram-base Base address of nvram\n"); printf("--nvram-size Size of nvram\n"); + printf("--rpmc-nvram-base Base address of RPMC nvram\n"); + printf("--rpmc-nvram-size Size of RPMC nvram\n"); printf("--whitelist Set if there is a whitelist\n"); printf("--use-pspsecureos Set if psp secure OS is needed\n"); printf("--load-mp2-fw Set if load MP2 firmware\n"); @@ -577,6 +583,16 @@ int amdfwtool_getopt(int argc, char *argv[], amd_cb_config *cb_config, context * register_amd_psp_fw_addr(AMD_FW_PSP_NVRAM, sub, 0, optarg); sub = instance = 0; break; + case LONGOPT_RPMC_NVRAM_BASE: + /* PSP RPMC NV base */ + register_amd_psp_fw_addr(AMD_RPMC_NVRAM, sub, optarg, 0); + sub = instance = 0; + break; + case LONGOPT_RPMC_NVRAM_SIZE: + /* PSP RPMC NV size */ + register_amd_psp_fw_addr(AMD_RPMC_NVRAM, sub, 0, optarg); + sub = instance = 0; + break; case AMDFW_OPT_CONFIG: cb_config->config = optarg; break; -- cgit v1.2.3