Where's gpxe-eepro100-80862449.rom ?
Commit db667a12 added a reference to ROM file gpxe-eepro100-80862449.rom, but no such file. Intentional?
Am 12.10.2010 14:41, schrieb Markus Armbruster:
Quoted 2 lines
Commit
db667a12added a reference to ROM file gpxe-eepro100-80862449.rom, but no such file. Intentional?
Yes. See http://lists.nongnu.org/archive/html/qemu-devel/2010-05/msg00418.html
Citation from my former mail:
Yes, it is missing. I did not add it for several reasons:
* The new variant i82801 (which needs the missing ROM) is currently not available
via model=i82801 (it can be selected by experts using other methods).
* Experts can get the missing ROM from ROM-o-matic.
* All three ROMs differ only in one or two bytes (device id). That's a waste
of binary space (56832 bytes!). Therefore I plan to remove all but the first
ROM file. The missing ones can be created by make or patched on the fly by
QEMU during load. Maybe it is also possible to create ROM files which support
more than one vendor/device entry - that would be the best solution.
There is still nothing new regarding these last points because I did not spend any time on them.
Do you think there is urgent need for a gpxe-eepro100-80862449.rom binary?
Quoted 7 lines · Stefan Weil
Am 12.10.2010 14:41, schrieb Markus Armbruster:
Quoted 2 lines
Commit
db667a12added a reference to ROM file gpxe-eepro100-80862449.rom, but no such file. Intentional?Yes. See
http://lists.nongnu.org/archive/html/qemu-devel/2010-05/msg00418.html
Quoted 7 lines
Citation from my former mail:
Yes, it is missing. I did not add it for several reasons:
* The new variant i82801 (which needs the missing ROM) is currently not available
via model=i82801 (it can be selected by experts using other methods).
It's available via -device i82801. -net nic,model= is obsolescent.
Quoted 11 lines
* Experts can get the missing ROM from ROM-o-matic.
* All three ROMs differ only in one or two bytes (device id). That's a waste
of binary space (56832 bytes!). Therefore I plan to remove all but the first
ROM file. The missing ones can be created by make or patched on the fly by
QEMU during load. Maybe it is also possible to create ROM files which support
more than one vendor/device entry - that would be the best solution.
No objections to creating by make or on load, but I'd be just fine with the duplicated ROMs. Disk space waste in the order of 100KiB is lost in the noise nowadays. My qemu/.git is >100MiB, and my build tree for all targets ~1.5GiB.
Quoted 4 lines
There is still nothing new regarding these last points because I did not spend any time on them.
Do you think there is urgent need for a gpxe-eepro100-80862449.rom binary?
Well, "-device i82801" complains because it misses this binary. Do we want to ship that way?
PATCH 1/2 pci: Automatically patch PCI device id in PCI ROM
PCI device with different device ids sometimes share the same rom code. Only the device id and the checksum differ in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.
By automatically patching the device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
--- hw/pci.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-)
hw/pci.c +53 -0
@@ -1797,6 +1797,57 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI device id in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_device_id (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word / pci_set_word. */ + +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); +if (pcir_offset +8 >= size ||memcmp (ptr + pcir_offset,"PCIR" ,4 )) { +PCI_DPRINTF ("Bad PCIR offset 0x%x or signature\n" , pcir_offset); +return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +/* Don't patch a rom with wrong vendor id (might be changed if needed). */ +if (vendor_id != rom_vendor_id) { +return ; + } + +PCI_DPRINTF ("ROM id %04x%04x / PCI id %04x%04x\n" , + vendor_id, device_id, rom_vendor_id, rom_device_id); + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */ +uint8_t checksum; + checksum = ptr[6 ]; + checksum += (uint8_t )rom_device_id + (uint8_t )(rom_device_id >>8 ); + checksum -= (uint8_t )device_id + (uint8_t )(device_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ static int pci_add_option_rom (PCIDevice *pdev) {
@@ -1849,6 +1900,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +pci_patch_device_id (pdev, ptr, size); +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);
Signature · 1 line
1.7.1
PATCH 2/2 eepro100: Use a single rom file for all i825xx devices
In reply to Markus ArmbrusterPatching the rom data during load (in qemu) now
also supports i82801 (which had no rom file).
We only need a single rom file for the whole device family, so remove the second one which is no longer needed.
--- Makefile | 1 - hw/eepro100.c | 14 +++----------- pc-bios/README | 2 +- pc-bios/gpxe-eepro100-80861229.rom | Bin 56832 -> 0 bytes 4 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 pc-bios/gpxe-eepro100-80861229.rom
Makefile +0 -1
@@ -178,7 +178,6 @@ ifdef INSTALL_BLOBS BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ openbios-sparc32 openbios-sparc64 openbios-ppc \ gpxe-eepro100-80861209.rom \ -gpxe-eepro100-80861229.rom \ pxe-e1000.bin \ pxe-ne2k_pci.bin pxe-pcnet.bin \ pxe-rtl8139.bin pxe-virtio.bin \
hw/eepro100.c +3 -11
@@ -2048,17 +2048,9 @@ static void eepro100_register_devices(void)size_t i;for (i =0 ; i <ARRAY_SIZE (e100_devices); i++) {PCIDeviceInfo *pci_dev = &e100_devices[i].pci; -switch (e100_devices[i].device_id) { -case PCI_DEVICE_ID_INTEL_82551IT : - pci_dev->romfile ="gpxe-eepro100-80861209.rom" ; -break ; -case PCI_DEVICE_ID_INTEL_82557 : - pci_dev->romfile ="gpxe-eepro100-80861229.rom" ; -break ; -case 0x2449 : - pci_dev->romfile ="gpxe-eepro100-80862449.rom" ; -break ; - } +/* We use the same rom file for all device ids. +QEMU fixes the device id during rom load. */ + pci_dev->romfile ="gpxe-eepro100-80861209.rom" ; pci_dev->init = e100_nic_init; pci_dev->exit = pci_nic_uninit; pci_dev->qdev.props = e100_properties;
pc-bios/README +1 -1
@@ -16,7 +16,7 @@ - The PXE roms come from Rom-o-Matic gPXE 0.9.9 with BANNER_TIMEOUT=0 e1000 8086:100E - eepro100 8086:1209, 8086:1229 + eepro100 8086:1209 (also used for 8086:1229 and 8086:2449) ns8390 1050:0940 pcnet32 1022:2000 rtl8139 10ec:8139
pc-bios/gpxe-eepro100-80861229.rom deleted binary +0 -0
Signature · 1 line
1.7.1
Am 13.10.2010 09:13, schrieb Markus Armbruster:
Quoted 40 lines
Quoted 8 lines · Stefan Weil
Am 12.10.2010 14:41, schrieb Markus Armbruster:
Quoted 3 lines
Commit
db667a12added a reference to ROM file gpxe-eepro100-80862449.rom, but no such file. Intentional?Yes. See
http://lists.nongnu.org/archive/html/qemu-devel/2010-05/msg00418.htmlQuoted 8 lines
Citation from my former mail:
Yes, it is missing. I did not add it for several reasons:
* The new variant i82801 (which needs the missing ROM) is currently not available
via model=i82801 (it can be selected by experts using other methods).It's available via -device i82801. -net nic,model= is obsolescent.
Quoted 12 lines
* Experts can get the missing ROM from ROM-o-matic.
* All three ROMs differ only in one or two bytes (device id). That's a waste
of binary space (56832 bytes!). Therefore I plan to remove all but the first
ROM file. The missing ones can be created by make or patched on the fly by
QEMU during load. Maybe it is also possible to create ROM files which support
more than one vendor/device entry - that would be the best solution.No objections to creating by make or on load, but I'd be just fine with the duplicated ROMs. Disk space waste in the order of 100KiB is lost in the noise nowadays. My qemu/.git is>100MiB, and my build tree for all targets ~1.5GiB.
Quoted 8 lines
Quoted 5 lines
There is still nothing new regarding these last points because I did not spend any time on them.
Do you think there is urgent need for a gpxe-eepro100-80862449.rom binary?
Well, "-device i82801" complains because it misses this binary. Do we want to ship that way?
I just sent two patches which create the rom data on load. So -device i82801 no longer complains but gets the boot information from dhcp (tested with i386-softmmu).
Your build tree will be made smaller by at least 50 KB :-)
Do you think these patches should be added to stable-0.13, too?
Regards,
Stefan
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
In reply to Stefan WeilQuoted 4 lines · Stefan Weil
PCI device with different device ids sometimes share the same rom code. Only the device id and the checksum differ in a boot rom for such devices.
BTW, SeaBIOS doesn't reject ROMs when they're loaded via rombar, only when they're loaded via romfile.
Maybe it's better to use fw_cfg to explicitly tell SeaBIOS to ignore the PCI device id in the rom header for a certain device?
Regards,
Anthony Liguori
Quoted 87 lines
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching the device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
Cc Markus Armbruster<[email protected]>Cc Michael S. Tsirkin<[email protected]>Signed-off-by Stefan Weil<[email protected]>--- hw/pci.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-)hw/pci.c +53
-0@@ -1797,6 +1797,57 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI device id in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_device_id (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word / pci_set_word. */ + +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); +if (pcir_offset +8 >= size ||memcmp (ptr + pcir_offset,"PCIR" ,4 )) { +PCI_DPRINTF ("Bad PCIR offset 0x%x or signature\n" , pcir_offset); +return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +/* Don't patch a rom with wrong vendor id (might be changed if needed). */ +if (vendor_id != rom_vendor_id) { +return ; + } + +PCI_DPRINTF ("ROM id %04x%04x / PCI id %04x%04x\n" , + vendor_id, device_id, rom_vendor_id, rom_device_id); + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */ +uint8_t checksum; + checksum = ptr[6 ]; + checksum += (uint8_t )rom_device_id + (uint8_t )(rom_device_id>>8 ); + checksum -= (uint8_t )device_id + (uint8_t )(device_id>>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ static int pci_add_option_rom (PCIDevice *pdev) {@@ -1849,6 +1900,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +pci_patch_device_id (pdev, ptr, size); +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
In reply to Stefan WeilHi,
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p · line 1834
Quoted 4 lines
hw/pci.c +4
-0+/* Don't patch a rom with wrong vendor id (might be changed if needed). */ +if (vendor_id != rom_vendor_id) { +return ; + }
Yes, please drop that one. If this is accepted I'd like to use this for vga roms too, so we have to carry only two of them instead of four.
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p · line 1840
Quoted 2 lines
hw/pci.c +2
-0+if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */
Does this offset work for all roms?
hw/pci.c static int pci_add_option_rom(PCIDevice *pdev) · line 1904
Quoted 9 lines
/* Add an option rom for the device */
static intpci_add_option_rom(PCIDevice *pdev)
{hw/pci.c +2
-0@@ -1849,6 +1900,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +pci_patch_device_id (pdev, ptr, size); +
I'd prefer this being opt-in per driver instead of being applied globally (and maybe also pass in a flag whenever a vendor mismatch is fine or not).
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
In reply to Anthony LiguoriQuoted 7 lines · Anthony Liguori
Quoted 3 lines · Stefan Weil
PCI device with different device ids sometimes share the same rom code. Only the device id and the checksum differ in a boot rom for such devices.
BTW, SeaBIOS doesn't reject ROMs when they're loaded via rombar, only when they're loaded via romfile.
SeaBIOS rejects them when loaded from the rom bar and doesn't reject them when loaded via fw_cfg.
Using the rom bar is the prefered way though, fw_cfg is only there for compatibility with older versions.
Quoted 2 lines
Maybe it's better to use
fw_cfgto explicitly tell SeaBIOS to ignore the PCI device id in the rom header for a certain device?
Patching the rom is fine IMHO. Why create + use a separate communication path when we can use a much simpler approach?
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
In reply to Gerd HoffmannAm 18.10.2010 12:04, schrieb Gerd Hoffmann:
Quoted 8 lines
Hi,
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p · line 1834
Quoted 5 lines
+ /* Don't patch a rom with wrong vendor id (might be changed if
needed). */hw/pci.c +3
-0+if (vendor_id != rom_vendor_id) { +return ; + }
Quoted 8 lines
Yes, please drop that one. If this is accepted I'd like to use this for vga roms too, so we have to carry only two of them instead of four.
Quoted 3 lines
(quoted diff) +2
-0+ if (device_id != rom_device_id) { + /* Patch device id and checksum (at offset 6 for etherbootroms). */
Does this offset work for all roms?
As far as I know there is no well-defined checksum offset. The checksum is simply set by modifying any byte (which normally should be unused).
Etherboot has some unused bytes at the beginning of rom data and always uses the same offset 6.
For other roms which also don't use the byte at offset 6, this approach will work, too. If they store code or vital data at that location, we destroy that data, so it won't work.
The VGA bios roms have a sequence of several bytes of zero starting at offset 6, so maybe this data is not important and we may change the byte at offset 6, but that should be checked before using this mechanism.
Quoted 8 lines
Quoted 8 lines
/* Add an option rom for the device */
static intpci_add_option_rom(PCIDevice *pdev)
{hw/pci.c +0
-0@@ -1849,6 +1900,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path);
Quoted 7 lines
hw/pci.c static int pci_add_option_rom(PCIDevice *pdev) · line 1904
Quoted 2 lines
hw/pci.c +2
-0+pci_patch_device_id (pdev, ptr, size); +I'd prefer this being opt-in per driver instead of being applied globally (and maybe also pass in a flag whenever a vendor mismatch is fine or not).
cheers,
Gerd
As long as the driver specifies the romfile name, we get an implicitly defined behaviour: either the rom matches and nothing special is done, or it doesn't and the id(s) will be fixed.
So neither flag nor opt-in seems to be needed.
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Hi,
Quoted 6 lines
As far as I know there is no well-defined checksum offset. The checksum is simply set by modifying any byte (which normally should be unused).
Etherboot has some unused bytes at the beginning of rom data and always uses the same offset 6.
Ah, so you don't actually update the checksum but change some unused byte to make the checksum stay the same, right?
Quoted 8 lines
For other roms which also don't use the byte at offset 6, this approach will work, too. If they store code or vital data at that location, we destroy that data, so it won't work.
The VGA bios roms have a sequence of several bytes of zero starting at offset 6, so maybe this data is not important and we may change the byte at offset 6, but that should be checked before using this mechanism.
From vgabios:
.org 0
vgabios_start:
.byte 0x55, 0xaa /* BIOS signature */
.byte 0x40 /* BIOS extension length */
vgabios_entry_point:
jmp vgabios_init_funcFrom seabios:
struct rom_header {
u16 signature;
u8 size;
u8 initVector[4];
u8 reserved[17];
u16 pcioffset;
u16 pnpoffset;
} PACKED;Hmm. So offset 6 is the last byte of initVector. If (and only if) you happen to know that the jump instruction takes 3 bytes only it is save to modify the unused 4th byte. Seems to be true for both vgabios and etherboot/gPXE. We can't assume this in general, although it is quite likely given that there hardly would be anything but a 16bit jump.
Quoted 6 lines
As long as the driver specifies the romfile name, we get an implicitly defined behaviour: either the rom matches and nothing special is done, or it doesn't and the id(s) will be fixed.
So neither flag nor opt-in seems to be needed.
When following this argumentation the vendor id sanity check shouldn't be there in the first place ;)
Note that romfile is a pci bus property, so it isn't fully under the drivers control because it can be overridden from the command line for every pci device.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Hi,
Am 18.10.2010 13:54, schrieb Gerd Hoffmann:
Quoted 10 lines
Hi,
Quoted 6 lines
As far as I know there is no well-defined checksum offset. The checksum is simply set by modifying any byte (which normally should be unused).
Etherboot has some unused bytes at the beginning of rom data and always uses the same offset 6.
Ah, so you don't actually update the checksum but change some unused byte to make the checksum stay the same, right?
Right. The sum of all bytes modulo 255 must be 0.
Any byte can be modified to achieve this.
Quoted 32 lines
Quoted 9 lines
For other roms which also don't use the byte at offset 6, this approach will work, too. If they store code or vital data at that location, we destroy that data, so it won't work.
The VGA bios roms have a sequence of several bytes of zero starting at offset 6, so maybe this data is not important and we may change the byte at offset 6, but that should be checked before using this mechanism.
From vgabios:
.org 0 vgabios_start: .byte 0x55, 0xaa /* BIOS signature */ .byte 0x40 /* BIOS extension length */ vgabios_entry_point: jmp vgabios_init_funcFrom seabios:
struct rom_header { u16 signature; u8 size; u8 initVector[4]; u8 reserved[17]; u16 pcioffset; u16 pnpoffset; } PACKED;
Quoted 1 line
Hmm. So offset 6 is the last byte of initVector. If (and only if) you happen to know that the jump instruction takes 3 bytes only it is save to modify the unused 4th byte. Seems to be true for both vgabios and etherboot/gPXE. We can't assume this in general, although it is quite likely given that there hardly would be anything but a 16bit jump.
I agree. So it would work with vga bios, too.
It looks like vgabios uses the last byte to fix the checksum (rom data ends with a sequence of 0xff, only last byte is different).
Quoted 9 lines
Quoted 7 lines
As long as the driver specifies the romfile name, we get an implicitly defined behaviour: either the rom matches and nothing special is done, or it doesn't and the id(s) will be fixed.
So neither flag nor opt-in seems to be needed.
When following this argumentation the vendor id sanity check shouldn't be there in the first place ;)
The sanity check is simply there because I had no test case which patches the vendor id. How could I test with vga bios?
Quoted 2 lines
Note that romfile is a pci bus property, so it isn't fully under the drivers control because it can be overridden from the command line for every pci device.
Maybe this is an argument why the driver should not include any flags for id patching. A user who overrides the rom name from the command line should know what she/he does.
Quoted 4 lines
cheers,
Gerd
Regards,
Stefan
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Hi,
Quoted 5 lines
Quoted 2 lines
When following this argumentation the vendor id sanity check shouldn't be there in the first place ;)
The sanity check is simply there because I had no test case which patches the vendor id. How could I test with vga bios?
No trivial way as the vgabios needs to be patched to handle that.
The vgabios searches for its hardware, right now the IDs are compile-time constants (same constants are compiled into the pci header). Needs to be changed to lookup the ID at runtime in the pci header.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Quoted 9 lines · Gerd Hoffmann
Hi,
Quoted 5 lines
Quoted 2 lines
When following this argumentation the vendor id sanity check shouldn't be there in the first place ;)
The sanity check is simply there because I had no test case which patches the vendor id. How could I test with vga bios?
No trivial way as the vgabios needs to be patched to handle that.
patchrom branches available now:
http://cgit.freedesktop.org/~kraxel/vgabios/log/
http://cgit.freedesktop.org/spice/qemu/log/?h=patchrom
very short instructions:
(1) fetch+compile vgabios, copy new vgabios-pci binary so qemu can find it.
(2) fetch qemu, apply/merge id patching, compile qemu
(3) both standard and vmware vga should happily work with the same vgabios binary now, including vesa graphic modes.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Am 18.10.2010 17:50, schrieb Gerd Hoffmann:
Quoted 25 lines · Gerd Hoffmann
Quoted 9 lines
Hi,
Quoted 5 lines
Quoted 2 lines
When following this argumentation the vendor id sanity check shouldn't be there in the first place ;)
The sanity check is simply there because I had no test case which patches the vendor id. How could I test with vga bios?
No trivial way as the vgabios needs to be patched to handle that.
patchrom branches available now:
http://cgit.freedesktop.org/~kraxel/vgabios/log/
http://cgit.freedesktop.org/spice/qemu/log/?h=patchromvery short instructions:
(1) fetch+compile vgabios, copy new vgabios-pci binary so qemu can find it.
(2) fetch qemu, apply/merge id patching, compile qemu
(3) both standard and vmware vga should happily work with the same vgabios binary now, including vesa graphic modes.
Quoted 3 lines
cheers,
Gerd
Hi Gerd,
a new patch which also modifies the vendor id will follow immediately. Perhaps you can try it with your modified vga bios.
Cheers,
Stefan
PATCH 1/2 pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Gerd HoffmannPCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.
By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
v2:
* Patch also the vendor id (and remove the sanity check for vendor id).
--- hw/pci.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)
hw/pci.c +58 -0
@@ -1797,6 +1797,62 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; +uint8_t checksum; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word / pci_set_word. */ + +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); +if (pcir_offset +8 >= size ||memcmp (ptr + pcir_offset,"PCIR" ,4 )) { +PCI_DPRINTF ("Bad PCIR offset 0x%x or signature\n" , pcir_offset); +return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +PCI_DPRINTF ("ROM id %04x%04x / PCI id %04x%04x\n" , + vendor_id, device_id, rom_vendor_id, rom_device_id); + + checksum = ptr[6 ]; + +if (vendor_id != rom_vendor_id) { +/* Patch vendor id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_vendor_id + (uint8_t )(rom_vendor_id >>8 ); + checksum -= (uint8_t )vendor_id + (uint8_t )(vendor_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +4 , vendor_id); + } + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_device_id + (uint8_t )(rom_device_id >>8 ); + checksum -= (uint8_t )device_id + (uint8_t )(device_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ static int pci_add_option_rom (PCIDevice *pdev) {
@@ -1849,6 +1905,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +pci_patch_ids (pdev, ptr, size); +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);
Signature · 1 line
1.7.1
[Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
Quoted 30 lines · Stefan Weil
PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
v2:
* Patch also the vendor id (and remove the sanity check for vendor id).
Cc Gerd Hoffmann <[email protected]>Cc Markus Armbruster <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Stefan Weil <[email protected]>--- hw/pci.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)hw/pci.c +0
-0
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p · line 1802
Quoted 6 lines
hw/pci.c +3
-0@@ -1797,6 +1797,62 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size)
let's return an error code on malformed roms so management can detect errors?
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
In reply to Gerd HoffmannQuoted 10 lines · Gerd Hoffmann
Quoted 7 lines · Anthony Liguori
Quoted 3 lines · Stefan Weil
PCI device with different device ids sometimes share the same rom code. Only the device id and the checksum differ in a boot rom for such devices.
BTW, SeaBIOS doesn't reject ROMs when they're loaded via rombar, only when they're loaded via romfile.
SeaBIOS rejects them when loaded from the rom bar and doesn't reject them when loaded via
fw_cfg.
What I meant was, rombar=0 in qdev. Sometimes my fingers don't work the same way my brain does :-)
Quoted 6 lines
Using the rom bar is the prefered way though,
fw_cfgis only there for compatibility with older versions.Quoted 2 lines
Maybe it's better to use
fw_cfgto explicitly tell SeaBIOS to ignore the PCI device id in the rom header for a certain device?Patching the rom is fine IMHO. Why create + use a separate communication path when we can use a much simpler approach?
How does this interact with PCI device passthrough?
We clearly can't patch in that case whereas if we had a hint to SeaBIOS, it would still work.
Regards,
Anthony Liguori
Quoted 3 lines
cheers,
Gerd
Re: [Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Michael S. TsirkinQuoted 35 lines · Michael S. Tsirkin
Quoted 33 lines · Stefan Weil
PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
v2:
* Patch also the vendor id (and remove the sanity check for vendor id).
Cc Gerd Hoffmann<[email protected]>Cc Markus Armbruster<[email protected]>Cc Michael S. Tsirkin<[email protected]>Signed-off-by Stefan Weil<[email protected]>--- hw/pci.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)hw/pci.c +0
-0@@ -1797,6 +1797,62 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); }
Quoted 6 lines
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p
Quoted 4 lines
hw/pci.c +3
-0+/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size)let's return an error code on malformed roms so management can detect errors?
A bad/missing PnP header does not mean it's an invalid ROM.
Regards,
Anthony Liguori
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Stefan WeilQuoted 13 lines · Stefan Weil
PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
Quoted 9 lines
v2:
* Patch also the vendor id (and remove the sanity check for vendor id).
Cc Gerd Hoffmann<[email protected]>Cc Markus Armbruster<[email protected]>Cc Michael S. Tsirkin<[email protected]>Signed-off-by Stefan Weil<[email protected]>
I get very nervous about patching a ROM. Who's to say that the ROM doesn't somehow depend on the contents of its header? Maybe it has an internal CRC built into it or something like that.
Regards,
Anthony Liguori
Quoted 81 lines
--- hw/pci.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)hw/pci.c +58
-0@@ -1797,6 +1797,62 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; +uint8_t checksum; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word / pci_set_word. */ + +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); +if (pcir_offset +8 >= size ||memcmp (ptr + pcir_offset,"PCIR" ,4 )) { +PCI_DPRINTF ("Bad PCIR offset 0x%x or signature\n" , pcir_offset); +return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +PCI_DPRINTF ("ROM id %04x%04x / PCI id %04x%04x\n" , + vendor_id, device_id, rom_vendor_id, rom_device_id); + + checksum = ptr[6 ]; + +if (vendor_id != rom_vendor_id) { +/* Patch vendor id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_vendor_id + (uint8_t )(rom_vendor_id>>8 ); + checksum -= (uint8_t )vendor_id + (uint8_t )(vendor_id>>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +4 , vendor_id); + } + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_device_id + (uint8_t )(rom_device_id>>8 ); + checksum -= (uint8_t )device_id + (uint8_t )(device_id>>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ static int pci_add_option_rom (PCIDevice *pdev) {@@ -1849,6 +1905,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +pci_patch_ids (pdev, ptr, size); +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
Quoted 16 lines · Anthony Liguori
Quoted 15 lines · Stefan Weil
PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
v2:
Quoted 8 lines
Quoted 6 lines
* Patch also the vendor id (and remove the sanity check for vendor id).
Cc Gerd Hoffmann<[email protected]>Cc Markus Armbruster<[email protected]>Cc Michael S. Tsirkin<[email protected]>Signed-off-by Stefan Weil<[email protected]>I get very nervous about patching a ROM. Who's to say that the ROM doesn't somehow depend on the contents of its header? Maybe it has an internal CRC built into it or something like that.
As part of PMM, ROMs typically reduce their size by decompressing and removing code or something of that nature and then rewrite themselves in scratch RAM. The BIOS then copies the resulting ROM (using the ROM size in the base header as an indication of how much to copy) into the option ROM space.
So the likelihood of depending on the contents of the header seems non-trivial to me.
Regards,
Anthony Liguori
Quoted 96 lines
Regards,
Anthony Liguori
Quoted 90 lines
--- hw/pci.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)hw/pci.c +2
-0@@ -1797,6 +1797,62 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */
hw/pci.c +12
-0+static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; +uint8_t checksum; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word /
pci_set_word. */hw/pci.c +9
-0+ +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); + if (pcir_offset + 8>= size || memcmp(ptr + pcir_offset, "PCIR",4)) {
+ PCI_DPRINTF("Bad PCIR offset 0x%x or signature\n",pcir_offset);hw/pci.c +15
-0+return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +PCI_DPRINTF ("ROM id %04x%04x / PCI id %04x%04x\n" , + vendor_id, device_id, rom_vendor_id, rom_device_id); + + checksum = ptr[6 ]; + +if (vendor_id != rom_vendor_id) { +/* Patch vendor id and checksum (at offset 6 for etherboot roms). */
+ checksum += (uint8_t)rom_vendor_id +
(uint8_t)(rom_vendor_id>> 8);hw/pci.c +8
-0+ checksum -= (uint8_t )vendor_id + (uint8_t )(vendor_id>>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +4 , vendor_id); + } + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */
+ checksum += (uint8_t)rom_device_id +
(uint8_t)(rom_device_id>> 8);hw/pci.c +9
-0+ checksum -= (uint8_t )device_id + (uint8_t )(device_id>>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ static int pci_add_option_rom (PCIDevice *pdev) {@@ -1849,6 +1905,8 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +pci_patch_ids (pdev, ptr, size); +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);
Re: [Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Anthony LiguoriQuoted 6 lines · Anthony Liguori
Quoted 4 lines
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p · line 1802
Quoted 3 lines
hw/pci.c +3
-0+/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size)let's return an error code on malformed roms so management can detect errors?
A bad/missing PnP header does not mean it's an invalid ROM.
I don't see this as a generic capability - rather a specific hack that helps reduce some duplication for eepro100 and friends. As such, if we can't patch the id we know it's an invalid file.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Anthony LiguoriAm 18.10.2010 20:53, schrieb Anthony Liguori:
Quoted 26 lines · Anthony Liguori
Quoted 16 lines · Stefan Weil
Quoted 15 lines
PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
v2:
Quoted 8 lines
Quoted 6 lines
* Patch also the vendor id (and remove the sanity check for vendor id).
Cc Gerd Hoffmann<[email protected]>Cc Markus Armbruster<[email protected]>Cc Michael S. Tsirkin<[email protected]>Signed-off-by Stefan Weil<[email protected]>I get very nervous about patching a ROM. Who's to say that the ROM doesn't somehow depend on the contents of its header? Maybe it has an internal CRC built into it or something like that.
Quoted 8 lines
As part of PMM, ROMs typically reduce their size by decompressing and removing code or something of that nature and then rewrite themselves in scratch RAM. The BIOS then copies the resulting ROM (using the ROM size in the base header as an indication of how much to copy) into the option ROM space.
So the likelihood of depending on the contents of the header seems non-trivial to me.
Regards,
Anthony Liguori
[snip]
Etherboot uses compressed code and always fixes the checksum by modifying the byte at relative address 6, so for etherboot there is no problem. The etherboot distribution even includes a perl script which can be used to patch vendor/device ids. I thought about using that script in QEMU's make but then decided against this alternate solution.
VGA bios seems to work, too (practical test still is missing).
What could happen for other kinds of roms? Either there is nothing to patch (the 99 % standard case), or they work, or they don't work. QEMU must only make sure that patching of the supported roms with supported devices work.
Regards,
Stefan Weil
Re: [Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Michael S. TsirkinAm 18.10.2010 21:03, schrieb Michael S. Tsirkin:
Quoted 8 lines · Anthony Liguori
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
+/* Patch the PCI vendor and device ids in a PCI rom image if necessary.
+ This is needed for an option rom which is used for more than one device. */
+static voidpci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size)let's return an error code on malformed roms so management can detect errors?
Quoted 5 lines
Quoted 1 line
A bad/missing PnP header does not mean it's an invalid ROM.
I don't see this as a generic capability - rather a specific hack that helps reduce some duplication for eepro100 and friends. As such, if we can't patch the id we know it's an invalid file.
There is already some kind of error feedback: the rom will not work. For etherboot roms, booting from network won't work.
This is a qemu internal error, so more error handling is not needed.
Users who configure a device with their own rom file don't need an id patch, and their rom data will not be patched because they normally specify a rom file with correct ids. For the rare case where they configure a rom with a "wrong" id, their rom data will be patched (something they don't expect) or not modified because of the sanity checks (then the rom is ignored by the bios).
Maybe a more perfect solution would only patch the preconfigured rom files but not user configured files, but I don't think we need this degree of perfection.
Regards,
Stefan
Re: [Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Michael S. TsirkinQuoted 8 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony Liguori
Quoted 6 lines
hw/pci.c static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p · line 1802
Quoted 4 lines
hw/pci.c +3
-0+/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size)let's return an error code on malformed roms so management can detect errors?
Quoted 6 lines
Quoted 2 lines
A bad/missing PnP header does not mean it's an invalid ROM.
I don't see this as a generic capability - rather a specific hack that helps reduce some duplication for eepro100 and friends. As such, if we can't patch the id we know it's an invalid file.
This code is unconditional in the pci option rom loading path.
If it's restricted to a qdev property that's defaulted to enabled for the eepro cards, that would be a reasonable argument to make.
Regards,
Anthony Liguori
Re: [Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Stefan WeilQuoted 3 lines · Stefan Weil
Maybe a more perfect solution would only patch the preconfigured rom files but not user configured files, but I don't think we need this degree of perfection.
Generally speaking, patching third-party code is not something that we should get in the habit of doing unless we're very very sure that it's okay and we have as many checks in place as possible to avoid bad things from happening.
There are so many bad things that can happen. If attempted to support attestation in QEMU and prepopulated a virtual TPM with checksums from the BIOS and ROMs, when the virtual BIOS attempts to measure itself if we've patched the ROM underneath of it, then the measurements will fail.
In the very least, if we go this route, it has to be an optional feature.
Regards,
Anthony Liguori
Quoted 3 lines
Regards,
Stefan
Re: [Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Stefan WeilQuoted 2 lines · Stefan Weil
There is already some kind of error feedback: the rom will not work. For etherboot roms, booting from network won't work.
VGA works, after hacking the vgabios to not have the PCI ID hardcoded elsewhere.
Nevertheless /me gets the feeling that we better should not take that route. vgabios needs special patching to work. etherboot does not work as-is. Even if we make it work now it always will be fragile. The next rom update might break it again. The ID automagically adapting doesn't happen on real hardware ...
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Stefan WeilQuoted 2 lines · Stefan Weil
QEMU must only make sure that patching of the supported roms with supported devices work.
I think that's what Anthony was saying too - make this depend on a qdev property and set it only in eepro100 for now.
Signature · 1 line
MST
PATCH 1/2 pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Anthony LiguoriPCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.
By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
Only qemu's built-in default rom files will be patched.
v2:
* Patch also the vendor id (and remove the sanity check for vendor id).
v3:
* Don't patch a rom file when its name was set by the user. Thus we avoid modifications of unknown rom data.
--- hw/pci.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 69 insertions(+), 4 deletions(-)
hw/pci.c +69 -4
@@ -78,7 +78,7 @@ static struct BusInfo pci_bus_info = {static void pci_update_mappings (PCIDevice *d);static void pci_set_irq (void *opaque,int irq_num,int level); -static int pci_add_option_rom (PCIDevice *pdev); +static int pci_add_option_rom (PCIDevice *pdev,bool is_default_rom);static void pci_del_option_rom (PCIDevice *pdev);static uint16_t pci_default_sub_vendor_id =PCI_SUBVENDOR_ID_REDHAT_QUMRANET ;
@@ -1672,6 +1672,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)PCIDeviceInfo *info =container_of (base, PCIDeviceInfo, qdev);PCIBus *bus;int devfn, rc; +bool is_default_rom;/* initialize cap_present for pci_is_express() and pci_config_size() */ if (info->is_express) {
@@ -1692,9 +1693,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) }/* rom loading */ -if (pci_dev->romfile ==NULL && info->romfile !=NULL ) + is_default_rom = false; +if (pci_dev->romfile ==NULL && info->romfile !=NULL ) { pci_dev->romfile =qemu_strdup (info->romfile); -pci_add_option_rom (pci_dev); + is_default_rom = true; + } +pci_add_option_rom (pci_dev, is_default_rom);if (qdev->hotplugged) { rc = bus->hotplug (bus->hotplug_qdev, pci_dev,1 );
@@ -1797,8 +1801,64 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; +uint8_t checksum; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word / pci_set_word. */ + +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); +if (pcir_offset +8 >= size ||memcmp (ptr + pcir_offset,"PCIR" ,4 )) { +PCI_DPRINTF ("Bad PCIR offset 0x%x or signature\n" , pcir_offset); +return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +PCI_DPRINTF ("%s: ROM id %04x%04x / PCI id %04x%04x\n" , pdev->romfile, + vendor_id, device_id, rom_vendor_id, rom_device_id); + + checksum = ptr[6 ]; + +if (vendor_id != rom_vendor_id) { +/* Patch vendor id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_vendor_id + (uint8_t )(rom_vendor_id >>8 ); + checksum -= (uint8_t )vendor_id + (uint8_t )(vendor_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +4 , vendor_id); + } + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_device_id + (uint8_t )(rom_device_id >>8 ); + checksum -= (uint8_t )device_id + (uint8_t )(device_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ -static int pci_add_option_rom (PCIDevice *pdev) +static int pci_add_option_rom (PCIDevice *pdev,bool is_default_rom) {int size;char *path;
@@ -1849,6 +1909,11 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +if (is_default_rom) { +/* Only the default rom images will be patched (if needed). */ +pci_patch_ids (pdev, ptr, size); + } +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Michael S. TsirkinAm 19.10.2010 10:37, schrieb Michael S. Tsirkin:
Quoted 7 lines · Stefan Weil
Quoted 2 lines
QEMU must only make sure that patching of the supported roms with supported devices work.
I think that's what Anthony was saying too - make this depend on a qdev property and set it only in eepro100 for now.
My new patch v3 implements something similar and does not need a new qdev property:
Don't patch because the rom file was defined by the user:
qemu -L pc-bios -boot n -netdev user,id=internet \
-device i82801,netdev=internet,romfile=gpxe-eepro100-80861209.romPatch because we work with the built-in default rom file:
qemu -L pc-bios -boot n -netdev user,id=internet \
-device i82801,netdev=internetThis is a safe solution which respects user's rom data without adding much more complexity.
Regards,
Stefan
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
Quoted 11 lines · Stefan Weil
Am 19.10.2010 10:37, schrieb Michael S. Tsirkin:
Quoted 7 lines · Stefan Weil
Quoted 2 lines
QEMU must only make sure that patching of the supported roms with supported devices work.
I think that's what Anthony was saying too - make this depend on a qdev property and set it only in eepro100 for now.
My new patch v3 implements something similar and does not need a new qdev property:
I prefer to have an explicit property in case a user actually wants to use this functionality. That said, if Michael's happy with the approach, I'm okay with it too.
Regards,
Anthony Liguori
Quoted 16 lines
Don't patch because the rom file was defined by the user:
qemu -L pc-bios -boot n -netdev user,id=internet \ -device i82801,netdev=internet,romfile=gpxe-eepro100-80861209.romPatch because we work with the built-in default rom file:
qemu -L pc-bios -boot n -netdev user,id=internet \ -device i82801,netdev=internetThis is a safe solution which respects user's rom data without adding much more complexity.
Regards,
Stefan
Re: [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Stefan Weil
Am 19.10.2010 10:37, schrieb Michael S. Tsirkin:
Quoted 7 lines · Stefan Weil
Quoted 2 lines
QEMU must only make sure that patching of the supported roms with supported devices work.
I think that's what Anthony was saying too - make this depend on a qdev property and set it only in eepro100 for now.
My new patch v3 implements something similar and does not need a new qdev property:
Quoted 7 lines
I prefer to have an explicit property in case a user actually wants
to use this functionality. That said, if Michael's happy with the
approach, I'm okay with it too.Regards,
Anthony Liguori
I currently feel kind of the same, just to make this explicit ... if you like, let me sleep on it.
Quoted 16 lines
Quoted 16 lines
Don't patch because the rom file was defined by the user:
qemu -L pc-bios -boot n -netdev user,id=internet \ -device i82801,netdev=internet,romfile=gpxe-eepro100-80861209.romPatch because we work with the built-in default rom file:
qemu -L pc-bios -boot n -netdev user,id=internet \ -device i82801,netdev=internetThis is a safe solution which respects user's rom data without adding much more complexity.
Regards,
Stefan
[Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Stefan WeilHi,
Quoted 3 lines
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.
Does this actually work now with the etherboot roms?
cheers,
Gerd
[Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
Am 20.10.2010 09:19, schrieb Gerd Hoffmann:
Quoted 10 lines
Hi,
Quoted 3 lines
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.Does this actually work now with the etherboot roms?
cheers,
Gerd
Yes. I tested these two cases:
qemu -L pc-bios -boot n -netdev user,id=internet \
-device i82801,netdev=internet,romfile=gpxe-eepro100-80861209.rom=> no bootable device
qemu -L pc-bios -boot n -netdev user,id=internet \
-device i82801,netdev=internet=> device gets ip address via dhcp
The same works with i82559c or other eepro100 variants, too.
Cheers,
Stefan
Re: [SeaBIOS] [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
In reply to Anthony LiguoriQuoted 4 lines · Anthony Liguori
Quoted 1 line
SeaBIOS rejects them when loaded from the rom bar and doesn't reject them when loaded via
fw_cfg.What I meant was, rombar=0 in qdev. Sometimes my fingers don't work the same way my brain does :-)
Are you using qmp or the human monitor protocol?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [SeaBIOS] [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Anthony Liguori
Quoted 1 line
SeaBIOS rejects them when loaded from the rom bar and doesn't reject them when loaded via
fw_cfg.What I meant was, rombar=0 in qdev. Sometimes my fingers don't work the same way my brain does :-)
Are you using qmp or the human monitor protocol?
I'm still running on a DCE/RPC implementation from the early 80s.
Regards,
Anthony Liguori
Re: [SeaBIOS] [Qemu-devel] [PATCH 1/2] pci: Automatically patch PCI device id in PCI ROM
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Avi Kivity
Quoted 3 lines · Anthony Liguori
Quoted 1 line
SeaBIOS rejects them when loaded from the rom bar and doesn't reject them when loaded via
fw_cfg.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
What I meant was, rombar=0 in qdev. Sometimes my fingers don't work the same way my brain does :-)
Are you using qmp or the human monitor protocol?
I'm still running on a DCE/RPC implementation from the early 80s.
Well, I hope you keep it up to date. I wouldn't want a vulnerability inserted into qemu by an attacker controlling a maintainer's hands.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 2 lines · Stefan Weil
Am 13.10.2010 09:13, schrieb Markus Armbruster:
Quoted 1 line
Stefan Weil<[email protected]> writes:
[...]
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Do you think there is urgent need for a gpxe-eepro100-80862449.rom binary?
Well, "-device i82801" complains because it misses this binary. Do we want to ship that way?
Quoted 7 lines
I just sent two patches which create the rom data on load. So -device i82801 no longer complains but gets the boot information from dhcp (tested with i386-softmmu).
Your build tree will be made smaller by at least 50 KB :-)
Do you think these patches should be added to stable-0.13, too?
If the gain for "-device i82801" is worth the risk, which depends on the patch. Have we reached consensus on how to fix it in master?
Am 25.10.2010 14:11, schrieb Markus Armbruster:
Quoted 15 lines
Quoted 2 lines · Stefan Weil
Am 13.10.2010 09:13, schrieb Markus Armbruster:
Quoted 1 line
Stefan Weil<[email protected]> writes:
[...]
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
Do you think there is urgent need for a gpxe-eepro100-80862449.rom binary?
Well, "-device i82801" complains because it misses this binary. Do we want to ship that way?
I just sent two patches which create the rom data on load. So -device i82801 no longer complains but gets the boot information from dhcp (tested with i386-softmmu).
Quoted 6 lines
Quoted 3 lines
Your build tree will be made smaller by at least 50 KB :-)
Do you think these patches should be added to stable-0.13, too?
If the gain for "-device i82801" is worth the risk, which depends on the patch. Have we reached consensus on how to fix it in master?
The latest patch version fixes rom data only for the default roms, so the risk is minimized and full tests are possible.
There is still no consensus whether we need a new qdev property (which allows users to have their rom data fixed, too) or not.
My patch does not prevent adding that new qdev property, so I suggest applying my patch now and adding the property later (if it is ever needed).
Regards
Stefan
Quoted 31 lines · Stefan Weil
Am 25.10.2010 14:11, schrieb Markus Armbruster:
Quoted 16 lines
Quoted 2 lines · Stefan Weil
Am 13.10.2010 09:13, schrieb Markus Armbruster:
Quoted 1 line
Stefan Weil<[email protected]> writes:
[...]
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
Do you think there is urgent need for a
gpxe-eepro100-80862449.rom binary?Well, "-device i82801" complains because it misses this binary. Do we want to ship that way?
I just sent two patches which create the rom data on load. So -device i82801 no longer complains but gets the boot information from dhcp (tested with i386-softmmu).
Quoted 6 lines
Quoted 3 lines
Your build tree will be made smaller by at least 50 KB :-)
Do you think these patches should be added to stable-0.13, too?
If the gain for "-device i82801" is worth the risk, which depends on the patch. Have we reached consensus on how to fix it in master?
The latest patch version fixes rom data only for the default roms, so the risk is minimized and full tests are possible.
There is still no consensus whether we need a new qdev property (which allows users to have their rom data fixed, too) or not.
Quoted 6 lines
My patch does not prevent adding that new qdev property, so I suggest applying my patch now and adding the property later (if it is ever needed).
Regards
Stefan
Fair enough, I guess.
Signature · 1 line
MST
Am 25.10.2010 18:54, schrieb Michael S. Tsirkin:
Quoted 39 lines · Stefan Weil
Quoted 38 lines
Am 25.10.2010 14:11, schrieb Markus Armbruster:
Quoted 21 lines
Quoted 4 lines · Stefan Weil
Am 13.10.2010 09:13, schrieb Markus Armbruster:
Quoted 2 lines
Stefan Weil<[email protected]> writes:
[...]
Quoted 12 lines
Quoted 8 lines
Quoted 4 lines
Do you think there is urgent need for a
gpxe-eepro100-80862449.rom binary?Well, "-device i82801" complains because it misses this binary. Do we want to ship that way?
I just sent two patches which create the rom data on load. So -device i82801 no longer complains but gets the boot information from dhcp (tested with i386-softmmu).
Quoted 7 lines
Quoted 4 lines
Your build tree will be made smaller by at least 50 KB :-)
Do you think these patches should be added to stable-0.13, too?
If the gain for "-device i82801" is worth the risk, which depends on the patch. Have we reached consensus on how to fix it in master?
The latest patch version fixes rom data only for the default roms, so the risk is minimized and full tests are possible.
There is still no consensus whether we need a new qdev property (which allows users to have their rom data fixed, too) or not.
Quoted 9 lines
Quoted 7 lines
My patch does not prevent adding that new qdev property, so I suggest applying my patch now and adding the property later (if it is ever needed).
Regards
StefanFair enough, I guess.
So is there consensus that both patches can be committed to qemu master?
[Qemu-devel] Re: [PATCH 1/2] pci: Automatically patch PCI vendor id and device id in PCI ROM
In reply to Stefan WeilQuoted 18 lines · Stefan Weil
PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices.
The i825xx ethernet controller family is a typical example which is implemented in
hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed.By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom.
VGA bios roms are another example with different vendor and device ids.
Only qemu's built-in default rom files will be patched.
v2:
* Patch also the vendor id (and remove the sanity check for vendor id).
Quoted 8 lines
v3:
* Don't patch a rom file when its name was set by the user. Thus we avoid modifications of unknown rom data.Cc Gerd Hoffmann <[email protected]>Cc Markus Armbruster <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Stefan Weil <[email protected]>
Looks safe enough for me.
Applied.
Quoted 120 lines
--- hw/pci.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 69 insertions(+), 4 deletions(-)hw/pci.c +69
-4@@ -78,7 +78,7 @@ static struct BusInfo pci_bus_info = {static void pci_update_mappings (PCIDevice *d);static void pci_set_irq (void *opaque,int irq_num,int level); -static int pci_add_option_rom (PCIDevice *pdev); +static int pci_add_option_rom (PCIDevice *pdev,bool is_default_rom);static void pci_del_option_rom (PCIDevice *pdev);static uint16_t pci_default_sub_vendor_id =PCI_SUBVENDOR_ID_REDHAT_QUMRANET ;@@ -1672,6 +1672,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)PCIDeviceInfo *info =container_of (base, PCIDeviceInfo, qdev);PCIBus *bus;int devfn, rc; +bool is_default_rom;/* initialize cap_present for pci_is_express() and pci_config_size() */ if (info->is_express) {@@ -1692,9 +1693,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) }/* rom loading */ -if (pci_dev->romfile ==NULL && info->romfile !=NULL ) + is_default_rom = false; +if (pci_dev->romfile ==NULL && info->romfile !=NULL ) { pci_dev->romfile =qemu_strdup (info->romfile); -pci_add_option_rom (pci_dev); + is_default_rom = true; + } +pci_add_option_rom (pci_dev, is_default_rom);if (qdev->hotplugged) { rc = bus->hotplug (bus->hotplug_qdev, pci_dev,1 );@@ -1797,8 +1801,64 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcpu_register_physical_memory (addr, size, pdev->rom_offset); } +/* Patch the PCI vendor and device ids in a PCI rom image if necessary. +This is needed for an option rom which is used for more than one device. */ +static void pci_patch_ids (PCIDevice *pdev,uint8_t *ptr,int size) +{ +uint16_t vendor_id; +uint16_t device_id; +uint16_t rom_vendor_id; +uint16_t rom_device_id; +uint16_t rom_magic; +uint16_t pcir_offset; +uint8_t checksum; + +/* Words in rom data are little endian (like in PCI configuration), +so they can be read / written with pci_get_word / pci_set_word. */ + +/* Only a valid rom will be patched. */ + rom_magic =pci_get_word (ptr); +if (rom_magic !=0xaa55 ) { +PCI_DPRINTF ("Bad ROM magic %04x\n" , rom_magic); +return ; + } + pcir_offset =pci_get_word (ptr +0x18 ); +if (pcir_offset +8 >= size ||memcmp (ptr + pcir_offset,"PCIR" ,4 )) { +PCI_DPRINTF ("Bad PCIR offset 0x%x or signature\n" , pcir_offset); +return ; + } + + vendor_id =pci_get_word (pdev->config +PCI_VENDOR_ID ); + device_id =pci_get_word (pdev->config +PCI_DEVICE_ID ); + rom_vendor_id =pci_get_word (ptr + pcir_offset +4 ); + rom_device_id =pci_get_word (ptr + pcir_offset +6 ); + +PCI_DPRINTF ("%s: ROM id %04x%04x / PCI id %04x%04x\n" , pdev->romfile, + vendor_id, device_id, rom_vendor_id, rom_device_id); + + checksum = ptr[6 ]; + +if (vendor_id != rom_vendor_id) { +/* Patch vendor id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_vendor_id + (uint8_t )(rom_vendor_id >>8 ); + checksum -= (uint8_t )vendor_id + (uint8_t )(vendor_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +4 , vendor_id); + } + +if (device_id != rom_device_id) { +/* Patch device id and checksum (at offset 6 for etherboot roms). */ + checksum += (uint8_t )rom_device_id + (uint8_t )(rom_device_id >>8 ); + checksum -= (uint8_t )device_id + (uint8_t )(device_id >>8 ); +PCI_DPRINTF ("ROM checksum %02x / %02x\n" , ptr[6 ], checksum); + ptr[6 ] = checksum; +pci_set_word (ptr + pcir_offset +6 , device_id); + } +} +/* Add an option rom for the device */ -static int pci_add_option_rom (PCIDevice *pdev) +static int pci_add_option_rom (PCIDevice *pdev,bool is_default_rom) {int size;char *path;@@ -1849,6 +1909,11 @@ static int pci_add_option_rom(PCIDevice *pdev)load_image (path, ptr);qemu_free (path); +if (is_default_rom) { +/* Only the default rom images will be patched (if needed). */ +pci_patch_ids (pdev, ptr, size); + } +pci_register_bar (pdev,PCI_ROM_SLOT , size,0 , pci_map_option_rom);Signature · 1 line
1.7.1
Michael S. Tsirkin
Applied[Qemu-devel] Re: [PATCH 2/2] eepro100: Use a single rom file for all i825xx devices
In reply to Stefan WeilQuoted 9 lines · Stefan Weil
Patching the rom data during load (in qemu) now
also supports i82801 (which had no rom file).We only need a single rom file for the whole device family, so remove the second one which is no longer needed.
Cc Markus Armbruster <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Stefan Weil <[email protected]>
Applied, thanks.
Quoted 1,142 lines
--- Makefile | 1 - hw/eepro100.c | 14 +++----------- pc-bios/README | 2 +- pc-bios/gpxe-eepro100-80861229.rom | Bin 56832 -> 0 bytes 4 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 pc-bios/gpxe-eepro100-80861229.romMakefile +0
-1@@ -178,7 +178,6 @@ ifdef INSTALL_BLOBS BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ openbios-sparc32 openbios-sparc64 openbios-ppc \ gpxe-eepro100-80861209.rom \ -gpxe-eepro100-80861229.rom \ pxe-e1000.bin \ pxe-ne2k_pci.bin pxe-pcnet.bin \ pxe-rtl8139.bin pxe-virtio.bin \hw/eepro100.c +3
-11@@ -2048,17 +2048,9 @@ static void eepro100_register_devices(void)size_t i;for (i =0 ; i <ARRAY_SIZE (e100_devices); i++) {PCIDeviceInfo *pci_dev = &e100_devices[i].pci; -switch (e100_devices[i].device_id) { -case PCI_DEVICE_ID_INTEL_82551IT : - pci_dev->romfile ="gpxe-eepro100-80861209.rom" ; -break ; -case PCI_DEVICE_ID_INTEL_82557 : - pci_dev->romfile ="gpxe-eepro100-80861229.rom" ; -break ; -case 0x2449 : - pci_dev->romfile ="gpxe-eepro100-80862449.rom" ; -break ; - } +/* We use the same rom file for all device ids. +QEMU fixes the device id during rom load. */ + pci_dev->romfile ="gpxe-eepro100-80861209.rom" ; pci_dev->init = e100_nic_init; pci_dev->exit = pci_nic_uninit; pci_dev->qdev.props = e100_properties;pc-bios/README +1
-1@@ -16,7 +16,7 @@ - The PXE roms come from Rom-o-Matic gPXE 0.9.9 with BANNER_TIMEOUT=0 e1000 8086:100E - eepro100 8086:1209, 8086:1229 + eepro100 8086:1209 (also used for 8086:1229 and 8086:2449) ns8390 1050:0940 pcnet32 1022:2000 rtl8139 10ec:8139pc-bios/gpxe-eepro100-80861229.rom deleted binary +0
-0Signature · 2 lines
-- 1.7.1