[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1] virtio: stregthen virtqueue size invariants
From: |
Denis Plotnikov |
Subject: |
[PATCH v1] virtio: stregthen virtqueue size invariants |
Date: |
Mon, 23 Dec 2019 16:18:20 +0300 |
1. virtqueue_size is a power of 2
2. virtqueue_size > 2, since seg_max is virtqueue_size - 2
Signed-off-by: Denis Plotnikov <address@hidden>
---
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH v1] virtio: stregthen virtqueue size invariants,
Denis Plotnikov <=