diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2011-04-23 05:52:56 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-22 08:39:45 -0400 |
commit | 62aaa2f05abd59598f132e6ebad86318291b5be0 (patch) | |
tree | 8e9df242281bd20d23421387cc82fc0190386170 /arch/x86/kvm/emulate.c | |
parent | b96a7fad020b42eb4a564f8a2fb41827a83c4375 (diff) |
KVM: x86 emulator: Use opcode::execute for PUSHF/POPF (9C/9D)
For this, em_pushf/popf() are introduced.
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.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index b7c6e43e4f2..c1d9116cf3a 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1448,6 +1448,16 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt, | |||
1448 | return rc; | 1448 | return rc; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | static int em_popf(struct x86_emulate_ctxt *ctxt) | ||
1452 | { | ||
1453 | struct decode_cache *c = &ctxt->decode; | ||
1454 | |||
1455 | c->dst.type = OP_REG; | ||
1456 | c->dst.addr.reg = &ctxt->eflags; | ||
1457 | c->dst.bytes = c->op_bytes; | ||
1458 | return emulate_popf(ctxt, ctxt->ops, &c->dst.val, c->op_bytes); | ||
1459 | } | ||
1460 | |||
1451 | static int emulate_push_sreg(struct x86_emulate_ctxt *ctxt, | 1461 | static int emulate_push_sreg(struct x86_emulate_ctxt *ctxt, |
1452 | struct x86_emulate_ops *ops, int seg) | 1462 | struct x86_emulate_ops *ops, int seg) |
1453 | { | 1463 | { |
@@ -1494,6 +1504,14 @@ static int em_pusha(struct x86_emulate_ctxt *ctxt) | |||
1494 | return rc; | 1504 | return rc; |
1495 | } | 1505 | } |
1496 | 1506 | ||
1507 | static int em_pushf(struct x86_emulate_ctxt *ctxt) | ||
1508 | { | ||
1509 | struct decode_cache *c = &ctxt->decode; | ||
1510 | |||
1511 | c->src.val = (unsigned long)ctxt->eflags; | ||
1512 | return em_push(ctxt); | ||
1513 | } | ||
1514 | |||
1497 | static int em_popa(struct x86_emulate_ctxt *ctxt) | 1515 | static int em_popa(struct x86_emulate_ctxt *ctxt) |
1498 | { | 1516 | { |
1499 | struct decode_cache *c = &ctxt->decode; | 1517 | struct decode_cache *c = &ctxt->decode; |
@@ -3126,7 +3144,8 @@ static struct opcode opcode_table[256] = { | |||
3126 | /* 0x98 - 0x9F */ | 3144 | /* 0x98 - 0x9F */ |
3127 | D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), | 3145 | D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), |
3128 | I(SrcImmFAddr | No64, em_call_far), N, | 3146 | I(SrcImmFAddr | No64, em_call_far), N, |
3129 | DI(ImplicitOps | Stack, pushf), DI(ImplicitOps | Stack, popf), N, N, | 3147 | II(ImplicitOps | Stack, em_pushf, pushf), |
3148 | II(ImplicitOps | Stack, em_popf, popf), N, N, | ||
3130 | /* 0xA0 - 0xA7 */ | 3149 | /* 0xA0 - 0xA7 */ |
3131 | I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), | 3150 | I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), |
3132 | I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov), | 3151 | I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov), |
@@ -3900,16 +3919,6 @@ special_insn: | |||
3900 | case 8: c->dst.val = (s32)c->dst.val; break; | 3919 | case 8: c->dst.val = (s32)c->dst.val; break; |
3901 | } | 3920 | } |
3902 | break; | 3921 | break; |
3903 | case 0x9c: /* pushf */ | ||
3904 | c->src.val = (unsigned long) ctxt->eflags; | ||
3905 | rc = em_push(ctxt); | ||
3906 | break; | ||
3907 | case 0x9d: /* popf */ | ||
3908 | c->dst.type = OP_REG; | ||
3909 | c->dst.addr.reg = &ctxt->eflags; | ||
3910 | c->dst.bytes = c->op_bytes; | ||
3911 | rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes); | ||
3912 | break; | ||
3913 | case 0xa8 ... 0xa9: /* test ax, imm */ | 3922 | case 0xa8 ... 0xa9: /* test ax, imm */ |
3914 | goto test; | 3923 | goto test; |
3915 | case 0xc0 ... 0xc1: | 3924 | case 0xc0 ... 0xc1: |