Skip to contentSkip to conversation

pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument

PATCH In review Bruce Edge 3 participants 5 messages Oct 21, 2009

lore
Share & tools
lore

Bruce Edge

author
#0 lore raw

PATCH 1/1 pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument

I submitted this patch last week and did'nt see any feedback or indication as to why it would not be accepted.
This is a confirmed tested fix that is required for pci passthorugh with msi-x.

If there is something wrong with the format or the contents please let me know so that I can fix and resubmit.

Thanks in advance.

-Bruce

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 <[email protected] <[email protected]>>

--- ./tools/ioemu-remote/hw/pass-through.h.orig 2009-10-15 10:22:17.000000000 -0700
+++ ./tools/ioemu-remote/hw/pass-through.h 2009-10-15
11:08:58.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 {

--- ./tools/ioemu-remote/hw/pt-msi.c.orig 2009-10-13
11:54:11.000000000 -0700
+++ ./tools/ioemu-remote/hw/pt-msi.c 2009-10-15 10:29:50.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);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

If you don't cc Ian Jackson, the tree maintainer, the patch may get missed.

-- Keir

Quoted 77 lines · Bruce Edge

I submitted this patch last week and did'nt see any feedback or indication as to why it would not be accepted.
This is a confirmed tested fix that is required for pci passthorugh with msi-x.

If there is something wrong with the format or the contents please let me know so that I can fix and resubmit.

Thanks in advance.

-Bruce

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 <[email protected] <mailto:[email protected]> >

--- ./tools/ioemu-remote/hw/pass-through.h.orig 2009-10-15 10:22:17.000000000 -0700
+++ ./tools/ioemu-remote/hw/pass-through.h      2009-10-15 11:08:58.000000000 -0700

(quoted diff) +1 -1
@@ -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 {
 
 
--- ./tools/ioemu-remote/hw/pt-msi.c.orig       2009-10-13

11:54:11.000000000 -0700
+++ ./tools/ioemu-remote/hw/pt-msi.c    2009-10-15 10:29:50.000000000 -0700

(quoted diff) +10 -2
@@ -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));

(quoted diff) +2 -1
@@ -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);
#2 lore raw

Keir Fraser writes ("Re: [Xen-devel] [PATCH] pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument"):

Quoted 1 line

If you don't cc Ian Jackson, the tree maintainer, the patch may get missed.

Sorry about that; I must indeed have overlooked it.

Ian.

#3 lore raw
In reply to Bruce Edge

Bruce Edge writes ("[Xen-devel] [PATCH] pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument"):

Quoted 4 lines

I submitted this patch last week and did'nt see any feedback or indication as to why it would not be accepted.
This is a confirmed tested fix that is required for pci passthorugh with msi-x.

This looks like a sensible patch.

Quoted 2 lines

If there is something wrong with the format or the contents please let me know so that I can fix and resubmit.

However, your mail program has mangled it:

Quoted 2 lines

--- ./tools/ioemu-remote/hw/pass-through.h.orig 2009-10-15 10:22:17.000000000 -0700

^ Here it has linewrapped it.

Quoted 3 lines
   struct msix_entry_info msix_entry[0];

+ uint32_t table_offset_adjust; /* page align mmap */
};

^ And here the indentation is wrong (perhaps you have literal tabs with a tab width of 2 or something).

Can you try to resubmit it please ? Try including the patch as an attachment as well as in the body of the message.

Thanks,
Ian.

author
#4 lore raw

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

Patch is demangled, unwrapped, attached and in-line.

-Bruce

--cut--
diff -Naur xen-unstable.hg/tools/ioemu-remote/hw/pass-through.h xen-unstable.hg.msi-x-patch/tools/ioemu-remote/hw/pass-through.h
--- xen-unstable.hg/tools/ioemu-remote/hw/pass-through.h 2009-10-18
21:27:43.000000000 -0700
+++ xen-unstable.hg.msi-x-patch/tools/ioemu-remote/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 xen-unstable.hg/tools/ioemu-remote/hw/pt-msi.c xen-unstable.hg.msi-x-patch/tools/ioemu-remote/hw/pt-msi.c
--- xen-unstable.hg/tools/ioemu-remote/hw/pt-msi.c 2009-10-18
21:27:43.000000000 -0700
+++ xen-unstable.hg.msi-x-patch/tools/ioemu-remote/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);

--cut--

Quoted 28 lines · Ian Jackson

Bruce Edge writes ("[Xen-devel] [PATCH] pt_msix_init: Error: Can't map physical MSI-X  table: Invalid argument"):

Quoted 4 lines

I submitted this patch last week and did'nt see any feedback or indication as to why it would not be accepted.
This is a confirmed tested fix that is required for pci passthorugh with msi-x.

This looks like a sensible patch.

Quoted 2 lines

If there is something wrong with the format or the contents please let me know so that I can fix and resubmit.

However, your mail program has mangled it:

Quoted 2 lines

--- ./tools/ioemu-remote/hw/pass-through.h.orig 2009-10-15 10:22:17.000000000 -0700

^ Here it has linewrapped it.

Quoted 3 lines

   struct msix_entry_info msix_entry[0];
+       uint32_t table_offset_adjust;   /* page align mmap */ };

^ And here the indentation is wrong (perhaps you have literal tabs with a tab width of 2 or something).

Can you try to resubmit it please ?  Try including the patch as an attachment as well as in the body of the message.

Quoted 8 lines

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/ioemu-remote/hw/pass-through.h +1 -0
diff -Naur xen-unstable.hg/tools/ioemu-remote/hw/pass-through.h xen-unstable.hg.msi-x-patch/tools/ioemu-remote/hw/pass-through.h
@@ -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 {
tools/ioemu-remote/hw/pt-msi.c +11 -3
diff -Naur xen-unstable.hg/tools/ioemu-remote/hw/pt-msi.c xen-unstable.hg.msi-x-patch/tools/ioemu-remote/hw/pt-msi.c
@@ -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);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel