diff options
| author | Anthony Liguori <aliguori@us.ibm.com> | 2013-08-12 08:32:43 -0500 |
|---|---|---|
| committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-08-12 08:32:43 -0500 |
| commit | 6624fecd8e4df6be13f86846abce979702917931 (patch) | |
| tree | 217bdd2147bad789f3294194921f6ed23624e6dc | |
| parent | 3bba9c115ba31f53fb9fc0a2711bf36c0ed6f031 (diff) | |
| parent | f7b803b377f74f7e109559e8e64f04c4c1fcd86b (diff) | |
| download | focaccia-qemu-6624fecd8e4df6be13f86846abce979702917931.tar.gz focaccia-qemu-6624fecd8e4df6be13f86846abce979702917931.zip | |
Merge remote-tracking branch 'pmaydell/tags/pull-arm-devs-20130812' into staging
arm-devs queue # gpg: Signature made Mon 12 Aug 2013 05:58:14 AM CDT using RSA key ID 14360CDE # gpg: Can't check signature: public key not found # By Peter Maydell # Via Peter Maydell * pmaydell/tags/pull-arm-devs-20130812: hw/virtio/virtio-mmio: Make QueueNumMax read 0 for unavailable queues hw/virtio/virtio: Don't allow guests to add/remove queues Message-id: 1376305261-29561-1-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
| -rw-r--r-- | hw/virtio/virtio-mmio.c | 3 | ||||
| -rw-r--r-- | hw/virtio/virtio.c | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 88cf994b97..4bd29533f3 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -151,6 +151,9 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) } return proxy->host_features; case VIRTIO_MMIO_QUEUENUMMAX: + if (!virtio_queue_get_num(vdev, vdev->queue_sel)) { + return 0; + } return VIRTQUEUE_MAX_SIZE; case VIRTIO_MMIO_QUEUEPFN: return virtio_queue_get_addr(vdev, vdev->queue_sel) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 09f62c6c70..60653f764e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -673,10 +673,16 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n) void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) { - if (num <= VIRTQUEUE_MAX_SIZE) { - vdev->vq[n].vring.num = num; - virtqueue_init(&vdev->vq[n]); + /* Don't allow guest to flip queue between existent and + * nonexistent states, or to set it to an invalid size. + */ + if (!!num != !!vdev->vq[n].vring.num || + num > VIRTQUEUE_MAX_SIZE || + num < 0) { + return; } + vdev->vq[n].vring.num = num; + virtqueue_init(&vdev->vq[n]); } int virtio_queue_get_num(VirtIODevice *vdev, int n) |