xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dongxiao Xu <dongxiao.xu@intel.com>
To: xen-devel@lists.xen.org
Subject: [PATCH] nested vmx: Fix the booting of L2 PAE guest
Date: Mon, 24 Jun 2013 13:55:00 +0800	[thread overview]
Message-ID: <1372053300-20211-1-git-send-email-dongxiao.xu@intel.com> (raw)

When doing virtual VM entry and virtual VM exit, we need to
sychronize the PAE PDPTR related VMCS registers. With this fix,
we can boot 32bit PAE L2 guest (Win7 & RHEL6.4) on "Xen on Xen"
environment.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Tested-by: Yongjie Ren <yongjie.ren@intel.com>
---
 xen/arch/x86/hvm/vmx/vvmx.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index bb7688f..5dfbc54 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -864,6 +864,13 @@ static const u16 vmcs_gstate_field[] = {
     GUEST_SYSENTER_EIP,
 };
 
+static const u16 gpdptr_fields[] = {
+    GUEST_PDPTR0,
+    GUEST_PDPTR1,
+    GUEST_PDPTR2,
+    GUEST_PDPTR3,
+};
+
 /*
  * Context: shadow -> virtual VMCS
  */
@@ -1053,18 +1060,6 @@ static void load_shadow_guest_state(struct vcpu *v)
                      (__get_vvmcs(vvmcs, CR4_READ_SHADOW) & cr_gh_mask);
     __vmwrite(CR4_READ_SHADOW, cr_read_shadow);
 
-    if ( nvmx_ept_enabled(v) && hvm_pae_enabled(v) &&
-         (v->arch.hvm_vcpu.guest_efer & EFER_LMA) )
-    {
-        static const u16 gpdptr_fields[] = {
-            GUEST_PDPTR0,
-            GUEST_PDPTR1,
-            GUEST_PDPTR2,
-            GUEST_PDPTR3,
-        };
-        vvmcs_to_shadow_bulk(v, ARRAY_SIZE(gpdptr_fields), gpdptr_fields);
-    }
-
     /* TODO: CR3 target control */
 }
 
@@ -1159,6 +1154,10 @@ static void virtual_vmentry(struct cpu_user_regs *regs)
     if ( lm_l1 != lm_l2 )
         paging_update_paging_modes(v);
 
+    if ( nvmx_ept_enabled(v) && hvm_pae_enabled(v) &&
+         !(v->arch.hvm_vcpu.guest_efer & EFER_LMA) )
+        vvmcs_to_shadow_bulk(v, ARRAY_SIZE(gpdptr_fields), gpdptr_fields);
+
     regs->eip = __get_vvmcs(vvmcs, GUEST_RIP);
     regs->esp = __get_vvmcs(vvmcs, GUEST_RSP);
     regs->eflags = __get_vvmcs(vvmcs, GUEST_RFLAGS);
@@ -1294,6 +1293,10 @@ static void virtual_vmexit(struct cpu_user_regs *regs)
     sync_vvmcs_guest_state(v, regs);
     sync_exception_state(v);
 
+    if ( nvmx_ept_enabled(v) && hvm_pae_enabled(v) &&
+         !(v->arch.hvm_vcpu.guest_efer & EFER_LMA) )
+        shadow_to_vvmcs_bulk(v, ARRAY_SIZE(gpdptr_fields), gpdptr_fields);
+
     vmx_vmcs_switch(v->arch.hvm_vmx.vmcs, nvcpu->nv_n1vmcx);
 
     nestedhvm_vcpu_exit_guestmode(v);
-- 
1.8.1.5

             reply	other threads:[~2013-06-24  5:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24  5:55 Dongxiao Xu [this message]
2013-06-24  6:46 ` [PATCH] nested vmx: Fix the booting of L2 PAE guest Keir Fraser
2013-06-27  1:14   ` Xu, Dongxiao
2013-06-27  8:40     ` Jan Beulich
2013-06-27 10:57       ` George Dunlap
2013-06-27 12:05         ` Jan Beulich
2013-06-27 13:41           ` George Dunlap
2013-06-27 15:03         ` Jan Beulich
2013-06-27 14:51       ` Dong, Eddie

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=1372053300-20211-1-git-send-email-dongxiao.xu@intel.com \
    --to=dongxiao.xu@intel.com \
    --cc=xen-devel@lists.xen.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).