From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [RFC PATCH 1/4] vhost: add VHOST_VRING_F_BYTESWAP flag Date: Mon, 3 Nov 2014 18:28:52 +0200 Message-ID: <20141103162852.GD24877@redhat.com> References: <1414571925-16918-1-git-send-email-clg@fr.ibm.com> <1414571925-16918-2-git-send-email-clg@fr.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, agraf@suse.de, paulus@samba.org, gkurz@linux.vnet.ibm.com.patch, aik@ozlabs.ru To: =?iso-8859-1?Q?C=E9dric?= Le Goater Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45434 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752128AbaKCQ3G (ORCPT ); Mon, 3 Nov 2014 11:29:06 -0500 Content-Disposition: inline In-Reply-To: <1414571925-16918-2-git-send-email-clg@fr.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Oct 29, 2014 at 09:38:42AM +0100, C=E9dric Le Goater wrote: > The VHOST_VRING_F_BYTESWAP flag will be used by the host to byteswap > the vring data when the guest and the host have a different endian > order. >=20 > Signed-off-by: C=E9dric Le Goater I don't think it's a good API. You should ask for specific header format, not for a swap. > --- > drivers/vhost/vhost.c | 5 ++++- > drivers/vhost/vhost.h | 1 + > include/uapi/linux/vhost.h | 3 +++ > 3 files changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index c90f4374442a..72c21b790ba3 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 =3D NULL; > vq->log_ctx =3D NULL; > vq->memory =3D NULL; > + vq->byteswap =3D 0; > } > =20 > static int vhost_worker(void *data) > @@ -701,7 +702,8 @@ long vhost_vring_ioctl(struct vhost_dev *d, int i= octl, void __user *argp) > r =3D -EFAULT; > break; > } > - if (a.flags & ~(0x1 << VHOST_VRING_F_LOG)) { > + if (a.flags & ~(0x1 << VHOST_VRING_F_LOG | > + 0x1 << VHOST_VRING_F_BYTESWAP)) { > r =3D -EOPNOTSUPP; > break; > } > @@ -747,6 +749,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, int i= octl, void __user *argp) > vq->avail =3D (void __user *)(unsigned long)a.avail_user_addr; > vq->log_addr =3D a.log_guest_addr; > vq->used =3D (void __user *)(unsigned long)a.used_user_addr; > + vq->byteswap =3D !!(a.flags & (0x1 << VHOST_VRING_F_BYTESWAP)); > 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 3eda654b8f5a..ab25b7d0720d 100644 > --- a/drivers/vhost/vhost.h > +++ b/drivers/vhost/vhost.h > @@ -110,6 +110,7 @@ struct vhost_virtqueue { > /* Log write descriptors */ > void __user *log_base; > struct vhost_log *log; > + bool byteswap; > }; > =20 > struct vhost_dev { > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h > index bb6a5b4cb3c5..6a8c2b325c44 100644 > --- a/include/uapi/linux/vhost.h > +++ b/include/uapi/linux/vhost.h > @@ -34,6 +34,9 @@ struct vhost_vring_addr { > /* Flag values: */ > /* Whether log address is valid. If set enables logging. */ > #define VHOST_VRING_F_LOG 0 > + /* Whether vring memory accesses should be byte-swapped. > + * required when the guest has a different endianness */ > +#define VHOST_VRING_F_BYTESWAP 1 > =20 > /* Start of array of descriptors (virtually contiguous) */ > __u64 desc_user_addr; > --=20 > 1.7.10.4