* [PATCH 0/2] virtio-mmio updates for 3.7
@ 2012-09-24 13:33 Pawel Moll
2012-09-24 13:33 ` [PATCH 1/2] virtio_mmio: fix off by one error allocating queue Pawel Moll
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Pawel Moll @ 2012-09-24 13:33 UTC (permalink / raw)
To: Rusty Russell; +Cc: Brian Foley, Pawel Moll, virtualization
Hi Rusty,
Would you be so kind and consider getting those two small fixes into
3.7 merge? All credits go to Brian, all shame on me :-)
Cheers!
Pawel
Brian Foley (2):
virtio_mmio: fix off by one error allocating queue
virtio_mmio: Don't attempt to create empty virtqueues
drivers/virtio/virtio_mmio.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] virtio_mmio: fix off by one error allocating queue
2012-09-24 13:33 [PATCH 0/2] virtio-mmio updates for 3.7 Pawel Moll
@ 2012-09-24 13:33 ` Pawel Moll
2012-09-24 13:33 ` [PATCH 2/2] virtio_mmio: Don't attempt to create empty virtqueues Pawel Moll
2012-09-25 0:11 ` [PATCH 0/2] virtio-mmio updates for 3.7 Rusty Russell
2 siblings, 0 replies; 7+ messages in thread
From: Pawel Moll @ 2012-09-24 13:33 UTC (permalink / raw)
To: Rusty Russell; +Cc: Brian Foley, Pawel Moll, virtualization
From: Brian Foley <brian.foley@arm.com>
vm_setup_vq fails to allow VirtQueues needing only 2 pages of
storage, as it should. Found with a kernel using 64kB pages, but
can be provoked if a virtio device reports QueueNumMax where the
descriptor table and available ring fit in one page, and the used
ring on the second (<= 227 descriptors with 4kB pages and <= 3640
with 64kB pages.)
Signed-off-by: Brian Foley <brian.foley@arm.com>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
drivers/virtio/virtio_mmio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 453db0c..58e2d78 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -335,8 +335,8 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index,
while (1) {
size = PAGE_ALIGN(vring_size(info->num,
VIRTIO_MMIO_VRING_ALIGN));
- /* Already smallest possible allocation? */
- if (size <= VIRTIO_MMIO_VRING_ALIGN * 2) {
+ /* Did the last iter shrink the queue below minimum size? */
+ if (size < VIRTIO_MMIO_VRING_ALIGN * 2) {
err = -ENOMEM;
goto error_alloc_pages;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] virtio_mmio: Don't attempt to create empty virtqueues
2012-09-24 13:33 [PATCH 0/2] virtio-mmio updates for 3.7 Pawel Moll
2012-09-24 13:33 ` [PATCH 1/2] virtio_mmio: fix off by one error allocating queue Pawel Moll
@ 2012-09-24 13:33 ` Pawel Moll
2012-09-25 0:11 ` [PATCH 0/2] virtio-mmio updates for 3.7 Rusty Russell
2 siblings, 0 replies; 7+ messages in thread
From: Pawel Moll @ 2012-09-24 13:33 UTC (permalink / raw)
To: Rusty Russell; +Cc: Brian Foley, Pawel Moll, virtualization
From: Brian Foley <brian.foley@arm.com>
If a virtio device reports a QueueNumMax of 0, vring_new_virtqueue()
doesn't check this, and thanks to an unsigned (i < num - 1) loop
guard, scribbles over memory when initialising the free list.
Avoid by not trying to create zero-descriptor queues, as there's no
way to do any I/O with one.
Signed-off-by: Brian Foley <brian.foley@arm.com>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
drivers/virtio/virtio_mmio.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 58e2d78..6979c1b 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -332,6 +332,16 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index,
* and two rings (which makes it "alignment_size * 2")
*/
info->num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM_MAX);
+
+ /* If the device reports a 0 entry queue, we won't be able to
+ * use it to perform I/O, and vring_new_virtqueue() can't create
+ * empty queues anyway, so don't bother to set up the device.
+ */
+ if (info->num == 0) {
+ err = -ENOENT;
+ goto error_alloc_pages;
+ }
+
while (1) {
size = PAGE_ALIGN(vring_size(info->num,
VIRTIO_MMIO_VRING_ALIGN));
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] virtio-mmio updates for 3.7
2012-09-24 13:33 [PATCH 0/2] virtio-mmio updates for 3.7 Pawel Moll
2012-09-24 13:33 ` [PATCH 1/2] virtio_mmio: fix off by one error allocating queue Pawel Moll
2012-09-24 13:33 ` [PATCH 2/2] virtio_mmio: Don't attempt to create empty virtqueues Pawel Moll
@ 2012-09-25 0:11 ` Rusty Russell
2012-09-25 11:12 ` Pawel Moll
2 siblings, 1 reply; 7+ messages in thread
From: Rusty Russell @ 2012-09-25 0:11 UTC (permalink / raw)
Cc: Brian Foley, Pawel Moll, virtualization
Pawel Moll <pawel.moll@arm.com> writes:
> Hi Rusty,
>
> Would you be so kind and consider getting those two small fixes into
> 3.7 merge? All credits go to Brian, all shame on me :-)
Should these also be cc'd to stable@kernel.org?
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] virtio-mmio updates for 3.7
2012-09-25 0:11 ` [PATCH 0/2] virtio-mmio updates for 3.7 Rusty Russell
@ 2012-09-25 11:12 ` Pawel Moll
2012-09-26 0:10 ` Rusty Russell
0 siblings, 1 reply; 7+ messages in thread
From: Pawel Moll @ 2012-09-25 11:12 UTC (permalink / raw)
To: Rusty Russell; +Cc: virtualization@lists.linux-foundation.org, Brian Foley
On Tue, 2012-09-25 at 01:11 +0100, Rusty Russell wrote:
> > Would you be so kind and consider getting those two small fixes into
> > 3.7 merge? All credits go to Brian, all shame on me :-)
>
> Should these also be cc'd to stable@kernel.org?
I was thinking about it, but as the problem manifests itself mainly on
architectures with large page size, the impact is limited.
But if you think it's worth it, I will repost with Cc: stable.
Cheers!
Paweł
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] virtio-mmio updates for 3.7
2012-09-25 11:12 ` Pawel Moll
@ 2012-09-26 0:10 ` Rusty Russell
2012-09-27 16:33 ` Pawel Moll
0 siblings, 1 reply; 7+ messages in thread
From: Rusty Russell @ 2012-09-26 0:10 UTC (permalink / raw)
To: Pawel Moll; +Cc: virtualization@lists.linux-foundation.org, Brian Foley
Pawel Moll <pawel.moll@arm.com> writes:
> On Tue, 2012-09-25 at 01:11 +0100, Rusty Russell wrote:
>> > Would you be so kind and consider getting those two small fixes into
>> > 3.7 merge? All credits go to Brian, all shame on me :-)
>>
>> Should these also be cc'd to stable@kernel.org?
>
> I was thinking about it, but as the problem manifests itself mainly on
> architectures with large page size, the impact is limited.
>
> But if you think it's worth it, I will repost with Cc: stable.
I agree with you. But if it's not CC' stable, it's not for 3.7 either,
since at this late stage the rules are basically synonymous.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] virtio-mmio updates for 3.7
2012-09-26 0:10 ` Rusty Russell
@ 2012-09-27 16:33 ` Pawel Moll
0 siblings, 0 replies; 7+ messages in thread
From: Pawel Moll @ 2012-09-27 16:33 UTC (permalink / raw)
To: Rusty Russell; +Cc: virtualization@lists.linux-foundation.org, Brian Foley
On Wed, 2012-09-26 at 01:10 +0100, Rusty Russell wrote:
> > I was thinking about it, but as the problem manifests itself mainly on
> > architectures with large page size, the impact is limited.
> >
> > But if you think it's worth it, I will repost with Cc: stable.
>
> I agree with you. But if it's not CC' stable, it's not for 3.7 either,
> since at this late stage the rules are basically synonymous.
Ok, let's postpone it till 3.8 for now, than. If we find out that this
is a real problem I'll re-post it with Cc: stable around 3.7-rc2, 3.
Cheers!
Pawel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-09-27 16:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-24 13:33 [PATCH 0/2] virtio-mmio updates for 3.7 Pawel Moll
2012-09-24 13:33 ` [PATCH 1/2] virtio_mmio: fix off by one error allocating queue Pawel Moll
2012-09-24 13:33 ` [PATCH 2/2] virtio_mmio: Don't attempt to create empty virtqueues Pawel Moll
2012-09-25 0:11 ` [PATCH 0/2] virtio-mmio updates for 3.7 Rusty Russell
2012-09-25 11:12 ` Pawel Moll
2012-09-26 0:10 ` Rusty Russell
2012-09-27 16:33 ` Pawel Moll
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).