14 Jan, 2013

1 commit

  • Calling kvm_mmu_slot_remove_write_access() for a deleted slot does
    nothing but search for non-existent mmu pages which have mappings to
    that deleted memory; this is safe but a waste of time.

    Since we want to make the function rmap based in a later patch, in a
    manner which makes it unsafe to be called for a deleted slot, we makes
    the caller see if the slot is non-zero and being dirty logged.

    Reviewed-by: Marcelo Tosatti
    Signed-off-by: Takuya Yoshikawa
    Signed-off-by: Gleb Natapov

    Takuya Yoshikawa
     

24 Dec, 2012

1 commit


23 Dec, 2012

1 commit

  • Previous patch "kvm: Minor memory slot optimization" (b7f69c555ca43)
    overlooked the generation field of the memory slots. Re-using the
    original memory slots left us with with two slightly different memory
    slots with the same generation. To fix this, make update_memslots()
    take a new parameter to specify the last generation. This also makes
    generation management more explicit to avoid such problems in the future.

    Reported-by: Takuya Yoshikawa
    Signed-off-by: Alex Williamson
    Signed-off-by: Gleb Natapov

    Alex Williamson
     

14 Dec, 2012

7 commits

  • We're currently offering a whopping 32 memory slots to user space, an
    int is a bit excessive for storing this. We would like to increase
    our memslots, but SHRT_MAX should be more than enough.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     
  • There's no need for this to be an int, it holds a boolean.
    Move to the end of the struct for alignment.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     
  • It's easy to confuse KVM_MEMORY_SLOTS and KVM_MEM_SLOTS_NUM. One is
    the user accessible slots and the other is user + private. Make this
    more obvious.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     
  • If a slot is removed or moved in the guest physical address space, we
    first allocate and install a new slot array with the invalidated
    entry. The old array is then freed. We then proceed to allocate yet
    another slot array to install the permanent replacement. Re-use the
    original array when this occurs and avoid the extra kfree/kmalloc.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     
  • The iommu integration into memory slots expects memory slots to be
    added or removed and doesn't handle the move case. We can unmap
    slots from the iommu after we mark them invalid and map them before
    installing the final memslot array. Also re-order the kmemdup vs
    map so we don't leave iommu mappings if we get ENOMEM.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     
  • The API documents that only flags and guest physical memory space can
    be modified on an existing slot, but we don't enforce that the
    userspace address cannot be modified. Instead we just ignore it.
    This means that a user may think they've successfully moved both the
    guest and user addresses, when in fact only the guest address changed.
    Check and error instead.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     
  • The API documentation states:

    When changing an existing slot, it may be moved in the guest
    physical memory space, or its flags may be modified.

    An "existing slot" requires a non-zero npages (memory_size). The only
    transition we should therefore allow for a non-existing slot should be
    to create the slot, which includes setting a non-zero memory_size. We
    currently allow calls to modify non-existing slots, which is pointless,
    confusing, and possibly wrong.

    With this we know that the invalidation path of __kvm_set_memory_region
    is always for a delete or move and never for adding a zero size slot.

    Reviewed-by: Gleb Natapov
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     

30 Nov, 2012

1 commit

  • Prior to memory slot sorting this loop compared all of the user memory
    slots for overlap with new entries. With memory slot sorting, we're
    just checking some number of entries in the array that may or may not
    be user slots. Instead, walk all the slots with kvm_for_each_memslot,
    which has the added benefit of terminating early when we hit the first
    empty slot, and skip comparison to private slots.

    Cc: stable@vger.kernel.org
    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     

28 Nov, 2012

2 commits

  • TSC initialization will soon make use of online_vcpus.

    Signed-off-by: Marcelo Tosatti

    Marcelo Tosatti
     
  • KVM added a global variable to guarantee monotonicity in the guest.
    One of the reasons for that is that the time between

    1. ktime_get_ts(×pec);
    2. rdtscll(tsc);

    Is variable. That is, given a host with stable TSC, suppose that
    two VCPUs read the same time via ktime_get_ts() above.

    The time required to execute 2. is not the same on those two instances
    executing in different VCPUS (cache misses, interrupts...).

    If the TSC value that is used by the host to interpolate when
    calculating the monotonic time is the same value used to calculate
    the tsc_timestamp value stored in the pvclock data structure, and
    a single tuple is visible to all
    vcpus simultaneously, this problem disappears. See comment on top
    of pvclock_update_vm_gtod_copy for details.

    Monotonicity is then guaranteed by synchronicity of the host TSCs
    and guest TSCs.

    Set TSC stable pvclock flag in that case, allowing the guest to read
    clock from userspace.

    Signed-off-by: Marcelo Tosatti

    Marcelo Tosatti
     

14 Nov, 2012

2 commits


30 Oct, 2012

1 commit

  • This patch filters noslot pfn out from error pfns based on Marcelo comment:
    noslot pfn is not a error pfn

    After this patch,
    - is_noslot_pfn indicates that the gfn is not in slot
    - is_error_pfn indicates that the gfn is in slot but the error is occurred
    when translate the gfn to pfn
    - is_error_noslot_pfn indicates that the pfn either it is error pfns or it
    is noslot pfn
    And is_invalid_pfn can be removed, it makes the code more clean

    Signed-off-by: Xiao Guangrong
    Signed-off-by: Marcelo Tosatti

    Xiao Guangrong
     

24 Oct, 2012

1 commit


23 Oct, 2012

1 commit

  • We can not directly call kvm_release_pfn_clean to release the pfn
    since we can meet noslot pfn which is used to cache mmio info into
    spte

    Signed-off-by: Xiao Guangrong
    Cc: stable@vger.kernel.org
    Signed-off-by: Avi Kivity

    Xiao Guangrong
     

06 Oct, 2012

1 commit


05 Oct, 2012

1 commit

  • Pull KVM updates from Avi Kivity:
    "Highlights of the changes for this release include support for vfio
    level triggered interrupts, improved big real mode support on older
    Intels, a streamlines guest page table walker, guest APIC speedups,
    PIO optimizations, better overcommit handling, and read-only memory."

    * tag 'kvm-3.7-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (138 commits)
    KVM: s390: Fix vcpu_load handling in interrupt code
    KVM: x86: Fix guest debug across vcpu INIT reset
    KVM: Add resampling irqfds for level triggered interrupts
    KVM: optimize apic interrupt delivery
    KVM: MMU: Eliminate pointless temporary 'ac'
    KVM: MMU: Avoid access/dirty update loop if all is well
    KVM: MMU: Eliminate eperm temporary
    KVM: MMU: Optimize is_last_gpte()
    KVM: MMU: Simplify walk_addr_generic() loop
    KVM: MMU: Optimize pte permission checks
    KVM: MMU: Update accessed and dirty bits after guest pagetable walk
    KVM: MMU: Move gpte_access() out of paging_tmpl.h
    KVM: MMU: Optimize gpte_access() slightly
    KVM: MMU: Push clean gpte write protection out of gpte_access()
    KVM: clarify kvmclock documentation
    KVM: make processes waiting on vcpu mutex killable
    KVM: SVM: Make use of asm.h
    KVM: VMX: Make use of asm.h
    KVM: VMX: Make lto-friendly
    KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()
    ...

    Conflicts:
    arch/s390/include/asm/processor.h
    arch/x86/kvm/i8259.c

    Linus Torvalds
     

18 Sep, 2012

1 commit

  • vcpu mutex can be held for unlimited time so
    taking it with mutex_lock on an ioctl is wrong:
    one process could be passed a vcpu fd and
    call this ioctl on the vcpu used by another process,
    it will then be unkillable until the owner exits.

    Call mutex_lock_killable instead and return status.
    Note: mutex_lock_interruptible would be even nicer,
    but I am not sure all users are prepared to handle EINTR
    from these ioctls. They might misinterpret it as an error.

    Cleanup paths expect a vcpu that can't be used by
    any userspace so this will always succeed - catch bugs
    by calling BUG_ON.

    Catch callers that don't check return state by adding
    __must_check.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Marcelo Tosatti

    Michael S. Tsirkin
     

06 Sep, 2012

3 commits


28 Aug, 2012

1 commit

  • The build error was caused by that builtin functions are calling
    the functions implemented in modules. This error was introduced by
    commit 4d8b81abc4 ("KVM: introduce readonly memslot").

    The patch fixes the build error by moving function __gfn_to_hva_memslot()
    from kvm_main.c to kvm_host.h and making that "inline" so that the
    builtin function (kvmppc_h_enter) can use that.

    Acked-by: Paul Mackerras
    Signed-off-by: Gavin Shan
    Signed-off-by: Marcelo Tosatti

    Gavin Shan
     

27 Aug, 2012

1 commit

  • KVM_SET_SIGNAL_MASK passed a NULL argument leaves the on stack signal
    sets uninitialized. It then passes them through to
    kvm_vcpu_ioctl_set_sigmask.

    We should be passing a NULL in this case not translated garbage.

    Signed-off-by: Alan Cox
    Signed-off-by: Marcelo Tosatti

    Alan Cox
     

22 Aug, 2012

7 commits


06 Aug, 2012

7 commits