1. 20 9月, 2012 2 次提交
    • G
      KVM: optimize apic interrupt delivery · 1e08ec4a
      Gleb Natapov 提交于
      Most interrupt are delivered to only one vcpu. Use pre-build tables to
      find interrupt destination instead of looping through all vcpus. In case
      of logical mode loop only through vcpus in a logical cluster irq is sent
      to.
      Signed-off-by: NGleb Natapov <gleb@redhat.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      1e08ec4a
    • A
      KVM: MMU: Optimize pte permission checks · 97d64b78
      Avi Kivity 提交于
      walk_addr_generic() permission checks are a maze of branchy code, which is
      performed four times per lookup.  It depends on the type of access, efer.nxe,
      cr0.wp, cr4.smep, and in the near future, cr4.smap.
      
      Optimize this away by precalculating all variants and storing them in a
      bitmap.  The bitmap is recalculated when rarely-changing variables change
      (cr0, cr4) and is indexed by the often-changing variables (page fault error
      code, pte access permissions).
      
      The permission check is moved to the end of the loop, otherwise an SMEP
      fault could be reported as a false positive, when PDE.U=1 but PTE.U=0.
      Noted by Xiao Guangrong.
      
      The result is short, branch-free code.
      Reviewed-by: NXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      97d64b78
  2. 18 9月, 2012 1 次提交
    • M
      KVM: make processes waiting on vcpu mutex killable · 9fc77441
      Michael S. Tsirkin 提交于
      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: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      9fc77441
  3. 06 9月, 2012 4 次提交
  4. 05 9月, 2012 3 次提交
  5. 31 8月, 2012 1 次提交
  6. 28 8月, 2012 1 次提交
  7. 22 8月, 2012 2 次提交
  8. 14 8月, 2012 1 次提交
  9. 09 8月, 2012 1 次提交
  10. 07 8月, 2012 2 次提交
  11. 06 8月, 2012 4 次提交
  12. 05 8月, 2012 1 次提交
  13. 04 8月, 2012 1 次提交
  14. 02 8月, 2012 1 次提交
    • B
      KVM: x86: apply kvmclock offset to guest wall clock time · 4b648665
      Bruce Rogers 提交于
      When a guest migrates to a new host, the system time difference from the
      previous host is used in the updates to the kvmclock system time visible
      to the guest, resulting in a continuation of correct kvmclock based guest
      timekeeping.
      
      The wall clock component of the kvmclock provided time is currently not
      updated with this same time offset. Since the Linux guest caches the
      wall clock based time, this discrepency is not noticed until the guest is
      rebooted. After reboot the guest's time calculations are off.
      
      This patch adjusts the wall clock by the kvmclock_offset, resulting in
      correct guest time after a reboot.
      
      Cc: Zachary Amsden <zamsden@gmail.com>
      Signed-off-by: NBruce Rogers <brogers@suse.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      4b648665
  15. 01 8月, 2012 1 次提交
  16. 26 7月, 2012 1 次提交
  17. 21 7月, 2012 1 次提交
  18. 20 7月, 2012 1 次提交
    • X
      KVM: x86: remove unnecessary mark_page_dirty · 9d3c92af
      Xiao Guangrong 提交于
      fix:
      [  132.474633] 3.5.0-rc1+ #50 Not tainted
      [  132.474634] -------------------------------
      [  132.474635] include/linux/kvm_host.h:369 suspicious rcu_dereference_check() usage!
      [  132.474636]
      [  132.474636] other info that might help us debug this:
      [  132.474636]
      [  132.474638]
      [  132.474638] rcu_scheduler_active = 1, debug_locks = 1
      [  132.474640] 1 lock held by qemu-kvm/2832:
      [  132.474657]  #0:  (&vcpu->mutex){+.+.+.}, at: [<ffffffffa01e1636>] vcpu_load+0x1e/0x91 [kvm]
      [  132.474658]
      [  132.474658] stack backtrace:
      [  132.474660] Pid: 2832, comm: qemu-kvm Not tainted 3.5.0-rc1+ #50
      [  132.474661] Call Trace:
      [  132.474665]  [<ffffffff81092f40>] lockdep_rcu_suspicious+0xfc/0x105
      [  132.474675]  [<ffffffffa01e0c85>] kvm_memslots+0x6d/0x75 [kvm]
      [  132.474683]  [<ffffffffa01e0ca1>] gfn_to_memslot+0x14/0x4c [kvm]
      [  132.474693]  [<ffffffffa01e3575>] mark_page_dirty+0x17/0x2a [kvm]
      [  132.474706]  [<ffffffffa01f21ea>] kvm_arch_vcpu_ioctl+0xbcf/0xc07 [kvm]
      
      Actually, we do not write vcpu->arch.time at this time, mark_page_dirty
      should be removed.
      Signed-off-by: NXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      9d3c92af
  19. 19 7月, 2012 1 次提交
  20. 12 7月, 2012 1 次提交
    • M
      KVM: VMX: Implement PCID/INVPCID for guests with EPT · ad756a16
      Mao, Junjie 提交于
      This patch handles PCID/INVPCID for guests.
      
      Process-context identifiers (PCIDs) are a facility by which a logical processor
      may cache information for multiple linear-address spaces so that the processor
      may retain cached information when software switches to a different linear
      address space. Refer to section 4.10.1 in IA32 Intel Software Developer's Manual
      Volume 3A for details.
      
      For guests with EPT, the PCID feature is enabled and INVPCID behaves as running
      natively.
      For guests without EPT, the PCID feature is disabled and INVPCID triggers #UD.
      Signed-off-by: NJunjie Mao <junjie.mao@intel.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      ad756a16
  21. 09 7月, 2012 1 次提交
  22. 25 6月, 2012 3 次提交
    • M
      KVM: host side for eoi optimization · ae7a2a3f
      Michael S. Tsirkin 提交于
      Implementation of PV EOI using shared memory.
      This reduces the number of exits an interrupt
      causes as much as by half.
      
      The idea is simple: there's a bit, per APIC, in guest memory,
      that tells the guest that it does not need EOI.
      We set it before injecting an interrupt and clear
      before injecting a nested one. Guest tests it using
      a test and clear operation - this is necessary
      so that host can detect interrupt nesting -
      and if set, it can skip the EOI MSR.
      
      There's a new MSR to set the address of said register
      in guest memory. Otherwise not much changed:
      - Guest EOI is not required
      - Register is tested & ISR is automatically cleared on exit
      
      For testing results see description of previous patch
      'kvm_para: guest side for eoi avoidance'.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      ae7a2a3f
    • M
      KVM: rearrange injection cancelling code · d905c069
      Michael S. Tsirkin 提交于
      Each time we need to cancel injection we invoke same code
      (cancel_injection callback).  Move it towards the end of function using
      the familiar goto on error pattern.
      
      Will make it easier to do more cleanups for PV EOI.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      d905c069
    • M
      KVM: only sync when attention bits set · 5cfb1d5a
      Michael S. Tsirkin 提交于
      Commit eb0dc6d0368072236dcd086d7fdc17fd3c4574d4 introduced apic
      attention bitmask but kvm still syncs lapic unconditionally.
      As that commit suggested and in anticipation of adding more attention
      bits, only sync lapic if(apic_attention).
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      5cfb1d5a
  23. 19 6月, 2012 1 次提交
  24. 06 6月, 2012 1 次提交
  25. 05 6月, 2012 1 次提交
  26. 17 5月, 2012 1 次提交
  27. 06 5月, 2012 1 次提交
    • G
      KVM: ensure async PF event wakes up vcpu from halt · a4fa1635
      Gleb Natapov 提交于
      If vcpu executes hlt instruction while async PF is waiting to be delivered
      vcpu can block and deliver async PF only after another even wakes it
      up. This happens because kvm_check_async_pf_completion() will remove
      completion event from vcpu->async_pf.done before entering kvm_vcpu_block()
      and this will make kvm_arch_vcpu_runnable() return false. The solution
      is to make vcpu runnable when processing completion.
      Signed-off-by: NGleb Natapov <gleb@redhat.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      a4fa1635