Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 May 2018 14:46:07 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 228335] [patch] virtio indirect descriptors should use contiguous memory
Message-ID:  <bug-228335-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D228335

            Bug ID: 228335
           Summary: [patch] virtio indirect descriptors should use
                    contiguous memory
           Product: Base System
           Version: 11.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: nreilly@blackberry.com

virtio is allocating the standard descriptors using contigmalloc() but the
indirect descriptors using malloc(). This doesn't normally cause an issue
because the malloc() happens to get contiguous memory, but I was using a
different memory allocator and ran into this issue. In my scenario then the
virtio network driver caused QEMU on Linux to exit.=20

Index: sys/dev/virtio/virtqueue.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/dev/virtio/virtqueue.c  (revision 330873)
+++ sys/dev/virtio/virtqueue.c  (working copy)
@@ -249,7 +249,8 @@
        for (i =3D 0; i < vq->vq_nentries; i++) {
                dxp =3D &vq->vq_descx[i];

-               dxp->indirect =3D malloc(size, M_DEVBUF, M_NOWAIT);
+               dxp->indirect =3D contigmalloc(size, M_DEVBUF, M_NOWAIT,
+                   0, 0xFFFFFFFFUL, PAGE_SIZE, 0);
                if (dxp->indirect =3D=3D NULL) {
                        device_printf(dev, "cannot allocate indirect list\n=
");
                        return (ENOMEM);
@@ -274,7 +275,7 @@
                if (dxp->indirect =3D=3D NULL)
                        break;

-               free(dxp->indirect, M_DEVBUF);
+               contigfree(dxp->indirect, vq->vq_indirect_mem_size, M_DEVBU=
F);
                dxp->indirect =3D NULL;
                dxp->indirect_paddr =3D 0;
        }

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-228335-227>