diff options
| author | Ladi Prosek <lprosek@redhat.com> | 2017-03-23 08:04:18 +0100 |
|---|---|---|
| committer | Ben Hutchings <ben@decadent.org.uk> | 2017-07-18 18:38:37 +0100 |
| commit | 6918f8446eacec98afccae5b42c3511d5b23e028 (patch) | |
| tree | 3b5ede159bcf01527afb1f47e6a990901f27e347 /drivers | |
| parent | 1487bf5c5f6089f42de4e4370ab260944039b03e (diff) | |
| download | linux-6918f8446eacec98afccae5b42c3511d5b23e028.tar.gz linux-6918f8446eacec98afccae5b42c3511d5b23e028.tar.bz2 linux-6918f8446eacec98afccae5b42c3511d5b23e028.zip | |
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: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/virtio/virtio_balloon.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 2975c5089dac..1601e3eb3614 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -320,6 +320,8 @@ static int virtballoon_probe(struct virtio_device *vdev) * Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later. */ + update_balloon_stats(vb); + sg_init_one(&sg, vb->stats, sizeof vb->stats); if (virtqueue_add_buf(vb->stats_vq, &sg, 1, 0, vb) < 0) BUG(); |
