Message ID | 1494424994-26232-5-git-send-email-olekstysh@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Oleksandr, On 10/05/17 15:03, Oleksandr Tyshchenko wrote: > 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> > CC: Julien Grall <julien.grall@arm.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. > --- > xen/arch/arm/p2m.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > index 34d5776..9ca491b 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; > > Cheers,
On Thu, May 11, 2017 at 2:24 PM, Julien Grall <julien.grall@arm.com> wrote: > Hi Oleksandr, Hi Julien > > On 10/05/17 15:03, Oleksandr Tyshchenko wrote: >> >> 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> >> CC: Julien Grall <julien.grall@arm.com> > > > Acked-by: Julien Grall <julien.grall@arm.com> Great. Thank you. > > >> >> --- >> 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. >> --- >> xen/arch/arm/p2m.c | 10 +++++++++- >> 1 file changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c >> index 34d5776..9ca491b 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; >> >> > > Cheers, > > -- > Julien Grall
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 34d5776..9ca491b 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;