[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 2/4] iommu: set correct IOMMU entries when iommu_hap_pt_share == 0
>>> On 23.04.14 at 10:16, <roger.pau@xxxxxxxxxx> wrote: > If the memory map is not shared between HAP and IOMMU we fail to set > correct IOMMU mappings for memory types other than p2m_ram_rw. > > This patchs adds IOMMU support for the following memory types: > p2m_grant_map_rw, p2m_map_foreign, p2m_ram_ro, p2m_grant_map_ro and > p2m_ram_logdirty. > > Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> > Changes since v1: > - Move the p2m type switch to IOMMU flags to an inline function that > is shared between p2m-ept and p2m-pt. > - Make p2m_set_entry also use p2m_get_iommu_flags. > --- > xen/arch/x86/mm/p2m-ept.c | 7 ++++--- > xen/arch/x86/mm/p2m-pt.c | 11 +++++------ > xen/include/asm-x86/p2m.h | 27 +++++++++++++++++++++++++++ > 3 files changed, 36 insertions(+), 9 deletions(-) > > diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c > index 7dcfcb6..6e8a1af 100644 > --- a/xen/arch/x86/mm/p2m-ept.c > +++ b/xen/arch/x86/mm/p2m-ept.c > @@ -472,10 +472,11 @@ out: > iommu_pte_flush(d, gfn, &ept_entry->epte, order, > vtd_pte_present); > else > { > - if ( p2mt == p2m_ram_rw ) > + unsigned int flags = p2m_get_iommu_flags(p2mt); > + > + if ( flags != 0 ) > for ( i = 0; i < (1 << order); i++ ) > - iommu_map_page(d, gfn + i, mfn_x(mfn) + i, > - IOMMUF_readable | IOMMUF_writable); > + iommu_map_page(d, gfn + i, mfn_x(mfn) + i, flags); > else > for ( i = 0; i < (1 << order); i++ ) > iommu_unmap_page(d, gfn + i); > diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c > index 915f60d..2b36a10 100644 > --- a/xen/arch/x86/mm/p2m-pt.c > +++ b/xen/arch/x86/mm/p2m-pt.c > @@ -291,9 +291,7 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long > gfn, mfn_t mfn, > l2_pgentry_t l2e_content; > l3_pgentry_t l3e_content; > int rc; > - unsigned int iommu_pte_flags = (p2mt == p2m_ram_rw) ? > - IOMMUF_readable|IOMMUF_writable: > - 0; > + unsigned int iommu_pte_flags = p2m_get_iommu_flags(p2mt); > unsigned long old_mfn = 0; > > if ( tb_init_done ) > @@ -456,10 +454,11 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long > gfn, mfn_t mfn, > } > else > { > - if ( p2mt == p2m_ram_rw ) > + unsigned int flags = p2m_get_iommu_flags(p2mt); > + > + if ( flags != 0 ) > for ( i = 0; i < (1UL << page_order); i++ ) > - iommu_map_page(p2m->domain, gfn+i, mfn_x(mfn)+i, > - IOMMUF_readable|IOMMUF_writable); > + iommu_map_page(p2m->domain, gfn+i, mfn_x(mfn)+i, flags); > else > for ( int i = 0; i < (1UL << page_order); i++ ) > iommu_unmap_page(p2m->domain, gfn+i); > diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h > index 47604da..54f5a88 100644 > --- a/xen/include/asm-x86/p2m.h > +++ b/xen/include/asm-x86/p2m.h > @@ -670,6 +670,33 @@ void p2m_flush_nestedp2m(struct domain *d); > void nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, > l1_pgentry_t *p, mfn_t table_mfn, l1_pgentry_t new, unsigned int > level); > > +/* > + * p2m type to IOMMU flags > + */ > +static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt) > +{ > + unsigned int flags; > + > + switch( p2mt ) > + { > + case p2m_ram_rw: > + case p2m_grant_map_rw: > + case p2m_ram_logdirty: > + case p2m_map_foreign: > + flags = IOMMUF_readable | IOMMUF_writable; > + break; > + case p2m_ram_ro: > + case p2m_grant_map_ro: > + flags = IOMMUF_readable; > + break; > + default: > + flags = 0; > + break; > + } > + > + return flags; > +} > + > #endif /* _XEN_P2M_H */ > > /* > -- > 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |