virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Venkatesh Srinivas via Virtualization <virtualization@lists.linux-foundation.org>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: vsrinivas@ops101.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] tools/virtio: fix byteswap logic
Date: Fri, 4 Dec 2015 11:37:53 -0800	[thread overview]
Message-ID: <20151204193753.GA19430@google.com> (raw)
In-Reply-To: <1448872410-11553-1-git-send-email-mst@redhat.com>

On Mon, Nov 30, 2015 at 10:33:34AM +0200, Michael S. Tsirkin wrote:
> commit cf561f0d2eb74574ad9985a2feab134267a9d298 ("virtio: introduce
> virtio_is_little_endian() helper") changed byteswap logic to
> skip feature bit checks for LE platforms, but didn't
> update tools/virtio, so vring_bench started failing.
> 
> Update the copy under tools/virtio/ (TODO: find a way to avoid this code
> duplication).
> 
> Cc: Greg Kurz <gkurz@linux.vnet.ibm.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  tools/virtio/linux/virtio_config.h | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h
> index 806d683..57a6964 100644
> --- a/tools/virtio/linux/virtio_config.h
> +++ b/tools/virtio/linux/virtio_config.h
> @@ -40,33 +40,39 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev,
>  #define virtio_has_feature(dev, feature) \
>  	(__virtio_test_bit((dev), feature))
>  
> +static inline bool virtio_is_little_endian(struct virtio_device *vdev)
> +{
> +	return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
> +		virtio_legacy_is_little_endian();
> +}
> +
> +/* Memory accessors */
>  static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val)
>  {
> -	return __virtio16_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
> +	return __virtio16_to_cpu(virtio_is_little_endian(vdev), val);
>  }
>  
>  static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val)
>  {
> -	return __cpu_to_virtio16(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
> +	return __cpu_to_virtio16(virtio_is_little_endian(vdev), val);
>  }
>  
>  static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val)
>  {
> -	return __virtio32_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
> +	return __virtio32_to_cpu(virtio_is_little_endian(vdev), val);
>  }
>  
>  static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val)
>  {
> -	return __cpu_to_virtio32(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
> +	return __cpu_to_virtio32(virtio_is_little_endian(vdev), val);
>  }
>  
>  static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val)
>  {
> -	return __virtio64_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
> +	return __virtio64_to_cpu(virtio_is_little_endian(vdev), val);
>  }
>  
>  static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
>  {
> -	return __cpu_to_virtio64(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
> +	return __cpu_to_virtio64(virtio_is_little_endian(vdev), val);
>  }

Tested patch with vring-bench. (I did something similar when reviving it).

Tested-by: Venkatesh Srinivas <venkateshs@google.com>

-- vs;

      parent reply	other threads:[~2015-12-04 19:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30  8:33 [PATCH] tools/virtio: fix byteswap logic Michael S. Tsirkin
2015-11-30  9:38 ` Greg Kurz
2015-11-30 10:02 ` Cornelia Huck
2015-12-04 19:37 ` Venkatesh Srinivas via Virtualization [this message]

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=20151204193753.GA19430@google.com \
    --to=virtualization@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=venkateshs@google.com \
    --cc=vsrinivas@ops101.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).