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 <felix-coreboot@felixheld.de>
Change-Id: Idafa7d9bf64125bcabd9b47e77147bcffee739e2
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83812
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
This commit is contained in:
Felix Held 2024-08-07 16:18:03 +02:00
parent 1ce1b58b01
commit f9af266189
2 changed files with 18 additions and 1 deletions

View File

@ -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;

View File

@ -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 <HEX_VAL> Base address of nvram\n");
printf("--nvram-size <HEX_VAL> Size of nvram\n");
printf("--rpmc-nvram-base <HEX_VAL> Base address of RPMC nvram\n");
printf("--rpmc-nvram-size <HEX_VAL> 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;