1. 19 4月, 2012 1 次提交
    • A
      KVM: lock slots_lock around device assignment · 21a1416a
      Alex Williamson 提交于
      As pointed out by Jason Baron, when assigning a device to a guest
      we first set the iommu domain pointer, which enables mapping
      and unmapping of memory slots to the iommu.  This leaves a window
      where this path is enabled, but we haven't synchronized the iommu
      mappings to the existing memory slots.  Thus a slot being removed
      at that point could send us down unexpected code paths removing
      non-existent pinnings and iommu mappings.  Take the slots_lock
      around creating the iommu domain and initial mappings as well as
      around iommu teardown to avoid this race.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      21a1416a
  2. 12 4月, 2012 1 次提交
    • A
      KVM: unmap pages from the iommu when slots are removed · 32f6daad
      Alex Williamson 提交于
      We've been adding new mappings, but not destroying old mappings.
      This can lead to a page leak as pages are pinned using
      get_user_pages, but only unpinned with put_page if they still
      exist in the memslots list on vm shutdown.  A memslot that is
      destroyed while an iommu domain is enabled for the guest will
      therefore result in an elevated page reference count that is
      never cleared.
      
      Additionally, without this fix, the iommu is only programmed
      with the first translation for a gpa.  This can result in
      peer-to-peer errors if a mapping is destroyed and replaced by a
      new mapping at the same gpa as the iommu will still be pointing
      to the original, pinned memory address.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      32f6daad
  3. 13 1月, 2012 1 次提交
  4. 27 12月, 2011 1 次提交
  5. 10 11月, 2011 1 次提交
    • O
      iommu/core: split mapping to page sizes as supported by the hardware · 7d3002cc
      Ohad Ben-Cohen 提交于
      When mapping a memory region, split it to page sizes as supported
      by the iommu hardware. Always prefer bigger pages, when possible,
      in order to reduce the TLB pressure.
      
      The logic to do that is now added to the IOMMU core, so neither the iommu
      drivers themselves nor users of the IOMMU API have to duplicate it.
      
      This allows a more lenient granularity of mappings; traditionally the
      IOMMU API took 'order' (of a page) as a mapping size, and directly let
      the low level iommu drivers handle the mapping, but now that the IOMMU
      core can split arbitrary memory regions into pages, we can remove this
      limitation, so users don't have to split those regions by themselves.
      
      Currently the supported page sizes are advertised once and they then
      remain static. That works well for OMAP and MSM but it would probably
      not fly well with intel's hardware, where the page size capabilities
      seem to have the potential to be different between several DMA
      remapping devices.
      
      register_iommu() currently sets a default pgsize behavior, so we can convert
      the IOMMU drivers in subsequent patches. After all the drivers
      are converted, the temporary default settings will be removed.
      
      Mainline users of the IOMMU API (kvm and omap-iovmm) are adopted
      to deal with bytes instead of page order.
      
      Many thanks to Joerg Roedel <Joerg.Roedel@amd.com> for significant review!
      Signed-off-by: NOhad Ben-Cohen <ohad@wizery.com>
      Cc: David Brown <davidb@codeaurora.org>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Joerg Roedel <Joerg.Roedel@amd.com>
      Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
      Cc: KyongHo Cho <pullip.cho@samsung.com>
      Cc: Hiroshi DOYU <hdoyu@nvidia.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: kvm@vger.kernel.org
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      7d3002cc
  6. 01 11月, 2011 2 次提交
  7. 21 10月, 2011 2 次提交
  8. 24 9月, 2011 1 次提交
  9. 24 7月, 2011 1 次提交
    • A
      KVM: IOMMU: Disable device assignment without interrupt remapping · 3f68b031
      Alex Williamson 提交于
      IOMMU interrupt remapping support provides a further layer of
      isolation for device assignment by preventing arbitrary interrupt
      block DMA writes by a malicious guest from reaching the host.  By
      default, we should require that the platform provides interrupt
      remapping support, with an opt-in mechanism for existing behavior.
      
      Both AMD IOMMU and Intel VT-d2 hardware support interrupt
      remapping, however we currently only have software support on
      the Intel side.  Users wishing to re-enable device assignment
      when interrupt remapping is not supported on the platform can
      use the "allow_unsafe_assigned_interrupts=1" module option.
      
      [avi: break long lines]
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      3f68b031
  10. 02 8月, 2010 1 次提交
  11. 01 8月, 2010 2 次提交
    • S
      KVM: Fix IOMMU memslot reference warning · 95c87e2b
      Sheng Yang 提交于
      This patch fixes the following warning.
      
      ===================================================
      [ INFO: suspicious rcu_dereference_check() usage. ]
      ---------------------------------------------------
      include/linux/kvm_host.h:259 invoked rcu_dereference_check() without
      protection!
      
      other info that might help us debug this:
      
      rcu_scheduler_active = 1, debug_locks = 0
      no locks held by qemu-system-x86/29679.
      
      stack backtrace:
      Pid: 29679, comm: qemu-system-x86 Not tainted 2.6.35-rc3+ #200
      Call Trace:
       [<ffffffff810a224e>] lockdep_rcu_dereference+0xa8/0xb1
       [<ffffffffa018a06f>] kvm_iommu_unmap_memslots+0xc9/0xde [kvm]
       [<ffffffffa018a0c4>] kvm_iommu_unmap_guest+0x40/0x4e [kvm]
       [<ffffffffa018f772>] kvm_arch_destroy_vm+0x1a/0x186 [kvm]
       [<ffffffffa01800d0>] kvm_put_kvm+0x110/0x167 [kvm]
       [<ffffffffa0180ecc>] kvm_vcpu_release+0x18/0x1c [kvm]
       [<ffffffff81156f5d>] fput+0x22a/0x3a0
       [<ffffffff81152288>] filp_close+0xb4/0xcd
       [<ffffffff8106599f>] put_files_struct+0x1b7/0x36b
       [<ffffffff81065830>] ? put_files_struct+0x48/0x36b
       [<ffffffff8131ee59>] ? do_raw_spin_unlock+0x118/0x160
       [<ffffffff81065bc0>] exit_files+0x6d/0x75
       [<ffffffff81068348>] do_exit+0x47d/0xc60
       [<ffffffff8177e7b5>] ? _raw_spin_unlock_irq+0x30/0x36
       [<ffffffff81068bfa>] do_group_exit+0xcf/0x134
       [<ffffffff81080790>] get_signal_to_deliver+0x732/0x81d
       [<ffffffff81095996>] ? cpu_clock+0x4e/0x60
       [<ffffffff81002082>] do_notify_resume+0x117/0xc43
       [<ffffffff810a2fa3>] ? trace_hardirqs_on+0xd/0xf
       [<ffffffff81080d79>] ? sys_rt_sigtimedwait+0x2b5/0x3bf
       [<ffffffff8177d9f2>] ? trace_hardirqs_off_thunk+0x3a/0x3c
       [<ffffffff81003221>] ? sysret_signal+0x5/0x3d
       [<ffffffff8100343b>] int_signal+0x12/0x17
      Signed-off-by: NSheng Yang <sheng@linux.intel.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      95c87e2b
    • A
      KVM: Update Red Hat copyrights · 221d059d
      Avi Kivity 提交于
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      221d059d
  12. 09 6月, 2010 1 次提交
  13. 17 5月, 2010 1 次提交
    • L
      KVM: use the correct RCU API for PROVE_RCU=y · 90d83dc3
      Lai Jiangshan 提交于
      The RCU/SRCU API have already changed for proving RCU usage.
      
      I got the following dmesg when PROVE_RCU=y because we used incorrect API.
      This patch coverts rcu_deference() to srcu_dereference() or family API.
      
      ===================================================
      [ INFO: suspicious rcu_dereference_check() usage. ]
      ---------------------------------------------------
      arch/x86/kvm/mmu.c:3020 invoked rcu_dereference_check() without protection!
      
      other info that might help us debug this:
      
      rcu_scheduler_active = 1, debug_locks = 0
      2 locks held by qemu-system-x86/8550:
       #0:  (&kvm->slots_lock){+.+.+.}, at: [<ffffffffa011a6ac>] kvm_set_memory_region+0x29/0x50 [kvm]
       #1:  (&(&kvm->mmu_lock)->rlock){+.+...}, at: [<ffffffffa012262d>] kvm_arch_commit_memory_region+0xa6/0xe2 [kvm]
      
      stack backtrace:
      Pid: 8550, comm: qemu-system-x86 Not tainted 2.6.34-rc4-tip-01028-g939eab1 #27
      Call Trace:
       [<ffffffff8106c59e>] lockdep_rcu_dereference+0xaa/0xb3
       [<ffffffffa012f6c1>] kvm_mmu_calculate_mmu_pages+0x44/0x7d [kvm]
       [<ffffffffa012263e>] kvm_arch_commit_memory_region+0xb7/0xe2 [kvm]
       [<ffffffffa011a5d7>] __kvm_set_memory_region+0x636/0x6e2 [kvm]
       [<ffffffffa011a6ba>] kvm_set_memory_region+0x37/0x50 [kvm]
       [<ffffffffa015e956>] vmx_set_tss_addr+0x46/0x5a [kvm_intel]
       [<ffffffffa0126592>] kvm_arch_vm_ioctl+0x17a/0xcf8 [kvm]
       [<ffffffff810a8692>] ? unlock_page+0x27/0x2c
       [<ffffffff810bf879>] ? __do_fault+0x3a9/0x3e1
       [<ffffffffa011b12f>] kvm_vm_ioctl+0x364/0x38d [kvm]
       [<ffffffff81060cfa>] ? up_read+0x23/0x3d
       [<ffffffff810f3587>] vfs_ioctl+0x32/0xa6
       [<ffffffff810f3b19>] do_vfs_ioctl+0x495/0x4db
       [<ffffffff810e6b2f>] ? fget_light+0xc2/0x241
       [<ffffffff810e416c>] ? do_sys_open+0x104/0x116
       [<ffffffff81382d6d>] ? retint_swapgs+0xe/0x13
       [<ffffffff810f3ba6>] sys_ioctl+0x47/0x6a
       [<ffffffff810021db>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      90d83dc3
  14. 08 3月, 2010 1 次提交
  15. 01 3月, 2010 4 次提交
  16. 10 6月, 2009 1 次提交
    • S
      KVM: Enable snooping control for supported hardware · 522c68c4
      Sheng Yang 提交于
      Memory aliases with different memory type is a problem for guest. For the guest
      without assigned device, the memory type of guest memory would always been the
      same as host(WB); but for the assigned device, some part of memory may be used
      as DMA and then set to uncacheable memory type(UC/WC), which would be a conflict of
      host memory type then be a potential issue.
      
      Snooping control can guarantee the cache correctness of memory go through the
      DMA engine of VT-d.
      
      [avi: fix build on ia64]
      Signed-off-by: NSheng Yang <sheng@linux.intel.com>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      522c68c4
  17. 15 2月, 2009 1 次提交
  18. 03 1月, 2009 6 次提交
  19. 15 10月, 2008 3 次提交