Skip to contentSkip to conversation

qemu 2.5.0 ivshmem segfault with msi=off option

Qemu-devel maquefel 4 participants 5 messages Dec 29, 2015 – Jun 23, 2016

lore
Share & tools
lore

maquefel

author
#0 lore raw

Public bug reported:

Launching qemu with "-device ivshmem,chardev=ivshmemid,msi=off -chardev socket,path=/tmp/ivshmem_socket,id=ivshmemid"

Causes segfault because, s->msi_vectors is not initialized and s->msi_vectors == 0.

Does ivshmem exactly need this line ? :

s->msi_vectors[vector].pdev = pdev;

It makes no sence for me.

Subject: [PATCH] fixed ivshmem empty msi vector on msi=off segfault

---
 hw/misc/ivshmem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/misc/ivshmem.c +4 -5
index f73f0c2..2087d5e 100644
@@ -359,8 +359,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
     int eventfd = event_notifier_get_fd(n);
     CharDriverState *chr;
 
-    s->msi_vectors[vector].pdev = pdev;
-
     chr = qemu_chr_open_eventfd(eventfd);
 
     if (chr == NULL) {
@@ -1038,10 +1036,11 @@ static void pci_ivshmem_exit(PCIDevice *dev)
     }
 
     if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
-        msix_uninit_exclusive_bar(dev);
+        msix_uninit_exclusive_bar(dev);
     }
-
-    g_free(s->msi_vectors);
+    
+    if(s->msi_vectors)
+       g_free(s->msi_vectors);
 }
 
 static bool test_msix(void *opaque, int version_id)
Signature · 72 lines
2.3.6

** Affects: qemu
     Importance: Undecided
         Status: New


** Tags: ivshmem

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1529859

Title:
  qemu 2.5.0 ivshmem segfault with msi=off option

Status in QEMU:
  New

Bug description:
  Launching qemu with "-device ivshmem,chardev=ivshmemid,msi=off
  -chardev socket,path=/tmp/ivshmem_socket,id=ivshmemid"

  Causes segfault because, s->msi_vectors is not initialized and
  s->msi_vectors == 0.

  Does ivshmem exactly need this line ? :

  s->msi_vectors[vector].pdev = pdev;

  It makes no sence for me.

  Subject: [PATCH] fixed ivshmem empty msi vector on msi=off segfault

  ---
   hw/misc/ivshmem.c | 9 ++++-----
   1 file changed, 4 insertions(+), 5 deletions(-)

  diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
  index f73f0c2..2087d5e 100644
  --- a/hw/misc/ivshmem.c
  +++ b/hw/misc/ivshmem.c
  @@ -359,8 +359,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
       int eventfd = event_notifier_get_fd(n);
       CharDriverState *chr;
   
  -    s->msi_vectors[vector].pdev = pdev;
  -
       chr = qemu_chr_open_eventfd(eventfd);
   
       if (chr == NULL) {
  @@ -1038,10 +1036,11 @@ static void pci_ivshmem_exit(PCIDevice *dev)
       }
   
       if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
  -        msix_uninit_exclusive_bar(dev);
  +        msix_uninit_exclusive_bar(dev);
       }
  -
  -    g_free(s->msi_vectors);
  +    
  +    if(s->msi_vectors)
  +       g_free(s->msi_vectors);
   }
   
   static bool test_msix(void *opaque, int version_id)
  -- 
  2.3.6

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1529859/+subscriptions
#1 lore raw
Quoted 8 lines · maquefel

Public bug reported:

Launching qemu with "-device ivshmem,chardev=ivshmemid,msi=off -chardev socket,path=/tmp/ivshmem_socket,id=ivshmemid"

Causes segfault because, s->msi_vectors is not initialized and s->msi_vectors == 0.

Quoted 7 lines

Does ivshmem exactly need this line ? :

s->msi_vectors[vector].pdev = pdev;

It makes no sence for me.

