From patchwork Sat Apr 23 09:52:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 728961 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3N9r3vZ004353 for ; Sat, 23 Apr 2011 09:53:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752877Ab1DWJxA (ORCPT ); Sat, 23 Apr 2011 05:53:00 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=nk1a6QkjHnoUwdGwcHKp08dlP1lyWEAXkWPxHcbFdJU=; b=YpP16pGTZhSu2ePneRZupEZa7qIPsj9c5vum3ifxJ2BvlDHTDMSVyoaeaQA8AOdRPU 22IYgG4eEoC6eHcw7fq8Te1sMvtX2206ORnw2ih7IqFQ+80aa6nWSCQwEqMUTeja8qiK 5ZI86gtEgyZkjd1aM9KxSXen3IRqyFeJe8kmc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=qfDSYWX3iEW/wz87HO0K/VKn1FqFYnyNkXNZcVnKW1WH7ZodBBzshqsn8ccuM8AXbm pvYgL4V5ry3GzYE+5xfo4l6JwYPu8Tf4+wck8cr9ELKX9ocg2lnNeHWbvSfkqDbMf6QV zrsOTScwfzJTigeid9kQocN9A30rM72xdCWjs= Received: by 10.68.44.73 with SMTP id c9mr1160389pbm.163.1303552380023; Sat, 23 Apr 2011 02:53:00 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id f1sm2565058pbm.93.2011.04.23.02.52.57 (version=SSLv3 cipher=OTHER); Sat, 23 Apr 2011 02:52:59 -0700 (PDT) Date: Sat, 23 Apr 2011 18:52:56 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, gleb@redhat.com Subject: [PATCH 4/4] KVM: x86 emulator: Use opcode::execute for PUSHF/POPF (9C/9D) Message-Id: <20110423185256.bb60f813.takuya.yoshikawa@gmail.com> In-Reply-To: <20110423184549.025d4831.takuya.yoshikawa@gmail.com> References: <20110423184549.025d4831.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 23 Apr 2011 09:53:04 +0000 (UTC) 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: