16 Oct, 2009

1 commit


04 Oct, 2009

1 commit


02 Oct, 2009

1 commit


28 Sep, 2009

1 commit


24 Sep, 2009

1 commit


10 Sep, 2009

35 commits

  • This code is not executed before file has been initialized to the result of
    calling eventfd_fget. This function returns an ERR_PTR value in an error
    case instead of NULL. Thus the test that file is not NULL is always true.

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

    //
    @match exists@
    expression x, E;
    statement S1, S2;
    @@

    x = eventfd_fget(...)
    ... when != x = E
    (
    * if (x == NULL || ...) S1 else S2
    |
    * if (x == NULL && ...) S1 else S2
    )
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Avi Kivity

    Julia Lawall
     
  • CC arch/s390/kvm/../../../virt/kvm/kvm_main.o
    arch/s390/kvm/../../../virt/kvm/kvm_main.c: In function '__kvm_set_memory_region':
    arch/s390/kvm/../../../virt/kvm/kvm_main.c:485: warning: unused variable 'j'
    arch/s390/kvm/../../../virt/kvm/kvm_main.c:484: warning: unused variable 'lpages'
    arch/s390/kvm/../../../virt/kvm/kvm_main.c:483: warning: unused variable 'ugfn'

    Cc: Carsten Otte
    Signed-off-by: Heiko Carstens
    Signed-off-by: Marcelo Tosatti

    Heiko Carstens
     
  • This bug was introduced by b4a2f5e723e4f7df467.

    Cc: stable@kernel.org
    Signed-off-by: Gleb Natapov
    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • The symbol only controls irq routing, not MSI-X.

    Signed-off-by: Avi Kivity

    Avi Kivity
     
  • Remove debugfs file if kvm_arch_init() return error

    Signed-off-by: Xiao Guangrong
    Signed-off-by: Avi Kivity

    Xiao Guangrong
     
  • spin_lock disables preemption, so we can simply read the current cpu.

    Signed-off-by: Jan Kiszka
    Signed-off-by: Marcelo Tosatti

    Jan Kiszka
     
  • Remove kvm_cpu_has_interrupt() and kvm_arch_interrupt_allowed() from
    interface between general code and arch code. kvm_arch_vcpu_runnable()
    checks for interrupts instead.

    Signed-off-by: Gleb Natapov
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • ioeventfd is a mechanism to register PIO/MMIO regions to trigger an eventfd
    signal when written to by a guest. Host userspace can register any
    arbitrary IO address with a corresponding eventfd and then pass the eventfd
    to a specific end-point of interest for handling.

    Normal IO requires a blocking round-trip since the operation may cause
    side-effects in the emulated model or may return data to the caller.
    Therefore, an IO in KVM traps from the guest to the host, causes a VMX/SVM
    "heavy-weight" exit back to userspace, and is ultimately serviced by qemu's
    device model synchronously before returning control back to the vcpu.

    However, there is a subclass of IO which acts purely as a trigger for
    other IO (such as to kick off an out-of-band DMA request, etc). For these
    patterns, the synchronous call is particularly expensive since we really
    only want to simply get our notification transmitted asychronously and
    return as quickly as possible. All the sychronous infrastructure to ensure
    proper data-dependencies are met in the normal IO case are just unecessary
    overhead for signalling. This adds additional computational load on the
    system, as well as latency to the signalling path.

    Therefore, we provide a mechanism for registration of an in-kernel trigger
    point that allows the VCPU to only require a very brief, lightweight
    exit just long enough to signal an eventfd. This also means that any
    clients compatible with the eventfd interface (which includes userspace
    and kernelspace equally well) can now register to be notified. The end
    result should be a more flexible and higher performance notification API
    for the backend KVM hypervisor and perhipheral components.

    To test this theory, we built a test-harness called "doorbell". This
    module has a function called "doorbell_ring()" which simply increments a
    counter for each time the doorbell is signaled. It supports signalling
    from either an eventfd, or an ioctl().

    We then wired up two paths to the doorbell: One via QEMU via a registered
    io region and through the doorbell ioctl(). The other is direct via
    ioeventfd.

    You can download this test harness here:

    ftp://ftp.novell.com/dev/ghaskins/doorbell.tar.bz2

    The measured results are as follows:

    qemu-mmio: 110000 iops, 9.09us rtt
    ioeventfd-mmio: 200100 iops, 5.00us rtt
    ioeventfd-pio: 367300 iops, 2.72us rtt

    I didn't measure qemu-pio, because I have to figure out how to register a
    PIO region with qemu's device model, and I got lazy. However, for now we
    can extrapolate based on the data from the NULLIO runs of +2.56us for MMIO,
    and -350ns for HC, we get:

    qemu-pio: 153139 iops, 6.53us rtt
    ioeventfd-hc: 412585 iops, 2.37us rtt

    these are just for fun, for now, until I can gather more data.

    Here is a graph for your convenience:

    http://developer.novell.com/wiki/images/7/76/Iofd-chart.png

    The conclusion to draw is that we save about 4us by skipping the userspace
    hop.

    --------------------

    Signed-off-by: Gregory Haskins
    Acked-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Gregory Haskins
     
  • Today kvm_io_bus_regsiter_dev() returns void and will internally BUG_ON
    if it fails. We want to create dynamic MMIO/PIO entries driven from
    userspace later in the series, so we need to enhance the code to be more
    robust with the following changes:

    1) Add a return value to the registration function
    2) Fix up all the callsites to check the return code, handle any
    failures, and percolate the error up to the caller.
    3) Add an unregister function that collapses holes in the array

    Signed-off-by: Gregory Haskins
    Acked-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Gregory Haskins
     
  • Add tracepoint in msi/ioapic/pic set_irq() functions,
    in IPI sending and in the point where IRQ is placed into
    apic's IRR.

    Signed-off-by: Gleb Natapov
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • Irqfd sets level for interrupt to 1 and then to 0.
    For MSI, check level so that a single message is sent.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Michael S. Tsirkin
     
  • Cosmetic only. No logic is changed by this patch.

    Signed-off-by: Gleb Natapov
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • Signed-off-by: Avi Kivity

    Avi Kivity
     
  • There is a missing unlock on one fail path in ioapic_mmio_write,
    fix that.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Avi Kivity

    Jiri Slaby
     
  • Document kvm->lock nesting within kvm->slots_lock

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Michael S. Tsirkin
     
  • This changes bus accesses to use high-level kvm_io_bus_read/kvm_io_bus_write
    functions. in_range now becomes unused so it is removed from device ops in
    favor of read/write callbacks performing range checks internally.

    This allows aliasing (mostly for in-kernel virtio), as well as better error
    handling by making it possible to pass errors up to userspace.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Michael S. Tsirkin
     
  • Use slots_lock to protect device list on the bus. slots_lock is already
    taken for read everywhere, so we only need to take it for write when
    registering devices. This is in preparation to removing in_range and
    kvm->lock around it.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Michael S. Tsirkin
     
  • switch coalesced mmio slots_lock. slots_lock is already taken for read
    everywhere, so we only need to take it for write when changing zones.
    This is in preparation to removing in_range and kvm->lock around it.

    [avi: fix build]

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Michael S. Tsirkin
     
  • slots_lock is taken everywhere when device ops are called.
    Document this as we will use this to rework locking for io.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Avi Kivity

    Michael S. Tsirkin
     
  • Return EOPNOTSUPP for KVM_TRACE_ENABLE/PAUSE/DISABLE ioctls.

    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • Correct missing locking in a few places in x86's vm_ioctl handling path.

    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • [avi: fix build on non-x86]

    Signed-off-by: Joerg Roedel
    Signed-off-by: Avi Kivity

    Joerg Roedel
     
  • Since
    commit 854b5338196b1175706e99d63be43a4f8d8ab607
    Author: Christian Ehrhardt
    KVM: s390: streamline memslot handling

    s390 uses the values of the memslot instead of doing everything in the arch
    ioctl handler of the KVM_SET_USER_MEMORY_REGION. Unfortunately we missed to
    set the userspace_addr of our memslot due to our s390 ifdef in
    __kvm_set_memory_region.
    Old s390 userspace launchers did not notice, since they started the guest at
    userspace address 0.
    Because of CONFIG_DEFAULT_MMAP_MIN_ADDR we now put the guest at 1M userspace,
    which does not work. This patch makes sure that new.userspace_addr is set
    on s390.
    This fix should go in quickly. Nevertheless, looking at the code we should
    clean up that ifdef in the long term. Any kernel janitors?

    Signed-off-by: Christian Borntraeger
    Signed-off-by: Avi Kivity

    Christian Borntraeger
     
  • This allows use of the powerful ftrace infrastructure.

    See Documentation/trace/ for usage information.

    [avi, stephen: various build fixes]
    [sheng: fix control register breakage]

    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Sheng Yang
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • Disable usage of 2M pages if VMX_EPT_2MB_PAGE_BIT (bit 16) is clear
    in MSR_IA32_VMX_EPT_VPID_CAP and EPT is enabled.

    [avi: s/largepages_disabled/largepages_enabled/ to avoid negative logic]

    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • [christian: remove unused variables on s390]

    Signed-off-by: Gleb Natapov
    Signed-off-by: Christian Borntraeger
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • Archs are free to use vcpu_id as they see fit. For x86 it is used as
    vcpu's apic id. New ioctl is added to configure boot vcpu id that was
    assumed to be 0 till now.

    Signed-off-by: Gleb Natapov
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • Use it instead of open code "vcpu_id zero is BSP" assumption.

    Signed-off-by: Gleb Natapov
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • Protect irq injection/acking data structures with a separate irq_lock
    mutex. This fixes the following deadlock:

    CPU A CPU B
    kvm_vm_ioctl_deassign_dev_irq()
    mutex_lock(&kvm->lock); worker_thread()
    -> kvm_deassign_irq() -> kvm_assigned_dev_interrupt_work_handler()
    -> deassign_host_irq() mutex_lock(&kvm->lock);
    -> cancel_work_sync() [blocked]

    [gleb: fix ia64 path]

    Reported-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Gleb Natapov
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • Introduce irq_lock, and use to protect ioapic data structures.

    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • Move coalesced_mmio locking to its own device, instead of relying on
    kvm->lock.

    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Marcelo Tosatti
     
  • Instead of checking whether we'll wrap around, calculate how many entries
    are available, and check whether we have enough (just one) for the pending
    mmio.

    By itself, this doesn't change anything, but it paves the way for making
    this function lockless.

    Signed-off-by: Avi Kivity

    Avi Kivity
     
  • We modernize the io_device code so that we use container_of() instead of
    dev->private, and move the vtable to a separate ops structure
    (theoretically allows better caching for multiple instances of the same
    ops structure)

    Signed-off-by: Gregory Haskins
    Acked-by: Chris Wright
    Signed-off-by: Avi Kivity

    Gregory Haskins
     
  • We invoke kfree() on a data member instead of the structure. This works today
    because the kvm_io_device is the first element of the private structure, but
    this could change in the future, so lets clean this up.

    Signed-off-by: Gregory Haskins
    Acked-by: Chris Wright
    Signed-off-by: Avi Kivity

    Gregory Haskins
     
  • Disable interrupt at interrupt handler and enable it when guest ack is for
    the level triggered interrupt, to prevent reinjected interrupt. MSI/MSI-X don't
    need it.

    One possible problem is multiply same vector interrupt injected between irq
    handler and scheduled work handler would be merged as one for MSI/MSI-X.
    But AFAIK, the drivers handle it well.

    The patch fixed the oplin card performance issue(MSI-X performance is half of
    MSI/INTx).

    Signed-off-by: Sheng Yang
    Signed-off-by: Avi Kivity

    Sheng Yang