All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Egger, Christoph" <chegger@amazon.de>
To: Yang Zhang <yang.z.zhang@intel.com>, xen-devel@lists.xen.org
Cc: andrew.cooper3@citrix.com, xiantao.zhang@intel.com,
	eddie.dong@intel.com, jun.nakajima@intel.com, JBeulich@suse.com
Subject: Re: [PATCH] nested EPT: fixing wrong handling for L2 guest's direct mmio access
Date: Fri, 17 Jan 2014 09:59:54 +0100	[thread overview]
Message-ID: <52D8F10A.7080501@amazon.de> (raw)
In-Reply-To: <1389940508-2239-1-git-send-email-yang.z.zhang@intel.com>

On 17.01.14 07:35, Yang Zhang wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
> 
> L2 guest will access the physical device directly(nested VT-d). For such access,
> Shadow EPT table should point to device's MMIO. But in current logic, L0 doesn't
> distinguish the MMIO whether from qemu or physical device when building shadow EPT table.
> This is wrong. This patch will setup the correct shadow EPT table for such MMIO ranges.
> 
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> ---
>  xen/arch/x86/mm/hap/nested_hap.c    |   10 ++++++++--
>  xen/include/asm-x86/hvm/nestedhvm.h |    1 +
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/x86/mm/hap/nested_hap.c b/xen/arch/x86/mm/hap/nested_hap.c
> index c2ef1d1..38e2327 100644
> --- a/xen/arch/x86/mm/hap/nested_hap.c
> +++ b/xen/arch/x86/mm/hap/nested_hap.c
> @@ -170,8 +170,11 @@ nestedhap_walk_L0_p2m(struct p2m_domain *p2m, paddr_t L1_gpa, paddr_t *L0_gpa,
>      mfn = get_gfn_type_access(p2m, L1_gpa >> PAGE_SHIFT, p2mt, p2ma,
>                                0, page_order);
>  
> +    rc = NESTEDHVM_PAGEFAULT_DIRECT_MMIO;
> +    if ( *p2mt == p2m_mmio_direct )
> +        goto direct_mmio_out;
>      rc = NESTEDHVM_PAGEFAULT_MMIO;
> -    if ( p2m_is_mmio(*p2mt) )
> +    if ( *p2mt == p2m_mmio_dm )
>          goto out;

Why does p2m_is_mmio() not cover p2m_mmio_direct ?

Christoph

>      rc = NESTEDHVM_PAGEFAULT_L0_ERROR;
> @@ -184,8 +187,9 @@ nestedhap_walk_L0_p2m(struct p2m_domain *p2m, paddr_t L1_gpa, paddr_t *L0_gpa,
>      if ( !mfn_valid(mfn) )
>          goto out;
>  
> -    *L0_gpa = (mfn_x(mfn) << PAGE_SHIFT) + (L1_gpa & ~PAGE_MASK);
>      rc = NESTEDHVM_PAGEFAULT_DONE;
> +direct_mmio_out:
> +    *L0_gpa = (mfn_x(mfn) << PAGE_SHIFT) + (L1_gpa & ~PAGE_MASK);
>  out:
>      __put_gfn(p2m, L1_gpa >> PAGE_SHIFT);
>      return rc;
> @@ -245,6 +249,8 @@ nestedhvm_hap_nested_page_fault(struct vcpu *v, paddr_t *L2_gpa,
>          break;
>      case NESTEDHVM_PAGEFAULT_MMIO:
>          return rv;
> +    case NESTEDHVM_PAGEFAULT_DIRECT_MMIO:
> +        break;
>      default:
>          BUG();
>          break;
> diff --git a/xen/include/asm-x86/hvm/nestedhvm.h b/xen/include/asm-x86/hvm/nestedhvm.h
> index d8124cf..cca41b3 100644
> --- a/xen/include/asm-x86/hvm/nestedhvm.h
> +++ b/xen/include/asm-x86/hvm/nestedhvm.h
> @@ -53,6 +53,7 @@ bool_t nestedhvm_vcpu_in_guestmode(struct vcpu *v);
>  #define NESTEDHVM_PAGEFAULT_L0_ERROR   3
>  #define NESTEDHVM_PAGEFAULT_MMIO       4
>  #define NESTEDHVM_PAGEFAULT_RETRY      5
> +#define NESTEDHVM_PAGEFAULT_DIRECT_MMIO 6
>  int nestedhvm_hap_nested_page_fault(struct vcpu *v, paddr_t *L2_gpa,
>      bool_t access_r, bool_t access_w, bool_t access_x);
>  
> 

  reply	other threads:[~2014-01-17  8:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17  6:35 [PATCH] nested EPT: fixing wrong handling for L2 guest's direct mmio access Yang Zhang
2014-01-17  8:59 ` Egger, Christoph [this message]
2014-01-17 13:10   ` Tim Deegan
2014-01-17 13:16 ` Tim Deegan

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=52D8F10A.7080501@amazon.de \
    --to=chegger@amazon.de \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xiantao.zhang@intel.com \
    --cc=yang.z.zhang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.