xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Yang Zhang <yang.z.zhang@intel.com>
To: xen-devel@lists.xen.org
Cc: Yang Zhang <yang.z.zhang@Intel.com>,
	chegger@amazon.de, eddie.dong@intel.com, xiantao.zhang@intel.com,
	JBeulich@suse.com
Subject: [PATCH 2/2] Nested EPT: fixing issue of translate L2 gva to L1 gfn
Date: Wed, 12 Feb 2014 10:08:56 +0800	[thread overview]
Message-ID: <1392170936-31362-2-git-send-email-yang.z.zhang@intel.com> (raw)
In-Reply-To: <1392170936-31362-1-git-send-email-yang.z.zhang@intel.com>

From: Yang Zhang <yang.z.zhang@Intel.com>

There is no way to translate L2 gva to L1 gfn directly. To do it,
we need to get L2's gfn first. Then look up the virtual EPT to get L1's gfn.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
---
 xen/arch/x86/mm/p2m.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 8f380ed..e92cfbe 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1605,22 +1605,37 @@ unsigned long paging_gva_to_gfn(struct vcpu *v,
         && paging_mode_hap(v->domain) 
         && nestedhvm_is_n2(v) )
     {
-        unsigned long gfn;
+        unsigned long gfn, l1gfn, exit_qual;
         struct p2m_domain *p2m;
         const struct paging_mode *mode;
-        uint32_t pfec_21 = *pfec;
         uint64_t np2m_base = nhvm_vcpu_p2m_base(v);
+        unsigned int page_order, exit_reason;
+        int rc;
+        uint8_t p2m_acc;
+        struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
 
         /* translate l2 guest va into l2 guest gfn */
         p2m = p2m_get_nestedp2m(v, np2m_base);
         mode = paging_get_nestedmode(v);
         gfn = mode->gva_to_gfn(v, p2m, va, pfec);
 
+        if ( gfn == INVALID_GFN )
+            return gfn;
+
         /* translate l2 guest gfn into l1 guest gfn */
-        return hostmode->p2m_ga_to_gfn(v, hostp2m, np2m_base,
-                                       gfn << PAGE_SHIFT, &pfec_21, NULL);
-    }
+        rc = nept_translate_l2ga(v, gfn << 12 , &page_order, 4, &l1gfn, &p2m_acc,
+                                &exit_qual, &exit_reason);
+        if ( rc == EPT_TRANSLATE_VIOLATION || rc == EPT_TRANSLATE_MISCONFIG )
+        {
+            nvmx->ept.exit_reason = exit_reason;
+            nvmx->ept.exit_qual = exit_qual;
+            vcpu_nestedhvm(current).nv_vmexit_pending = 1;
+        }
+        if ( rc == EPT_TRANSLATE_RETRY )
+            *pfec = PFEC_page_paged;
 
+        return l1gfn;
+    }
     return hostmode->gva_to_gfn(v, hostp2m, va, pfec);
 }
 
-- 
1.7.1

  reply	other threads:[~2014-02-12  2:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12  2:08 [PATCH 1/2] Nested VMX: update nested paging mode on vmexit Yang Zhang
2014-02-12  2:08 ` Yang Zhang [this message]
2014-02-12  9:28   ` [PATCH 2/2] Nested EPT: fixing issue of translate L2 gva to L1 gfn Egger, Christoph
2014-02-13  4:24     ` Zhang, Yang Z
2014-02-12  9:22 ` [PATCH 1/2] Nested VMX: update nested paging mode on vmexit Egger, Christoph

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=1392170936-31362-2-git-send-email-yang.z.zhang@intel.com \
    --to=yang.z.zhang@intel.com \
    --cc=JBeulich@suse.com \
    --cc=chegger@amazon.de \
    --cc=eddie.dong@intel.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xiantao.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 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).