soc/amd/common/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: If1d355972cc743b8d8c451e1b3f827abd15e98fe
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75453
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
diff --git a/src/soc/amd/common/psp_verstage/psp_verstage.c b/src/soc/amd/common/psp_verstage/psp_verstage.c
index 294950b..c9092f4 100644
--- a/src/soc/amd/common/psp_verstage/psp_verstage.c
+++ b/src/soc/amd/common/psp_verstage/psp_verstage.c
@@ -113,6 +113,7 @@
 	if (ef_table->signature != EMBEDDED_FW_SIGNATURE) {
 		printk(BIOS_ERR, "ROMSIG address is not correct.\n");
 		cbfs_unmap(amdfw_location);
+		rdev_munmap(boot_device_ro(), amdfw_location);
 		rdev_munmap(boot_device_ro(), map_base);
 		return POSTCODE_ROMSIG_MISMATCH_ERROR;
 	}
@@ -124,6 +125,7 @@
 	if (*psp_dir_in_spi != PSP_COOKIE) {
 		printk(BIOS_ERR, "PSP Directory address is not correct.\n");
 		cbfs_unmap(amdfw_location);
+		rdev_munmap(boot_device_ro(), amdfw_location);
 		rdev_munmap(boot_device_ro(), map_base);
 		return POSTCODE_PSP_COOKIE_MISMATCH_ERROR;
 	}
@@ -134,6 +136,7 @@
 		if (*bios_dir_in_spi != BHD_COOKIE) {
 			printk(BIOS_ERR, "BIOS Directory address is not correct.\n");
 			cbfs_unmap(amdfw_location);
+			rdev_munmap(boot_device_ro(), amdfw_location);
 			rdev_munmap(boot_device_ro(), map_base);
 			return POSTCODE_BHD_COOKIE_MISMATCH_ERROR;
 		}
@@ -149,6 +152,7 @@
 	if (update_psp_bios_dir(&psp_dir_addr, &bios_dir_addr)) {
 		printk(BIOS_ERR, "Updated BIOS Directory could not be set.\n");
 		cbfs_unmap(amdfw_location);
+		rdev_munmap(boot_device_ro(), amdfw_location);
 		rdev_munmap(boot_device_ro(), map_base);
 		return POSTCODE_UPDATE_PSP_BIOS_DIR_ERROR;
 	}
@@ -157,6 +161,7 @@
 		update_psp_fw_hash_table(hash_fname);
 
 	cbfs_unmap(amdfw_location);
+	rdev_munmap(boot_device_ro(), amdfw_location);
 	rdev_munmap(boot_device_ro(), map_base);
 	return 0;
 }