diff options
author | Karthikeyan Ramasubramanian <kramasub@google.com> | 2023-05-25 15:49:29 -0600 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2023-05-27 01:58:07 +0000 |
commit | 1da0340aa8834681082128b5da42ac96ed55af33 (patch) | |
tree | df156c797321a1a7bfb7408a67e3587e95abe475 | |
parent | 91795a6da1c02e8af75cf52f9e28662a7947b204 (diff) |
soc/amd/common/psp_verstage: Fix build for FMAP without RW slots
On FMAP without RW slots, PSP verstage fails to build because of
reference to FMAP_SECTION_FW_MAIN_A_*. Instead extract the offset and
size of relevant sections using fmap_locate_area().
BUG=b:240664755
TEST=Build and boot to OS in Skyrim with unsigned PSP verstage.
Change-Id: I29997534c6843b47a36655431f79e5c70bd17f9b
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75452
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
-rw-r--r-- | src/soc/amd/common/psp_verstage/psp_verstage.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/soc/amd/common/psp_verstage/psp_verstage.c b/src/soc/amd/common/psp_verstage/psp_verstage.c index dfea43d6c9..294950b392 100644 --- a/src/soc/amd/common/psp_verstage/psp_verstage.c +++ b/src/soc/amd/common/psp_verstage/psp_verstage.c @@ -75,8 +75,8 @@ static uint32_t update_boot_region(struct vb2_context *ctx) const char *fname; const char *hash_fname; void *amdfw_location; + struct region fw_slot; void *map_base = NULL; - size_t map_offset; /* Continue booting from RO */ if (ctx->flags & VB2_CONTEXT_RECOVERY_MODE) { @@ -87,13 +87,14 @@ static uint32_t update_boot_region(struct vb2_context *ctx) if (vboot_is_firmware_slot_a(ctx)) { fname = "apu/amdfw_a"; hash_fname = "apu/amdfw_a_hash"; - map_offset = FMAP_SECTION_FW_MAIN_A_START - FMAP_SECTION_FLASH_START; - map_base = rdev_mmap(boot_device_ro(), map_offset, FMAP_SECTION_FW_MAIN_A_SIZE); + if (!fmap_locate_area("FW_MAIN_A", &fw_slot)) + map_base = rdev_mmap(boot_device_ro(), fw_slot.offset, fw_slot.size); + } else { fname = "apu/amdfw_b"; hash_fname = "apu/amdfw_b_hash"; - map_offset = FMAP_SECTION_FW_MAIN_B_START - FMAP_SECTION_FLASH_START; - map_base = rdev_mmap(boot_device_ro(), map_offset, FMAP_SECTION_FW_MAIN_B_SIZE); + if (!fmap_locate_area("FW_MAIN_B", &fw_slot)) + map_base = rdev_mmap(boot_device_ro(), fw_slot.offset, fw_slot.size); } if (!map_base) { @@ -119,7 +120,7 @@ static uint32_t update_boot_region(struct vb2_context *ctx) psp_dir_addr = ef_table->new_psp_directory; bios_dir_addr = get_bios_dir_addr(ef_table); psp_dir_in_spi = (uint32_t *)((psp_dir_addr & SPI_ADDR_MASK) + - (uint32_t)map_base - map_offset); + (uint32_t)map_base - fw_slot.offset); if (*psp_dir_in_spi != PSP_COOKIE) { printk(BIOS_ERR, "PSP Directory address is not correct.\n"); cbfs_unmap(amdfw_location); @@ -129,7 +130,7 @@ static uint32_t update_boot_region(struct vb2_context *ctx) if (bios_dir_addr) { bios_dir_in_spi = (uint32_t *)((bios_dir_addr & SPI_ADDR_MASK) + - (uint32_t)map_base - map_offset); + (uint32_t)map_base - fw_slot.offset); if (*bios_dir_in_spi != BHD_COOKIE) { printk(BIOS_ERR, "BIOS Directory address is not correct.\n"); cbfs_unmap(amdfw_location); |