From patchwork Wed Dec 23 16:35:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 69572 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBNGgTdb027840 for ; Wed, 23 Dec 2009 16:42:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756478AbZLWQmZ (ORCPT ); Wed, 23 Dec 2009 11:42:25 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756473AbZLWQmY (ORCPT ); Wed, 23 Dec 2009 11:42:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65243 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756140AbZLWQmV (ORCPT ); Wed, 23 Dec 2009 11:42:21 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBNGgLwb027152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Dec 2009 11:42:21 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBNGgKwS021074; Wed, 23 Dec 2009 11:42:20 -0500 Received: from amt.cnet (vpn-11-164.rdu.redhat.com [10.11.11.164]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nBNGgJTh024160; Wed, 23 Dec 2009 11:42:19 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 548EB680259; Wed, 23 Dec 2009 14:42:05 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id nBNGg4Ul016197; Wed, 23 Dec 2009 14:42:04 -0200 Message-Id: <20091223163634.124646324@redhat.com> User-Agent: quilt/0.47-1 Date: Wed, 23 Dec 2009 14:35:20 -0200 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: avi@redhat.com, Marcelo Tosatti Subject: [patch 05/11] KVM: use gfn_to_pfn_memslot in kvm_iommu_map_pages References: <20091223163515.215618069@redhat.com> Content-Disposition: inline; filename=pass-memslot-to-kvm_iommu_map_pages X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Index: kvm/include/linux/kvm_host.h =================================================================== --- kvm.orig/include/linux/kvm_host.h +++ kvm/include/linux/kvm_host.h @@ -439,8 +439,7 @@ void kvm_free_irq_source_id(struct kvm * #define KVM_IOMMU_CACHE_COHERENCY 0x1 #ifdef CONFIG_IOMMU_API -int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, - unsigned long npages); +int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); int kvm_iommu_map_guest(struct kvm *kvm); int kvm_iommu_unmap_guest(struct kvm *kvm); int kvm_assign_device(struct kvm *kvm, Index: kvm/virt/kvm/iommu.c =================================================================== --- kvm.orig/virt/kvm/iommu.c +++ kvm/virt/kvm/iommu.c @@ -32,10 +32,10 @@ static int kvm_iommu_unmap_memslots(stru static void kvm_iommu_put_pages(struct kvm *kvm, gfn_t base_gfn, unsigned long npages); -int kvm_iommu_map_pages(struct kvm *kvm, - gfn_t base_gfn, unsigned long npages) +int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot) { - gfn_t gfn = base_gfn; + gfn_t gfn = slot->base_gfn; + unsigned long npages = slot->npages; pfn_t pfn; int i, r = 0; struct iommu_domain *domain = kvm->arch.iommu_domain; @@ -54,7 +54,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, if (iommu_iova_to_phys(domain, gfn_to_gpa(gfn))) continue; - pfn = gfn_to_pfn(kvm, gfn); + pfn = gfn_to_pfn_memslot(kvm, slot, gfn); r = iommu_map_range(domain, gfn_to_gpa(gfn), pfn_to_hpa(pfn), @@ -69,7 +69,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, return 0; unmap_pages: - kvm_iommu_put_pages(kvm, base_gfn, i); + kvm_iommu_put_pages(kvm, slot->base_gfn, i); return r; } @@ -81,8 +81,7 @@ static int kvm_iommu_map_memslots(struct slots = kvm->memslots; for (i = 0; i < slots->nmemslots; i++) { - r = kvm_iommu_map_pages(kvm, slots->memslots[i].base_gfn, - slots->memslots[i].npages); + r = kvm_iommu_map_pages(kvm, &slots->memslots[i]); if (r) break; } Index: kvm/virt/kvm/kvm_main.c =================================================================== --- kvm.orig/virt/kvm/kvm_main.c +++ kvm/virt/kvm/kvm_main.c @@ -684,7 +684,7 @@ skip_lpage: spin_unlock(&kvm->mmu_lock); #ifdef CONFIG_DMAR /* map the pages in iommu page table */ - r = kvm_iommu_map_pages(kvm, base_gfn, npages); + r = kvm_iommu_map_pages(kvm, memslot); if (r) goto out; #endif