Commit 62aaa2f0 authored by Takuya Yoshikawa's avatar Takuya Yoshikawa Committed by Avi Kivity

KVM: x86 emulator: Use opcode::execute for PUSHF/POPF (9C/9D)

For this, em_pushf/popf() are introduced.
Signed-off-by: default avatarTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent b96a7fad
...@@ -1448,6 +1448,16 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt, ...@@ -1448,6 +1448,16 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt,
return rc; return rc;
} }
static int em_popf(struct x86_emulate_ctxt *ctxt)
{
struct decode_cache *c = &ctxt->decode;
c->dst.type = OP_REG;
c->dst.addr.reg = &ctxt->eflags;
c->dst.bytes = c->op_bytes;
return emulate_popf(ctxt, ctxt->ops, &c->dst.val, c->op_bytes);
}
static int emulate_push_sreg(struct x86_emulate_ctxt *ctxt, static int emulate_push_sreg(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops, int seg) struct x86_emulate_ops *ops, int seg)
{ {
...@@ -1494,6 +1504,14 @@ static int em_pusha(struct x86_emulate_ctxt *ctxt) ...@@ -1494,6 +1504,14 @@ static int em_pusha(struct x86_emulate_ctxt *ctxt)
return rc; return rc;
} }
static int em_pushf(struct x86_emulate_ctxt *ctxt)
{
struct decode_cache *c = &ctxt->decode;
c->src.val = (unsigned long)ctxt->eflags;
return em_push(ctxt);
}
static int em_popa(struct x86_emulate_ctxt *ctxt) static int em_popa(struct x86_emulate_ctxt *ctxt)
{ {
struct decode_cache *c = &ctxt->decode; struct decode_cache *c = &ctxt->decode;
...@@ -3126,7 +3144,8 @@ static struct opcode opcode_table[256] = { ...@@ -3126,7 +3144,8 @@ static struct opcode opcode_table[256] = {
/* 0x98 - 0x9F */ /* 0x98 - 0x9F */
D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd),
I(SrcImmFAddr | No64, em_call_far), N, I(SrcImmFAddr | No64, em_call_far), N,
DI(ImplicitOps | Stack, pushf), DI(ImplicitOps | Stack, popf), N, N, II(ImplicitOps | Stack, em_pushf, pushf),
II(ImplicitOps | Stack, em_popf, popf), N, N,
/* 0xA0 - 0xA7 */ /* 0xA0 - 0xA7 */
I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov), I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov),
...@@ -3900,16 +3919,6 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -3900,16 +3919,6 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
case 8: c->dst.val = (s32)c->dst.val; break; case 8: c->dst.val = (s32)c->dst.val; break;
} }
break; break;
case 0x9c: /* pushf */
c->src.val = (unsigned long) ctxt->eflags;
rc = em_push(ctxt);
break;
case 0x9d: /* popf */
c->dst.type = OP_REG;
c->dst.addr.reg = &ctxt->eflags;
c->dst.bytes = c->op_bytes;
rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes);
break;
case 0xa8 ... 0xa9: /* test ax, imm */ case 0xa8 ... 0xa9: /* test ax, imm */
goto test; goto test;
case 0xc0 ... 0xc1: case 0xc0 ... 0xc1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment