1. 13 3月, 2014 2 次提交
    • R
      virtio: fail adding buffer on broken queues. · 70670444
      Rusty Russell 提交于
      Heinz points out that adding buffers to a broken virtqueue (which
      should "never happen") still works.  Failing allows drivers to detect
      and complain about broken devices.
      
      Now drivers are robust, we can add this extra check.
      Reported-by: NHeinz Graalfs <graalfs@linux.vnet.ibm.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      70670444
    • J
      tools/virtio: fix missing kmemleak_ignore symbol · 6abb2dd9
      Joel Stanley 提交于
      In commit bb478d8b virtio_ring: plug kmemleak false positive,
      kmemleak_ignore was introduced. This broke compilation of virtio_test:
      
        cc -g -O2 -Wall -I. -I ../../usr/include/ -Wno-pointer-sign
          -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD
          -U_FORTIFY_SOURCE   -c -o virtio_ring.o ../../drivers/virtio/virtio_ring.c
        ../../drivers/virtio/virtio_ring.c: In function ‘vring_add_indirect’:
        ../../drivers/virtio/virtio_ring.c:177:2: warning: implicit declaration
        of function ‘kmemleak_ignore’ [-Wimplicit-function-declaration]
          kmemleak_ignore(desc);
          ^
        cc   virtio_test.o virtio_ring.o   -o virtio_test
        virtio_ring.o: In function `vring_add_indirect':
        tools/virtio/../../drivers/virtio/virtio_ring.c:177:
        undefined reference to `kmemleak_ignore'
      
      Add a dummy header for tools/virtio, and add #incldue <linux/kmemleak.h>
      to drivers/virtio/virtio_ring.c so it is picked up by the userspace
      tools.
      Signed-off-by: NJoel Stanley <joel@jms.id.au>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      6abb2dd9
  2. 05 11月, 2013 1 次提交
  3. 29 10月, 2013 3 次提交
  4. 17 10月, 2013 1 次提交
    • R
      virtio_ring: plug kmemleak false positive. · bb478d8b
      Rusty Russell 提交于
      unreferenced object 0xffff88003d467e20 (size 32):
        comm "softirq", pid 0, jiffies 4295197765 (age 6.364s)
        hex dump (first 32 bytes):
          28 19 bf 3d 00 00 00 00 0c 00 00 00 01 00 01 00  (..=............
          02 dc 51 3c 00 00 00 00 56 00 00 00 00 00 00 00  ..Q<....V.......
        backtrace:
          [<ffffffff8152db19>] kmemleak_alloc+0x59/0xc0
          [<ffffffff81102e93>] __kmalloc+0xf3/0x180
          [<ffffffff812db5d6>] vring_add_indirect+0x36/0x280
          [<ffffffff812dc59f>] virtqueue_add_outbuf+0xbf/0x4e0
          [<ffffffff813a8b30>] start_xmit+0x1a0/0x3b0
          [<ffffffff81445861>] dev_hard_start_xmit+0x2d1/0x4d0
          [<ffffffff81460052>] sch_direct_xmit+0xf2/0x1c0
          [<ffffffff81445c28>] dev_queue_xmit+0x1c8/0x460
          [<ffffffff814e3187>] ip6_finish_output2+0x1d7/0x470
          [<ffffffff814e34b0>] ip6_finish_output+0x90/0xb0
          [<ffffffff814e3507>] ip6_output+0x37/0xb0
          [<ffffffff815021eb>] igmp6_send+0x2db/0x470
          [<ffffffff81502645>] igmp6_timer_handler+0x95/0xa0
          [<ffffffff8104b57c>] call_timer_fn+0x2c/0x90
          [<ffffffff8104b7ba>] run_timer_softirq+0x1da/0x1f0
          [<ffffffff81045721>] __do_softirq+0xd1/0x1b0
      
      Address gets embedded in a descriptor via virt_to_phys().  See detach_buf,
      which frees it:
      
      	if (vq->vring.desc[i].flags & VRING_DESC_F_INDIRECT)
      		kfree(phys_to_virt(vq->vring.desc[i].addr));
      Reported-by: NChristoph Paasch <christoph.paasch@uclouvain.be>
      Fix-suggested-by: NChristoph Paasch <christoph.paasch@uclouvain.be>
      Typing-done-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      bb478d8b
  5. 10 7月, 2013 1 次提交
  6. 20 5月, 2013 1 次提交
  7. 20 3月, 2013 3 次提交
  8. 18 12月, 2012 2 次提交
  9. 22 10月, 2012 1 次提交
    • W
      virtio: force vring descriptors to be allocated from lowmem · b92b1b89
      Will Deacon 提交于
      Virtio devices may attempt to add descriptors to a virtqueue from atomic
      context using GFP_ATOMIC allocation. This is problematic because such
      allocations can fall outside of the lowmem mapping, causing virt_to_phys
      to report bogus physical addresses which are subsequently passed to
      userspace via the buffers for the virtual device.
      
      This patch masks out __GFP_HIGH and __GFP_HIGHMEM from the requested
      flags when allocating descriptors for a virtqueue. If an atomic
      allocation is requested and later fails, we will return -ENOSPC which
      will be handled by the driver.
      
      Cc: stable@kernel.org
      Cc: Sasha Levin <levinsasha928@gmail.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      b92b1b89
  10. 28 9月, 2012 1 次提交
  11. 28 1月, 2012 2 次提交
  12. 12 1月, 2012 7 次提交
  13. 01 11月, 2011 1 次提交
  14. 24 10月, 2011 1 次提交
  15. 30 5月, 2011 2 次提交
    • M
      virtio: add api for delayed callbacks · 7ab358c2
      Michael S. Tsirkin 提交于
      Add an API that tells the other side that callbacks
      should be delayed until a lot of work has been done.
      Implement using the new event_idx feature.
      
      Note: it might seem advantageous to let the drivers
      ask for a callback after a specific capacity has
      been reached. However, as a single head can
      free many entries in the descriptor table,
      we don't really have a clue about capacity
      until get_buf is called. The API is the simplest
      to implement at the moment, we'll see what kind of
      hints drivers can pass when there's more than one
      user of the feature.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      7ab358c2
    • M
      virtio_ring: support event idx feature · a5c262c5
      Michael S. Tsirkin 提交于
      Support for the new event idx feature:
      1. When enabling interrupts, publish the current avail index
         value to the host to get interrupts on the next update.
      2. Use the new avail_event feature to reduce the number
         of exits from the guest.
      
      Simple test with the simulator:
      
      [virtio]# time ./virtio_test
      spurious wakeus: 0x7
      
      real    0m0.169s
      user    0m0.140s
      sys     0m0.019s
      [virtio]# time ./virtio_test --no-event-idx
      spurious wakeus: 0x11
      
      real    0m0.649s
      user    0m0.295s
      sys     0m0.335s
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      a5c262c5
  16. 21 4月, 2011 1 次提交
  17. 24 11月, 2010 1 次提交
  18. 26 7月, 2010 1 次提交
  19. 23 6月, 2010 1 次提交
  20. 19 5月, 2010 2 次提交
  21. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  22. 24 2月, 2010 4 次提交
    • A
      virtio: Initialize vq->data entries to NULL · 3b870624
      Amit Shah 提交于
      vq operations depend on vq->data[i] being NULL to figure out if the vq
      entry is in use (since the previous patch).
      
      We have to initialize them to NULL to ensure we don't work with junk
      data and trigger false BUG_ONs.
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Shirley Ma <xma@us.ibm.com>
      3b870624
    • S
      virtio: Add ability to detach unused buffers from vrings · c021eac4
      Shirley Ma 提交于
      There's currently no way for a virtio driver to ask for unused
      buffers, so it has to keep a list itself to reclaim them at shutdown.
      This is redundant, since virtio_ring stores that information.  So
      add a new hook to do this.
      Signed-off-by: NShirley Ma <xma@us.ibm.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      c021eac4
    • M
      virtio: use smp_XX barriers on SMP · d57ed95d
      Michael S. Tsirkin 提交于
      virtio is communicating with a virtual "device" that actually runs on
      another host processor. Thus SMP barriers can be used to control
      memory access ordering.
      
      Where possible, we should use SMP barriers which are more lightweight than
      mandatory barriers, because mandatory barriers also control MMIO effects on
      accesses through relaxed memory I/O windows (which virtio does not use)
      (compare specifically smp_rmb and rmb on x86_64).
      
      We can't just use smp_mb and friends though, because
      we must force memory ordering even if guest is UP since host could be
      running on another CPU, but SMP barriers are defined to barrier() in
      that configuration. So, for UP fall back to mandatory barriers instead.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      d57ed95d
    • R
      virtio: remove bogus barriers from DEBUG version of virtio_ring.c · 97a545ab
      Rusty Russell 提交于
      With DEBUG defined, we add an ->in_use flag to detect if the caller
      invokes two virtio methods in parallel.  The barriers attempt to ensure
      timely update of the ->in_use flag.
      
      But they're voodoo: if we need these barriers it implies that the
      calling code doesn't have sufficient synchronization to ensure the
      code paths aren't invoked at the same time anyway, and we want to
      detect it.
      
      Also, adding barriers changes timing, so turning on debug has more
      chance of hiding real problems.
      
      Thanks to MST for drawing my attention to this code...
      
      CC: Michael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      97a545ab