aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2011-04-12 11:31:23 -0400
committerAvi Kivity <avi@redhat.com>2011-05-11 07:57:08 -0400
commit4487b3b48d8fa3f6a5dd4155c9e34d5e998ad7fe (patch)
tree95209290c591173b9edf9b5d4e4530dd4875199f /arch/x86/kvm/emulate.c
parent4179bb02fd3e87183e5f698495dfcb80df187889 (diff)
KVM: x86 emulator: Use em_push() instead of emulate_push()
em_push() is a simple wrapper of emulate_push(). So this patch replaces emulate_push() with em_push() and removes the unnecessary former. In addition, the unused ops arguments are removed from emulate_pusha() and emulate_grp45(). Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 4f4d9bc6178a..cb2efa463793 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1345,8 +1345,7 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt,
1345 return X86EMUL_CONTINUE; 1345 return X86EMUL_CONTINUE;
1346} 1346}
1347 1347
1348static int emulate_push(struct x86_emulate_ctxt *ctxt, 1348static int em_push(struct x86_emulate_ctxt *ctxt)
1349 struct x86_emulate_ops *ops)
1350{ 1349{
1351 struct decode_cache *c = &ctxt->decode; 1350 struct decode_cache *c = &ctxt->decode;
1352 struct segmented_address addr; 1351 struct segmented_address addr;
@@ -1426,7 +1425,7 @@ static int emulate_push_sreg(struct x86_emulate_ctxt *ctxt,
1426 1425
1427 c->src.val = ops->get_segment_selector(seg, ctxt->vcpu); 1426 c->src.val = ops->get_segment_selector(seg, ctxt->vcpu);
1428 1427
1429 return emulate_push(ctxt, ops); 1428 return em_push(ctxt);
1430} 1429}
1431 1430
1432static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt, 1431static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt,
@@ -1444,8 +1443,7 @@ static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt,
1444 return rc; 1443 return rc;
1445} 1444}
1446 1445
1447static int emulate_pusha(struct x86_emulate_ctxt *ctxt, 1446static int emulate_pusha(struct x86_emulate_ctxt *ctxt)
1448 struct x86_emulate_ops *ops)
1449{ 1447{
1450 struct decode_cache *c = &ctxt->decode; 1448 struct decode_cache *c = &ctxt->decode;
1451 unsigned long old_esp = c->regs[VCPU_REGS_RSP]; 1449 unsigned long old_esp = c->regs[VCPU_REGS_RSP];
@@ -1456,7 +1454,7 @@ static int emulate_pusha(struct x86_emulate_ctxt *ctxt,
1456 (reg == VCPU_REGS_RSP) ? 1454 (reg == VCPU_REGS_RSP) ?
1457 (c->src.val = old_esp) : (c->src.val = c->regs[reg]); 1455 (c->src.val = old_esp) : (c->src.val = c->regs[reg]);
1458 1456
1459 rc = emulate_push(ctxt, ops); 1457 rc = em_push(ctxt);
1460 if (rc != X86EMUL_CONTINUE) 1458 if (rc != X86EMUL_CONTINUE)
1461 return rc; 1459 return rc;
1462 1460
@@ -1500,19 +1498,19 @@ int emulate_int_real(struct x86_emulate_ctxt *ctxt,
1500 1498
1501 /* TODO: Add limit checks */ 1499 /* TODO: Add limit checks */
1502 c->src.val = ctxt->eflags; 1500 c->src.val = ctxt->eflags;
1503 rc = emulate_push(ctxt, ops); 1501 rc = em_push(ctxt);
1504 if (rc != X86EMUL_CONTINUE) 1502 if (rc != X86EMUL_CONTINUE)
1505 return rc; 1503 return rc;
1506 1504
1507 ctxt->eflags &= ~(EFLG_IF | EFLG_TF | EFLG_AC); 1505 ctxt->eflags &= ~(EFLG_IF | EFLG_TF | EFLG_AC);
1508 1506
1509 c->src.val = ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu); 1507 c->src.val = ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu);
1510 rc = emulate_push(ctxt, ops); 1508 rc = em_push(ctxt);
1511 if (rc != X86EMUL_CONTINUE) 1509 if (rc != X86EMUL_CONTINUE)
1512 return rc; 1510 return rc;
1513 1511
1514 c->src.val = c->eip; 1512 c->src.val = c->eip;
1515 rc = emulate_push(ctxt, ops); 1513 rc = em_push(ctxt);
1516 if (rc != X86EMUL_CONTINUE) 1514 if (rc != X86EMUL_CONTINUE)
1517 return rc; 1515 return rc;
1518 1516
@@ -1701,8 +1699,7 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
1701 return X86EMUL_CONTINUE; 1699 return X86EMUL_CONTINUE;
1702} 1700}
1703 1701
1704static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, 1702static int emulate_grp45(struct x86_emulate_ctxt *ctxt)
1705 struct x86_emulate_ops *ops)
1706{ 1703{
1707 struct decode_cache *c = &ctxt->decode; 1704 struct decode_cache *c = &ctxt->decode;
1708 int rc = X86EMUL_CONTINUE; 1705 int rc = X86EMUL_CONTINUE;
@@ -1719,14 +1716,14 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
1719 old_eip = c->eip; 1716 old_eip = c->eip;
1720 c->eip = c->src.val; 1717 c->eip = c->src.val;
1721 c->src.val = old_eip; 1718 c->src.val = old_eip;
1722 rc = emulate_push(ctxt, ops); 1719 rc = em_push(ctxt);
1723 break; 1720 break;
1724 } 1721 }
1725 case 4: /* jmp abs */ 1722 case 4: /* jmp abs */
1726 c->eip = c->src.val; 1723 c->eip = c->src.val;
1727 break; 1724 break;
1728 case 6: /* push */ 1725 case 6: /* push */
1729 rc = emulate_push(ctxt, ops); 1726 rc = em_push(ctxt);
1730 break; 1727 break;
1731 } 1728 }
1732 return rc; 1729 return rc;
@@ -2373,7 +2370,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
2373 c->op_bytes = c->ad_bytes = (next_tss_desc.type & 8) ? 4 : 2; 2370 c->op_bytes = c->ad_bytes = (next_tss_desc.type & 8) ? 4 : 2;
2374 c->lock_prefix = 0; 2371 c->lock_prefix = 0;
2375 c->src.val = (unsigned long) error_code; 2372 c->src.val = (unsigned long) error_code;
2376 ret = emulate_push(ctxt, ops); 2373 ret = em_push(ctxt);
2377 } 2374 }
2378 2375
2379 return ret; 2376 return ret;
@@ -2410,11 +2407,6 @@ static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned seg,
2410 op->addr.mem.seg = seg; 2407 op->addr.mem.seg = seg;
2411} 2408}
2412 2409
2413static int em_push(struct x86_emulate_ctxt *ctxt)
2414{
2415 return emulate_push(ctxt, ctxt->ops);
2416}
2417
2418static int em_das(struct x86_emulate_ctxt *ctxt) 2410static int em_das(struct x86_emulate_ctxt *ctxt)
2419{ 2411{
2420 struct decode_cache *c = &ctxt->decode; 2412 struct decode_cache *c = &ctxt->decode;
@@ -2472,12 +2464,12 @@ static int em_call_far(struct x86_emulate_ctxt *ctxt)
2472 memcpy(&c->eip, c->src.valptr, c->op_bytes); 2464 memcpy(&c->eip, c->src.valptr, c->op_bytes);
2473 2465
2474 c->src.val = old_cs; 2466 c->src.val = old_cs;
2475 rc = emulate_push(ctxt, ctxt->ops); 2467 rc = em_push(ctxt);
2476 if (rc != X86EMUL_CONTINUE) 2468 if (rc != X86EMUL_CONTINUE)
2477 return rc; 2469 return rc;
2478 2470
2479 c->src.val = old_eip; 2471 c->src.val = old_eip;
2480 return emulate_push(ctxt, ctxt->ops); 2472 return em_push(ctxt);
2481} 2473}
2482 2474
2483static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt) 2475static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt)
@@ -3666,7 +3658,7 @@ special_insn:
3666 rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes); 3658 rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes);
3667 break; 3659 break;
3668 case 0x60: /* pusha */ 3660 case 0x60: /* pusha */
3669 rc = emulate_pusha(ctxt, ops); 3661 rc = emulate_pusha(ctxt);
3670 break; 3662 break;
3671 case 0x61: /* popa */ 3663 case 0x61: /* popa */
3672 rc = emulate_popa(ctxt, ops); 3664 rc = emulate_popa(ctxt, ops);
@@ -3770,7 +3762,7 @@ special_insn:
3770 break; 3762 break;
3771 case 0x9c: /* pushf */ 3763 case 0x9c: /* pushf */
3772 c->src.val = (unsigned long) ctxt->eflags; 3764 c->src.val = (unsigned long) ctxt->eflags;
3773 rc = emulate_push(ctxt, ops); 3765 rc = em_push(ctxt);
3774 break; 3766 break;
3775 case 0x9d: /* popf */ 3767 case 0x9d: /* popf */
3776 c->dst.type = OP_REG; 3768 c->dst.type = OP_REG;
@@ -3845,7 +3837,7 @@ special_insn:
3845 long int rel = c->src.val; 3837 long int rel = c->src.val;
3846 c->src.val = (unsigned long) c->eip; 3838 c->src.val = (unsigned long) c->eip;
3847 jmp_rel(c, rel); 3839 jmp_rel(c, rel);
3848 rc = emulate_push(ctxt, ops); 3840 rc = em_push(ctxt);
3849 break; 3841 break;
3850 } 3842 }
3851 case 0xe9: /* jmp rel */ 3843 case 0xe9: /* jmp rel */
@@ -3923,7 +3915,7 @@ special_insn:
3923 break; 3915 break;
3924 case 0xfe: /* Grp4 */ 3916 case 0xfe: /* Grp4 */
3925 grp45: 3917 grp45:
3926 rc = emulate_grp45(ctxt, ops); 3918 rc = emulate_grp45(ctxt);
3927 break; 3919 break;
3928 case 0xff: /* Grp5 */ 3920 case 0xff: /* Grp5 */
3929 if (c->modrm_reg == 5) 3921 if (c->modrm_reg == 5)