From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: KONRAD Frederic <fred.konrad@greensocs.com>,
Anthony Liguori <aliguori@us.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
kvmarm@lists.cs.columbia.edu, patches@linaro.org
Subject: [Qemu-devel] [PATCH 1/2] hw/virtio/virtio: Don't allow guests to add/remove queues
Date: Thu, 25 Jul 2013 14:37:42 +0100 [thread overview]
Message-ID: <1374759463-6351-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1374759463-6351-1-git-send-email-peter.maydell@linaro.org>
A queue size of 0 is used to indicate a nonexistent queue, so
don't allow the guest to flip a queue between zero-size and
non-zero-size. Don't permit setting of negative queue sizes
either.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/virtio/virtio.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 09f62c6..d5b0502 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -673,10 +673,14 @@ 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]);
+ if ((num == 0 && vdev->vq[n].vring.num != 0) ||
+ (num != 0 && vdev->vq[n].vring.num == 0) ||
+ (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)
--
1.7.9.5
next prev parent reply other threads:[~2013-07-25 13:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 13:37 [Qemu-devel] [PATCH 0/2] virtio-mmio: fixes to QueueNum, QueueNumMax Peter Maydell
2013-07-25 13:37 ` Peter Maydell [this message]
2013-07-25 22:33 ` [Qemu-devel] [PATCH 1/2] hw/virtio/virtio: Don't allow guests to add/remove queues Michael S. Tsirkin
2013-07-25 22:37 ` Peter Maydell
2013-07-25 23:27 ` Michael S. Tsirkin
2013-07-26 8:05 ` Peter Maydell
2013-07-28 6:54 ` Michael S. Tsirkin
2013-07-25 13:37 ` [Qemu-devel] [PATCH 2/2] hw/virtio/virtio-mmio: Make QueueNumMax read 0 for unavailable queues Peter Maydell
2013-07-25 22:34 ` Michael S. Tsirkin
2013-07-25 22:37 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374759463-6351-2-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aliguori@us.ibm.com \
--cc=fred.konrad@greensocs.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=mst@redhat.com \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).