From: Greg Kurz <gkurz@linux.vnet.ibm.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: paulus@samba.org, "Cédric Le Goater" <clg@fr.ibm.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [Qemu-ppc] [RFC PATCH 1/2] vhost: add VHOST_VRING_F_BYTESWAP flag
Date: Mon, 3 Nov 2014 18:33:50 +0100 [thread overview]
Message-ID: <20141103183350.70764cb3@bahia.local> (raw)
In-Reply-To: <20141103162931.4edbed1f.cornelia.huck@de.ibm.com>
On Mon, 3 Nov 2014 16:29:31 +0100
Cornelia Huck <cornelia.huck@de.ibm.com> wrote:
> On Wed, 29 Oct 2014 09:42:09 +0100
> Cédric Le Goater <clg@fr.ibm.com> wrote:
>
> > When the guest and the host have a different endian order, the data
> > being accessed in the vring queues needs to be byteswapped.
> >
> > This patch adds a VHOST_VRING_F_BYTESWAP flag to inform the vhost
> > kernel backend to byteswap vring data.
> >
> > Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> > ---
> > hw/virtio/vhost.c | 25 ++++++++++++++++++++++++-
> > include/hw/virtio/vhost.h | 1 +
> > linux-headers/linux/vhost.h | 3 +++
> > 3 files changed, 28 insertions(+), 1 deletion(-)
>
> > +static bool vhost_virtqueue_needs_byteswap(VirtIODevice *vdev)
> > +{
> > +#ifdef TARGET_IS_BIENDIAN
> > +#ifdef HOST_WORDS_BIGENDIAN
> > + return !virtio_is_big_endian(vdev);
> > +#else
> > + return virtio_is_big_endian(vdev);
> > +#endif
> > +
> > +#else
> > + return false;
> > +#endif
> > +}
>
> *thinks aloud*
>
> We call this function after features have been negotiated, so we should
> be able to reuse this interface for virtio-1 by checking for
> VIRTIO_F_VERSION_1, right?
>
>
Yes. Moreover, we're not on a hot path, so we could simply ignore
TARGET_IS_BIENDIAN and only have:
static bool vhost_virtqueue_needs_byteswap(VirtIODevice *vdev)
{
#ifdef HOST_WORDS_BIGENDIAN
return !virtio_is_big_endian(vdev);
#else
return virtio_is_big_endian(vdev);
#endif
}
in which case, this would work right away with the changes brought by
Conny's virtio-1 series:
static inline bool virtio_device_is_legacy(VirtIODevice *vdev)
{
return !(vdev->guest_features[1] & (1 << (VIRTIO_F_VERSION_1 - 32)));
}
static inline bool virtio_is_big_endian(VirtIODevice *vdev)
{
if (virtio_device_is_legacy(vdev)) {
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG;
}
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
return false;
}
Cheers.
--
Greg
next prev parent reply other threads:[~2014-11-03 17:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-29 8:42 [Qemu-devel] [RFC PATCH 0/2] vhost: support for cross endian Cédric Le Goater
2014-10-29 8:42 ` [Qemu-devel] [RFC PATCH 1/2] vhost: add VHOST_VRING_F_BYTESWAP flag Cédric Le Goater
2014-11-03 15:29 ` Cornelia Huck
2014-11-03 17:33 ` Greg Kurz [this message]
2014-10-29 8:42 ` [Qemu-devel] [RFC PATCH 2/2] vhost_net: re-enable when cross endian Cédric Le Goater
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=20141103183350.70764cb3@bahia.local \
--to=gkurz@linux.vnet.ibm.com \
--cc=clg@fr.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=mst@redhat.com \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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).