From: "Jan Beulich" Subject: [PATCH 5/5] x86/PV: don't commit debug register values early in arch_set_info_guest() Date: Tue, 10 Dec 2013 15:48:57 +0000 Message-ID: <52A745FA020000780010BF2E@nat28.tlf.novell.com> References: <52A744B7020000780010BEF1@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part5360ABF9.1__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VqPYU-0005XN-PF for xen-devel@lists.xenproject.org; Tue, 10 Dec 2013 15:49:06 +0000 In-Reply-To: <52A744B7020000780010BEF1@nat28.tlf.novell.com> 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 Cc: George Dunlap , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part5360ABF9.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline They're being taken care of later (via set_debugreg()), and temporarily copying them into struct vcpu means that bad values may end up getting loaded during context switch if the vCPU is already running and the function errors out between the premature and real commit step, leading to the same issue that XSA-12 dealt with. Signed-off-by: Jan Beulich Acked-by: Ian Campbell --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -740,11 +740,12 @@ int arch_set_info_guest( XLAT_trap_info(v->arch.pv_vcpu.trap_ctxt + i, c.cmp->trap_ctxt + i); } - for ( i =3D 0; i < ARRAY_SIZE(v->arch.debugreg); ++i ) - v->arch.debugreg[i] =3D c(debugreg[i]); =20 if ( has_hvm_container_vcpu(v) ) { + for ( i =3D 0; i < ARRAY_SIZE(v->arch.debugreg); ++i ) + v->arch.debugreg[i] =3D c(debugreg[i]); + /* * NB: TF_kernel_mode is set unconditionally for HVM guests, * so we always use the gs_base_kernel here. If we change this --=__Part5360ABF9.1__= Content-Type: text/plain; name="x86-PV-commit-DRs-once.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-PV-commit-DRs-once.patch" x86/PV: don't commit debug register values early in arch_set_info_guest()= =0A=0AThey're being taken care of later (via set_debugreg()), and = temporarily=0Acopying them into struct vcpu means that bad values may end = up getting=0Aloaded during context switch if the vCPU is already running = and the=0Afunction errors out between the premature and real commit step, = leading=0Ato the same issue that XSA-12 dealt with.=0A=0ASigned-off-by: = Jan Beulich =0AAcked-by: Ian Campbell =0A=0A--- a/xen/arch/x86/domain.c=0A+++ b/xen/arch/x86/domain.c=0A@@= -740,11 +740,12 @@ int arch_set_info_guest(=0A XLAT_trap_info(= v->arch.pv_vcpu.trap_ctxt + i,=0A c.cmp->trap_ct= xt + i);=0A }=0A- for ( i =3D 0; i < ARRAY_SIZE(v->arch.debugreg); = ++i )=0A- v->arch.debugreg[i] =3D c(debugreg[i]);=0A =0A if ( = has_hvm_container_vcpu(v) )=0A {=0A+ for ( i =3D 0; i < = ARRAY_SIZE(v->arch.debugreg); ++i )=0A+ v->arch.debugreg[i] =3D = c(debugreg[i]);=0A+=0A /*=0A * NB: TF_kernel_mode is set = unconditionally for HVM guests,=0A * so we always use the = gs_base_kernel here. If we change this=0A --=__Part5360ABF9.1__= 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 --=__Part5360ABF9.1__=--