]> xenbits.xen.org Git - xenclient/ioemu.git/commitdiff
Fix passthrough regression
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 23 Mar 2009 17:00:50 +0000 (17:00 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 23 Mar 2009 17:00:50 +0000 (17:00 +0000)
pt_init() iterates through the PHP slots independantly of
the assignment that occurs inside __insert_to_pci_slot
which is called by register_real_device(). It assumes
that vslots are assigned in order sarting at PHP_SLOT_START.

This was valid before my change, although why it didn't take the
simpler option of just checking what value had been assigned to
pt_dev->dev.devfn in register_real_device() is a mystery to
me [Simon].  Its also a mystery to what valid circumstance could lead
to pt_init() using 0 (a.k.a. unknown?) as the vslot.

My patch made one the assumptions that pt_init() made about slot numbers
invalid. That is, they don't start at PHP_SLOT_START, they start
wherever there is a free device.

A simple solution seems to be to use the value assigned to
pt_dev->dev.devfn in register_real_device().

Signed-off-by: Simon Horman <horms@verge.net.au>
hw/pass-through.c

index bb35af3c5b0ad6cecb876a20d70d5eab4d69fe5b..5de35fd4b8951b6b447f3bbada40ce4088368597 100644 (file)
@@ -3880,7 +3880,7 @@ int power_off_php_slot(int php_slot)
 
 int pt_init(PCIBus *e_bus, const char *direct_pci)
 {
-    int seg, b, d, f, slot, status = -1;
+    int seg, b, d, f, status = -1;
     struct pt_dev *pt_dev;
     struct pci_access *pci_access;
     char *vslots;
@@ -3916,9 +3916,7 @@ int pt_init(PCIBus *e_bus, const char *direct_pci)
     vslots = qemu_mallocz ( strlen(direct_pci) / 3 );
 
     /* Assign given devices to guest */
-    for ( slot = 0;
-          slot < NR_PCI_DEV && next_bdf(&direct_pci_p, &seg, &b, &d, &f, &opt);
-          slot++ )
+    while ( next_bdf(&direct_pci_p, &seg, &b, &d, &f, &opt) )
     {
         /* Register real device with the emulated bus */
         pt_dev = register_real_device(e_bus, "DIRECT PCI", PT_VIRT_DEVFN_AUTO,
@@ -3930,9 +3928,7 @@ int pt_init(PCIBus *e_bus, const char *direct_pci)
         }
 
         /* Record the virtual slot info */
-        sprintf(slot_str, "0x%02x;",
-                dpci_infos.php_devs[slot].pt_dev == pt_dev ? slot :
-                AUTO_PHP_SLOT);
+        sprintf(slot_str, "0x%02x;", PCI_SLOT(pt_dev->dev.devfn));
 
         strcat(vslots, slot_str);
     }