From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: [PATCH] nestedsvm: fix VMEXIT emulation Date: Wed, 17 Oct 2012 11:08:35 +0200 Message-ID: <507E7593.9080904@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040904050005060908070009" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --------------040904050005060908070009 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit Values in regs can be newer than those in the shadow vmcb (e.g. due to an instruction emulation right before). So use the values from regs. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --------------040904050005060908070009 Content-Type: text/plain; charset="us-ascii"; name="xen_nh_vmexit.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_nh_vmexit.diff" Content-Description: xen_nh_vmexit.diff diff -r 6b73078a4403 xen/arch/x86/hvm/svm/nestedsvm.c --- a/xen/arch/x86/hvm/svm/nestedsvm.c Fri Oct 12 14:38:20 2012 +0200 +++ b/xen/arch/x86/hvm/svm/nestedsvm.c Wed Oct 17 09:19:05 2012 +0200 @@ -990,7 +999,7 @@ nsvm_vmcb_guest_intercepts_trap(struct v } static int -nsvm_vmcb_prepare4vmexit(struct vcpu *v) +nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct cpu_user_regs *regs) { struct nestedvcpu *nv = &vcpu_nestedhvm(v); struct nestedsvm *svm = &vcpu_nestedsvm(v); @@ -1114,17 +1123,22 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v) ns_vmcb->_dr7 = n2vmcb->_dr7; ns_vmcb->_dr6 = n2vmcb->_dr6; + /* Restore registers from regs as those values + * can be newer than in n2vmcb (e.g. due to an + * instruction emulation right before). + */ + /* RFLAGS */ - ns_vmcb->rflags = n2vmcb->rflags; + ns_vmcb->rflags = n2vmcb->rflags = regs->rflags; /* RIP */ - ns_vmcb->rip = n2vmcb->rip; + ns_vmcb->rip = n2vmcb->rip = regs->rip; /* RSP */ - ns_vmcb->rsp = n2vmcb->rsp; + ns_vmcb->rsp = n2vmcb->rsp = regs->rsp; /* RAX */ - ns_vmcb->rax = n2vmcb->rax; + ns_vmcb->rax = n2vmcb->rax = regs->rax; /* Keep the l2 guest values of the fs, gs, ldtr, tr, kerngsbase, * star, lstar, cstar, sfmask, sysenter_cs, sysenter_esp, @@ -1358,7 +1372,7 @@ nestedsvm_vmexit_n2n1(struct vcpu *v, st ASSERT(vcpu_nestedhvm(v).nv_vmswitch_in_progress); ASSERT(nestedhvm_vcpu_in_guestmode(v)); - rc = nsvm_vmcb_prepare4vmexit(v); + rc = nsvm_vmcb_prepare4vmexit(v, regs); if (rc) ret = NESTEDHVM_VMEXIT_ERROR; --------------040904050005060908070009 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------040904050005060908070009--