aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorBen-Ami Yassour <benami@il.ibm.com>2008-09-13 20:48:28 -0400
committerAvi Kivity <avi@redhat.com>2008-10-15 08:25:04 -0400
commit62c476c7c7f25a5b245b9902a935636e6316e58c (patch)
tree6584591c7c345fcbb3c6d437203dc7f4a628573a /virt
parent387179464257921eb9aa3d15cc3ff194f6945a7c (diff)
KVM: Device Assignment with VT-d
Based on a patch by: Kay, Allen M <allen.m.kay@intel.com> This patch enables PCI device assignment based on VT-d support. When a device is assigned to the guest, the guest memory is pinned and the mapping is updated in the VT-d IOMMU. [Amit: Expose KVM_CAP_IOMMU so we can check if an IOMMU is present and also control enable/disable from userspace] Signed-off-by: Kay, Allen M <allen.m.kay@intel.com> Signed-off-by: Weidong Han <weidong.han@intel.com> Signed-off-by: Ben-Ami Yassour <benami@il.ibm.com> Signed-off-by: Amit Shah <amit.shah@qumranet.com> Acked-by: Mark Gross <mgross@linux.intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 63e661be040a..f42d5c2a396d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -41,6 +41,7 @@
41#include <linux/pagemap.h> 41#include <linux/pagemap.h>
42#include <linux/mman.h> 42#include <linux/mman.h>
43#include <linux/swap.h> 43#include <linux/swap.h>
44#include <linux/intel-iommu.h>
44 45
45#include <asm/processor.h> 46#include <asm/processor.h>
46#include <asm/io.h> 47#include <asm/io.h>
@@ -76,7 +77,7 @@ static inline int valid_vcpu(int n)
76 return likely(n >= 0 && n < KVM_MAX_VCPUS); 77 return likely(n >= 0 && n < KVM_MAX_VCPUS);
77} 78}
78 79
79static inline int is_mmio_pfn(pfn_t pfn) 80inline int is_mmio_pfn(pfn_t pfn)
80{ 81{
81 if (pfn_valid(pfn)) 82 if (pfn_valid(pfn))
82 return PageReserved(pfn_to_page(pfn)); 83 return PageReserved(pfn_to_page(pfn));
@@ -578,6 +579,12 @@ int __kvm_set_memory_region(struct kvm *kvm,
578 } 579 }
579 580
580 kvm_free_physmem_slot(&old, &new); 581 kvm_free_physmem_slot(&old, &new);
582
583 /* map the pages in iommu page table */
584 r = kvm_iommu_map_pages(kvm, base_gfn, npages);
585 if (r)
586 goto out;
587
581 return 0; 588 return 0;
582 589
583out_free: 590out_free: