From: "Jan Beulich" Subject: [PATCH] x86/emulation: honor failure of in_longmode() Date: Fri, 28 Aug 2009 09:21:42 +0100 Message-ID: <4A97AFB602000078000120E2@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Failure of in_longmode() shouldn't be treated the same as the function returning 'true'. Besides that, the function should always return false on 32-bits, eliminating the possibility for it failing there altogether. Signed-off-by: Jan Beulich --- 2009-08-18.orig/xen/arch/x86/x86_emulate/x86_emulate.c 2009-08-18 = 14:18:20.000000000 +0200 +++ 2009-08-18/xen/arch/x86/x86_emulate/x86_emulate.c 2009-08-24 = 11:30:17.000000000 +0200 @@ -958,6 +958,7 @@ in_longmode( struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) { +#ifdef __x86_64__ uint64_t efer; =20 if (ops->read_msr =3D=3D NULL) @@ -965,6 +966,9 @@ in_longmode( =20 ops->read_msr(MSR_EFER, &efer, ctxt); return !!(efer & EFER_LMA); +#else + return 0; +#endif } =20 static int @@ -3605,7 +3609,10 @@ x86_emulate( ss.attr.bytes =3D 0xc93; /* G+DB+P+S+Data */ =20 #ifdef __x86_64__ - if ( in_longmode(ctxt, ops) ) + rc =3D in_longmode(ctxt, ops); + if ( rc < 0 ) + goto cannot_emulate; + if ( rc ) { cs.attr.fields.db =3D 0; cs.attr.fields.l =3D 1; @@ -3777,7 +3784,10 @@ x86_emulate( ss.limit =3D ~0u; /* 4GB limit */ ss.attr.bytes =3D 0xc93; /* G+DB+P+S+Data */ =20 - if ( in_longmode(ctxt, ops) ) + rc =3D in_longmode(ctxt, ops); + if ( rc < 0 ) + goto cannot_emulate; + if ( rc ) { cs.attr.fields.db =3D 0; cs.attr.fields.l =3D 1;