All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akio Takebe <takebe_akio@jp.fujitsu.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [Patch] Mask Expansion ROM Enable bit
Date: Mon, 15 Jun 2009 21:09:07 +0900	[thread overview]
Message-ID: <EBC9EDB21579BDtakebe_akio@jp.fujitsu.com> (raw)

[-- 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

                 reply	other threads:[~2009-06-15 12:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EBC9EDB21579BDtakebe_akio@jp.fujitsu.com \
    --to=takebe_akio@jp.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.