From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] x86/HVM: correct segment register loading during task switch Date: Fri, 23 Sep 2016 04:09:44 -0600 Message-ID: <57E51B880200007800111E4C@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part5C6AE278.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnNQR-0005L1-Bn for xen-devel@lists.xenproject.org; Fri, 23 Sep 2016 10:09:47 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper 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. --=__Part5C6AE278.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Instead of #NP, #SS needs to be raised for a non-present %ss descriptor. Don't lose the low two selector bits on null selector loads. Signed-off-by: Jan Beulich --- This basically mirrors https://lists.xenproject.org/archives/html/xen-devel/2016-09/msg02198.html= =20 taking into account that there's no 64-bit mode case here. --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2723,6 +2723,7 @@ static int hvm_load_segment_selector( if ( (seg =3D=3D x86_seg_cs) || (seg =3D=3D x86_seg_ss) ) goto fail; memset(&segr, 0, sizeof(segr)); + segr.sel =3D sel; hvm_set_segment_register(v, seg, &segr); return 0; } @@ -2749,7 +2750,8 @@ static int hvm_load_segment_selector( /* Segment present in memory? */ if ( !(desc.b & _SEGMENT_P) ) { - fault_type =3D TRAP_no_segment; + fault_type =3D (seg !=3D x86_seg_ss) ? TRAP_no_segment + : TRAP_stack_error; goto unmap_and_fail; } =20 --=__Part5C6AE278.1__= Content-Type: text/plain; name="x86-HVM-task-switch-seg.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-task-switch-seg.patch" x86/HVM: correct segment register loading during task switch=0A=0AInstead = of #NP, #SS needs to be raised for a non-present %ss=0Adescriptor.=0A=0ADon= 't lose the low two selector bits on null selector loads.=0A=0ASigned-off-b= y: Jan Beulich =0A---=0AThis basically mirrors=0Ahttps:/= /lists.xenproject.org/archives/html/xen-devel/2016-09/msg02198.html=0Atakin= g into account that there's no 64-bit mode case here.=0A=0A--- a/xen/arch/x= 86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ -2723,6 +2723,7 @@ static = int hvm_load_segment_selector(=0A if ( (seg =3D=3D x86_seg_cs) || = (seg =3D=3D x86_seg_ss) )=0A goto fail;=0A memset(&segr= , 0, sizeof(segr));=0A+ segr.sel =3D sel;=0A hvm_set_segment= _register(v, seg, &segr);=0A return 0;=0A }=0A@@ -2749,7 = +2750,8 @@ static int hvm_load_segment_selector(=0A /* Segment = present in memory? */=0A if ( !(desc.b & _SEGMENT_P) )=0A = {=0A- fault_type =3D TRAP_no_segment;=0A+ fault_type = =3D (seg !=3D x86_seg_ss) ? TRAP_no_segment=0A+ = : TRAP_stack_error;=0A goto unmap_and_fail;=0A= }=0A =0A --=__Part5C6AE278.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__Part5C6AE278.1__=--