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 <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75454
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Karthikeyan Ramasubramanian 2023-05-25 15:58:25 -06:00 committed by Felix Held
parent 01c9dfbae6
commit d6f73972cf
1 changed files with 9 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#include <arch/hlt.h>
#include <bl_uapp/bl_errorcodes_public.h>
#include <bl_uapp/bl_syscall_public.h>
#include <boot_device.h>
#include <cbfs.h>
#include <console/console.h>
#include <psp_verstage.h>
@ -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)