Message ID | 20161130164950.43543-8-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 30.11.16 at 17:49, <roger.pau@citrix.com> wrote: > --- a/xen/include/asm-x86/p2m.h > +++ b/xen/include/asm-x86/p2m.h > @@ -834,6 +834,7 @@ static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt) > case p2m_grant_map_rw: > case p2m_ram_logdirty: > case p2m_map_foreign: > + case p2m_mmio_direct: > flags = IOMMUF_readable | IOMMUF_writable; > break; I think you need to take mmio_ro_ranges into account here. Jan
On Thu, Dec 08, 2016 at 09:24:08AM -0700, Jan Beulich wrote: > >>> On 30.11.16 at 17:49, <roger.pau@citrix.com> wrote: > > --- a/xen/include/asm-x86/p2m.h > > +++ b/xen/include/asm-x86/p2m.h > > @@ -834,6 +834,7 @@ static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt) > > case p2m_grant_map_rw: > > case p2m_ram_logdirty: > > case p2m_map_foreign: > > + case p2m_mmio_direct: > > flags = IOMMUF_readable | IOMMUF_writable; > > break; > > I think you need to take mmio_ro_ranges into account here. Right, I've split p2m_mmio_direct into a separate case and added a check for mmio_ro_ranges, this however forces all the callers of p2m_get_iommu_flags to pass a second mfn parameter (it isn't that bad since the mfn is always available in the call sites). Roger.
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 6a45185..7e33ab6 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1053,16 +1053,7 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn, ret = p2m_set_entry(p2m, gfn, _mfn(gfn), PAGE_ORDER_4K, p2m_mmio_direct, p2ma); else if ( mfn_x(mfn) == gfn && p2mt == p2m_mmio_direct && a == p2ma ) - { ret = 0; - /* - * PVH fixme: during Dom0 PVH construction, p2m entries are being set - * but iomem regions are not mapped with IOMMU. This makes sure that - * RMRRs are correctly mapped with IOMMU. - */ - if ( is_hardware_domain(d) && !iommu_use_hap_pt(d) ) - ret = iommu_map_page(d, gfn, gfn, IOMMUF_readable|IOMMUF_writable); - } else { if ( flag & XEN_DOMCTL_DEV_RDM_RELAXED ) diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 7035860..b562da3 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -834,6 +834,7 @@ static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt) case p2m_grant_map_rw: case p2m_ram_logdirty: case p2m_map_foreign: + case p2m_mmio_direct: flags = IOMMUF_readable | IOMMUF_writable; break; case p2m_ram_ro:
There's nothing wrong with allowing the domain to perform DMA transfers to MMIO areas that it already can access from the CPU, and this allows us to remove the hack in set_identity_p2m_entry for PVH Dom0. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- xen/arch/x86/mm/p2m.c | 9 --------- xen/include/asm-x86/p2m.h | 1 + 2 files changed, 1 insertion(+), 9 deletions(-)