]> xenbits.xen.org Git - xenclient/ioemu.git/commitdiff
passthrough: fix pt_chk_bar_overlap
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 24 Mar 2009 18:23:29 +0000 (18:23 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 24 Mar 2009 18:23:29 +0000 (18:23 +0000)
This patch fixes pt_chk_bar_overlap.

Current pt_chk_bar_overlap does not distinguish memory resources and
io resources. They are placed in different address space. So
pt_chk_bar_overlap should distinguish them.

Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
hw/pass-through.c
hw/pci.c
hw/pci.h

index 00baa6c8a48a6d6e2db88b2f67cd82da9b8b2f16..48e2e4b7967969ada78ce5cb851ce910c0389e95 100644 (file)
@@ -1771,7 +1771,8 @@ static void pt_bar_mapping(struct pt_dev *ptdev, int io_enable, int mem_enable)
         PT_GET_EMUL_SIZE(base->bar_flag, r_size);
 
         /* check overlapped address */
-        ret = pt_chk_bar_overlap(dev->bus, dev->devfn, r_addr, r_size);
+        ret = pt_chk_bar_overlap(dev->bus, dev->devfn,
+                        r_addr, r_size, r->type);
         if (ret > 0)
             PT_LOG("Warning: ptdev[%02x:%02x.%x][Region:%d][Address:%08xh]"
                 "[Size:%08xh] is overlapped.\n", pci_bus_num(dev->bus),
index fb94c03f8e4166a76b0c8a24a53993b44055c154..62298d10e8c2e40a2986b0c5e12d35fdab92b3a5 100644 (file)
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -770,7 +770,8 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did,
     return s->bus;
 }
 
-int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr, uint32_t size)
+int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr,
+                        uint32_t size, uint8_t type)
 {
     PCIDevice *devices = NULL;
     PCIIORegion *r;
@@ -790,6 +791,17 @@ int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr, uint32_t size)
         for (j=0; j<PCI_NUM_REGIONS; j++)
         {
             r = &devices->io_regions[j];
+
+            /* skip different resource type, but don't skip when
+             * prefetch and non-prefetch memory are compared.
+             */
+            if (type != r->type)
+            {
+                if (type == PCI_ADDRESS_SPACE_IO ||
+                    r->type == PCI_ADDRESS_SPACE_IO)
+                    continue;
+            }
+
             if ((addr < (r->addr + r->size)) && ((addr + size) > r->addr))
             {
                 printf("Overlapped to device[%02x:%02x.%x][Region:%d]"
index 2828b61e2e0d9a4348433005d49513cb39d9f9ab..a48ac30960166e75f455fbb8e9e52ad9b15127c1 100644 (file)
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -210,7 +210,8 @@ void pci_register_io_region(PCIDevice *pci_dev, int region_num,
                             uint32_t size, int type,
                             PCIMapIORegionFunc *map_func);
 
-int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr, uint32_t size);
+int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr,
+                       uint32_t size, uint8_t type);
 
 uint32_t pci_default_read_config(PCIDevice *d,
                                  uint32_t address, int len);