aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-07-29 08:11:55 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:50:26 -0400
commit63540382ccb83d2857964858c1ac7eb7d37de497 (patch)
tree669e79e9dd45e2d5d84f9ab31d0a42b5bcf1f7dc /arch/x86/kvm/emulate.c
parentd0e533255d3811382c97b594ff7ab19b9b036814 (diff)
KVM: x86 emulator: convert some push instructions to direct decode
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.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 7e9bcda3937e..904fc1c99b97 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2016,6 +2016,12 @@ static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned long base,
2016 op->ptr = (unsigned long *)register_address(c, base, c->regs[reg]); 2016 op->ptr = (unsigned long *)register_address(c, base, c->regs[reg]);
2017} 2017}
2018 2018
2019static int em_push(struct x86_emulate_ctxt *ctxt)
2020{
2021 emulate_push(ctxt, ctxt->ops);
2022 return X86EMUL_CONTINUE;
2023}
2024
2019#define D(_y) { .flags = (_y) } 2025#define D(_y) { .flags = (_y) }
2020#define N D(0) 2026#define N D(0)
2021#define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) } 2027#define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) }
@@ -2111,7 +2117,7 @@ static struct opcode opcode_table[256] = {
2111 /* 0x40 - 0x4F */ 2117 /* 0x40 - 0x4F */
2112 X16(D(DstReg)), 2118 X16(D(DstReg)),
2113 /* 0x50 - 0x57 */ 2119 /* 0x50 - 0x57 */
2114 X8(D(SrcReg | Stack)), 2120 X8(I(SrcReg | Stack, em_push)),
2115 /* 0x58 - 0x5F */ 2121 /* 0x58 - 0x5F */
2116 X8(D(DstReg | Stack)), 2122 X8(D(DstReg | Stack)),
2117 /* 0x60 - 0x67 */ 2123 /* 0x60 - 0x67 */
@@ -2119,7 +2125,8 @@ static struct opcode opcode_table[256] = {
2119 N, D(DstReg | SrcMem32 | ModRM | Mov) /* movsxd (x86/64) */ , 2125 N, D(DstReg | SrcMem32 | ModRM | Mov) /* movsxd (x86/64) */ ,
2120 N, N, N, N, 2126 N, N, N, N,
2121 /* 0x68 - 0x6F */ 2127 /* 0x68 - 0x6F */
2122 D(SrcImm | Mov | Stack), N, D(SrcImmByte | Mov | Stack), N, 2128 I(SrcImm | Mov | Stack, em_push), N,
2129 I(SrcImmByte | Mov | Stack, em_push), N,
2123 D(DstDI | ByteOp | Mov | String), D(DstDI | Mov | String), /* insb, insw/insd */ 2130 D(DstDI | ByteOp | Mov | String), D(DstDI | Mov | String), /* insb, insw/insd */
2124 D(SrcSI | ByteOp | ImplicitOps | String), D(SrcSI | ImplicitOps | String), /* outsb, outsw/outsd */ 2131 D(SrcSI | ByteOp | ImplicitOps | String), D(SrcSI | ImplicitOps | String), /* outsb, outsw/outsd */
2125 /* 0x70 - 0x7F */ 2132 /* 0x70 - 0x7F */
@@ -2786,9 +2793,6 @@ special_insn:
2786 case 0x48 ... 0x4f: /* dec r16/r32 */ 2793 case 0x48 ... 0x4f: /* dec r16/r32 */
2787 emulate_1op("dec", c->dst, ctxt->eflags); 2794 emulate_1op("dec", c->dst, ctxt->eflags);
2788 break; 2795 break;
2789 case 0x50 ... 0x57: /* push reg */
2790 emulate_push(ctxt, ops);
2791 break;
2792 case 0x58 ... 0x5f: /* pop reg */ 2796 case 0x58 ... 0x5f: /* pop reg */
2793 pop_instruction: 2797 pop_instruction:
2794 rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes); 2798 rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes);
@@ -2810,10 +2814,6 @@ special_insn:
2810 goto cannot_emulate; 2814 goto cannot_emulate;
2811 c->dst.val = (s32) c->src.val; 2815 c->dst.val = (s32) c->src.val;
2812 break; 2816 break;
2813 case 0x68: /* push imm */
2814 case 0x6a: /* push imm8 */
2815 emulate_push(ctxt, ops);
2816 break;
2817 case 0x6c: /* insb */ 2817 case 0x6c: /* insb */
2818 case 0x6d: /* insw/insd */ 2818 case 0x6d: /* insw/insd */
2819 c->dst.bytes = min(c->dst.bytes, 4u); 2819 c->dst.bytes = min(c->dst.bytes, 4u);