27 Feb, 2013

1 commit

  • Pull virtio updates from Rusty Russell:
    "All trivial, thanks to the stuff which didn't quite make it time"

    * tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    virtio_console: Initialize guest_connected=true for rproc_serial
    virtio: use module_virtio_driver.
    virtio: Add module driver macro for virtio drivers.
    virtio_console: Use virtio device index to generate port name
    virtio: make pci_device_id const
    virtio: make config_ops const
    virtio-mmio: fix wrong comment about register offset
    virtio_console: Let unconnected rproc device receive data.

    Linus Torvalds
     

13 Feb, 2013

1 commit


11 Feb, 2013

2 commits


04 Feb, 2013

1 commit


12 Jan, 2013

1 commit

  • The CONFIG_EXPERIMENTAL config item has not carried much meaning for a
    while now and is almost always enabled by default. As agreed during the
    Linux kernel summit, remove it from any "depends on" lines in Kconfigs.

    CC: Rusty Russell
    CC: "Michael S. Tsirkin"
    Signed-off-by: Kees Cook
    Acked-by: Rusty Russell

    Kees Cook
     

04 Jan, 2013

1 commit

  • CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
    markings need to be removed.

    This change removes the use of __devinit, __devexit_p, and __devexit
    from these drivers.

    Based on patches originally written by Bill Pemberton, but redone by me
    in order to handle some of the coding style issues better, by hand.

    Cc: Bill Pemberton
    Cc: Rusty Russell
    Cc: "Michael S. Tsirkin"
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

21 Dec, 2012

