p***@xen.org
2018-11-14 13:33:42 UTC
commit 5b6fb33d8f4fe753377090e6be8aaa816a6814ec
Author: Paul Durrant <***@citrix.com>
AuthorDate: Mon Nov 5 16:15:17 2018 +0100
Commit: Jan Beulich <***@suse.com>
CommitDate: Mon Nov 5 16:15:17 2018 +0100
vtd: add missing check for shared EPT...
...in intel_iommu_unmap_page().
This patch also includes some non-functional modifications in
intel_iommu_map_page().
Signed-off-by: Paul Durrant <***@citrix.com>
Acked-by: Kevin Tian <***@intel.com>
master commit: e30c47cd8be8ba73cfc1ec7b1ebd036464708a24
master date: 2018-10-04 14:53:57 +0200
---
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 4e734394e3..78ad7a71e9 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1766,7 +1766,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;
@@ -1781,14 +1781,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, (paddr_t)gfn << PAGE_SHIFT_4K, 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 + (gfn & LEVEL_MASK);
+ pte = &page[gfn & LEVEL_MASK];
old = *pte;
+
dma_set_pte_addr(new, (paddr_t)mfn << PAGE_SHIFT_4K);
dma_set_pte_prot(new,
((flags & IOMMUF_readable) ? DMA_PTE_READ : 0) |
@@ -1804,6 +1806,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));
@@ -1819,6 +1822,10 @@ static int __must_check intel_iommu_map_page(struct domain *d,
static int __must_check intel_iommu_unmap_page(struct domain *d,
unsigned long gfn)
{
+ /* 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_passthrough && is_hardware_domain(d) )
return 0;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.8
Author: Paul Durrant <***@citrix.com>
AuthorDate: Mon Nov 5 16:15:17 2018 +0100
Commit: Jan Beulich <***@suse.com>
CommitDate: Mon Nov 5 16:15:17 2018 +0100
vtd: add missing check for shared EPT...
...in intel_iommu_unmap_page().
This patch also includes some non-functional modifications in
intel_iommu_map_page().
Signed-off-by: Paul Durrant <***@citrix.com>
Acked-by: Kevin Tian <***@intel.com>
master commit: e30c47cd8be8ba73cfc1ec7b1ebd036464708a24
master date: 2018-10-04 14:53:57 +0200
---
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 4e734394e3..78ad7a71e9 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1766,7 +1766,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;
@@ -1781,14 +1781,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, (paddr_t)gfn << PAGE_SHIFT_4K, 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 + (gfn & LEVEL_MASK);
+ pte = &page[gfn & LEVEL_MASK];
old = *pte;
+
dma_set_pte_addr(new, (paddr_t)mfn << PAGE_SHIFT_4K);
dma_set_pte_prot(new,
((flags & IOMMUF_readable) ? DMA_PTE_READ : 0) |
@@ -1804,6 +1806,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));
@@ -1819,6 +1822,10 @@ static int __must_check intel_iommu_map_page(struct domain *d,
static int __must_check intel_iommu_unmap_page(struct domain *d,
unsigned long gfn)
{
+ /* 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_passthrough && is_hardware_domain(d) )
return 0;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.8