All of lore.kernel.org
 help / color / mirror / Atom feed
From: Halil Pasic <pasic@linux.ibm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	 Halil Pasic <pasic@linux.ibm.com>,
	qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Thomas Huth <thuth@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	David Hildenbrand <david@redhat.com>
Subject: [RFC PATCH v2 4/5] vhost: push features to backend on force_modern
Date: Fri, 12 Nov 2021 15:57:48 +0100	[thread overview]
Message-ID: <20211112145749.618157-5-pasic@linux.ibm.com> (raw)
In-Reply-To: <20211112145749.618157-1-pasic@linux.ibm.com>

In vhost we don't push the features to the vhost device when the
features are set, but when the vhost device is started. This can
lead to problems when config space is implemented in the vhost
device, and the driver does some early config space reading (early in a
sense that it precedes setting FEATURES_OK).

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
---
 hw/virtio/vhost.c         | 17 +++++++++++++++++
 include/hw/virtio/vhost.h |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b4b29413e6..5764970298 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1628,6 +1628,23 @@ void vhost_dev_free_inflight(struct vhost_inflight *inflight)
     }
 }
 
+int vhost_dev_force_modern(struct vhost_dev *hdev)
+{
+    uint64_t features;
+    int r;
+
+    assert(hdev->vhost_ops);
+
+    hdev->acked_features |= (0x1ULL << VIRTIO_F_VERSION_1);
+    features = hdev->acked_features;
+    r = hdev->vhost_ops->vhost_set_features(hdev, features);
+    if (r < 0) {
+        VHOST_OPS_DEBUG("vhost_set_features failed");
+        return -errno;
+    }
+    return 0;
+}
+
 static int vhost_dev_resize_inflight(struct vhost_inflight *inflight,
                                      uint64_t new_size)
 {
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 1a9fc65089..9ef784e2e9 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -138,6 +138,8 @@ int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config,
                          uint32_t config_len, Error **errp);
 int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data,
                          uint32_t offset, uint32_t size, uint32_t flags);
+
+int vhost_dev_force_modern(struct vhost_dev *vdev);
 /* notifier callback in case vhost device config space changed
  */
 void vhost_dev_set_config_notifier(struct vhost_dev *dev,
-- 
2.25.1



  parent reply	other threads:[~2021-11-12 15:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 14:57 [RFC PATCH v2 0/5] virtio: early detect 'modern' virtio Halil Pasic
2021-11-12 14:57 ` [RFC PATCH v2 1/5] virtio: introduce virtio_force_modern() Halil Pasic
2021-11-12 15:37   ` Cornelia Huck
2021-11-15 13:26     ` Halil Pasic
2021-11-15 16:57       ` Cornelia Huck
2021-11-16 14:44         ` Halil Pasic
2021-11-12 14:57 ` [RFC PATCH v2 2/5] virtio-ccw: use virtio_force_modern() Halil Pasic
2021-11-12 14:57 ` [RFC PATCH v2 3/5] virtio-pci: " Halil Pasic
2021-11-12 14:57 ` Halil Pasic [this message]
2021-11-12 14:57 ` [RFC PATCH v2 5/5] virtio-net: handle force_modern for vhost Halil Pasic
2021-11-23 13:13 ` [RFC PATCH v2 0/5] virtio: early detect 'modern' virtio Halil Pasic
2021-11-29 11:59   ` Halil Pasic
2021-12-08 18:56 ` Michael S. Tsirkin
2021-12-09 13:29   ` Halil Pasic
2021-12-09 17:54     ` Michael S. Tsirkin

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=20211112145749.618157-5-pasic@linux.ibm.com \
    --to=pasic@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@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 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.