1 commit

  • Pull virtio update from Rusty Russell:
    "Some nice cleanups, and even a patch my wife did as a "live" demo for
    Latinoware 2012.

    There's a slightly non-trivial merge in virtio-net, as we cleaned up
    the virtio add_buf interface while DaveM accepted the mq virtio-net
    patches."

    * tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: (27 commits)
    virtio_console: Add support for remoteproc serial
    virtio_console: Merge struct buffer_token into struct port_buffer
    virtio: add drv_to_virtio to make code clearly
    virtio: use dev_to_virtio wrapper in virtio
    virtio-mmio: Fix irq parsing in command line parameter
    virtio_console: Free buffers from out-queue upon close
    virtio: Convert dev_printk(KERN_ to dev_(
    virtio_console: Use kmalloc instead of kzalloc
    virtio_console: Free buffer if splice fails
    virtio: tools: make it clear that virtqueue_add_buf() no longer returns > 0
    virtio: scsi: make it clear that virtqueue_add_buf() no longer returns > 0
    virtio: rpmsg: make it clear that virtqueue_add_buf() no longer returns > 0
    virtio: net: make it clear that virtqueue_add_buf() no longer returns > 0
    virtio: console: make it clear that virtqueue_add_buf() no longer returns > 0
    virtio: make virtqueue_add_buf() returning 0 on success, not capacity.
    virtio: console: don't rely on virtqueue_add_buf() returning capacity.
    virtio_net: don't rely on virtqueue_add_buf() returning capacity.
    virtio-net: remove unused skb_vnet_hdr->num_sg field
    virtio-net: correct capacity math on ring full
    virtio: move queue_index and num_free fields into core struct virtqueue.
    ...

    Linus Torvalds
     

18 Dec, 2012

7 commits


12 Dec, 2012

1 commit

  • Memory fragmentation introduced by ballooning might reduce significantly
    the number of 2MB contiguous memory blocks that can be used within a guest,
    thus imposing performance penalties associated with the reduced number of
    transparent huge pages that could be used by the guest workload.

    Besides making balloon pages movable at allocation time and introducing
    the necessary primitives to perform balloon page migration/compaction,
    this patch also introduces the following locking scheme, in order to
    enhance the syncronization methods for accessing elements of struct
    virtio_balloon, thus providing protection against concurrent access
    introduced by parallel memory migration threads.

    - balloon_lock (mutex) : synchronizes the access demand to elements of
    struct virtio_balloon and its queue operations;

    [yongjun_wei@trendmicro.com.cn: fix missing unlock on error in fill_balloon()]
    [akpm@linux-foundation.org: avoid having multiple return points in fill_balloon()]
    [akpm@linux-foundation.org: fix printk warning]Signed-off-by: Rafael Aquini
    Acked-by: Michael S. Tsirkin
    Cc: Rusty Russell
    Cc: Rik van Riel
    Cc: Mel Gorman
    Cc: Andi Kleen
    Cc: Konrad Rzeszutek Wilk
    Cc: Minchan Kim
    Signed-off-by: Wei Yongjun

    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael Aquini
     

09 Nov, 2012

1 commit

  • Virtio wants to release used indices after the corresponding
    virtio device has been unregistered. However, virtio does not
    hold an extra reference, giving up its last reference with
    device_unregister(), making accessing dev->index afterwards
    invalid.

    I actually saw problems when testing my (not-yet-merged)
    virtio-ccw code:

    - device_add virtio-net,id=xxx
    -> creates device virtio with n>0

    - device_del xxx
    -> deletes virtio, but calls ida_simple_remove with an
    index of 0

    - device_add virtio-net,id=xxx
    -> tries to add virtio0, which is still in use...

    So let's save the index we want to release before calling
    device_unregister().

    Signed-off-by: Cornelia Huck
    Acked-by: Sjur Brændeland
    Cc: stable@kernel.org
    Signed-off-by: Rusty Russell

    Cornelia Huck
     

22 Oct, 2012

1 commit

  • 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
    Signed-off-by: Will Deacon
    Signed-off-by: Rusty Russell

    Will Deacon
     

28 Sep, 2012

11 commits

  • If a virtio device reports a QueueNumMax of 0, vring_new_virtqueue()
    doesn't check this, and thanks to an unsigned (i < num - 1) loop
    guard, scribbles over memory when initialising the free list.

    Avoid by not trying to create zero-descriptor queues, as there's no
    way to do any I/O with one.

    Signed-off-by: Brian Foley
    Signed-off-by: Pawel Moll
    Signed-off-by: Rusty Russell

    Brian Foley
     
  • vm_setup_vq fails to allow VirtQueues needing only 2 pages of
    storage, as it should. Found with a kernel using 64kB pages, but
    can be provoked if a virtio device reports QueueNumMax where the
    descriptor table and available ring fit in one page, and the used
    ring on the second (
    Signed-off-by: Pawel Moll
    Signed-off-by: Rusty Russell

    Brian Foley
     
  • Convert a nonnegative error return code to a negative one, as returned
    elsewhere in the function.

    A simplified version of the semantic match that finds this problem is as
    follows: (http://coccinelle.lip6.fr/)

    //
    (
    if@p1 (\(ret < 0\|ret != 0\))
    { ... return ret; }
    |
    ret@p1 = 0
    )
    ... when != ret = e1
    when != &ret
    *if(...)
    {
    ... when != ret = e2
    when forall
    return ret;
    }
    //

    Signed-off-by: Peter Senna Tschudin
    Signed-off-by: Rusty Russell

    Peter Senna Tschudin
     
  • Because of a sanity check in virtio_dev_remove, a buggy device can crash
    kernel. And in case of rproc it's userspace so it's not a good idea.
    We are unloading a driver so how bad can it be?
    Be less aggressive in handling this error: if it's a driver bug,
    warning once should be enough.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Rusty Russell

    Michael S. Tsirkin
     
  • Everyone who selects VIRTIO is also made to select VIRTIO_RING; just make
    them synonymous, since we removed the indirection layer some time ago.

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • Trying to enable a virtio driver (eg CONFIG_VIRTIO_BLK) is painful
    because it depends on CONFIG_VIRTIO. CONFIG_VIRTIO doesn't tell you
    how to turn it on (it's selected from anything which provides a virtio
    bus).

    This patch at least adds some documentation, visible in menuconfig, as
    a hint.

    Reported-by: Kent Overstreet
    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • virtio network device multiqueue support reserves
    vq 3 for future use (useful both for future extensions and to make it
    pretty - this way receive vqs have even and transmit - odd numbers).
    Make it possible to skip initialization for
    specific vq numbers by specifying NULL for name.
    Document this usage as well as (existing) NULL callback.

    Drivers using this not coded up yet, so I simply tested
    with virtio-pci and verified that this patch does
    not break existing drivers.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Rusty Russell

    Michael S. Tsirkin
     
  • Sometimes, virtio device need to configure irq affinity hint to maximize the
    performance. Instead of just exposing the irq of a virtqueue, this patch
    introduce an API to set the affinity for a virtqueue.

    The api is best-effort, the affinity hint may not be set as expected due to
    platform support, irq sharing or irq type. Currently, only pci method were
    implemented and we set the affinity according to:

    - if device uses INTX, we just ignore the request
    - if device has per vq vector, we force the affinity hint
    - if the virtqueues share MSI, make the affinity OR over all affinities
    requested

    Signed-off-by: Jason Wang
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Rusty Russell

    Jason Wang
     
  • Instead of storing the queue index in transport-specific virtio structs,
    this patch moves them to vring_virtqueue and introduces an helper to get
    the value. This lets drivers simplify their management and tracing of
    virtqueues.

    Signed-off-by: Jason Wang
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Rusty Russell

    Jason Wang
     
  • It is not experimental in any vaguely-sane sense.

    Reported-by: Michael S. Tsirkin
    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • Devices should depend on virtio, not select it. It's supposed to be
    selected by the particular driver, e.g. VIRTIO_PCI.
    Make balloon depend on VIRTIO and EXPERIMENTAL
    (to match description).

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Rusty Russell

    Michael S. Tsirkin
     

20 Jul, 2012

1 commit

  • This patch changes virtio-scsi to use a new virtio_driver->scan() callback
    so that scsi_scan_host() can be properly invoked once virtio_dev_probe() has
    set add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK) to signal active virtio-ring
    operation, instead of from within virtscsi_probe().

    This fixes a bug where SCSI LUN scanning for both virtio-scsi-raw and
    virtio-scsi/tcm_vhost setups was happening before VIRTIO_CONFIG_S_DRIVER_OK
    had been set, causing VIRTIO_SCSI_S_BAD_TARGET to occur. This fixes a bug
    with virtio-scsi/tcm_vhost where LUN scan was not detecting LUNs.

    Tested with virtio-scsi-raw + virtio-scsi/tcm_vhost w/ IBLOCK on 3.5-rc2 code.

    Signed-off-by: Nicholas Bellinger
    Acked-by: Paolo Bonzini
    Signed-off-by: James Bottomley

    Nicholas Bellinger
     

09 Jul, 2012

1 commit

  • Since ee7cd8981e15bcb365fc762afe3fc47b8242f630 'virtio: expose added
    descriptors immediately.', in virtio balloon virtqueue_get_buf might
    now run concurrently with virtqueue_kick. I audited both and this
    seems safe in practice but this is not guaranteed by the API.
    Additionally, a spurious interrupt might in theory make
    virtqueue_get_buf run in parallel with virtqueue_add_buf, which is
    racy.

    While we might try to protect against spurious callbacks it's
    easier to fix the driver: balloon seems to be the only one
    (mis)using the API like this, so let's just fix balloon.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Rusty Russell (removed unused var)

    Michael S. Tsirkin
     

22 May, 2012

4 commits


17 May, 2012

1 commit

  • When the balloon module is removed, we deflate the balloon, reclaiming
    all the pages that were given to the host. However, we don't update the
    config values for the new balloon size, resulting in the host showing
    outdated balloon values.

    The size update is done after each leak and fill operation, only the
    module removal case was left out.

    Signed-off-by: Amit Shah
    Signed-off-by: Michael S. Tsirkin

    Amit Shah
     

15 Apr, 2012

2 commits

  • As reported by David Gibson, current code handles PAGE_SIZE != 4k
    completely wrong which can lead to guest memory corruption errors:

    - page_to_balloon_pfn is wrong: e.g. on system with 64K page size
    it gives the same pfn value for 16 different pages.

    - we also need to convert back to linux pfns when we free.

    - for each linux page we need to tell host about multiple balloon
    pages, but code only adds one pfn to the array.

    This patch fixes all that, tested with a 64k ppc64 kernel.

    Reported-by: David Gibson
    Tested-by: David Gibson
    Signed-off-by: Michael S. Tsirkin

    Michael S. Tsirkin
     
  • Although virtio config space fields are usually in guest-native endian,
    the spec for the virtio balloon device explicitly states that both fields
    in its config space are little-endian.

    However, the current virtio_balloon driver does not have a suitable endian
    swap for the 'num_pages' field, although it does have one for the 'actual'
    field. This patch corrects the bug, adding sparse annotation while we're
    at it.

    Signed-off-by: David Gibson
    Signed-off-by: Michael S. Tsirkin

    David Gibson
     

31 Mar, 2012

2 commits