xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Unshared IOMMU issues
@ 2017-02-15 15:52 Oleksandr Tyshchenko
  2017-02-15 16:22 ` Jan Beulich
  0 siblings, 1 reply; 17+ messages in thread
From: Oleksandr Tyshchenko @ 2017-02-15 15:52 UTC (permalink / raw)
  To: Xen Devel; +Cc: Julien Grall, Stefano Stabellini, Jan Beulich

Hi, all.

As it was suggested by Julien in IRC I open this thread.

Currently, I am trying to add support for IPMMU in Xen.
It is VMSA-compatible IOMMU that integrated in the newest Renesas SoCs (ARM).
This IPMMU can't share the page table with the CPU since it uses
stage-1 page table
unlike the CPU that uses stage-2.
So, the IPMMU driver has own page table inside it and maintains them
like other "unshared IOMMU" drivers usually do.

For passing all mapping updates via IOMMU I slightly
modified P2M code (p2m_set_entry) on ARM to call iommu_map_page/iommu_unmap_page
if following (need_iommu(p2m->domain) &&
!iommu_use_hap_pt(p2m->domain)) is true.
I even optimized a bit by adding iommu_map_pages/iommu_unmap_pages API
and map_pages/unmap_pages flatform ops
for passing the whole memory block (nr pages) to the IOMMU code. But
it is not scope of this thread.

I faced several generic problems that had prevented me from making
IPMMU driver (but it might be another "unshared IOMMU" driver) happy
inside XEN on ARM.
Most of them I have already resolved somehow just to see that it
worked out well for me, but I am still have doubts about how to do it
in a right way.

So, for allowing P2M core to update IOMMU mapping from the first
"set_entry" and for "unshared IOMMU" driver to be ready to handle
IOMMU mapping updates
I do two things:
1. I always allocate IOMMU page table in iommu_domain_init() for every
domain even this domain won't have any assigned devices in future.
The main reason why I do so is not to skip any IOMMU mapping updates
from P2M code (RAM, MMIOs, etc). The IOMMU driver has to be ready for
processing
IOMMU mapping updates from the *very beginning*.
Of course, the IOMMU page table will be completely deleted in iommu_teardown().
But, anyway allocating IOMMU page table if it won't be really used in
domain looks not good.
Although there is an arch_iommu_populate_page_table() solution that
could help in a such situation,
but it does not look suitable for ARM because we have no way to
translate a MFN to a GFN as Julien had noticed me in IRC.

2. Another action I do is to explicitly set need_iommu flag during
arch_iommu_domain_init() call in ARM part if following
 (iommu_enabled && !is_hardware_domain(d) && !iommu_use_hap_pt(d)) is true.
I do that since in case of domU need_iommu flag is set during device
assignment, but it is too late. For dom0 we force need_iommu flag.
There are many mapping updates to P2M by the time the first device
will have been assigned.
I see the way how this action can be dropped. For example, don't rely
on need_iommu flag before updating IOMMU mapping from P2M,
check for iommu_enabled flag instead.

I think, but I am not 100% sure that we could avoid actions above if
we would have knowledge about device assignment for particular
domain before making any updates in P2M.

Could you please suggest me a right way in resolving such problems?

-- 
Regards,

Oleksandr Tyshchenko

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-02-22 11:59 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-15 15:52 Unshared IOMMU issues Oleksandr Tyshchenko
2017-02-15 16:22 ` Jan Beulich
2017-02-15 17:43   ` Oleksandr Tyshchenko
2017-02-16  9:36     ` Jan Beulich
2017-02-16 15:02       ` Oleksandr Tyshchenko
2017-02-16 15:52         ` Jan Beulich
2017-02-16 16:11           ` Julien Grall
2017-02-16 16:34             ` Jan Beulich
2017-02-16 18:09               ` Julien Grall
2017-02-16 18:58                 ` Stefano Stabellini
2017-02-17  7:43                 ` Jan Beulich
2017-02-17 15:25                   ` Julien Grall
2017-02-17 20:20                     ` Oleksandr Tyshchenko
2017-02-20  8:31                       ` Julien Grall
2017-02-21 10:39                         ` Oleksandr Tyshchenko
2017-02-22 11:39                           ` Julien Grall
2017-02-22 11:59                             ` Oleksandr Tyshchenko

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).