soc/amd/common/psp_verstage: Fix update_boot_region

On SoCs where PSP use A/B recovery layout, PSP expects PSP L2 directory
address relative to the start of the SPI ROM. Unfortunately there is
nothing in the EFS2 header to help identify such SoCs. Hence add a
config item to statically identify such SoCs.

Also when PSP uses A/B recovery layout, BIOS L2 directory is an entry in
the PSP L2 directory. Hence the address of BIOS L2 directory is not part
of EFS2 header. Thankfully PSP is able to identify the BIOS L2 directory
itself and does not expect PSP verstage to pass the address. Modify PSP
verstage to handle these updates.

BUG=b:217414563
TEST=Build Skyrim BIOS image. Ensure that PSP verstage returned the PSP
L2 directory as expected.

Change-Id: I2f856a62055c80b8e2db91c983832611a5f0389c
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65865
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Karthikeyan Ramasubramanian 2022-07-14 15:37:07 -06:00 committed by Martin L Roth
parent df74de1cac
commit e3eedf7548
2 changed files with 18 additions and 6 deletions

View file

@ -21,3 +21,11 @@ config PSP_INIT_TPM_ON_S0I3_RESUME
If the TPM is reset while in S0i3, it must be reinitialized
during s0i3 resume. This must be performed in PSP verstage since
coreboot is otherwise not involved with s0i3 resume.
config PSP_SUPPORTS_EFS2_RELATIVE_ADDR
bool
default n
help
On SoCs where PSP uses A/B recovery layout, PSP support relative addressing
from the start of the SPI ROM. Enable this config on SoCs where PSP supports
relative addressing so that PSP verstage can pass the offset.

View file

@ -104,19 +104,23 @@ static uint32_t update_boot_region(struct vb2_context *ctx)
bios_dir_addr = get_bios_dir_addr(ef_table);
psp_dir_in_spi = (uint32_t *)((psp_dir_addr & SPI_ADDR_MASK) +
(uint32_t)boot_dev_base);
bios_dir_in_spi = (uint32_t *)((bios_dir_addr & SPI_ADDR_MASK) +
(uint32_t)boot_dev_base);
if (*psp_dir_in_spi != PSP_COOKIE) {
printk(BIOS_ERR, "PSP Directory address is not correct.\n");
return POSTCODE_PSP_COOKIE_MISMATCH_ERROR;
}
if (bios_dir_addr) {
bios_dir_in_spi = (uint32_t *)((bios_dir_addr & SPI_ADDR_MASK) +
(uint32_t)boot_dev_base);
if (*bios_dir_in_spi != BHD_COOKIE) {
printk(BIOS_ERR, "BIOS Directory address is not correct.\n");
return POSTCODE_BHD_COOKIE_MISMATCH_ERROR;
}
}
/* EFS2 uses relative address and PSP isn't happy with that */
if (ef_table->efs_gen.gen == EFS_SECOND_GEN) {
if (ef_table->efs_gen.gen == EFS_SECOND_GEN &&
!CONFIG(PSP_SUPPORTS_EFS2_RELATIVE_ADDR)) {
psp_dir_addr = FLASH_BASE_ADDR + (psp_dir_addr & SPI_ADDR_MASK);
bios_dir_addr = FLASH_BASE_ADDR + (bios_dir_addr & SPI_ADDR_MASK);
}