All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches
@ 2019-02-12 14:06 Philippe Mathieu-Daudé
  2019-02-12 14:06   ` [Qemu-devel] " Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 14:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Changpeng Liu, Peter Xu, Paolo Bonzini, Philippe Mathieu-Daudé

Commit a56de056c91f8 squashed two unrelated commits at once.
Revert it and reapply the two commits to avoid confusion.

See: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg02966.html

Changpeng Liu (1):
  contrib/vhost-user-blk: fix the compilation issue

Peter Xu (1):
  i386/kvm: ignore masked irqs when update msi routes

Philippe Mathieu-Daudé (1):
  Revert "contrib/vhost-user-blk: fix the compilation issue"


-- 
2.20.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] Revert "contrib/vhost-user-blk: fix the compilation issue"
  2019-02-12 14:06 [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Philippe Mathieu-Daudé
@ 2019-02-12 14:06   ` Philippe Mathieu-Daudé
  2019-02-12 14:06 ` [Qemu-devel] [PATCH 2/3] contrib/vhost-user-blk: fix the compilation issue Philippe Mathieu-Daudé
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 14:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Eduardo Habkost, open list:X86, Marcelo Tosatti, Peter Xu,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Changpeng Liu, Richard Henderson

Commit a56de056c91f8 squashed the following two unrelated commits
at once:

- "contrib/vhost-user-blk: fix the compilation issue"
  (Message-Id: 1547615970-23545-2-git-send-email-changpeng.liu@intel.com)
- "i386/kvm: ignore masked irqs when update msi routes"
  (Message-Id: 20190116030815.27273-5-peterx@redhat.com)

While the git history remains bisectable, having a commit that changes
MSI/MSIX code but describes it as "fix vhost-user-blk compilation" is
rather confusing.
Revert the offending commit to properly apply both patches separately.

Reported-by: Peter Xu <peterx@redhat.com>
Fixes: a56de056c91f8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 contrib/vhost-user-blk/vhost-user-blk.c |  6 +-----
 target/i386/kvm.c                       | 14 +++-----------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
index 43583f2659..5c2092e13a 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -20,10 +20,6 @@
 #include "contrib/libvhost-user/libvhost-user-glib.h"
 #include "contrib/libvhost-user/libvhost-user.h"
 
-#if defined(__linux__)
-#include <linux/fs.h>
-#include <sys/ioctl.h>
-#endif
 
 struct virtio_blk_inhdr {
     unsigned char status;
@@ -525,7 +521,7 @@ vub_get_blocksize(int fd)
 
 #if defined(__linux__) && defined(BLKSSZGET)
     if (ioctl(fd, BLKSSZGET, &blocksize) == 0) {
-        return blocksize;
+        return blocklen;
     }
 #endif
 
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index beae1b99da..9af4542fb8 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \
 static void kvm_update_msi_routes_all(void *private, bool global,
                                       uint32_t index, uint32_t mask)
 {
-    int cnt = 0, vector;
+    int cnt = 0;
     MSIRouteEntry *entry;
     MSIMessage msg;
     PCIDevice *dev;
@@ -3902,19 +3902,11 @@ static void kvm_update_msi_routes_all(void *private, bool global,
     /* TODO: explicit route update */
     QLIST_FOREACH(entry, &msi_route_list, list) {
         cnt++;
-        vector = entry->vector;
         dev = entry->dev;
-        if (msix_enabled(dev) && !msix_is_masked(dev, vector)) {
-            msg = msix_get_message(dev, vector);
-        } else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) {
-            msg = msi_get_message(dev, vector);
-        } else {
-            /*
-             * Either MSI/MSIX is disabled for the device, or the
-             * specific message was masked out.  Skip this one.
-             */
+        if (!msix_enabled(dev) && !msi_enabled(dev)) {
             continue;
         }
+        msg = pci_get_msi_message(dev, entry->vector);
         kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev);
     }
     kvm_irqchip_commit_routes(kvm_state);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 1/3] Revert "contrib/vhost-user-blk: fix the compilation issue"
@ 2019-02-12 14:06   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 14:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Changpeng Liu, Peter Xu, Paolo Bonzini,
	Philippe Mathieu-Daudé,
	Marcelo Tosatti, Richard Henderson, Eduardo Habkost,
	open list:X86

Commit a56de056c91f8 squashed the following two unrelated commits
at once:

- "contrib/vhost-user-blk: fix the compilation issue"
  (Message-Id: 1547615970-23545-2-git-send-email-changpeng.liu@intel.com)
- "i386/kvm: ignore masked irqs when update msi routes"
  (Message-Id: 20190116030815.27273-5-peterx@redhat.com)

While the git history remains bisectable, having a commit that changes
MSI/MSIX code but describes it as "fix vhost-user-blk compilation" is
rather confusing.
Revert the offending commit to properly apply both patches separately.

Reported-by: Peter Xu <peterx@redhat.com>
Fixes: a56de056c91f8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 contrib/vhost-user-blk/vhost-user-blk.c |  6 +-----
 target/i386/kvm.c                       | 14 +++-----------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
index 43583f2659..5c2092e13a 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -20,10 +20,6 @@
 #include "contrib/libvhost-user/libvhost-user-glib.h"
 #include "contrib/libvhost-user/libvhost-user.h"
 
-#if defined(__linux__)
-#include <linux/fs.h>
-#include <sys/ioctl.h>
-#endif
 
 struct virtio_blk_inhdr {
     unsigned char status;
@@ -525,7 +521,7 @@ vub_get_blocksize(int fd)
 
 #if defined(__linux__) && defined(BLKSSZGET)
     if (ioctl(fd, BLKSSZGET, &blocksize) == 0) {
-        return blocksize;
+        return blocklen;
     }
 #endif
 
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index beae1b99da..9af4542fb8 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \
 static void kvm_update_msi_routes_all(void *private, bool global,
                                       uint32_t index, uint32_t mask)
 {
-    int cnt = 0, vector;
+    int cnt = 0;
     MSIRouteEntry *entry;
     MSIMessage msg;
     PCIDevice *dev;
@@ -3902,19 +3902,11 @@ static void kvm_update_msi_routes_all(void *private, bool global,
     /* TODO: explicit route update */
     QLIST_FOREACH(entry, &msi_route_list, list) {
         cnt++;
-        vector = entry->vector;
         dev = entry->dev;
-        if (msix_enabled(dev) && !msix_is_masked(dev, vector)) {
-            msg = msix_get_message(dev, vector);
-        } else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) {
-            msg = msi_get_message(dev, vector);
-        } else {
-            /*
-             * Either MSI/MSIX is disabled for the device, or the
-             * specific message was masked out.  Skip this one.
-             */
+        if (!msix_enabled(dev) && !msi_enabled(dev)) {
             continue;
         }
+        msg = pci_get_msi_message(dev, entry->vector);
         kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev);
     }
     kvm_irqchip_commit_routes(kvm_state);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 2/3] contrib/vhost-user-blk: fix the compilation issue
  2019-02-12 14:06 [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Philippe Mathieu-Daudé
  2019-02-12 14:06   ` [Qemu-devel] " Philippe Mathieu-Daudé
@ 2019-02-12 14:06 ` Philippe Mathieu-Daudé
  2019-02-12 14:06   ` [Qemu-devel] " Philippe Mathieu-Daudé
  2019-02-13  3:00 ` [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Peter Xu
  3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 14:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Changpeng Liu, Peter Xu, Paolo Bonzini, Stefan Hajnoczi,
	Stefano Garzarella, Philippe Mathieu-Daudé

From: Changpeng Liu <changpeng.liu@intel.com>

Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <1547615970-23545-2-git-send-email-changpeng.liu@intel.com>
[PMD: this patch was first (incorrectly) introduced as a56de056c91f8]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 contrib/vhost-user-blk/vhost-user-blk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
index 5c2092e13a..43583f2659 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -20,6 +20,10 @@
 #include "contrib/libvhost-user/libvhost-user-glib.h"
 #include "contrib/libvhost-user/libvhost-user.h"
 
+#if defined(__linux__)
+#include <linux/fs.h>
+#include <sys/ioctl.h>
+#endif
 
 struct virtio_blk_inhdr {
     unsigned char status;
@@ -521,7 +525,7 @@ vub_get_blocksize(int fd)
 
 #if defined(__linux__) && defined(BLKSSZGET)
     if (ioctl(fd, BLKSSZGET, &blocksize) == 0) {
-        return blocklen;
+        return blocksize;
     }
 #endif
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] i386/kvm: ignore masked irqs when update msi routes
  2019-02-12 14:06 [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Philippe Mathieu-Daudé
@ 2019-02-12 14:06   ` Philippe Mathieu-Daudé
  2019-02-12 14:06 ` [Qemu-devel] [PATCH 2/3] contrib/vhost-user-blk: fix the compilation issue Philippe Mathieu-Daudé
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 14:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Eduardo Habkost, open list:X86, Marcelo Tosatti, Peter Xu,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Changpeng Liu, Richard Henderson

From: Peter Xu <peterx@redhat.com>

When we are with intel-iommu device and with IR on, KVM will register
an IEC notifier to detect interrupt updates from the guest and we'll
kick off kvm_update_msi_routes_all() when it happens to make sure
kernel IRQ cache is matching the latest.

Though, kvm_update_msi_routes_all() is buggy in that it ignored the
mask bit of either MSI/MSIX messages and it tries to translate the
message even if the corresponding message was already masked by the
guest driver (hence the MSI/MSIX message will be invalid).

Without this patch, we can receive an error message when we reboot a
guest with both an assigned vfio-pci device and intel-iommu enabled:

  qemu-system-x86_64: vtd_interrupt_remap_msi: MSI address low 32 bit invalid: 0x0

The error does not affect functionality of the guest since when we
failed to translate we'll just silently continue (which makes sense
since crashing the VM for this seems even worse), but still it's
better to fix it up.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20190116030815.27273-5-peterx@redhat.com>
[PMD: this patch was first (incorrectly) introduced as a56de056c91f8]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 target/i386/kvm.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 9af4542fb8..beae1b99da 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \
 static void kvm_update_msi_routes_all(void *private, bool global,
                                       uint32_t index, uint32_t mask)
 {
-    int cnt = 0;
+    int cnt = 0, vector;
     MSIRouteEntry *entry;
     MSIMessage msg;
     PCIDevice *dev;
@@ -3902,11 +3902,19 @@ static void kvm_update_msi_routes_all(void *private, bool global,
     /* TODO: explicit route update */
     QLIST_FOREACH(entry, &msi_route_list, list) {
         cnt++;
+        vector = entry->vector;
         dev = entry->dev;
-        if (!msix_enabled(dev) && !msi_enabled(dev)) {
+        if (msix_enabled(dev) && !msix_is_masked(dev, vector)) {
+            msg = msix_get_message(dev, vector);
+        } else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) {
+            msg = msi_get_message(dev, vector);
+        } else {
+            /*
+             * Either MSI/MSIX is disabled for the device, or the
+             * specific message was masked out.  Skip this one.
+             */
             continue;
         }
-        msg = pci_get_msi_message(dev, entry->vector);
         kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev);
     }
     kvm_irqchip_commit_routes(kvm_state);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 3/3] i386/kvm: ignore masked irqs when update msi routes
@ 2019-02-12 14:06   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 14:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Changpeng Liu, Peter Xu, Paolo Bonzini,
	Philippe Mathieu-Daudé,
	Marcelo Tosatti, Richard Henderson, Eduardo Habkost,
	open list:X86

From: Peter Xu <peterx@redhat.com>

When we are with intel-iommu device and with IR on, KVM will register
an IEC notifier to detect interrupt updates from the guest and we'll
kick off kvm_update_msi_routes_all() when it happens to make sure
kernel IRQ cache is matching the latest.

Though, kvm_update_msi_routes_all() is buggy in that it ignored the
mask bit of either MSI/MSIX messages and it tries to translate the
message even if the corresponding message was already masked by the
guest driver (hence the MSI/MSIX message will be invalid).

Without this patch, we can receive an error message when we reboot a
guest with both an assigned vfio-pci device and intel-iommu enabled:

  qemu-system-x86_64: vtd_interrupt_remap_msi: MSI address low 32 bit invalid: 0x0

The error does not affect functionality of the guest since when we
failed to translate we'll just silently continue (which makes sense
since crashing the VM for this seems even worse), but still it's
better to fix it up.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20190116030815.27273-5-peterx@redhat.com>
[PMD: this patch was first (incorrectly) introduced as a56de056c91f8]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 target/i386/kvm.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 9af4542fb8..beae1b99da 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \
 static void kvm_update_msi_routes_all(void *private, bool global,
                                       uint32_t index, uint32_t mask)
 {
-    int cnt = 0;
+    int cnt = 0, vector;
     MSIRouteEntry *entry;
     MSIMessage msg;
     PCIDevice *dev;
@@ -3902,11 +3902,19 @@ static void kvm_update_msi_routes_all(void *private, bool global,
     /* TODO: explicit route update */
     QLIST_FOREACH(entry, &msi_route_list, list) {
         cnt++;
+        vector = entry->vector;
         dev = entry->dev;
-        if (!msix_enabled(dev) && !msi_enabled(dev)) {
+        if (msix_enabled(dev) && !msix_is_masked(dev, vector)) {
+            msg = msix_get_message(dev, vector);
+        } else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) {
+            msg = msi_get_message(dev, vector);
+        } else {
+            /*
+             * Either MSI/MSIX is disabled for the device, or the
+             * specific message was masked out.  Skip this one.
+             */
             continue;
         }
-        msg = pci_get_msi_message(dev, entry->vector);
         kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev);
     }
     kvm_irqchip_commit_routes(kvm_state);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches
  2019-02-12 14:06 [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2019-02-12 14:06   ` [Qemu-devel] " Philippe Mathieu-Daudé
