From: "Michael S. Tsirkin" <mst@redhat.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/3] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag
Date: Sun, 22 Feb 2015 10:51:50 +0100 [thread overview]
Message-ID: <20150222095150.GC17529@redhat.com> (raw)
In-Reply-To: <20150220100731.18608.2797.stgit@bahia.local>
On Fri, Feb 20, 2015 at 11:07:39AM +0100, Greg Kurz wrote:
> The VHOST_VRING_F_LEGACY_BIG_ENDIAN flag informs the kernel that the
> associated device is big endian. Of course, this only makes sense for
> legacy virtio devices since modern virtio devices are always little
> endian.
>
> It will be used by the vhost memory accessors to byteswap vring data when
> we have a legacy device, in case host and guest endianness differ.
>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
> drivers/vhost/vhost.c | 6 +++++-
> drivers/vhost/vhost.h | 3 +++
> include/uapi/linux/vhost.h | 2 ++
> 3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 2ee2826..dad3c37 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -199,6 +199,7 @@ static void vhost_vq_reset(struct vhost_dev *dev,
> vq->call = NULL;
> vq->log_ctx = NULL;
> vq->memory = NULL;
> + vq->legacy_big_endian = false;
> }
>
> static int vhost_worker(void *data)
> @@ -701,7 +702,8 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
> r = -EFAULT;
> break;
> }
> - if (a.flags & ~(0x1 << VHOST_VRING_F_LOG)) {
> + if (a.flags & ~(0x1 << VHOST_VRING_F_LOG|
> + 0x1 << VHOST_VRING_F_LEGACY_BIG_ENDIAN)) {
whitespace damage here
> r = -EOPNOTSUPP;
> break;
> }
need to also make sure LEGACY_BIG_ENDIAN isn't set with VERSION_1.
> @@ -751,6 +753,8 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
> vq->avail = (void __user *)(unsigned long)a.avail_user_addr;
> vq->log_addr = a.log_guest_addr;
> vq->used = (void __user *)(unsigned long)a.used_user_addr;
> + vq->legacy_big_endian =
> + !!(a.flags & (0x1 << VHOST_VRING_F_LEGACY_BIG_ENDIAN));
> break;
> case VHOST_SET_VRING_KICK:
> if (copy_from_user(&f, argp, sizeof f)) {
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index 8c1c792..ce2c68e 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -106,6 +106,9 @@ struct vhost_virtqueue {
> /* Log write descriptors */
> void __user *log_base;
> struct vhost_log *log;
> +
> + /* We need to know the device endianness with legacy virtio. */
> + bool legacy_big_endian;
> };
>
> struct vhost_dev {
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index bb6a5b4..0bf4491 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -34,6 +34,8 @@ struct vhost_vring_addr {
> /* Flag values: */
> /* Whether log address is valid. If set enables logging. */
> #define VHOST_VRING_F_LOG 0
> + /* Whether we have a big-endian legacy virtio device. */
> +#define VHOST_VRING_F_LEGACY_BIG_ENDIAN 1
>
> /* Start of array of descriptors (virtually contiguous) */
> __u64 desc_user_addr;
next prev parent reply other threads:[~2015-02-22 9:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 10:07 [PATCH 0/3] vhost_net: support for cross endian guests Greg Kurz
2015-02-20 10:07 ` [PATCH 1/3] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag Greg Kurz
2015-02-22 9:51 ` Michael S. Tsirkin
2015-02-22 9:51 ` Michael S. Tsirkin [this message]
2015-02-20 10:14 ` [PATCH 2/3] vhost: add support for legacy virtio Greg Kurz
2015-02-20 10:14 ` Greg Kurz
2015-02-22 9:48 ` Michael S. Tsirkin
2015-02-22 9:48 ` Michael S. Tsirkin
2015-02-20 10:15 ` [PATCH 3/3] vhost_net: fix virtio_net header endianness Greg Kurz
2015-02-22 9:46 ` Michael S. Tsirkin
2015-02-20 10:15 ` Greg Kurz
2015-02-22 9:53 ` [PATCH 0/3] vhost_net: support for cross endian guests Michael S. Tsirkin
2015-02-23 13:24 ` Greg Kurz
2015-02-23 13:24 ` 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=20150222095150.GC17529@redhat.com \
--to=mst@redhat.com \
--cc=clg@fr.ibm.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 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.