device/pci_rom: Move VBIOS checksum fix

Move the VBIOS checksum code into the soc/amd folder, as it's
specific to AMD's FSP. The code now fixes the VBIOS in place
instead only fixing it for the VFCT table.

TEST: VBIOS has correct checksum after loading in BS_DEV_RESOURCES.
      VBIOS checksum is invalid entering graphics_dev_init().
      VBIOS checksum is correct leaving graphics_dev_init().

Change-Id: I63aaaefaf01ea456e2ed39cd0891e552a7fb5135
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86384
Reviewed-by: Ana Carolina Cabral <ana.cpmelo95@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Patrick Rudolph 2025-02-11 16:08:55 +01:00 committed by Felix Held
commit 5f5aa79cca
2 changed files with 20 additions and 9 deletions

View file

@ -242,15 +242,6 @@ ati_rom_acpi_fill_vfct(const struct device *device, acpi_vfct_t *vfct_struct,
vfct_struct->VBIOSImageOffset = (size_t)header - (size_t)vfct_struct;
/* Calculate and set checksum for VBIOS data if FSP GOP driver used,
Since GOP driver modifies ATOMBIOS tables at end of VBIOS */
if (CONFIG(RUN_FSP_GOP)) {
/* Clear existing checksum before recalculating */
header->VbiosContent[VFCT_VBIOS_CHECKSUM_OFFSET] = 0;
header->VbiosContent[VFCT_VBIOS_CHECKSUM_OFFSET] =
acpi_checksum(header->VbiosContent, header->ImageLength);
}
current += header->ImageLength;
return current;
}

View file

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <amdblocks/graphics.h>
#include <amdblocks/vbt.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
@ -15,4 +16,23 @@ void fsp_graphics_init(struct device *const dev)
else
printk(BIOS_ERR, "%s: Unable to find resource for %s\n",
__func__, dev_path(dev));
/*
* Calculate and set checksum for VBIOS data if FSP GOP driver used,
* Since GOP driver modifies ATOMBIOS tables at end of BS_DEV_RESOURCES.
* While Linux does not verify the checksum the Windows kernel driver does.
*/
struct rom_header *vbios = (struct rom_header *)vbt_get();
if (!vbios || !vbios->size) {
printk(BIOS_ERR, "%s: No VGA BIOS loaded for %s\n",
__func__, dev_path(dev));
return;
}
uint8_t *data = (uint8_t *)vbios;
/* Clear existing checksum before recalculating */
data[VFCT_VBIOS_CHECKSUM_OFFSET] = 0;
data[VFCT_VBIOS_CHECKSUM_OFFSET] =
acpi_checksum(data, vbios->size * 512);
}