From d6f73972cf7a1424ac81ffa5576aa233fb4d9b52 Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Thu, 25 May 2023 15:58:25 -0600 Subject: [PATCH] soc/amd/mendocino/psp_verstage: Fix pending maps cbfs_unmap does not unmap the mapped region from the boot device. This leads to some resource leaks eg. TLB slots in PSP. Explicitly call rdev_munmap on the address mapped by cbfs_map. BUG=b:240664755 TEST=Build and boot to OS in Skyrim with unsigned PSP verstage. Change-Id: I51b9d066a40103f2ebdf2ef2fc3da13beb467921 Signed-off-by: Karthikeyan Ramasubramanian Reviewed-on: https://review.coreboot.org/c/coreboot/+/75454 Tested-by: build bot (Jenkins) Reviewed-by: Raul Rangel --- src/soc/amd/mendocino/psp_verstage/chipset.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/soc/amd/mendocino/psp_verstage/chipset.c b/src/soc/amd/mendocino/psp_verstage/chipset.c index 0b622e73de..282ad21227 100644 --- a/src/soc/amd/mendocino/psp_verstage/chipset.c +++ b/src/soc/amd/mendocino/psp_verstage/chipset.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,8 @@ static struct psp_fw_entry_hash_384 hash_384[MAX_NUM_HASH_ENTRIES]; void update_psp_fw_hash_table(const char *fname) { - uint8_t *spi_ptr = (uint8_t *)cbfs_map(fname, NULL); + void *hash_file = cbfs_map(fname, NULL); + uint8_t *spi_ptr = (uint8_t *)hash_file; uint32_t len; if (!spi_ptr) { @@ -44,7 +46,8 @@ void update_psp_fw_hash_table(const char *fname) printk(BIOS_ERR, "Too many entries in AMD Firmware hash table" " (SHA256:%d, SHA384:%d)\n", hash_table.no_of_entries_256, hash_table.no_of_entries_384); - cbfs_unmap(spi_ptr); + cbfs_unmap(hash_file); + rdev_munmap(boot_device_ro(), hash_file); return; } @@ -53,7 +56,8 @@ void update_psp_fw_hash_table(const char *fname) printk(BIOS_ERR, "No entries in AMD Firmware hash table" " (SHA256:%d, SHA384:%d)\n", hash_table.no_of_entries_256, hash_table.no_of_entries_384); - cbfs_unmap(spi_ptr); + cbfs_unmap(hash_file); + rdev_munmap(boot_device_ro(), hash_file); return; } @@ -69,7 +73,8 @@ void update_psp_fw_hash_table(const char *fname) memcpy(hash_384, spi_ptr, len); svc_set_fw_hash_table(&hash_table); - cbfs_unmap(spi_ptr); + cbfs_unmap(hash_file); + rdev_munmap(boot_device_ro(), hash_file); } uint32_t update_psp_bios_dir(uint32_t *psp_dir_offset, uint32_t *bios_dir_offset)