]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
virtio_balloon: init 1st buffer in stats vq
authorLadi Prosek <lprosek@redhat.com>
Thu, 23 Mar 2017 07:04:18 +0000 (08:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Jun 2017 12:04:37 +0000 (14:04 +0200)
commite2e1170de69a3d518eeb3339068b1ef75ffe0be6
tree67b5cd1f811bbbdbf779845eea69dfaae2590bfc
parent0907dbed07d2aeb1c729a61fe114dcf6b8bb85fb
virtio_balloon: init 1st buffer in stats vq

commit fc8653228c8588a120f6b5dad6983b7b61ff669e upstream.

When init_vqs runs, virtio_balloon.stats is either uninitialized or
contains stale values. The host updates its state with garbage data
because it has no way of knowing that this is just a marker buffer
used for signaling.

This patch updates the stats before pushing the initial buffer.

Alternative fixes:
* Push an empty buffer in init_vqs. Not easily done with the current
  virtio implementation and violates the spec "Driver MUST supply the
  same subset of statistics in all buffers submitted to the statsq".
* Push a buffer with invalid tags in init_vqs. Violates the same
  spec clause, plus "invalid tag" is not really defined.

Note: the spec says:
When using the legacy interface, the device SHOULD ignore all values in
the first buffer in the statsq supplied by the driver after device
initialization. Note: Historically, drivers supplied an uninitialized
buffer in the first buffer.

Unfortunately QEMU does not seem to implement the recommendation
even for the legacy interface.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/virtio/virtio_balloon.c