From 49d8aa7043ea4c9c3f5c655007234b386ba33919 Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Thu, 25 May 2023 15:42:01 -0600 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75455 Reviewed-by: Raul Rangel Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/psp/psp_efs.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'src/soc/amd/common/block') diff --git a/src/soc/amd/common/block/psp/psp_efs.c b/src/soc/amd/common/block/psp/psp_efs.c index 709273e8d8..7227b9257a 100644 --- a/src/soc/amd/common/block/psp/psp_efs.c +++ b/src/soc/amd/common/block/psp/psp_efs.c @@ -7,31 +7,25 @@ #include #include -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) { - 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; + if (efs->signature == EMBEDDED_FW_SIGNATURE) { #ifndef SPI_MODE_FIELD - printk(BIOS_ERR, "Unknown cpu in psp_efs.h\n"); - printk(BIOS_ERR, "SPI speed/mode not set.\n"); - return false; + printk(BIOS_ERR, "Unknown cpu in psp_efs.h\n"); + printk(BIOS_ERR, "SPI speed/mode not set.\n"); #else - *mode = efs->SPI_MODE_FIELD; - *speed = efs->SPI_SPEED_FIELD; - return true; + *mode = efs->SPI_MODE_FIELD; + *speed = efs->SPI_SPEED_FIELD; + ret = true; #endif + } + rdev_munmap(boot_device_ro(), efs); + return ret; } -- cgit v1.2.3