From: Takuya Yoshikawa Subject: [PATCH 4/4] KVM: x86 emulator: Use opcode::execute for PUSHF/POPF (9C/9D) Date: Sat, 23 Apr 2011 18:52:56 +0900 Message-ID: <20110423185256.bb60f813.takuya.yoshikawa@gmail.com> References: <20110423184549.025d4831.takuya.yoshikawa@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, gleb@redhat.com To: avi@redhat.com, mtosatti@redhat.com Return-path: Received: from mail-pv0-f174.google.com ([74.125.83.174]:45737 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861Ab1DWJxA (ORCPT ); Sat, 23 Apr 2011 05:53:00 -0400 Received: by pvg12 with SMTP id 12so614330pvg.19 for ; Sat, 23 Apr 2011 02:53:00 -0700 (PDT) In-Reply-To: <20110423184549.025d4831.takuya.yoshikawa@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Takuya Yoshikawa For this, em_pushf/popf() are introduced. Signed-off-by: Takuya Yoshikawa --- 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 3cb6aec..4f349c0 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, 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, struct x86_emulate_ops *ops, int seg) { @@ -1494,6 +1504,14 @@ static int em_pusha(struct x86_emulate_ctxt *ctxt) 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) { struct decode_cache *c = &ctxt->decode; @@ -3040,7 +3058,8 @@ static struct opcode opcode_table[256] = { /* 0x98 - 0x9F */ D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), 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 */ I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov), @@ -3815,16 +3834,6 @@ special_insn: case 8: c->dst.val = (s32)c->dst.val; 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 */ goto test; case 0xc0 ... 0xc1: -- 1.7.1