Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1402915
| From | Cornelia Huck <cornelia.huck@de.ibm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH RFC 1/1] virtio-balloon: handle virtio-1 endianness |
| Date | 2016-05-18 14:20 +0200 |
| Message-ID | <rA8Ce-20k-9@gated-at.bofh.it> (permalink) |
| References | <rA8Ce-20k-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH RFC 0/1] virtio-balloon vs. endianness Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-05-18 14:20 +0200
[PATCH RFC 1/1] virtio-balloon: handle virtio-1 endianness Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-05-18 14:20 +0200
Re: [PATCH RFC 1/1] virtio-balloon: handle virtio-1 endianness "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 14:40 +0200
csiph-web