From patchwork Sun Mar 13 15:20:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 631781 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 p2DFKgCl005643 for ; Sun, 13 Mar 2011 15:20:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753111Ab1CMPUj (ORCPT ); Sun, 13 Mar 2011 11:20:39 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:61535 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752723Ab1CMPUj (ORCPT ); Sun, 13 Mar 2011 11:20:39 -0400 Received: by yxs7 with SMTP id 7so1761748yxs.19 for ; Sun, 13 Mar 2011 08:20:38 -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=EYGv7BknYz6RdVf3zXA/+gan4mo1e5/ehvpD4NpHY+g=; b=NGlVbKylGjR9dLhyMmS0VDUG8CZY3gxsLQBzWoFUP5v1+ARVVdiKVFTHd1X1/vfp2y sdz54C4zJa5yMMdL7G+LHrf1GGx2BTsApOLEgJU0TZSCOQeW2f6fuHMPZ4I19uaGUuZF GGEQWiHaCcpGXrJVqRe3QamXgHoCa46BwzFF8= 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=vYHvp0JOQJcd9A+e1PiJhBzqO/2pU7AhHl3kAzzJA4/aUs3rJCb+BgG9MqmGi4UFbd 7X/xF87D56TdeSEjKZPkWWn79TwBQ1CJlMU+F1IGtjTMAzpde6l1bXjDam0nFZO0PPti 4NJykcuw+92HRMI/aX4dHlWOdlnelbetApozI= Received: by 10.100.60.15 with SMTP id i15mr2736335ana.73.1300029638315; Sun, 13 Mar 2011 08:20:38 -0700 (PDT) Received: from amd (u061190.dynamic.ppp.asahi-net.or.jp [203.212.61.190]) by mx.google.com with ESMTPS id 19sm8576076anx.37.2011.03.13.08.20.35 (version=SSLv3 cipher=OTHER); Sun, 13 Mar 2011 08:20:37 -0700 (PDT) Date: Mon, 14 Mar 2011 00:20:34 +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 3/5] KVM: x86 emulator: Use single stage decoding for POP instructions Message-Id: <20110314002034.56688266.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:20:42 +0000 (UTC) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index fcc49ef..8295c50 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2224,6 +2224,13 @@ static int em_push_gs(struct x86_emulate_ctxt *ctxt) return X86EMUL_CONTINUE; } +static int em_pop(struct x86_emulate_ctxt *ctxt) +{ + struct decode_cache *c = &ctxt->decode; + + return emulate_pop(ctxt, ctxt->ops, &c->dst.val, c->op_bytes); +} + static int em_pop_es(struct x86_emulate_ctxt *ctxt) { return emulate_pop_sreg(ctxt, ctxt->ops, VCPU_SREG_ES); @@ -2558,7 +2565,7 @@ static struct opcode opcode_table[256] = { /* 0x50 - 0x57 */ X8(I(SrcReg | Stack, em_push)), /* 0x58 - 0x5F */ - X8(D(DstReg | Stack)), + X8(I(DstReg | Stack, em_pop)), /* 0x60 - 0x67 */ D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), N, D(DstReg | SrcMem32 | ModRM | Mov) /* movsxd (x86/64) */ , @@ -3181,10 +3188,6 @@ special_insn: case 0x48 ... 0x4f: /* dec r16/r32 */ emulate_1op("dec", c->dst, ctxt->eflags); break; - case 0x58 ... 0x5f: /* pop reg */ - pop_instruction: - rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes); - break; case 0x60: /* pusha */ rc = emulate_pusha(ctxt, ops); break; @@ -3294,7 +3297,8 @@ special_insn: c->dst.type = OP_REG; c->dst.addr.reg = &c->eip; c->dst.bytes = c->op_bytes; - goto pop_instruction; + rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes); + break; case 0xc4: /* les */ rc = emulate_load_segment(ctxt, ops, VCPU_SREG_ES); break;