From: Alex Williamson <alex.williamson@redhat.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: kvm@vger.kernel.org, "Kay, Allen M" <allen.m.kay@intel.com>,
joerg.roedel@amd.com, iommu@lists.linux-foundation.org
Subject: Re: [RFC][PATCH] Fix superpage unmap on Intel IOMMU
Date: Fri, 03 Jun 2011 14:01:57 -0600 [thread overview]
Message-ID: <1307131318.3128.10.camel@ul30vt> (raw)
In-Reply-To: <1307129491.23418.4.camel@i7.infradead.org>
On Fri, 2011-06-03 at 20:31 +0100, David Woodhouse wrote:
> Tell me it isn't so...
Looks accurate to me, in fact, with hugetlbfs it seems like it's doing
exactly what it should do. The non-hugetlbfs case isn't efficient, but
it isn't wrong either. Our only other option is to figure out what's
contiguous, map those chunks and try to keep track of all that. It's
much easier to make you do it since you have to manage the iommu page
table anyway ;) Besides, it's the only way we get page granularity on
unmapping.
And of course, isn't this just following the IOMMU API? It'd be nice if
that API was documented somewhere. Thanks,
Alex
> diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
> index 59f17ac..6c588ee 100644
> --- a/drivers/pci/intel-iommu.c
> +++ b/drivers/pci/intel-iommu.c
> @@ -3866,6 +3866,20 @@ static int intel_iommu_unmap(struct iommu_domain *domain,
> struct dmar_domain *dmar_domain = domain->priv;
> size_t size = PAGE_SIZE << gfp_order;
>
> + /* The KVM code is *fucked* in the head. It maps the range
> + one page at a time, using 4KiB pages unless it actually
> + allocated hugepages using hugetlbfs. (So we get to flush
> + the CPU data cache and then the IOTLB for each page in
> + its loop). And on unmap, it unmaps 4KiB at a time (always
> + passing gfp_order==0), regardless of whether it mapped
> + using superpages or not. So on unmap, if we detect a
> + superpage in our page tables we are expected to unmap
> + *more* than we are asked to, and return a value indicating
> + how much we actually unmapped. WTF? */
> + if (dma_pfn_level_pte (dmar_domain, iova >> VTD_PAGE_SHIFT,
> + 1, &gfp_order))
> + size = PAGE_SIZE << gfp_order;
> +
> dma_pte_clear_range(dmar_domain, iova >> VTD_PAGE_SHIFT,
> (iova + size - 1) >> VTD_PAGE_SHIFT);
>
>
next prev parent reply other threads:[~2011-06-03 20:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 19:31 [RFC][PATCH] Fix superpage unmap on Intel IOMMU David Woodhouse
2011-06-03 20:00 ` David Woodhouse
2011-06-03 20:01 ` Alex Williamson [this message]
2011-06-04 9:00 ` David Woodhouse
2011-06-06 9:50 ` Roedel, Joerg
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=1307131318.3128.10.camel@ul30vt \
--to=alex.williamson@redhat.com \
--cc=allen.m.kay@intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joerg.roedel@amd.com \
--cc=kvm@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