From patchwork Sun May 29 12:57:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 827692 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4TCw0W6005876 for ; Sun, 29 May 2011 12:58:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753782Ab1E2M56 (ORCPT ); Sun, 29 May 2011 08:57:58 -0400 Received: from mail-px0-f179.google.com ([209.85.212.179]:45532 "EHLO mail-px0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752195Ab1E2M55 (ORCPT ); Sun, 29 May 2011 08:57:57 -0400 Received: by pxi2 with SMTP id 2so1991682pxi.10 for ; Sun, 29 May 2011 05:57:57 -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=IuV3ajFAZnmgMj7aBB6DANwYUnBvNetjiIXhNJodyX0=; b=q+3bmX2zKcDsv/f195zLSzdVoYHxHrbqsaZpl3igiIcJLkMvHXZZhDxDmmLimW8d+q g+MPwtLa6KbW1JUsIZCMQyx/9i9vha3bIr/brKayIdaBOVGtLwzJuMTU3yF76xnXayow JKlun2mTobKUstjqDLwRcPECcnxLqoYa+fcoM= 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=tPdmVUqKyuR5NfqGlNs8UreEXNGdN8nNUtpAM+ny2vwUjExaWf4Bh9Kl1B5ZXOX+VK OHTld95OUg/NqQ1wT1xEjdCU7+ytWiIQb4u4oFNG8pYOZ31GIrgC2BXDqWTMi5jFGfVX 5cqCVm9E3lRdYj1a/T3GnwAO+Pv4qydvdyOWE= Received: by 10.143.97.17 with SMTP id z17mr544188wfl.273.1306673877348; Sun, 29 May 2011 05:57:57 -0700 (PDT) Received: from amd (x096101.dynamic.ppp.asahi-net.or.jp [122.249.96.101]) by mx.google.com with ESMTPS id p5sm2050687pbd.28.2011.05.29.05.57.55 (version=SSLv3 cipher=OTHER); Sun, 29 May 2011 05:57:56 -0700 (PDT) Date: Sun, 29 May 2011 21:57:53 +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 04/10] KVM: x86 emulator: Use opcode::execute for TEST(84/85, A8/A9) Message-Id: <20110529215753.66139f16.takuya.yoshikawa@gmail.com> In-Reply-To: <20110529215200.17be7761.takuya.yoshikawa@gmail.com> References: <20110529215200.17be7761.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0 (GTK+ 2.24.4; 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 (demeter2.kernel.org [140.211.167.43]); Sun, 29 May 2011 12:58:01 +0000 (UTC) From: Takuya Yoshikawa Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/emulate.c | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 9134965..2e2e87f 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2603,6 +2603,14 @@ static int em_cmp(struct x86_emulate_ctxt *ctxt) return X86EMUL_CONTINUE; } +static int em_test(struct x86_emulate_ctxt *ctxt) +{ + struct decode_cache *c = &ctxt->decode; + + emulate_2op_SrcV("test", c->src, c->dst, ctxt->eflags); + return X86EMUL_CONTINUE; +} + static int em_imul(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; @@ -3133,7 +3141,8 @@ static struct opcode opcode_table[256] = { G(DstMem | SrcImm | ModRM | Group, group1), G(ByteOp | DstMem | SrcImm | ModRM | No64 | Group, group1), G(DstMem | SrcImmByte | ModRM | Group, group1), - D2bv(DstMem | SrcReg | ModRM), D2bv(DstMem | SrcReg | ModRM | Lock), + I2bv(DstMem | SrcReg | ModRM, em_test), + D2bv(DstMem | SrcReg | ModRM | Lock), /* 0x88 - 0x8F */ I2bv(DstMem | SrcReg | ModRM | Mov, em_mov), I2bv(DstReg | SrcMem | ModRM | Mov, em_mov), @@ -3152,7 +3161,7 @@ static struct opcode opcode_table[256] = { I2bv(SrcSI | DstDI | Mov | String, em_mov), I2bv(SrcSI | DstDI | String, em_cmp), /* 0xA8 - 0xAF */ - D2bv(DstAcc | SrcImm), + I2bv(DstAcc | SrcImm, em_test), I2bv(SrcAcc | DstDI | Mov | String, em_mov), I2bv(SrcSI | DstAcc | Mov | String, em_mov), I2bv(SrcAcc | DstDI | String, em_cmp), @@ -3857,10 +3866,6 @@ special_insn: if (test_cc(c->b, ctxt->eflags)) jmp_rel(c, c->src.val); break; - case 0x84 ... 0x85: - test: - emulate_2op_SrcV("test", c->src, c->dst, ctxt->eflags); - break; case 0x86 ... 0x87: /* xchg */ xchg: /* Write back the register source. */ @@ -3916,8 +3921,6 @@ special_insn: case 8: c->dst.val = (s32)c->dst.val; break; } break; - case 0xa8 ... 0xa9: /* test ax, imm */ - goto test; case 0xc0 ... 0xc1: rc = em_grp2(ctxt); break;