From: "Jan Beulich" Subject: [PATCH 1/3] x86emul: use DstEax also for {, I}{MUL, DIV} Date: Tue, 16 Aug 2016 03:32:52 -0600 Message-ID: <57B2F9E402000078001063FD@prv-mh.provo.novell.com> References: <57B2F93802000078001063E6@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part84B26CD4.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZajz-0005dm-D4 for xen-devel@lists.xenproject.org; Tue, 16 Aug 2016 09:32:59 +0000 In-Reply-To: <57B2F93802000078001063E6@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. --=__Part84B26CD4.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just like said in commit c0bc0adf24 ("x86emul: use DstEax where possible"): While it avoids just a few instructions, we should nevertheless make use of generic code as much as possible. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1738,7 +1738,7 @@ x86_emulate( case 5: /* imul */ case 6: /* div */ case 7: /* idiv */ - d =3D (d & (ByteOp | ModRM)) | DstImplicit | SrcMem; + d =3D (d & (ByteOp | ModRM)) | DstEax | SrcMem; break; } break; @@ -3554,11 +3554,8 @@ x86_emulate( emulate_1op("neg", dst, _regs.eflags); break; case 4: /* mul */ - dst.type =3D OP_REG; - dst.reg =3D (unsigned long *)&_regs.eax; - dst.val =3D *dst.reg; _regs.eflags &=3D ~(EFLG_OF|EFLG_CF); - switch ( dst.bytes =3D src.bytes ) + switch ( dst.bytes ) { case 1: dst.val =3D (uint8_t)dst.val; @@ -3594,10 +3591,6 @@ x86_emulate( } break; case 5: /* imul */ - dst.type =3D OP_REG; - dst.reg =3D (unsigned long *)&_regs.eax; - dst.val =3D *dst.reg; - dst.bytes =3D src.bytes; imul: _regs.eflags &=3D ~(EFLG_OF|EFLG_CF); switch ( dst.bytes ) @@ -3639,9 +3632,7 @@ x86_emulate( } break; case 6: /* div */ - dst.type =3D OP_REG; - dst.reg =3D (unsigned long *)&_regs.eax; - switch ( dst.bytes =3D src.bytes ) + switch ( src.bytes ) { case 1: u[0] =3D (uint16_t)_regs.eax; @@ -3686,9 +3677,7 @@ x86_emulate( } break; case 7: /* idiv */ - dst.type =3D OP_REG; - dst.reg =3D (unsigned long *)&_regs.eax; - switch ( dst.bytes =3D src.bytes ) + switch ( src.bytes ) { case 1: u[0] =3D (int16_t)_regs.eax; --=__Part84B26CD4.1__= Content-Type: text/plain; name="x86emul-use-DstEax-mul-div.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86emul-use-DstEax-mul-div.patch" x86emul: use DstEax also for {,I}{MUL,DIV}=0A=0AJust like said in commit = c0bc0adf24 ("x86emul: use DstEax where=0Apossible"): While it avoids just = a few instructions, we should=0Anevertheless make use of generic code as = much as possible.=0A=0ASigned-off-by: Jan Beulich =0A=0A= --- a/xen/arch/x86/x86_emulate/x86_emulate.c=0A+++ b/xen/arch/x86/x86_emula= te/x86_emulate.c=0A@@ -1738,7 +1738,7 @@ x86_emulate(=0A = case 5: /* imul */=0A case 6: /* div */=0A = case 7: /* idiv */=0A- d =3D (d & (ByteOp | ModRM)) | = DstImplicit | SrcMem;=0A+ d =3D (d & (ByteOp | ModRM)) = | DstEax | SrcMem;=0A break;=0A }=0A = break;=0A@@ -3554,11 +3554,8 @@ x86_emulate(=0A = emulate_1op("neg", dst, _regs.eflags);=0A break;=0A = case 4: /* mul */=0A- dst.type =3D OP_REG;=0A- = dst.reg =3D (unsigned long *)&_regs.eax;=0A- dst.val =3D = *dst.reg;=0A _regs.eflags &=3D ~(EFLG_OF|EFLG_CF);=0A- = switch ( dst.bytes =3D src.bytes )=0A+ switch ( dst.bytes = )=0A {=0A case 1:=0A dst.val =3D = (uint8_t)dst.val;=0A@@ -3594,10 +3591,6 @@ x86_emulate(=0A = }=0A break;=0A case 5: /* imul */=0A- = dst.type =3D OP_REG;=0A- dst.reg =3D (unsigned long *)&_regs.ea= x;=0A- dst.val =3D *dst.reg;=0A- dst.bytes =3D = src.bytes;=0A imul:=0A _regs.eflags &=3D ~(EFLG_OF|EFLG= _CF);=0A switch ( dst.bytes )=0A@@ -3639,9 +3632,7 @@ = x86_emulate(=0A }=0A break;=0A case 6: /* = div */=0A- dst.type =3D OP_REG;=0A- dst.reg =3D = (unsigned long *)&_regs.eax;=0A- switch ( dst.bytes =3D = src.bytes )=0A+ switch ( src.bytes )=0A {=0A = case 1:=0A u[0] =3D (uint16_t)_regs.eax;=0A@@ -3686,9 = +3677,7 @@ x86_emulate(=0A }=0A break;=0A = case 7: /* idiv */=0A- dst.type =3D OP_REG;=0A- = dst.reg =3D (unsigned long *)&_regs.eax;=0A- switch ( = dst.bytes =3D src.bytes )=0A+ switch ( src.bytes )=0A = {=0A case 1:=0A u[0] =3D (int16_t)_regs.eax;= =0A --=__Part84B26CD4.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__Part84B26CD4.1__=--