diff mbox

[v2,04/13] xen/arm: p2m: Update IOMMU mapping whenever possible if page table is not shared

Message ID 1501003615-15274-5-git-send-email-olekstysh@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Tyshchenko July 25, 2017, 5:26 p.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Update IOMMU mapping if the IOMMU doesn't share page table with the CPU.
The best place to do so on ARM is __p2m_set_entry(). Use mfn as an indicator
of the required action. If mfn is valid call iommu_map_pages(),
otherwise - iommu_unmap_pages().

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Acked-by: Julien Grall <julien.grall@arm.com>

---
   Changes in v1:
      - Update IOMMU mapping in __p2m_set_entry() instead of p2m_set_entry().
      - Pass order argument to IOMMU APIs instead of page_count.

   Changes in v2:
      - Add Julien's acked-by
---
 xen/arch/arm/p2m.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index fc2a106..729ed94 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -984,7 +984,15 @@  static int __p2m_set_entry(struct p2m_domain *p2m,
         p2m_free_entry(p2m, orig_pte, level);
 
     if ( need_iommu(p2m->domain) && (p2m_valid(orig_pte) || p2m_valid(*entry)) )
-        rc = iommu_iotlb_flush(p2m->domain, gfn_x(sgfn), 1UL << page_order);
+    {
+        if ( iommu_use_hap_pt(p2m->domain) )
+            rc = iommu_iotlb_flush(p2m->domain, gfn_x(sgfn), 1UL << page_order);
+        else if ( !mfn_eq(smfn, INVALID_MFN) )
+            rc = iommu_map_pages(p2m->domain, gfn_x(sgfn), mfn_x(smfn),
+                                 page_order, p2m_get_iommu_flags(t));
+        else
+            rc = iommu_unmap_pages(p2m->domain, gfn_x(sgfn), page_order);
+    }
     else
         rc = 0;