WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] ioemu-remote: Align MSI-X table mmap/munmap - please

To: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] ioemu-remote: Align MSI-X table mmap/munmap - please apply
From: Bruce Edge <bruce.edge@xxxxxxxxx>
Date: Fri, 23 Oct 2009 09:09:47 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 23 Oct 2009 09:11:39 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:cc:content-type; bh=27hd7vQTGZ0VM0dZzWewam9+ks/F0Jm7pgJI0360DwM=; b=G+OXg2crGtsWUT+2E9z5lLVcrAfNRKI7jFl1m8TX6GuTeVf+gLnxxtgceWjQPT3m7y Xv+eqeIMCNcsDTRikyQeXLktGGTqNmxoWv9mZRMfcCToM7TS2BiAbjd9Up7C86mzijDc 95oVLx+29aoZcZX5JA/2RYYIJV6GT4KaXaCxQ=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=IoXci+Ygkg+RPbyDbTMPqdBEb9RDkWya/4mD/VkVwObED94Qex9aoNT9lHHTgoBfe6 yCZBbsJYDnm4i4asJs1t1hSF7L9hmVdCIJrcAe8YY/QWre2d8oIuzxnZ7FZxaxJQq94B XXdf/PHfSBnOY1E/KxBgGIm7EIaDX3ajp4fb8=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Figured out by cargo-culting that patches to qemu need to be based
from tools/ioemu-remote and have same in subject.
Resubmitting this patch re-based accordingly.
If someone else needs to be in the cc for qemu patches, please let me know.


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>


diff -Naur a/hw/pass-through.h b/hw/pass-through.h
--- a/hw/pass-through.h 2009-10-18 21:27:43.000000000 -0700
+++ b/hw/pass-through.h 2009-10-21 08:42:00.000000000 -0700
@@ -193,6 +193,7 @@
     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 -Naur a/hw/pt-msi.c b/hw/pt-msi.c
--- a/hw/pt-msi.c       2009-10-18 21:27:43.000000000 -0700
+++ b/hw/pt-msi.c       2009-10-21 08:39:43.000000000 -0700
@@ -542,6 +542,7 @@
     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 @@
         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 @@
     {
         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);

Attachment: ioemu-remote-msix-mmap-align.patch
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>