Subject: [PATCH] fixed ivshmem empty msi vector on msi=off segfault

Patches require a Signed-off-by: line before they can be applied.

Quoted 10 lines
---
 hw/misc/ivshmem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/misc/ivshmem.c +0 -0
index f73f0c2..2087d5e 100644

hw/misc/ivshmem.c static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * · line 363

Quoted 5 lines
hw/misc/ivshmem.c +0 -2
@@ -359,8 +359,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
     int eventfd = event_notifier_get_fd(n);
     CharDriverState *chr;
 
-    s->msi_vectors[vector].pdev = pdev;
-

This avoids the segfault, but it may break other uses. Are you sure you don't need an 'if (s->msi_vectors[vector])' conditional?

hw/misc/ivshmem.c static void pci_ivshmem_exit(PCIDevice *dev) · line 1039

Quoted 9 lines
hw/misc/ivshmem.c +1 -1
     chr = qemu_chr_open_eventfd(eventfd);
 
     if (chr == NULL) {
@@ -1038,10 +1036,11 @@ static void pci_ivshmem_exit(PCIDevice *dev)
     }
 
     if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
-        msix_uninit_exclusive_bar(dev);
+        msix_uninit_exclusive_bar(dev);

I can't see what's changing here. Whitespace?

hw/misc/ivshmem.c static void pci_ivshmem_exit(PCIDevice *dev) · line 1043

Quoted 6 lines
hw/misc/ivshmem.c +3 -2
     }
-
-    g_free(s->msi_vectors);
+    
+    if(s->msi_vectors)
+       g_free(s->msi_vectors);

This hunk is bogus. g_free(NULL) already works properly.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw

See previously posted patch:

http://lists.gnu.org/archive/html/qemu-stable/2015-12/msg00034.html

Quoted 63 lines · Eric Blake
Quoted 8 lines · maquefel

Public bug reported:

Launching qemu with "-device ivshmem,chardev=ivshmemid,msi=off -chardev socket,path=/tmp/ivshmem_socket,id=ivshmemid"

Causes segfault because, s->msi_vectors is not initialized and s->msi_vectors == 0.

Quoted 7 lines

Does ivshmem exactly need this line ? :

s->msi_vectors[vector].pdev = pdev;

It makes no sence for me.

Subject: [PATCH] fixed ivshmem empty msi vector on msi=off segfault

Patches require a Signed-off-by: line before they can be applied.

Quoted 10 lines
---
 hw/misc/ivshmem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/misc/ivshmem.c +0 -0
index f73f0c2..2087d5e 100644

hw/misc/ivshmem.c static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * · line 363

Quoted 5 lines
hw/misc/ivshmem.c +0 -2
@@ -359,8 +359,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
     int eventfd = event_notifier_get_fd(n);
     CharDriverState *chr;
 
-    s->msi_vectors[vector].pdev = pdev;
-

This avoids the segfault, but it may break other uses. Are you sure you don't need an 'if (s->msi_vectors[vector])' conditional?

hw/misc/ivshmem.c static void pci_ivshmem_exit(PCIDevice *dev) · line 1039

Quoted 9 lines
hw/misc/ivshmem.c +1 -1
     chr = qemu_chr_open_eventfd(eventfd);
 
     if (chr == NULL) {
@@ -1038,10 +1036,11 @@ static void pci_ivshmem_exit(PCIDevice *dev)
     }
 
     if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
-        msix_uninit_exclusive_bar(dev);
+        msix_uninit_exclusive_bar(dev);

I can't see what's changing here. Whitespace?

hw/misc/ivshmem.c static void pci_ivshmem_exit(PCIDevice *dev) · line 1043

Quoted 6 lines
hw/misc/ivshmem.c +3 -2
     }
-
-    g_free(s->msi_vectors);
+
+    if(s->msi_vectors)
+       g_free(s->msi_vectors);

This hunk is bogus. g_free(NULL) already works properly.

