From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: borntraeger@de.ibm.com, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH RFC 1/1] virtio-balloon: handle virtio-1 endianness
Date: Wed, 18 May 2016 15:33:58 +0300 [thread overview]
Message-ID: <20160518153318-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1463573563-34081-2-git-send-email-cornelia.huck@de.ibm.com>
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 <cornelia.huck@de.ibm.com>
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
prev parent reply other threads:[~2016-05-18 12:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-18 12:12 [PATCH RFC 0/1] virtio-balloon vs. endianness Cornelia Huck
2016-05-18 12:12 ` [PATCH RFC 1/1] virtio-balloon: handle virtio-1 endianness Cornelia Huck
2016-05-18 12:33 ` Michael S. Tsirkin [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=20160518153318-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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).