qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 4/9] virtio: handle virtqueue_map_desc() erro


From: Cornelia Huck
Subject: Re: [Qemu-devel] [PATCH v4 4/9] virtio: handle virtqueue_map_desc() errors
Date: Wed, 21 Sep 2016 13:15:41 +0200

On Wed, 21 Sep 2016 09:02:35 +0200
Greg Kurz <address@hidden> wrote:

> On Tue, 20 Sep 2016 15:49:33 +0100
> Stefan Hajnoczi <address@hidden> wrote:
> 
> > Errors can occur during virtqueue_pop(), especially in
> > virtqueue_map_desc().  In order to handle this we must unmap iov[]
> > before returning NULL.  The caller will consider the virtqueue empty and
> > the virtio_error() call will have marked the device broken.
> > 
> > Signed-off-by: Stefan Hajnoczi <address@hidden>
> > ---
> 
> Hi Stefan,
> 
> FWIW, Prasad's "virtio: add check for descriptor's mapped address" is already
> in Michael's tree:
> 
> https://git.kernel.org/cgit/virt/kvm/mst/qemu.git/commit/?h=pci&id=13c9ed60de6faaed325804620d13e7be37ea8183
> 
> I guess this patch should take it into account (as already suggested by 
> Laszlo).

Agreed.

(...)

> > +/* Only used by error code paths before we have a VirtQueueElement 
> > (therefore
> > + * virtqueue_unmap_sg() can't be used).  Assumes buffers weren't written to
> > + * yet.
> > + */
> > +static void virtqueue_undo_map_desc(unsigned out_num, unsigned in_num,

Should the arguments use 'unsigned int' as well, for consistency's sake?

> > +                                    struct iovec *iov)
> > +{
> > +    unsigned int i;
> > +
> > +    for (i = 0; i < out_num + in_num; i++) {
> > +        int is_write = i >= out_num;
> > +
> > +        cpu_physical_memory_unmap(iov->iov_base, iov->iov_len, is_write, 
> > 0);
> > +        iov++;
> > +    }
> >  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]