Re: [PATCH 1/2] virtio: Reduce BUG if total_sg > virtqueue size to WARN.

From: Richard W.M. Jones
Date: Thu Aug 10 2017 - 17:50:20 EST


On Fri, Aug 11, 2017 at 12:41:47AM +0300, Michael S. Tsirkin wrote:
> On Thu, Aug 10, 2017 at 10:35:11PM +0100, Richard W.M. Jones wrote:
> > On Fri, Aug 11, 2017 at 12:31:44AM +0300, Michael S. Tsirkin wrote:
> > > Then we probably should fail probe if vq size is too small.
> >
> > What does this mean?
> >
> > Rich.
>
> We must prevent driver from submitting s/g lists > vq size to device.

Fair point. I would have thought (not knowing anything about how this
works in the kernel) that the driver should be able to split up
scatter-gather lists if they are larger than what the driver supports?

Anyway the commit message is derived from what Paolo told me on IRC,
so let's see what he says.

Rich.

> Either tell linux to avoid s/g lists that are too long, or
> simply fail request if this happens, or refuse to attach driver to device.
>
> Later option would look something like this within probe:
>
> for (i = VIRTIO_SCSI_VQ_BASE; i < num_vqs; i++)
> if (vqs[i]->num < MAX_SG_USED_BY_LINUX)
> goto err;
>
>
> I don't know what's MAX_SG_USED_BY_LINUX though.
>
> > --
> > Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> > Read my programming and virtualization blog: http://rwmj.wordpress.com
> > virt-builder quickly builds VMs from scratch
> > http://libguestfs.org/virt-builder.1.html

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html