aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-09-07 09:41:38 -0400
committerAvi Kivity <avi@redhat.com>2011-09-25 12:52:35 -0400
commitd1eef45d5906a0738684833cf1e0395b4d098340 (patch)
treedccd1c94e7007b87b1d42b94a57f4efc659e8723 /arch/x86/kvm/emulate.c
parent29053a60d791a492b4609d87397b70a7a3254eb2 (diff)
KVM: x86 emulator: simplify emulate_1op()
emulate_1op() is always called with the same parameters. Simplify by passing just the emulation context. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 14b279185392..5b4e1d46aa2d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -298,7 +298,7 @@ struct gprefix {
298 } \ 298 } \
299 } while (0) 299 } while (0)
300 300
301#define __emulate_1op(_op, _dst, _eflags, _suffix) \ 301#define __emulate_1op(ctxt, _op, _suffix) \
302 do { \ 302 do { \
303 unsigned long _tmp; \ 303 unsigned long _tmp; \
304 \ 304 \
@@ -306,19 +306,19 @@ struct gprefix {
306 _PRE_EFLAGS("0", "3", "2") \ 306 _PRE_EFLAGS("0", "3", "2") \
307 _op _suffix " %1; " \ 307 _op _suffix " %1; " \
308 _POST_EFLAGS("0", "3", "2") \ 308 _POST_EFLAGS("0", "3", "2") \
309 : "=m" (_eflags), "+m" ((_dst).val), \ 309 : "=m" ((ctxt)->eflags), "+m" ((ctxt)->dst.val), \
310 "=&r" (_tmp) \ 310 "=&r" (_tmp) \
311 : "i" (EFLAGS_MASK)); \ 311 : "i" (EFLAGS_MASK)); \
312 } while (0) 312 } while (0)
313 313
314/* Instruction has only one explicit operand (no source operand). */ 314/* Instruction has only one explicit operand (no source operand). */
315#define emulate_1op(_op, _dst, _eflags) \ 315#define emulate_1op(ctxt, _op) \
316 do { \ 316 do { \
317 switch ((_dst).bytes) { \ 317 switch ((ctxt)->dst.bytes) { \
318 case 1: __emulate_1op(_op, _dst, _eflags, "b"); break; \ 318 case 1: __emulate_1op(ctxt, _op, "b"); break; \
319 case 2: __emulate_1op(_op, _dst, _eflags, "w"); break; \ 319 case 2: __emulate_1op(ctxt, _op, "w"); break; \
320 case 4: __emulate_1op(_op, _dst, _eflags, "l"); break; \ 320 case 4: __emulate_1op(ctxt, _op, "l"); break; \
321 case 8: ON64(__emulate_1op(_op, _dst, _eflags, "q")); break; \ 321 case 8: ON64(__emulate_1op(ctxt, _op, "q")); break; \
322 } \ 322 } \
323 } while (0) 323 } while (0)
324 324
@@ -1715,7 +1715,7 @@ static int em_grp3(struct x86_emulate_ctxt *ctxt)
1715 ctxt->dst.val = ~ctxt->dst.val; 1715 ctxt->dst.val = ~ctxt->dst.val;
1716 break; 1716 break;
1717 case 3: /* neg */ 1717 case 3: /* neg */
1718 emulate_1op("neg", ctxt->dst, ctxt->eflags); 1718 emulate_1op(ctxt, "neg");
1719 break; 1719 break;
1720 case 4: /* mul */ 1720 case 4: /* mul */
1721 emulate_1op_rax_rdx("mul", ctxt->src, *rax, *rdx, ctxt->eflags); 1721 emulate_1op_rax_rdx("mul", ctxt->src, *rax, *rdx, ctxt->eflags);
@@ -1745,10 +1745,10 @@ static int em_grp45(struct x86_emulate_ctxt *ctxt)
1745 1745
1746 switch (ctxt->modrm_reg) { 1746 switch (ctxt->modrm_reg) {
1747 case 0: /* inc */ 1747 case 0: /* inc */
1748 emulate_1op("inc", ctxt->dst, ctxt->eflags); 1748 emulate_1op(ctxt, "inc");
1749 break; 1749 break;
1750 case 1: /* dec */ 1750 case 1: /* dec */
1751 emulate_1op("dec", ctxt->dst, ctxt->eflags); 1751 emulate_1op(ctxt, "dec");
1752 break; 1752 break;
1753 case 2: /* call near abs */ { 1753 case 2: /* call near abs */ {
1754 long int old_eip; 1754 long int old_eip;
@@ -3849,10 +3849,10 @@ special_insn:
3849 rc = emulate_pop_sreg(ctxt, VCPU_SREG_DS); 3849 rc = emulate_pop_sreg(ctxt, VCPU_SREG_DS);
3850 break; 3850 break;
3851 case 0x40 ... 0x47: /* inc r16/r32 */ 3851 case 0x40 ... 0x47: /* inc r16/r32 */
3852 emulate_1op("inc", ctxt->dst, ctxt->eflags); 3852 emulate_1op(ctxt, "inc");
3853 break; 3853 break;
3854 case 0x48 ... 0x4f: /* dec r16/r32 */ 3854 case 0x48 ... 0x4f: /* dec r16/r32 */
3855 emulate_1op("dec", ctxt->dst, ctxt->eflags); 3855 emulate_1op(ctxt, "dec");
3856 break; 3856 break;
3857 case 0x63: /* movsxd */ 3857 case 0x63: /* movsxd */
3858 if (ctxt->mode != X86EMUL_MODE_PROT64) 3858 if (ctxt->mode != X86EMUL_MODE_PROT64)