On Wed, 29 Oct 2014 09:38:44 +0100 Cédric Le Goater <clg@xxxxxxxxxx> 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@xxxxxxxxxx> > --- > 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; > +} > + -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html