@ 2019-02-13  3:00 ` Peter Xu
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Xu @ 2019-02-13  3:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Michael S. Tsirkin, qemu-devel, Changpeng Liu, Paolo Bonzini

On Tue, Feb 12, 2019 at 03:06:18PM +0100, Philippe Mathieu-Daudé wrote:
> Commit a56de056c91f8 squashed two unrelated commits at once.
> Revert it and reapply the two commits to avoid confusion.
> 
> See: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg02966.html

This does look slightly better.  Thanks Phil & Michael.

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-02-13  3:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 14:06 [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Philippe Mathieu-Daudé
2019-02-12 14:06 ` [PATCH 1/3] Revert "contrib/vhost-user-blk: fix the compilation issue" Philippe Mathieu-Daudé
2019-02-12 14:06   ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-02-12 14:06 ` [Qemu-devel] [PATCH 2/3] contrib/vhost-user-blk: fix the compilation issue Philippe Mathieu-Daudé
2019-02-12 14:06 ` [PATCH 3/3] i386/kvm: ignore masked irqs when update msi routes Philippe Mathieu-Daudé
2019-02-12 14:06   ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-02-13  3:00 ` [Qemu-devel] [PATCH 0/3] pci, vhost-user: Fix two incorrectly applied patches Peter Xu

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.