xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org, Tim Deegan <tim@xen.org>,
	Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v3 2/4] iommu: set correct IOMMU entries when iommu_hap_pt_share == 0
Date: Fri, 23 May 2014 13:23:17 -0400	[thread overview]
Message-ID: <20140523172317.GC8343@phenom.dumpdata.com> (raw)
In-Reply-To: <1400862788-22037-3-git-send-email-roger.pau@citrix.com>

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@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Tim Deegan <tim@xen.org>

Seems that this has slipped:

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


> Cc: Tim Deegan <tim@xen.org>
> Cc: Jan Beulich <jbeulich@suse.com>
> ---
> 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@lists.xen.org
> http://lists.xen.org/xen-devel

  reply	other threads:[~2014-05-23 17:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 16:33 [PATCH v3 0/4] Fix grant map/unmap with auto-translated guests Roger Pau Monne
2014-05-23 16:33 ` [PATCH v3 1/4] xen: make logdirty and iommu mutually exclusive Roger Pau Monne
2014-05-26  9:45   ` Jan Beulich
2014-05-23 16:33 ` [PATCH v3 2/4] iommu: set correct IOMMU entries when iommu_hap_pt_share == 0 Roger Pau Monne
2014-05-23 17:23   ` Konrad Rzeszutek Wilk [this message]
2014-05-23 16:33 ` [PATCH v3 3/4] amd-iommu: disable iommu_hap_pt_share with AMD IOMMUs Roger Pau Monne
2014-05-23 16:33 ` [PATCH v3 4/4] xen: expose that grant table mappings update the IOMMU Roger Pau Monne
2014-05-26  9:49   ` Jan Beulich
2014-05-26 16:10     ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140523172317.GC8343@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).