aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2012-04-11 11:51:49 -0400
committerMarcelo Tosatti <mtosatti@redhat.com>2012-04-11 21:55:25 -0400
commit32f6daad4651a748a58a3ab6da0611862175722f (patch)
tree09e2643d6df18db1ab7655fcb53ab797e9ac69c1 /include
parentf19a0c2c2e6add90b7d6a1b7595abebfe2e4c37a (diff)
KVM: unmap pages from the iommu when slots are removed
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: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/kvm_host.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 665a260c7e09..72cbf08d45fb 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -596,6 +596,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
596 596
597#ifdef CONFIG_IOMMU_API 597#ifdef CONFIG_IOMMU_API
598int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); 598int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot);
599void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot);
599int kvm_iommu_map_guest(struct kvm *kvm); 600int kvm_iommu_map_guest(struct kvm *kvm);
600int kvm_iommu_unmap_guest(struct kvm *kvm); 601int kvm_iommu_unmap_guest(struct kvm *kvm);
601int kvm_assign_device(struct kvm *kvm, 602int kvm_assign_device(struct kvm *kvm,
@@ -609,6 +610,11 @@ static inline int kvm_iommu_map_pages(struct kvm *kvm,
609 return 0; 610 return 0;
610} 611}
611 612
613static inline void kvm_iommu_unmap_pages(struct kvm *kvm,
614 struct kvm_memory_slot *slot)
615{
616}
617
612static inline int kvm_iommu_map_guest(struct kvm *kvm) 618static inline int kvm_iommu_map_guest(struct kvm *kvm)
613{ 619{
614 return -ENODEV; 620 return -ENODEV;