[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen-unstable] Align MSI-X table mmap/munmap



commit 9f40cf4225bc7b500eafb7fcc030d6bbbd82480d
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date:   Fri Oct 23 17:53:23 2009 +0100

    Align MSI-X table mmap/munmap
    
    Force msi-x init mmap to a page boundary or mmap fails with:
       pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument
    
    Signed-off-by: Bruce Edge <bruce.edge@xxxxxxxxx>
---
 hw/pass-through.h |    1 +
 hw/pt-msi.c       |   14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/hw/pass-through.h b/hw/pass-through.h
index 028a03e..324df5b 100644
--- a/hw/pass-through.h
+++ b/hw/pass-through.h
@@ -193,6 +193,7 @@ struct pt_msix_info {
     int mmio_index;
     void *phys_iomem_base;
     struct msix_entry_info msix_entry[0];
+    uint32_t table_offset_adjust;      /* page align mmap */
 };
 
 struct pt_pm_info {
diff --git a/hw/pt-msi.c b/hw/pt-msi.c
index 6f923d0..cd0783c 100644
--- a/hw/pt-msi.c
+++ b/hw/pt-msi.c
@@ -542,6 +542,7 @@ int pt_msix_init(struct pt_dev *dev, int pos)
     int i, total_entries, table_off, bar_index;
     struct pci_dev *pd = dev->pci_dev;
     int fd;
+    int err;
 
     id = pci_read_byte(pd, pos + PCI_CAP_LIST_ID);
 
@@ -584,9 +585,15 @@ int pt_msix_init(struct pt_dev *dev, int pos)
         PT_LOG("Error: Can't open /dev/mem: %s\n", strerror(errno));
         goto error_out;
     }
-    dev->msix->phys_iomem_base = mmap(0, total_entries * 16,
+    PT_LOG("table_off = %llx, total_entries = %d\n",table_off,total_entries);
+    dev->msix->table_offset_adjust = table_off & 0x0fff;
+    dev->msix->phys_iomem_base = mmap(0, total_entries * 16 + 
dev->msix->table_offset_adjust,
                           PROT_WRITE | PROT_READ, MAP_SHARED | MAP_LOCKED,
-                          fd, dev->msix->table_base + table_off);
+                          fd, dev->msix->table_base + table_off - 
dev->msix->table_offset_adjust);
+    dev->msix->phys_iomem_base = (void *)((char *)dev->msix->phys_iomem_base + 
+                          dev->msix->table_offset_adjust);
+    err = errno;
+    PT_LOG("errno = %d\n",err);
     if ( dev->msix->phys_iomem_base == MAP_FAILED )
     {
         PT_LOG("Error: Can't map physical MSI-X table: %s\n", strerror(errno));
@@ -612,7 +619,8 @@ void pt_msix_delete(struct pt_dev *dev)
     {
         PT_LOG("unmapping physical MSI-X table from %lx\n",
            (unsigned long)dev->msix->phys_iomem_base);
-        munmap(dev->msix->phys_iomem_base, dev->msix->total_entries * 16);
+        munmap(dev->msix->phys_iomem_base, dev->msix->total_entries * 16 + 
+           dev->msix->table_offset_adjust);
     }
 
     free(dev->msix);
--
generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.