From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH 14/17] x86emul: support XSETBV Date: Thu, 08 Sep 2016 07:18:48 -0600 Message-ID: <57D18158020000780010D1DE@prv-mh.provo.novell.com> References: <57D17C78020000780010D127@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA3952828.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 1bhzEC-0001o2-Da for xen-devel@lists.xenproject.org; Thu, 08 Sep 2016 13:18:52 +0000 In-Reply-To: <57D17C78020000780010D127@prv-mh.provo.novell.com> 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. --=__PartA3952828.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This is a prereq for switching PV privileged op emulation to the generic instruction emulator. Since handle_xsetbv() is already capable of dealing with all guest kinds, avoid introducing another hook here. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -4174,6 +4174,24 @@ x86_emulate( =20 switch( modrm ) { +#ifdef __XEN__ + case 0xd1: /* xsetbv */ + { + unsigned long cr4; + + if ( vex.pfx ) + break; + if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) !=3D = X86EMUL_OKAY ) + cr4 =3D 0; + generate_exception_if(!(cr4 & X86_CR4_OSXSAVE), EXC_UD, -1); + generate_exception_if(!mode_ring0() || + handle_xsetbv(_regs._ecx, + _regs._eax | (_regs.rdx = << 32)), + EXC_GP, 0); + goto no_writeback; + } +#endif + case 0xdf: /* invlpga */ generate_exception_if(!in_protmode(ctxt, ops), EXC_UD, -1); generate_exception_if(!mode_ring0(), EXC_GP, 0); --=__PartA3952828.1__= Content-Type: text/plain; name="x86emul-XSETBV.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86emul-XSETBV.patch" x86emul: support XSETBV=0A=0AThis is a prereq for switching PV privileged = op emulation to the=0Ageneric instruction emulator. Since handle_xsetbv() = is already capable=0Aof dealing with all guest kinds, avoid introducing = another hook here.=0A=0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/arch/x86/x86_emulate/x86_emulate.c=0A+++ b/xen/arch/x86/x86_em= ulate/x86_emulate.c=0A@@ -4174,6 +4174,24 @@ x86_emulate(=0A =0A = switch( modrm )=0A {=0A+#ifdef __XEN__=0A+ case 0xd1: /* = xsetbv */=0A+ {=0A+ unsigned long cr4;=0A+=0A+ = if ( vex.pfx )=0A+ break;=0A+ if ( !ops->read_cr= || ops->read_cr(4, &cr4, ctxt) !=3D X86EMUL_OKAY )=0A+ cr4 = =3D 0;=0A+ generate_exception_if(!(cr4 & X86_CR4_OSXSAVE), = EXC_UD, -1);=0A+ generate_exception_if(!mode_ring0() ||=0A+ = handle_xsetbv(_regs._ecx,=0A+ = _regs._eax | (_regs.rdx << 32)),=0A+ = EXC_GP, 0);=0A+ goto no_writeback;=0A+= }=0A+#endif=0A+=0A case 0xdf: /* invlpga */=0A = generate_exception_if(!in_protmode(ctxt, ops), EXC_UD, -1);=0A = generate_exception_if(!mode_ring0(), EXC_GP, 0);=0A --=__PartA3952828.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__PartA3952828.1__=--