From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 30/40] KVM: use gfn_to_pfn_memslot in kvm_iommu_map_pages
Date: Wed, 10 Feb 2010 19:22:59 +0200 [thread overview]
Message-ID: <1265822589-11155-31-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1265822589-11155-1-git-send-email-avi@redhat.com>
From: Marcelo Tosatti <mtosatti@redhat.com>
So its possible to iommu map a memslot before making it visible to
kvm.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
include/linux/kvm_host.h | 3 +--
virt/kvm/iommu.c | 13 ++++++-------
virt/kvm/kvm_main.c | 2 +-
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f1f78de..9af2403 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -440,8 +440,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
#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,
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index bc697a6..cf567d8 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -32,10 +32,10 @@ static int kvm_iommu_unmap_memslots(struct kvm *kvm);
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 kvm *kvm)
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;
}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4e2321c..87d296d 100644
--- a/virt/kvm/kvm_main.c
+++ b/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
--
1.6.5.3
next prev parent reply other threads:[~2010-02-10 17:24 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 17:22 [PATCH 00/40] KVM updates for the 2.6.34 merge window (batch 1/4) Avi Kivity
2010-02-10 17:22 ` [PATCH 01/40] KVM: x86: make double/triple fault promotion generic to all exceptions Avi Kivity
2010-02-10 17:22 ` [PATCH 02/40] KVM: x86: raise TSS exception for NULL CS and SS segments Avi Kivity
2010-02-10 17:22 ` [PATCH 03/40] KVM: MMU: Report spte not found in rmap before BUG() Avi Kivity
2010-02-10 17:22 ` [PATCH 04/40] KVM: VMX: Trap and invalid MWAIT/MONITOR instruction Avi Kivity
2010-02-10 17:22 ` [PATCH 05/40] KVM: VMX: Move some cr[04] related constants to vmx.c Avi Kivity
2010-02-10 17:22 ` [PATCH 06/40] KVM: Add accessor for reading cr4 (or some bits of cr4) Avi Kivity
2010-02-10 17:22 ` [PATCH 07/40] KVM: VMX: Make guest cr4 mask more conservative Avi Kivity
2010-02-10 17:22 ` [PATCH 08/40] KVM: VMX: When using ept, allow the guest to own cr4.pge Avi Kivity
2010-02-10 17:22 ` [PATCH 09/40] KVM: VMX: Fold ept_update_paging_mode_cr4() into its caller Avi Kivity
2010-02-10 17:22 ` [PATCH 10/40] KVM: VMX: Remove redundant variable Avi Kivity
2010-02-10 17:22 ` [PATCH 11/40] KVM: Extended shared_msr_global to per CPU Avi Kivity
2010-02-10 17:22 ` [PATCH 12/40] x86: Raise vsyscall priority on hotplug notifier chain Avi Kivity
2010-02-10 17:22 ` [PATCH 13/40] KVM: Add cpuid_update() callback to kvm_x86_ops Avi Kivity
2010-02-10 17:22 ` [PATCH 14/40] KVM: VMX: Add instruction rdtscp support for guest Avi Kivity
2010-02-10 17:22 ` [PATCH 15/40] KVM: SVM: Adjust tsc_offset only if tsc_unstable Avi Kivity
2010-02-10 17:22 ` [PATCH 16/40] KVM: Disentangle mmu notifiers and coalesced_mmio registration Avi Kivity
2010-02-10 17:22 ` [PATCH 17/40] KVM: Add include guards for coalesced_mmio.h Avi Kivity
2010-02-10 17:22 ` [PATCH 18/40] KVM: Remove ifdefs from mmu notifier initialization Avi Kivity
2010-02-10 17:22 ` [PATCH 19/40] KVM: Add KVM_MMIO kconfig item Avi Kivity
2010-02-10 17:22 ` [PATCH 20/40] KVM: Simplify coalesced mmio initialization Avi Kivity
2010-02-10 17:22 ` [PATCH 21/40] KVM: powerpc: Move vector to irqprio resolving to separate function Avi Kivity
2010-02-10 17:22 ` [PATCH 22/40] KVM: powerpc: Improve DEC handling Avi Kivity
2010-02-10 17:22 ` [PATCH 23/40] KVM: powerpc: Remove AGGRESSIVE_DEC Avi Kivity
2010-02-10 17:22 ` [PATCH 24/40] KVM: powerpc: Change maintainer Avi Kivity
2010-02-10 17:22 ` [PATCH 25/40] KVM: trivial document fixes Avi Kivity
2010-02-10 17:22 ` [PATCH 26/40] KVM: modify memslots layout in struct kvm Avi Kivity
2010-02-10 17:22 ` [PATCH 27/40] KVM: modify alias layout in x86s struct kvm_arch Avi Kivity
2010-02-10 17:22 ` [PATCH 28/40] KVM: split kvm_arch_set_memory_region into prepare and commit Avi Kivity
2010-02-10 17:22 ` [PATCH 29/40] KVM: introduce gfn_to_pfn_memslot Avi Kivity
2010-02-10 17:22 ` Avi Kivity [this message]
2010-02-10 17:23 ` [PATCH 31/40] KVM: introduce kvm->srcu and convert kvm_set_memory_region to SRCU update Avi Kivity
2010-02-10 17:23 ` [PATCH 32/40] KVM: use SRCU for dirty log Avi Kivity
2010-02-10 17:23 ` [PATCH 33/40] KVM: x86: switch kvm_set_memory_alias to SRCU update Avi Kivity
2010-02-10 17:23 ` [PATCH 34/40] KVM: convert io_bus to SRCU Avi Kivity
2010-02-10 17:23 ` [PATCH 35/40] KVM: switch vcpu context to use SRCU Avi Kivity
2010-02-10 17:23 ` [PATCH 36/40] KVM: convert slots_lock to a mutex Avi Kivity
2010-02-10 17:23 ` [PATCH 37/40] KVM: Bump maximum vcpu count to 64 Avi Kivity
2010-02-10 17:23 ` [PATCH 38/40] KVM: Fill out ftrace exit reason strings Avi Kivity
2010-02-10 17:23 ` [PATCH 39/40] KVM: avoid taking ioapic mutex for non-ioapic EOIs Avi Kivity
2010-02-10 17:23 ` [PATCH 40/40] KVM: PPC: Fix typo in rebolting code Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1265822589-11155-31-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome