* Alex Beregszaszi alex@rtfs.hu [070907 12:54]:
Hi,
On Wed, 2007-09-05 at 04:29 +0200, Stefan Reinauer wrote:
- Alex Beregszaszi alex@rtfs.hu [070904 13:17]:
Hi,
the attached patch adds code to checksum the pci extension rom and stop if the stored and calculated checksum differ.
Is this checksum reliably correct? I am hesitating to add new restrictions that might break otherwise working cards.
You are right, attached is a correct method. There is no fixed checksum byte, instead the whole should sum to zero.
-- Alex
Signed-off-by: Alex Beregszaszi alex@rtfs.hu
Acked-by: Stefan Reinauer stepan@coresystems.de
Index: device/pci_rom.c
--- device/pci_rom.c (revision 494) +++ device/pci_rom.c (working copy) @@ -33,6 +33,8 @@ 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,7 +69,17 @@ 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_ERR, "Incorrent Expansion ROM checksum (%02x != 0)\n", sum);
return NULL;
}
rom_data = (struct pci_data *)((unsigned char *)rom_header + le32_to_cpu(rom_header->data));