public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: Avi Kivity <avi@redhat.com>,
	David Woodhouse <dwmw2@infradead.org>,
	kvm@vger.kernel.org, iommu@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/11] kvm: Change kvm_iommu_map_pages to map large pages
Date: Thu, 28 Jan 2010 20:24:55 -0200	[thread overview]
Message-ID: <20100128222455.GA26274@amt.cnet> (raw)
In-Reply-To: <1264678682-30655-7-git-send-email-joerg.roedel@amd.com>

On Thu, Jan 28, 2010 at 12:37:57PM +0100, Joerg Roedel wrote:
> This patch changes the implementation of of
> kvm_iommu_map_pages to map the pages with the host page size
> into the io virtual address space.
> 
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  virt/kvm/iommu.c |  106 ++++++++++++++++++++++++++++++++++++++++++-----------
>  1 files changed, 84 insertions(+), 22 deletions(-)
> 
> diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
> index 65a5143..92a434d 100644
> --- a/virt/kvm/iommu.c
> +++ b/virt/kvm/iommu.c
> @@ -32,12 +32,27 @@ 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);
>  
> +static pfn_t kvm_pin_pages(struct kvm *kvm, struct kvm_memory_slot *slot,
> +			   gfn_t gfn, unsigned long size)
> +{
> +	gfn_t end_gfn;
> +	pfn_t pfn;
> +
> +	pfn     = gfn_to_pfn_memslot(kvm, slot, gfn);

If gfn_to_pfn_memslot returns pfn of bad_page, you might create a
large iommu translation for it?

> +		/* Map into IO address space */
> +		r = iommu_map(domain, gfn_to_gpa(gfn), pfn_to_hpa(pfn),
> +			      get_order(page_size), flags);
> +
> +		gfn += page_size >> PAGE_SHIFT;

Should increase gfn after checking for failure, otherwise wrong
npages is passed to kvm_iommu_put_pages.

>  
> -		pfn = gfn_to_pfn_memslot(kvm, slot, gfn);
> -		r = iommu_map_range(domain,
> -				    gfn_to_gpa(gfn),
> -				    pfn_to_hpa(pfn),
> -				    PAGE_SIZE, flags);
>  		if (r) {
>  			printk(KERN_ERR "kvm_iommu_map_address:"
>  			       "iommu failed to map pfn=%lx\n", pfn);
>  			goto unmap_pages;
>  		}
> -		gfn++;
> +
>  	}
> +
>  	return 0;
>  
>  unmap_pages:
> -	kvm_iommu_put_pages(kvm, slot->base_gfn, i);
> +	kvm_iommu_put_pages(kvm, slot->base_gfn, gfn);
>  	return r;
>  }

  reply	other threads:[~2010-01-28 22:24 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-28 11:37 [PATCH 0/11] Large Page Support for IOMMU-API and KVM Joerg Roedel
2010-01-28 11:37 ` [PATCH 01/11] iommu-api: Rename ->{un}map function pointers to ->{un}map_range Joerg Roedel
2010-01-28 11:37 ` [PATCH 02/11] iommu-api: Add iommu_map and iommu_unmap functions Joerg Roedel
2010-02-07  9:38   ` Avi Kivity
2010-02-07 10:50     ` Joerg Roedel
2010-02-07 10:52       ` Avi Kivity
2010-01-28 11:37 ` [PATCH 03/11] iommu-api: Add ->{un}map callbacks to iommu_ops Joerg Roedel
2010-01-28 11:37 ` [PATCH 04/11] VT-d: Change {un}map_range functions to implement {un}map interface Joerg Roedel
2010-01-28 20:59   ` David Woodhouse
2010-01-29  9:05     ` Joerg Roedel
2010-02-01 14:16       ` [PATCH 04/11 v2] " Joerg Roedel
2010-02-05 11:00         ` Joerg Roedel
2010-01-28 11:37 ` [PATCH 05/11] kvm: Introduce kvm_host_page_size Joerg Roedel
2010-02-07 12:09   ` Avi Kivity
2010-02-07 14:13     ` Joerg Roedel
2010-01-28 11:37 ` [PATCH 06/11] kvm: Change kvm_iommu_map_pages to map large pages Joerg Roedel
2010-01-28 22:24   ` Marcelo Tosatti [this message]
2010-01-29  9:32     ` Joerg Roedel
2010-02-01 14:18       ` Joerg Roedel
2010-02-01 19:30         ` Marcelo Tosatti
2010-02-05 11:01           ` Joerg Roedel
2010-02-07 12:22             ` Avi Kivity
2010-02-07 12:41               ` Joerg Roedel
2010-02-07 12:18     ` Avi Kivity
2010-02-07 18:41       ` Marcelo Tosatti
2010-02-08  9:24         ` Avi Kivity
2010-01-28 11:37 ` [PATCH 07/11] x86/amd-iommu: Make iommu_map_page and alloc_pte aware of page sizes Joerg Roedel
2010-01-28 11:37 ` [PATCH 08/11] x86/amd-iommu: Make iommu_unmap_page and fetch_pte " Joerg Roedel
2010-01-28 11:38 ` [PATCH 09/11] x86/amd-iommu: Make amd_iommu_iova_to_phys aware of multiple " Joerg Roedel
2010-01-28 11:38 ` [PATCH 10/11] x86/amd-iommu: Implement ->{un}map callbacks for iommu-api Joerg Roedel
2010-01-28 11:38 ` [PATCH 11/11] iommu-api: Remove iommu_{un}map_range functions Joerg Roedel

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=20100128222455.GA26274@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joerg.roedel@amd.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