--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Signature · 1 line
Marc-André Lureau
author
#3 lore raw
In reply to maquefel
Quoted 2 lines

See previously posted patch:
http://lists.gnu.org/archive/html/qemu-stable/2015-12/msg00034.html

This patch resolves issue. I can confirm it works.

** Changed in: qemu
Status: New => Fix Committed

Signature · 62 lines
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1529859

Title:
  qemu 2.5.0 ivshmem segfault with msi=off option

Status in QEMU:
  Fix Committed

Bug description:
  Launching qemu with "-device ivshmem,chardev=ivshmemid,msi=off
  -chardev socket,path=/tmp/ivshmem_socket,id=ivshmemid"

  Causes segfault because, s->msi_vectors is not initialized and
  s->msi_vectors == 0.

  Does ivshmem exactly need this line ? :

  s->msi_vectors[vector].pdev = pdev;

  It makes no sence for me.

  Subject: [PATCH] fixed ivshmem empty msi vector on msi=off segfault

  ---
   hw/misc/ivshmem.c | 9 ++++-----
   1 file changed, 4 insertions(+), 5 deletions(-)

  diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
  index f73f0c2..2087d5e 100644
  --- a/hw/misc/ivshmem.c
  +++ b/hw/misc/ivshmem.c
  @@ -359,8 +359,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
       int eventfd = event_notifier_get_fd(n);
       CharDriverState *chr;
   
  -    s->msi_vectors[vector].pdev = pdev;
  -
       chr = qemu_chr_open_eventfd(eventfd);
   
       if (chr == NULL) {
  @@ -1038,10 +1036,11 @@ static void pci_ivshmem_exit(PCIDevice *dev)
       }
   
       if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
  -        msix_uninit_exclusive_bar(dev);
  +        msix_uninit_exclusive_bar(dev);
       }
  -
  -    g_free(s->msi_vectors);
  +    
  +    if(s->msi_vectors)
  +       g_free(s->msi_vectors);
   }
   
   static bool test_msix(void *opaque, int version_id)
  -- 
  2.3.6

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1529859/+subscriptions
#4 lore raw
In reply to maquefel

Patch has been included here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=47213eb1104709bf23

** Changed in: qemu
Status: Fix Committed => Fix Released

Signature · 62 lines
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1529859

Title:
  qemu 2.5.0 ivshmem segfault with msi=off option

Status in QEMU:
  Fix Released

Bug description:
  Launching qemu with "-device ivshmem,chardev=ivshmemid,msi=off
  -chardev socket,path=/tmp/ivshmem_socket,id=ivshmemid"

  Causes segfault because, s->msi_vectors is not initialized and
  s->msi_vectors == 0.

  Does ivshmem exactly need this line ? :

  s->msi_vectors[vector].pdev = pdev;

  It makes no sence for me.

  Subject: [PATCH] fixed ivshmem empty msi vector on msi=off segfault

  ---
   hw/misc/ivshmem.c | 9 ++++-----
   1 file changed, 4 insertions(+), 5 deletions(-)

  diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
  index f73f0c2..2087d5e 100644
  --- a/hw/misc/ivshmem.c
  +++ b/hw/misc/ivshmem.c
  @@ -359,8 +359,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
       int eventfd = event_notifier_get_fd(n);
       CharDriverState *chr;
   
  -    s->msi_vectors[vector].pdev = pdev;
  -
       chr = qemu_chr_open_eventfd(eventfd);
   
       if (chr == NULL) {
  @@ -1038,10 +1036,11 @@ static void pci_ivshmem_exit(PCIDevice *dev)
       }
   
       if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
  -        msix_uninit_exclusive_bar(dev);
  +        msix_uninit_exclusive_bar(dev);
       }
  -
  -    g_free(s->msi_vectors);
  +    
  +    if(s->msi_vectors)
  +       g_free(s->msi_vectors);
   }
   
   static bool test_msix(void *opaque, int version_id)
  -- 
  2.3.6

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1529859/+subscriptions