From patchwork Sun Mar 13 15:23:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 631801 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 p2DFNOBY007388 for ; Sun, 13 Mar 2011 15:23:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753287Ab1CMPXW (ORCPT ); Sun, 13 Mar 2011 11:23:22 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:57941 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751622Ab1CMPXV (ORCPT ); Sun, 13 Mar 2011 11:23:21 -0400 Received: by gxk21 with SMTP id 21so713385gxk.19 for ; Sun, 13 Mar 2011 08:23:21 -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=LZd/7iJUYiW6+6U9usZWeaNfVQPe5czBviMw7/KkDTk=; b=KMEdwj9sVLYCgID35+E6EPszvMAXVvOBU51x7rFRzJLMJ3w5JvVl3fBd1rGr1JWjRj wfNAvKhe/wQFm9PYICY26KNroVeVYiKZphVeMUBMr394tr6eB1/zUsWM0vc00E5TPk8g G+EkQpJipwBpnAp5w+ZyIGfMAYoBxFX/pFH6c= 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=H3BFQUNVBHEpuziy58mCRoumjgR6LsD+ythLh5f6uY+lf6Xqjg8XXtOyAYnv9OpR02 hAyY8SzfutA2vkrEx+WkTpZl8dezbxePEAu2fTiqIfJDA4XPouJuakPuvHxM6PZLCwZ5 QPJ0XQQEuanwQZbQChq+6KceyegfQsbqVXr64= Received: by 10.236.198.74 with SMTP id u50mr5341798yhn.196.1300029800933; Sun, 13 Mar 2011 08:23:20 -0700 (PDT) Received: from amd (u061190.dynamic.ppp.asahi-net.or.jp [203.212.61.190]) by mx.google.com with ESMTPS id g31sm4496046yhd.26.2011.03.13.08.23.16 (version=SSLv3 cipher=OTHER); Sun, 13 Mar 2011 08:23:18 -0700 (PDT) Date: Mon, 14 Mar 2011 00:23:15 +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 5/5] KVM: x86 emulator: Use single stage decoding for PUSHF and POPF instructions Message-Id: <20110314002315.908d34a1.takuya.yoshikawa@gmail.com> In-Reply-To: <20110314001524.f35e8a3f.takuya.yoshikawa@gmail.com> References: <20110314001524.f35e8a3f.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]); Sun, 13 Mar 2011 15:23:25 +0000 (UTC) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 4e16a55..60182d3 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2229,6 +2229,15 @@ static int em_pusha(struct x86_emulate_ctxt *ctxt) return emulate_pusha(ctxt, ctxt->ops); } +static int em_pushf(struct x86_emulate_ctxt *ctxt) +{ + struct decode_cache *c = &ctxt->decode; + + c->src.val = (unsigned long)ctxt->eflags; + emulate_push(ctxt, ctxt->ops); + return X86EMUL_CONTINUE; +} + static int em_pop(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; @@ -2266,6 +2275,16 @@ static int em_popa(struct x86_emulate_ctxt *ctxt) return emulate_popa(ctxt, ctxt->ops); } +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 em_das(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; @@ -2606,7 +2625,8 @@ static struct opcode opcode_table[256] = { /* 0x98 - 0x9F */ D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), I(SrcImmFAddr | No64, em_call_far), N, - D(ImplicitOps | Stack), D(ImplicitOps | Stack), N, N, + I(ImplicitOps | Stack, em_pushf), + I(ImplicitOps | Stack, em_popf), N, N, /* 0xA0 - 0xA7 */ I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov), @@ -3276,16 +3296,6 @@ special_insn: case 8: c->dst.val = (s32)c->dst.val; break; } break; - case 0x9c: /* pushf */ - c->src.val = (unsigned long) ctxt->eflags; - emulate_push(ctxt, ops); - 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 0xa6 ... 0xa7: /* cmps */ c->dst.type = OP_NONE; /* Disable writeback. */ emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags);