All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Cédric Le Goater" <clg@fr.ibm.com>
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
Subject: Re: [RFC PATCH 1/4] vhost: add VHOST_VRING_F_BYTESWAP flag
Date: Mon, 03 Nov 2014 16:28:52 +0000	[thread overview]
Message-ID: <20141103162852.GD24877@redhat.com> (raw)
In-Reply-To: <1414571925-16918-2-git-send-email-clg@fr.ibm.com>

On Wed, Oct 29, 2014 at 09:38:42AM +0100, Cédric 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.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>

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(-)
> 
> 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 = NULL;
>  	vq->log_ctx = NULL;
>  	vq->memory = NULL;
> +	vq->byteswap = 0;
>  }
>  
>  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_BYTESWAP)) {
>  			r = -EOPNOTSUPP;
>  			break;
>  		}
> @@ -747,6 +749,7 @@ 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->byteswap = !!(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;
>  };
>  
>  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
>  
>  	/* Start of array of descriptors (virtually contiguous) */
>  	__u64 desc_user_addr;
> -- 
> 1.7.10.4

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Cédric Le Goater" <clg@fr.ibm.com>
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
Subject: Re: [RFC PATCH 1/4] vhost: add VHOST_VRING_F_BYTESWAP flag
Date: Mon, 3 Nov 2014 18:28:52 +0200	[thread overview]
Message-ID: <20141103162852.GD24877@redhat.com> (raw)
In-Reply-To: <1414571925-16918-2-git-send-email-clg@fr.ibm.com>

On Wed, Oct 29, 2014 at 09:38:42AM +0100, Cédric 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.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>

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(-)
> 
> 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 = NULL;
>  	vq->log_ctx = NULL;
>  	vq->memory = NULL;
> +	vq->byteswap = 0;
>  }
>  
>  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_BYTESWAP)) {
>  			r = -EOPNOTSUPP;
>  			break;
>  		}
> @@ -747,6 +749,7 @@ 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->byteswap = !!(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;
>  };
>  
>  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
>  
>  	/* Start of array of descriptors (virtually contiguous) */
>  	__u64 desc_user_addr;
> -- 
> 1.7.10.4

  reply	other threads:[~2014-11-03 16:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29  8:38 [RFC PATCH 0/4] vhost_net: support for cross endian guests Cédric Le Goater
2014-10-29  8:38 ` Cédric Le Goater
2014-10-29  8:38 ` [RFC PATCH 1/4] vhost: add VHOST_VRING_F_BYTESWAP flag Cédric Le Goater
2014-10-29  8:38   ` Cédric Le Goater
2014-11-03 16:28   ` Michael S. Tsirkin [this message]
2014-11-03 16:28     ` Michael S. Tsirkin
2014-10-29  8:38 ` [RFC PATCH 2/4] vhost: add byteswap routines Cédric Le Goater
2014-10-29  8:38   ` Cédric Le Goater
2014-11-03 15:38   ` Cornelia Huck
2014-11-03 15:38     ` Cornelia Huck
2014-10-29  8:38 ` [RFC PATCH 3/4] vhost: byteswap virtqueue attributes Cédric Le Goater
2014-10-29  8:38   ` Cédric Le Goater
2014-11-03 16:02   ` Cornelia Huck
2014-11-03 16:02     ` Cornelia Huck
2014-10-29  8:38 ` [RFC PATCH 4/4] vhost_net: byteswap virtio_net header Cédric Le Goater
2014-10-29  8:38   ` Cédric Le Goater
2014-11-03 16:25   ` Michael S. Tsirkin
2014-11-03 16:25     ` Michael S. Tsirkin
2014-11-03 16:23 ` [RFC PATCH 0/4] vhost_net: support for cross endian guests Michael S. Tsirkin
2014-11-03 16:23   ` Michael S. Tsirkin
2014-11-04  8:07   ` Cedric Le Goater
2014-11-04  8:07     ` Cedric 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=20141103162852.GD24877@redhat.com \
    --to=mst@redhat.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=clg@fr.ibm.com \
    --cc=gkurz@linux.vnet.ibm.com.patch \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=paulus@samba.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.