From 446f7dffbbcee541dfc9067d8bea109e722d7f7e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 29 Nov 2007 01:23:08 +0000 Subject: [PATCH] The attached patch adds code to checksum the pci extension rom and warn if the stored and calculated checksum differ. There is no easy way to check extension ROMs in the current machine for correct signatures, but you could copy out the memory between 0xc0000 - 0xf00000 from /dev/mem and search for extension headers in it (see the code in pci_rom.c). Signed-off-by: Alex Beregszaszi Acked-by: Stefan Reinauer Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@532 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- device/pci_rom.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/device/pci_rom.c b/device/pci_rom.c index 18ac6db092..c721fcf459 100644 --- a/device/pci_rom.c +++ b/device/pci_rom.c @@ -33,6 +33,8 @@ struct rom_header *pci_rom_probe(struct device *dev) unsigned long rom_address; struct rom_header *rom_header; struct pci_data *rom_data; + unsigned int i; + unsigned char sum = 0, *rom_bytes; if (dev->on_mainboard) { /* In case some device PCI_ROM_ADDRESS can not be set @@ -67,6 +69,14 @@ struct rom_header *pci_rom_probe(struct device *dev) le32_to_cpu(rom_header->signature)); return NULL; } + + /* checksum */ + rom_bytes = (unsigned char *)rom_address; + for (i = 0; i < rom_header->size * 512; i++) + sum += *(rom_bytes + i); + + if (sum != 0) + printk(BIOS_ALERT, "Incorrent Expansion ROM checksum (%02x != 0)\n", sum); rom_data = (struct pci_data *)((unsigned char *)rom_header + le32_to_cpu(rom_header->data));