[LinuxBIOS] [PATCH] pci_rom.c checksum extension rom
Stefan Reinauer
stepan at coresystems.de
Wed Oct 17 11:30:30 CEST 2007
* Alex Beregszaszi <alex at rtfs.hu> [070907 12:54]:
> Hi,
>
> On Wed, 2007-09-05 at 04:29 +0200, Stefan Reinauer wrote:
> > * Alex Beregszaszi <alex at 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 at rtfs.hu>
Acked-by: Stefan Reinauer <stepan at 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));
>
--
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info at coresystems.de • http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
More information about the coreboot
mailing list