Skip to content

Commit 168c358

Browse files
committed
virtio_balloon: fix up endian-ness for free cmd id
free cmd id is read using virtio endian, spec says all fields in balloon are LE. Fix it up. Fixes: 86a5597 ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT") Cc: [email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]> Reviewed-by: Wei Wang <[email protected]> Acked-by: David Hildenbrand <[email protected]>
1 parent ca72cc3 commit 168c358

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/virtio/virtio_balloon.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,14 @@ static int init_vqs(struct virtio_balloon *vb)
578578
static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
579579
{
580580
if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
581-
&vb->config_read_bitmap))
581+
&vb->config_read_bitmap)) {
582582
virtio_cread(vb->vdev, struct virtio_balloon_config,
583583
free_page_hint_cmd_id,
584584
&vb->cmd_id_received_cache);
585+
/* Legacy balloon config space is LE, unlike all other devices. */
586+
if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
587+
vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
588+
}
585589

586590
return vb->cmd_id_received_cache;
587591
}

0 commit comments

Comments
 (0)