[Bug 228335] [patch] virtio indirect descriptors should use contiguous memory

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri May 18 14:46:10 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228335

            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 at FreeBSD.org
          Reporter: nreilly at 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. 

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

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

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

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


More information about the freebsd-bugs mailing list