From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Jason Wang <jasowang@redhat.com>,
virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH RFC 4/7] vhost: set vring endianness for legacy virtio
Date: Tue, 12 May 2015 17:15:53 +0200 [thread overview]
Message-ID: <20150512154127-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <20150512152530.4ab0c56f.cornelia.huck@de.ibm.com>
On Tue, May 12, 2015 at 03:25:30PM +0200, Cornelia Huck wrote:
> On Wed, 06 May 2015 14:08:02 +0200
> Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
>
> > Legacy virtio is native endian: if the guest and host endianness differ,
> > we have to tell vhost so it can swap bytes where appropriate. This is
> > done through a vhost ring ioctl.
> >
> > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > ---
> > hw/virtio/vhost.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 49 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> > index 54851b7..1d7b939 100644
> > --- a/hw/virtio/vhost.c
> > +++ b/hw/virtio/vhost.c
> (...)
> > @@ -677,6 +700,16 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
> > return -errno;
> > }
> >
> > + if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
>
> I think this should either go in after the virtio-1 base support (more
> feature bits etc.) or get a big fat comment and be touched up later.
> I'd prefer the first solution so it does not get forgotten, but I'm not
> sure when Michael plans to proceed with the virtio-1 patches (I think
> they're mostly fine already).
There are three main issues with virtio 1 patches that I am aware of.
One issue with virtio 1 patches as they are is with how features are
handled ATM. There are 3 types of features
a. virtio 1 only features
b. virtio 0 only features
c. shared features
and 3 types of devices
a. legacy device: has b+c features
b. modern device: has a+c features
c. transitional device: has a+c features but exposes
only c through the legacy interface
So I think a callback that gets features depending on guest
version isn't a good way to model it because fundamentally device
has one set of features.
A better way to model this is really just a single
host_features bitmask, and for transitional devices, a mask
hiding a features - which are so far all bits > 31, so maybe
for now we can just have a global mask.
We need to validate features at initialization time and make
sure they make sense, fail if not (sometimes we need to mask
features if they don't make sense - this is unfortunate
but might be needed for compatibility).
Moving host_features to virtio core would make all of the above
easier.
Second issue is migration, some of it is with migrating the new
features, so that's tied to the first one.
Third issue is fixing devices so they don't try to
access guest memory until DRIVER_OK is set.
This is surprisingly hard to do generally given need to support old
drivers which don't set DRIVER_OK or set it very late, and the fact that
we tied work-arounds for even older drivers which dont' set pci bus
master to the DRIVER_OK bit. I tried, and I'm close to giving up and
just checking guest ack for virtio 1, and ignoring DRIVER_OK requirement
if not there.
> > + virtio_legacy_is_cross_endian(vdev)) {
> > + r = vhost_virtqueue_set_vring_endian_legacy(dev,
> > + virtio_is_big_endian(vdev),
> > + vhost_vq_index);
> > + if (r) {
> > + return -errno;
> > + }
> > + }
> > +
> > s = l = virtio_queue_get_desc_size(vdev, idx);
> > a = virtio_queue_get_desc_addr(vdev, idx);
> > vq->desc = cpu_physical_memory_map(a, &l, 0);
next prev parent reply other threads:[~2015-05-12 15:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 12:07 [Qemu-devel] [PATCH RFC 0/7] vhost: cross-endian support (vhost-net only) Greg Kurz
2015-05-06 12:07 ` [Qemu-devel] [PATCH RFC 1/7] virtio: relax feature check Greg Kurz
2015-05-12 13:14 ` Cornelia Huck
2015-05-12 13:34 ` Michael S. Tsirkin
2015-05-12 13:44 ` Cornelia Huck
2015-05-12 14:46 ` Cornelia Huck
2015-05-12 15:30 ` Michael S. Tsirkin
2015-05-12 16:27 ` Cornelia Huck
2015-05-12 13:49 ` Peter Maydell
2015-05-12 13:55 ` Greg Kurz
2015-05-06 12:07 ` [Qemu-devel] [PATCH RFC 2/7] linux-headers: sync vhost.h Greg Kurz
2015-05-06 12:07 ` [Qemu-devel] [PATCH RFC 3/7] virtio: introduce virtio_legacy_is_cross_endian() Greg Kurz
2015-05-06 12:08 ` [Qemu-devel] [PATCH RFC 4/7] vhost: set vring endianness for legacy virtio Greg Kurz
2015-05-12 13:25 ` Cornelia Huck
2015-05-12 15:15 ` Michael S. Tsirkin [this message]
2015-05-12 16:25 ` Cornelia Huck
2015-05-12 16:40 ` Michael S. Tsirkin
2015-05-13 10:39 ` Cornelia Huck
2015-05-13 11:22 ` Michael S. Tsirkin
2015-05-06 12:08 ` [Qemu-devel] [PATCH RFC 5/7] tap: add VNET_LE/VNET_BE operations Greg Kurz
2015-05-06 12:08 ` [Qemu-devel] [PATCH RFC 6/7] vhost-net: tell tap backend about the vnet endianness Greg Kurz
2015-05-06 12:08 ` [Qemu-devel] [PATCH RFC 7/7] vhost_net: re-enable when cross endian Greg Kurz
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=20150512154127-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/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).