* [PATCH] nestedsvm: fix VMEXIT emulation
@ 2012-10-17 9:08 Christoph Egger
2012-10-22 15:24 ` Tim Deegan
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Egger @ 2012-10-17 9:08 UTC (permalink / raw)
To: xen-devel@lists.xen.org
[-- Attachment #1: Type: text/plain, Size: 451 bytes --]
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 <Christoph.Egger@amd.com>
--
---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
[-- Attachment #2: xen_nh_vmexit.diff --]
[-- Type: text/plain, Size: 1617 bytes --]
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;
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nestedsvm: fix VMEXIT emulation
2012-10-17 9:08 [PATCH] nestedsvm: fix VMEXIT emulation Christoph Egger
@ 2012-10-22 15:24 ` Tim Deegan
0 siblings, 0 replies; 2+ messages in thread
From: Tim Deegan @ 2012-10-22 15:24 UTC (permalink / raw)
To: Christoph Egger; +Cc: xen-devel@lists.xen.org
At 11:08 +0200 on 17 Oct (1350472115), Christoph Egger wrote:
>
> 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 <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <tim@xen.org>
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;
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-22 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 9:08 [PATCH] nestedsvm: fix VMEXIT emulation Christoph Egger
2012-10-22 15:24 ` Tim Deegan
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.