public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [KVM PATCH] pci passthrough: zap option rom scanning.
@ 2010-01-20 10:58 Gerd Hoffmann
  2010-01-21 16:18 ` Marcelo Tosatti
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2010-01-20 10:58 UTC (permalink / raw)
  To: kvm; +Cc: Gerd Hoffmann

Nowdays (qemu 0.12) seabios loads option roms from pci rom bars.  So
there is no need any more to scan for option roms and have qemu load
them.  Zap the code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/device-assignment.c |   75 ------------------------------------------------
 1 files changed, 0 insertions(+), 75 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index f4a1e32..e347d15 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1498,77 +1498,6 @@ void add_assigned_devices(PCIBus *bus, const char **devices, int n_devices)
     }
 }
 
-/* Option ROM header */
-struct option_rom_header {
-    uint8_t signature[2];
-    uint8_t rom_size;
-    uint32_t entry_point;
-    uint8_t reserved[17];
-    uint16_t pci_header_offset;
-    uint16_t expansion_header_offset;
-} __attribute__ ((packed));
-
-/* Option ROM PCI data structure */
-struct option_rom_pci_header {
-    uint8_t signature[4];
-    uint16_t vendor_id;
-    uint16_t device_id;
-    uint16_t vital_product_data_offset;
-    uint16_t structure_length;
-    uint8_t structure_revision;
-    uint8_t class_code[3];
-    uint16_t image_length;
-    uint16_t image_revision;
-    uint8_t code_type;
-    uint8_t indicator;
-    uint16_t reserved;
-} __attribute__ ((packed));
-
-/*
- * Scan the list of Option ROMs at roms. If a suitable Option ROM is found,
- * allocate a ram space and copy it there. Then return its size aligned to
- * both 2KB and target page size.
- */
-#define OPTION_ROM_ALIGN(x) (((x) + 2047) & ~2047)
-static void scan_option_rom(const char *name, uint8_t devfn, void *roms)
-{
-    int i, size;
-    uint8_t csum;
-    struct option_rom_header *rom;
-    struct option_rom_pci_header *pcih;
-
-    rom = roms;
-
-    for ( ; ; ) {
-        /* Invalid signature means we're out of option ROMs. */
-        if (strncmp((char *)rom->signature, "\x55\xaa", 2) ||
-             (rom->rom_size == 0))
-            break;
-
-        size = rom->rom_size * 512;
-        /* Invalid checksum means we're out of option ROMs. */
-        csum = 0;
-        for (i = 0; i < size; i++)
-            csum += ((uint8_t *)rom)[i];
-        if (csum != 0)
-            break;
-
-        /* Check the PCI header (if any) for a match. */
-        pcih = (struct option_rom_pci_header *)
-                ((char *)rom + rom->pci_header_offset);
-        if ((rom->pci_header_offset != 0) &&
-             !strncmp((char *)pcih->signature, "PCIR", 4))
-            goto found;
-
-        rom = (struct option_rom_header *)((char *)rom + size);
-    }
-    return;
-
- found:
-    rom_add_blob(name ? name : "assigned device", rom, size, 0);
-    return;
-}
-
 /*
  * Scan the assigned devices for the devices that have an option ROM, and then
  * load the corresponding ROM data to RAM. If an error occurs while loading an
@@ -1632,9 +1561,5 @@ static void assigned_dev_load_option_rom(AssignedDevice *dev)
                  size, PROT_READ);
     }
 
-    if (!dev->dev.qdev.hotplugged) {
-        /* Scan the buffer for suitable ROMs and increase the offset */
-        scan_option_rom(dev->dev.qdev.id, dev->dev.devfn, buf);
-    }
     free(buf);
 }
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [KVM PATCH] pci passthrough: zap option rom scanning.
  2010-01-20 10:58 [KVM PATCH] pci passthrough: zap option rom scanning Gerd Hoffmann
@ 2010-01-21 16:18 ` Marcelo Tosatti
  2010-03-24 14:21   ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Marcelo Tosatti @ 2010-01-21 16:18 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: kvm

On Wed, Jan 20, 2010 at 11:58:48AM +0100, Gerd Hoffmann wrote:
> Nowdays (qemu 0.12) seabios loads option roms from pci rom bars.  So
> there is no need any more to scan for option roms and have qemu load
> them.  Zap the code.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Applied, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [KVM PATCH] pci passthrough: zap option rom scanning.
  2010-01-21 16:18 ` Marcelo Tosatti
@ 2010-03-24 14:21   ` Alexander Graf
  2010-03-25 16:19     ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2010-03-24 14:21 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Gerd Hoffmann, kvm

Marcelo Tosatti wrote:
> On Wed, Jan 20, 2010 at 11:58:48AM +0100, Gerd Hoffmann wrote:
>   
>> Nowdays (qemu 0.12) seabios loads option roms from pci rom bars.  So
>> there is no need any more to scan for option roms and have qemu load
>> them.  Zap the code.
>>
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>     
>
> Applied, thanks.
>   

Without this patch (0.12.3) I get the following error message when
trying to pass 2 functions of an ixgbe adapter to the guest:

falla:/abuild/agraf/qemu-kvm/:[0]# qemu-kvm -pcidevice host=07:00.0
-pcidevice host=07:00.1 -nographic -append console=ttyS0 -kernel
/boot/vmlinuz.x -initrd /boot/initrd.x
device: 07:00.0: driver="pci-assign" host="07:00.0"
device: 07:00.1: driver="pci-assign" host="07:00.1"
rom: requested regions overlap (rom 07:00.1. free=0x000000000000ac00,
addr=0x0000000000000000)
rom loading failed


The same code works with qemu-kvm.git. Cherry picking this commit
(51c0dad5ce383be94ca7c46e491ada17cc9ec416) also makes it work in
0.12-stable.


Thus I'd incline we also take this patch into 0.12-stable.


Alex



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [KVM PATCH] pci passthrough: zap option rom scanning.
  2010-03-24 14:21   ` Alexander Graf
@ 2010-03-25 16:19     ` Avi Kivity
  0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2010-03-25 16:19 UTC (permalink / raw)
  To: Alexander Graf; +Cc: Marcelo Tosatti, Gerd Hoffmann, kvm

On 03/24/2010 04:21 PM, Alexander Graf wrote:
>
> The same code works with qemu-kvm.git. Cherry picking this commit
> (51c0dad5ce383be94ca7c46e491ada17cc9ec416) also makes it work in
> 0.12-stable.
>
>
> Thus I'd incline we also take this patch into 0.12-stable.
>    

Done.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-25 16:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-20 10:58 [KVM PATCH] pci passthrough: zap option rom scanning Gerd Hoffmann
2010-01-21 16:18 ` Marcelo Tosatti
2010-03-24 14:21   ` Alexander Graf
2010-03-25 16:19     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox