From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: "Cédric Le Goater" <clg@fr.ibm.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, agraf@suse.de,
paulus@samba.org, gkurz@linux.vnet.ibm.com, aik@ozlabs.ru
Subject: Re: [RFC PATCH 3/4] vhost: byteswap virtqueue attributes
Date: Mon, 3 Nov 2014 17:02:33 +0100 [thread overview]
Message-ID: <20141103170233.71f6dfa2.cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1414571925-16918-4-git-send-email-clg@fr.ibm.com>
On Wed, 29 Oct 2014 09:38:44 +0100
Cédric Le Goater <clg@fr.ibm.com> wrote:
> The virtqueue structure shares a few attributes with the guest OS
> which need to be byteswapped when the endian order of the host is
> different.
>
> This patch uses the vq->byteswap attribute to decide whether to
> byteswap or not data being accessed in the guest memory.
>
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
> drivers/vhost/vhost.c | 52 +++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 40 insertions(+), 12 deletions(-)
>
> +static int __copyhead_to_user(struct vhost_virtqueue *vq,
> + struct vring_used_elem *heads,
> + struct vring_used_elem __user *used,
> + unsigned count)
__copy_used_elems_to_user() ?
> +{
> + int i;
> +
> + for (i = 0; i < count; i++) {
> + if (__vq_put_user(vq, heads[i].id, &used[i].id)) {
> + vq_err(vq, "Failed to write used id");
> + return -EFAULT;
> + }
> + if (__vq_put_user(vq, heads[i].len, &used[i].len)) {
> + vq_err(vq, "Failed to write used len");
> + return -EFAULT;
> + }
> + }
Is there a number of elements where it would be more efficient to
byteswap the used elements first and then do __copy_to_user() in one
go? Depends on the backend, I guess.
> + return 0;
> +}
> +
next prev parent reply other threads:[~2014-11-03 16:02 UTC|newest]
Thread overview: 11+ 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 ` [RFC PATCH 1/4] vhost: add VHOST_VRING_F_BYTESWAP flag Cédric Le Goater
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-11-03 15:38 ` Cornelia Huck
2014-10-29 8:38 ` [RFC PATCH 3/4] vhost: byteswap virtqueue attributes Cédric Le Goater
2014-11-03 16:02 ` Cornelia Huck [this message]
2014-10-29 8:38 ` [RFC PATCH 4/4] vhost_net: byteswap virtio_net header Cédric Le Goater
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-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=20141103170233.71f6dfa2.cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=clg@fr.ibm.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox