From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753230AbcERMeE (ORCPT ); Wed, 18 May 2016 08:34:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37221 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751911AbcERMeB (ORCPT ); Wed, 18 May 2016 08:34:01 -0400 Date: Wed, 18 May 2016 15:33:58 +0300 From: "Michael S. Tsirkin" To: Cornelia Huck Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, borntraeger@de.ibm.com Subject: Re: [PATCH RFC 1/1] virtio-balloon: handle virtio-1 endianness Message-ID: <20160518153318-mutt-send-email-mst@redhat.com> References: <1463573563-34081-1-git-send-email-cornelia.huck@de.ibm.com> <1463573563-34081-2-git-send-email-cornelia.huck@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1463573563-34081-2-git-send-email-cornelia.huck@de.ibm.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 18 May 2016 12:34:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 18, 2016 at 02:12:43PM +0200, Cornelia Huck wrote: > As virtio-1 devices use little endian on their queues, we need > to make sure the pfns are in virtio32 format before we put > them on the queue. > > Signed-off-by: Cornelia Huck I have a less hacky version that I was testing. Will post now. > --- > drivers/virtio/virtio_balloon.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 7b6d74f..89da06c 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -76,6 +76,7 @@ struct virtio_balloon { > /* The array of pfns we tell the Host about. */ > unsigned int num_pfns; > u32 pfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX]; > + __virtio32 vpfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX]; > > /* Memory statistics */ > struct virtio_balloon_stat stats[VIRTIO_BALLOON_S_NR]; > @@ -115,8 +116,11 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) > { > struct scatterlist sg; > unsigned int len; > + int i; > > - sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); > + for (i = 0; i < vb->num_pfns; i++) > + vb->vpfns[i] = cpu_to_virtio32(vb->vdev, vb->pfns[i]); > + sg_init_one(&sg, vb->vpfns, sizeof(vb->vpfns[0]) * vb->num_pfns); > > /* We should always be able to add one buffer to an empty queue. */ > virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL); > -- > 2.6.6