From: "Jan Beulich" Subject: [PATCH] x86emul: introduce SrcEax for XCHG Date: Tue, 16 Aug 2016 07:51:59 -0600 Message-ID: <57B3369F0200007800106594@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF9CF106F.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 1bZemk-0001mD-3P for xen-devel@lists.xenproject.org; Tue, 16 Aug 2016 13:52:06 +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. --=__PartF9CF106F.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. Here we can arrange for that by simply introducing SrcEax (which requires no other code adjustments). Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -34,6 +34,7 @@ #define SrcNone (0<<3) /* No source operand. */ #define SrcImplicit (0<<3) /* Source operand is implicit in the opcode. = */ #define SrcReg (1<<3) /* Register operand. */ +#define SrcEax SrcReg /* Register EAX (aka SrcReg with no ModRM) */ #define SrcMem (2<<3) /* Memory operand. */ #define SrcMem16 (3<<3) /* Memory operand (16-bit). */ #define SrcImm (4<<3) /* Immediate operand. */ @@ -118,8 +119,10 @@ static uint8_t opcode_table[256] =3D { DstMem|SrcReg|ModRM|Mov, DstReg|SrcNone|ModRM, DstReg|SrcMem16|ModRM|Mov, DstMem|SrcNone|ModRM|Mov, /* 0x90 - 0x97 */ - ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, - ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, + DstImplicit|SrcEax, DstImplicit|SrcEax, + DstImplicit|SrcEax, DstImplicit|SrcEax, + DstImplicit|SrcEax, DstImplicit|SrcEax, + DstImplicit|SrcEax, DstImplicit|SrcEax, /* 0x98 - 0x9F */ ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps|Mov, ImplicitOps|Mov, ImplicitOps, ImplicitOps, @@ -2491,12 +2494,11 @@ x86_emulate( case 0x90: /* nop / xchg %%r8,%%rax */ if ( !(rex_prefix & 1) ) break; /* nop */ + /* fall through */ =20 case 0x91 ... 0x97: /* xchg reg,%%rax */ - src.type =3D dst.type =3D OP_REG; - src.bytes =3D dst.bytes =3D op_bytes; - src.reg =3D (unsigned long *)&_regs.eax; - src.val =3D *src.reg; + dst.type =3D OP_REG; + dst.bytes =3D op_bytes; dst.reg =3D decode_register( (b & 7) | ((rex_prefix & 1) << 3), &_regs, 0); dst.val =3D *dst.reg; --=__PartF9CF106F.1__= Content-Type: text/plain; name="x86emul-use-SrcEax-xchg.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86emul-use-SrcEax-xchg.patch" x86emul: introduce SrcEax for XCHG=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. Here we can=0Aarrange for that by simply introducing SrcEax = (which requires no other=0Acode adjustments).=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/arch/x86/x86_emulate/x86_emulate= .c=0A+++ b/xen/arch/x86/x86_emulate/x86_emulate.c=0A@@ -34,6 +34,7 @@=0A = #define SrcNone (0<<3) /* No source operand. */=0A #define SrcImplicit = (0<<3) /* Source operand is implicit in the opcode. */=0A #define SrcReg = (1<<3) /* Register operand. */=0A+#define SrcEax SrcReg /* = Register EAX (aka SrcReg with no ModRM) */=0A #define SrcMem (2<<3) = /* Memory operand. */=0A #define SrcMem16 (3<<3) /* Memory operand = (16-bit). */=0A #define SrcImm (4<<3) /* Immediate operand. */=0A@@ = -118,8 +119,10 @@ static uint8_t opcode_table[256] =3D {=0A DstMem|SrcR= eg|ModRM|Mov, DstReg|SrcNone|ModRM,=0A DstReg|SrcMem16|ModRM|Mov, = DstMem|SrcNone|ModRM|Mov,=0A /* 0x90 - 0x97 */=0A- ImplicitOps, = ImplicitOps, ImplicitOps, ImplicitOps,=0A- ImplicitOps, ImplicitOps, = ImplicitOps, ImplicitOps,=0A+ DstImplicit|SrcEax, DstImplicit|SrcEax,=0A= + DstImplicit|SrcEax, DstImplicit|SrcEax,=0A+ DstImplicit|SrcEax, = DstImplicit|SrcEax,=0A+ DstImplicit|SrcEax, DstImplicit|SrcEax,=0A = /* 0x98 - 0x9F */=0A ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps= ,=0A ImplicitOps|Mov, ImplicitOps|Mov, ImplicitOps, ImplicitOps,=0A@@ = -2491,12 +2494,11 @@ x86_emulate(=0A case 0x90: /* nop / xchg = %%r8,%%rax */=0A if ( !(rex_prefix & 1) )=0A break; /* = nop */=0A+ /* fall through */=0A =0A case 0x91 ... 0x97: /* = xchg reg,%%rax */=0A- src.type =3D dst.type =3D OP_REG;=0A- = src.bytes =3D dst.bytes =3D op_bytes;=0A- src.reg =3D (unsigned = long *)&_regs.eax;=0A- src.val =3D *src.reg;=0A+ dst.type = =3D OP_REG;=0A+ dst.bytes =3D op_bytes;=0A dst.reg =3D = decode_register(=0A (b & 7) | ((rex_prefix & 1) << 3), &_regs, = 0);=0A dst.val =3D *dst.reg;=0A --=__PartF9CF106F.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__PartF9CF106F.1__=--