All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] Mask Expansion ROM Enable bit
@ 2009-06-15 12:09 Akio Takebe
  0 siblings, 0 replies; only message in thread
From: Akio Takebe @ 2009-06-15 12:09 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 588 bytes --]

Hi,

I got the following unnecessary warning in qemu log,
when I created a guest with pass-through device.

Overlapped to device[00:05.0][Region:0][Address:f2060000h][Size:
00020000h]
pt_bar_mapping_one: Warning: ptdev[00:04.0][Region:6][Address:f2040001h]
[Size:00020000h] is overlapped.

It is a Expansion ROM Base Address Register,
so the last one bits doesn't mean the address space.
If we check overlap address space of all devices,
we shoud avoid the bit.
This patch masks non-address-bits of BAR.

Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>

Best Regards,

Akio Takebe

[-- Attachment #2: mask_bar_addr_space.patch --]
[-- Type: application/octet-stream, Size: 2649 bytes --]

diff --git a/hw/pass-through.c b/hw/pass-through.c
index a848164..1afbe5b 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -2031,7 +2031,8 @@ static void pt_bar_mapping_one(struct pt_dev *ptdev, int bar, int io_enable,
 
     /* check overlapped address */
     ret = pt_chk_bar_overlap(dev->bus, dev->devfn,
-                    r_addr, r_size, r->type);
+                    r_addr, r_size, r->type, bar);
+
     if (ret > 0)
         PT_LOG("Warning: ptdev[%02x:%02x.%x][Region:%d][Address:%08xh]"
             "[Size:%08xh] is overlapped.\n", pci_bus_num(dev->bus),
diff --git a/hw/pci.c b/hw/pci.c
index d7c516e..4f2e82c 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -919,13 +919,17 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did,
     return s->bus;
 }
 
+#define MEMORYSPACE_BAR_MASK   0xFFFFFC00
+#define IOSPACE_BAR_MASK       0xFFFFFFFC
+#define EXPANSION_ROM_BAR_MASK 0xFFFFFFFE
 int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr,
-                        uint32_t size, uint8_t type)
+                        uint32_t size, uint8_t type, int index)
 {
     PCIDevice *devices = NULL;
     PCIIORegion *r;
     int ret = 0;
     int i, j;
+    uint32_t mask=0xFFFFFFFF;
 
     /* check Overlapped to Base Address */
     for (i=0; i<256; i++)
@@ -951,7 +955,16 @@ int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr,
                     continue;
             }
 
-            if ((addr < (r->addr + r->size)) && ((addr + size) > r->addr))
+            if (index == PCI_ROM_SLOT)
+                mask = EXPANSION_ROM_BAR_MASK;
+            else if (type == PCI_ADDRESS_SPACE_IO)
+                mask = IOSPACE_BAR_MASK;
+            else if (type == PCI_ADDRESS_SPACE_MEM ||
+                     type == PCI_ADDRESS_SPACE_MEM_PREFETCH )
+                mask = MEMORYSPACE_BAR_MASK;
+
+            if (((addr&mask) < (r->addr + r->size)) &&
+                (((addr&mask) + size) > r->addr))
             {
                 printf("Overlapped to device[%02x:%02x.%x][Region:%d]"
                     "[Address:%08xh][Size:%08xh]\n", bus->bus_num,
diff --git a/hw/pci.h b/hw/pci.h
index d45b80c..e0c101d 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -225,7 +225,7 @@ void pci_register_io_region(PCIDevice *pci_dev, int region_num,
                             PCIMapIORegionFunc *map_func);
 
 int pt_chk_bar_overlap(PCIBus *bus, int devfn, uint32_t addr,
-                       uint32_t size, uint8_t type);
+                       uint32_t size, uint8_t type, int index);
 
 uint32_t pci_default_read_config(PCIDevice *d,
                                  uint32_t address, int len);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-15 12:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-15 12:09 [Patch] Mask Expansion ROM Enable bit Akio Takebe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.