From: Jan Beulich Date: Thu, 8 Dec 2016 11:22:33 +0000 (+0100) Subject: x86emul: simplify {,i}{mul,div} fix X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3223 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f5b9217531dac37451845cd83dfd30e4cc1053b4;p=xen.git x86emul: simplify {,i}{mul,div} fix Commit 75066cd4ea ("x86emul: fix {,i}mul and {,i}div") can be had with less code: Simply do the destination register override depending on DstEax being in effect (the four other ModRM.reg encoded operations of these two opcodes all use DstMem). Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 22b8dc8900..d66ce7ac1c 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -4104,6 +4104,8 @@ x86_emulate( break; case 0xf6 ... 0xf7: /* Grp3 */ + if ( (d & DstMask) == DstEax ) + dst.reg = (unsigned long *)&_regs.eax; switch ( modrm_reg & 7 ) { unsigned long u[2], v; @@ -4118,7 +4120,6 @@ x86_emulate( emulate_1op("neg", dst, _regs.eflags); break; case 4: /* mul */ - dst.reg = (unsigned long *)&_regs.eax; _regs.eflags &= ~(EFLG_OF|EFLG_CF); switch ( dst.bytes ) { @@ -4156,7 +4157,6 @@ x86_emulate( } break; case 5: /* imul */ - dst.reg = (unsigned long *)&_regs.eax; imul: _regs.eflags &= ~(EFLG_OF|EFLG_CF); switch ( dst.bytes ) @@ -4198,7 +4198,6 @@ x86_emulate( } break; case 6: /* div */ - dst.reg = (unsigned long *)&_regs.eax; switch ( src.bytes ) { case 1: @@ -4244,7 +4243,6 @@ x86_emulate( } break; case 7: /* idiv */ - dst.reg = (unsigned long *)&_regs.eax; switch ( src.bytes ) { case 1: