Skip to content

Commit

Permalink
virtio-balloon: Document byte ordering of poison_val
Browse files Browse the repository at this point in the history
The poison_val field in the virtio_balloon_config is treated as a
little-endian field by the host. Since we are currently only having to deal
with a single byte poison value this isn't a problem, however if the value
should ever expand it would cause byte ordering issues. Document that in
the code so that we know that if the value should ever expand we need to
byte swap the value on big-endian architectures.

Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Link: https://lore.kernel.org/r/20200713203539.17140.71425.stgit@localhost.localdomain
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: David Hildenbrand <david@redhat.com>
  • Loading branch information
Alexander Duyck authored and Michael S. Tsirkin committed Jul 29, 2020
1 parent 295c1b9 commit ca72cc3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/virtio/virtio_balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,11 @@ static int virtballoon_probe(struct virtio_device *vdev)
/*
* Let the hypervisor know that we are expecting a
* specific value to be written back in balloon pages.
*
* If the PAGE_POISON value was larger than a byte we would
* need to byte swap poison_val here to guarantee it is
* little-endian. However for now it is a single byte so we
* can pass it as-is.
*/
if (!want_init_on_free())
memset(&poison_val, PAGE_POISON, sizeof(poison_val));
Expand Down

0 comments on commit ca72cc3

Please sign in to comment.