soc/amd/common/block/psp: Unmap EFS region after use

EFS header is mapped during PSP verstage and bootblock to read some SPI
configuration. After use it is left unmapped. Unmap the EFS region after
use.

BUG=b:240664755
TEST=Build and boot to OS in Skyrim with unsigned PSP verstage.

Change-Id: I865f45a3d25bc639eb8435b54aa80895ec4afd27
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75455
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Karthikeyan Ramasubramanian 2023-05-25 15:42:01 -06:00 committed by Felix Held
parent d6f73972cf
commit 49d8aa7043
1 changed files with 14 additions and 20 deletions

View File

@ -7,31 +7,25 @@
#include <device/mmio.h> #include <device/mmio.h>
#include <types.h> #include <types.h>
static struct embedded_firmware *efs;
bool efs_is_valid(void)
{
if (!efs)
efs = rdev_mmap(boot_device_ro(), EFS_OFFSET, sizeof(*efs));
if (!efs || efs->signature != EMBEDDED_FW_SIGNATURE)
return false;
return true;
}
bool read_efs_spi_settings(uint8_t *mode, uint8_t *speed) bool read_efs_spi_settings(uint8_t *mode, uint8_t *speed)
{ {
if (!efs_is_valid()) bool ret = false;
struct embedded_firmware *efs;
efs = rdev_mmap(boot_device_ro(), EFS_OFFSET, sizeof(*efs));
if (!efs)
return false; return false;
if (efs->signature == EMBEDDED_FW_SIGNATURE) {
#ifndef SPI_MODE_FIELD #ifndef SPI_MODE_FIELD
printk(BIOS_ERR, "Unknown cpu in psp_efs.h\n"); printk(BIOS_ERR, "Unknown cpu in psp_efs.h\n");
printk(BIOS_ERR, "SPI speed/mode not set.\n"); printk(BIOS_ERR, "SPI speed/mode not set.\n");
return false;
#else #else
*mode = efs->SPI_MODE_FIELD; *mode = efs->SPI_MODE_FIELD;
*speed = efs->SPI_SPEED_FIELD; *speed = efs->SPI_SPEED_FIELD;
return true; ret = true;
#endif #endif
}
rdev_munmap(boot_device_ro(), efs);
return ret;
} }