qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: lagarcia@linux.ibm.com
To: qemu-devel@nongnu.org
Cc: farosas@br.ibm.com, gkurz@redhat.com,
	Leonardo Garcia <lagarcia@br.ibm.com>,
	dgilbert@redhat.com, stefanha@redhat.com
Subject: [PATCH v2] IOMMU not supported by vhost-user.
Date: Wed, 17 Feb 2021 16:55:12 -0300	[thread overview]
Message-ID: <a47b7a5dafcab0f3a662414ba6cbbc7eb280d478.1613591341.git.lagarcia@br.ibm.com> (raw)

From: Leonardo Garcia <lagarcia@br.ibm.com>

Currently, as IOMMU is not supported, if a user mistakenly set it and
tries to mount the vhost-user filesystem (or use any other vhost-user
based device) inside the guest, whenever the user tries to access the
device, the system will hang forever (because virtiofsd will not be
running anymore).

Signed-off-by: Leonardo Garcia <lagarcia@br.ibm.com>
---
 hw/virtio/vhost-user-fs.c | 5 +++++
 hw/virtio/vhost-user.c    | 7 +++++++
 hw/virtio/vhost.c         | 1 -
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index ac4fc34b36..059b0d2ef9 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -222,6 +222,11 @@ static void vuf_device_realize(DeviceState *dev, Error **errp)
     /* 1 high prio queue, plus the number configured */
     fs->vhost_dev.nvqs = 1 + fs->conf.num_request_queues;
     fs->vhost_dev.vqs = g_new0(struct vhost_virtqueue, fs->vhost_dev.nvqs);
+    /*
+     * vhost_user_backend_init does additional checks if VirtIODevice is defined
+     * in vhost_dev
+     */
+    fs->vhost_dev.vdev = vdev;
     ret = vhost_dev_init(&fs->vhost_dev, &fs->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0);
     if (ret < 0) {
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 2fdd5daf74..6ab760364b 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1849,6 +1849,13 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque)
             }
         }
 
+        if ((dev->vdev != NULL) &&
+            virtio_host_has_feature(dev->vdev, VIRTIO_F_IOMMU_PLATFORM) &&
+            !(features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) {
+            error_report("IOMMU is currently not supported with vhost-user");
+            return -1;
+        }
+
         if (virtio_has_feature(features, VIRTIO_F_IOMMU_PLATFORM) &&
                 !(virtio_has_feature(dev->protocol_features,
                     VHOST_USER_PROTOCOL_F_SLAVE_REQ) &&
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6e17d631f7..78e58d2148 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1293,7 +1293,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
     int i, r, n_initialized_vqs = 0;
     Error *local_err = NULL;
 
-    hdev->vdev = NULL;
     hdev->migration_blocker = NULL;
 
     r = vhost_set_backend_type(hdev, backend_type);
-- 
2.29.2



             reply	other threads:[~2021-02-17 19:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 19:55 lagarcia [this message]
2021-02-23 15:55 ` [PATCH v2] IOMMU not supported by vhost-user Greg Kurz
2021-03-31  9:11   ` Stefan Hajnoczi
2021-03-31  9:14 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a47b7a5dafcab0f3a662414ba6cbbc7eb280d478.1613591341.git.lagarcia@br.ibm.com \
    --to=lagarcia@linux.ibm.com \
    --cc=dgilbert@redhat.com \
    --cc=farosas@br.ibm.com \
    --cc=gkurz@redhat.com \
    --cc=lagarcia@br.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).