[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 2/4] iommu: set correct IOMMU entries when iommu_hap_pt_share == 0



On Fri, May 23, 2014 at 06:33:06PM +0200, Roger Pau Monne 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>
> Reviewed-by: Tim Deegan <tim@xxxxxxx>

Seems that this has slipped:

Tested-by: David Zhuang <david.zhuang@xxxxxxxxxx>


> Cc: Tim Deegan <tim@xxxxxxx>
> Cc: 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 12547a3..28ed184 100644
> --- a/xen/arch/x86/mm/p2m-ept.c
> +++ b/xen/arch/x86/mm/p2m-ept.c
> @@ -777,10 +777,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 a1794d0..085ab6f 100644
> --- a/xen/arch/x86/mm/p2m-pt.c
> +++ b/xen/arch/x86/mm/p2m-pt.c
> @@ -491,9 +491,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 )
> @@ -662,10 +660,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 d0cfdac..0ddbadb 100644
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -691,6 +691,33 @@ void p2m_flush_nestedp2m(struct domain *d);
>  void nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
>      l1_pgentry_t *p, 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

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.