Hi,

the attached patch adds code to checksum the pci extension rom and stop
if the stored and calculated checksum differ.

--
Alex

Index: device/pci_rom.c
===================================================================
--- device/pci_rom.c	(revision 486)
+++ 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,19 @@
 		       le32_to_cpu(rom_header->signature));
 		return NULL;
 	}
+	
+	/* checksum */
+	rom_bytes = (unsigned char *)rom_address;
+	for (i = 0; i < rom_header->size * 512 - 1; i++)
+	    sum += *(rom_bytes + i);
+	sum = -sum;
 
+	if (sum != *(rom_bytes + rom_header->size * 512 - 1)) {
+		printk(BIOS_ERR, "Incorrent Expansion ROM checksum (%02x != %02x)\n",
+		       *(rom_bytes + rom_header->size * 512 - 1), sum);
+		return NULL;
+	}
+
 	rom_data = (struct pci_data *)((unsigned char *)rom_header +
 				       le32_to_cpu(rom_header->data));
 
-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to