From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Paul Durrant <paul.durrant@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v10 6/7] vtd: add missing check for shared EPT...
Date: Tue, 18 Sep 2018 17:56:25 +0100 [thread overview]
Message-ID: <20180918165626.23927-7-paul.durrant@citrix.com> (raw)
In-Reply-To: <20180918165626.23927-1-paul.durrant@citrix.com>
...in intel_iommu_unmap_page().
This patch also includes some non-functional modifications in
intel_iommu_map_page().
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
---
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: George Dunlap <george.dunlap@citrix.com>
v8:
- New in v8. (Split from the next patch in the series as requested by
Kevin).
---
xen/drivers/passthrough/vtd/iommu.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 63eabb3c1b..0eac755ff3 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1771,7 +1771,7 @@ static int __must_check intel_iommu_map_page(struct domain *d,
unsigned int flags)
{
struct domain_iommu *hd = dom_iommu(d);
- struct dma_pte *page = NULL, *pte = NULL, old, new = { 0 };
+ struct dma_pte *page, *pte, old, new = {};
u64 pg_maddr;
int rc = 0;
@@ -1786,14 +1786,16 @@ static int __must_check intel_iommu_map_page(struct domain *d,
spin_lock(&hd->arch.mapping_lock);
pg_maddr = addr_to_dma_page_maddr(d, dfn_to_daddr(dfn), 1);
- if ( pg_maddr == 0 )
+ if ( !pg_maddr )
{
spin_unlock(&hd->arch.mapping_lock);
return -ENOMEM;
}
+
page = (struct dma_pte *)map_vtd_domain_page(pg_maddr);
- pte = page + (dfn_x(dfn) & LEVEL_MASK);
+ pte = &page[dfn_x(dfn) & LEVEL_MASK];
old = *pte;
+
dma_set_pte_addr(new, mfn_to_maddr(mfn));
dma_set_pte_prot(new,
((flags & IOMMUF_readable) ? DMA_PTE_READ : 0) |
@@ -1809,6 +1811,7 @@ static int __must_check intel_iommu_map_page(struct domain *d,
unmap_vtd_domain_page(page);
return 0;
}
+
*pte = new;
iommu_flush_cache_entry(pte, sizeof(struct dma_pte));
@@ -1824,6 +1827,10 @@ static int __must_check intel_iommu_map_page(struct domain *d,
static int __must_check intel_iommu_unmap_page(struct domain *d,
dfn_t dfn)
{
+ /* Do nothing if VT-d shares EPT page table */
+ if ( iommu_use_hap_pt(d) )
+ return 0;
+
/* Do nothing if hardware domain and iommu supports pass thru. */
if ( iommu_hwdom_passthrough && is_hardware_domain(d) )
return 0;
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-09-18 16:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 16:56 [PATCH v10 0/7] paravirtual IOMMU pre-requisites and clean-up Paul Durrant
2018-09-18 16:56 ` [PATCH v10 1/7] iommu: introduce the concept of DFN Paul Durrant
2018-09-18 16:56 ` [PATCH v10 2/7] iommu: make use of type-safe DFN and MFN in exported functions Paul Durrant
2018-09-18 16:56 ` [PATCH v10 3/7] iommu: push use of type-safe DFN and MFN into iommu_ops Paul Durrant
2018-09-18 16:56 ` [PATCH v10 4/7] iommu: don't domain_crash() inside iommu_map/unmap_page() Paul Durrant
2018-09-18 16:56 ` [PATCH v10 5/7] memory: add check_get_page_from_gfn() as a wrapper Paul Durrant
2018-09-18 17:04 ` Julien Grall
2018-09-18 16:56 ` Paul Durrant [this message]
2018-09-18 16:56 ` [PATCH v10 7/7] vtd: add lookup_page method to iommu_ops Paul Durrant
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=20180918165626.23927-7-paul.durrant@citrix.com \
--to=paul.durrant@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).