From patchwork Sat Apr 23 09:49:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 728941 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 p3N9nlCY002304 for ; Sat, 23 Apr 2011 09:49:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752867Ab1DWJtp (ORCPT ); Sat, 23 Apr 2011 05:49:45 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:59391 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861Ab1DWJto (ORCPT ); Sat, 23 Apr 2011 05:49:44 -0400 Received: by pvg12 with SMTP id 12so613860pvg.19 for ; Sat, 23 Apr 2011 02:49:44 -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=kTBaBtmTmsMOSBGdQkjxWRjb4lsU59DInmuuLMwEz3U=; b=Y0mmEKHsN4c2lDXEX1k79AmT7J5El2qP6H6O8WARduN4FmaB506m9be2+qu4NKReil BCEOE3X+VQBT165C8HCrzxFHF7B5Jl1P5jbYd5cy6EllWNB+tWNa11b1SF6wVmeZiMU1 UafCQD4oKR57zqIWDRlcaE7yPlnPRApt+/uWs= 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=nVZqKFpiARRi+EL294Kg6BM5Ab+nId5JhRcwC3ow7hLpD/09LBAJZ9kr1f4s1fZswC Wtfpe/PmRKGnGgouuxAZrc8waumNRmFG5wJVZl23TK5Bab8Mqn4l9fu4vQ8AQvVL3436 8ShCnaqe/NoyW5JpRcC2CkY0oC5rj44YqSsdo= Received: by 10.143.24.39 with SMTP id b39mr1137088wfj.341.1303552184310; Sat, 23 Apr 2011 02:49:44 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id k7sm1543056wfa.14.2011.04.23.02.49.42 (version=SSLv3 cipher=OTHER); Sat, 23 Apr 2011 02:49:43 -0700 (PDT) Date: Sat, 23 Apr 2011 18:49:40 +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 2/4] KVM: x86 emulator: Use opcode::execute for POP reg (58-5F) Message-Id: <20110423184940.73e78c2d.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:49:47 +0000 (UTC) From: Takuya Yoshikawa In addition, the RET emulation is changed to call em_pop() to remove the pop_instruction label. Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/emulate.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 89164e6..9936751 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1400,6 +1400,13 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt, return rc; } +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 emulate_popf(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops, void *dest, int len) @@ -3003,7 +3010,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) */ , @@ -3731,10 +3738,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); break; @@ -3837,7 +3840,8 @@ special_insn: c->dst.type = OP_REG; c->dst.addr.reg = &c->eip; c->dst.bytes = c->op_bytes; - goto pop_instruction; + rc = em_pop(ctxt); + break; case 0xc4: /* les */ rc = emulate_load_segment(ctxt, ops, VCPU_SREG_ES); break;