From: Denis Plotnikov <dplotnikov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com
Subject: [PATCH v1] virtio: stregthen virtqueue size invariants
Date: Mon, 23 Dec 2019 16:18:20 +0300 [thread overview]
Message-ID: <20191223131820.19300-1-dplotnikov@virtuozzo.com> (raw)
1. virtqueue_size is a power of 2
2. virtqueue_size > 2, since seg_max is virtqueue_size - 2
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
---
hw/virtio/virtio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 04716b5f6c..e3ab69061e 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2166,7 +2166,8 @@ void virtio_queue_set_num(VirtIODevice *vdev, int n, int num)
*/
if (!!num != !!vdev->vq[n].vring.num ||
num > VIRTQUEUE_MAX_SIZE ||
- num < 0) {
+ num < 2 ||
+ !is_power_of_2(num)) {
return;
}
vdev->vq[n].vring.num = num;
--
2.17.0
next reply other threads:[~2019-12-23 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-23 13:18 Denis Plotnikov [this message]
2020-01-02 14:55 ` [PATCH v1] virtio: stregthen virtqueue size invariants Stefan Hajnoczi
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=20191223131820.19300-1-dplotnikov@virtuozzo.com \
--to=dplotnikov@virtuozzo.com \
--cc=mst@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.