From patchwork Sun May 29 12:56:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 827632 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 p4TCuY7B029801 for ; Sun, 29 May 2011 12:56:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752385Ab1E2M4b (ORCPT ); Sun, 29 May 2011 08:56:31 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:53205 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220Ab1E2M4a (ORCPT ); Sun, 29 May 2011 08:56:30 -0400 Received: by pzk9 with SMTP id 9so1292269pzk.19 for ; Sun, 29 May 2011 05:56:30 -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=bgCGRVlNWpvDYKdS4TP6u3QNZUqWv3z+b7qWjvjydSg=; b=bwsRlsc2qlGj3lP8Nvlf67n0w8AjhdyDld27RLzHr0zaDWKzee5sfLnvHrNz/ui5Ew 15n7g2wIBRTabny4PmpOv88Hv92cObjqs7zYothHCu/s+DshGEmiZjDfGpOJimm/HgJ3 hlalaLEvE5sMyQqNr/dlTBW/gAt1oh4o4y8ug= 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=cuozNc02AjYKPchrnq/kbeN7It4BWM8sOWDPudMH7tsyEg7vk+Ac08dKl+VEfNUaaF FmKBWEOxNlaX3bEFkdRW7KbX+4rq/LaDj77qko13tM+pLq3DOtpbF5kDKGlN23T+rwDl yEKhi4OLitLWvr/+nMAY0nxWt0BotZ4rw/8xQ= Received: by 10.68.34.4 with SMTP id v4mr1616466pbi.159.1306673790372; Sun, 29 May 2011 05:56:30 -0700 (PDT) Received: from amd (x096101.dynamic.ppp.asahi-net.or.jp [122.249.96.101]) by mx.google.com with ESMTPS id i7sm2049891pbj.26.2011.05.29.05.56.28 (version=SSLv3 cipher=OTHER); Sun, 29 May 2011 05:56:29 -0700 (PDT) Date: Sun, 29 May 2011 21:56:26 +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 03/10] KVM: x86 emulator: Use opcode::execute for some instructions Message-Id: <20110529215626.b1ebccbf.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 (demeter1.kernel.org [140.211.167.41]); Sun, 29 May 2011 12:56:34 +0000 (UTC) From: Takuya Yoshikawa Move the following functions to the opcode tables: RET (Far return) : CB IRET : CF JMP (Jump far) : EA SYSCALL : 0F 05 CLTS : 0F 06 SYSENTER : 0F 34 SYSEXIT : 0F 35 Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/emulate.c | 37 ++++++++----------------------------- 1 files changed, 8 insertions(+), 29 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 756cbbd..9134965 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3167,9 +3167,9 @@ static struct opcode opcode_table[256] = { D(DstReg | SrcMemFAddr | ModRM | No64), D(DstReg | SrcMemFAddr | ModRM | No64), G(ByteOp, group11), G(0, group11), /* 0xC8 - 0xCF */ - N, N, N, D(ImplicitOps | Stack), + N, N, N, I(ImplicitOps | Stack, em_ret_far), D(ImplicitOps), DI(SrcImmByte, intn), - D(ImplicitOps | No64), DI(ImplicitOps, iret), + D(ImplicitOps | No64), II(ImplicitOps, em_iret, iret), /* 0xD0 - 0xD7 */ D2bv(DstMem | SrcOne | ModRM), D2bv(DstMem | ModRM), N, N, N, N, @@ -3181,7 +3181,7 @@ static struct opcode opcode_table[256] = { D2bvIP(SrcAcc | DstImmUByte, out, check_perm_out), /* 0xE8 - 0xEF */ D(SrcImm | Stack), D(SrcImm | ImplicitOps), - D(SrcImmFAddr | No64), D(SrcImmByte | ImplicitOps), + I(SrcImmFAddr | No64, em_jmp_far), D(SrcImmByte | ImplicitOps), D2bvIP(SrcNone | DstAcc, in, check_perm_in), D2bvIP(SrcAcc | ImplicitOps, out, check_perm_out), /* 0xF0 - 0xF7 */ @@ -3196,7 +3196,8 @@ static struct opcode opcode_table[256] = { static struct opcode twobyte_table[256] = { /* 0x00 - 0x0F */ G(0, group6), GD(0, &group7), N, N, - N, D(ImplicitOps | VendorSpecific), DI(ImplicitOps | Priv, clts), N, + N, I(ImplicitOps | VendorSpecific, em_syscall), + II(ImplicitOps | Priv, em_clts, clts), N, DI(ImplicitOps | Priv, invd), DI(ImplicitOps | Priv, wbinvd), N, N, N, D(ImplicitOps | ModRM), N, N, /* 0x10 - 0x1F */ @@ -3213,7 +3214,8 @@ static struct opcode twobyte_table[256] = { IIP(ImplicitOps, em_rdtsc, rdtsc, check_rdtsc), DI(ImplicitOps | Priv, rdmsr), DIP(ImplicitOps | Priv, rdpmc, check_rdpmc), - D(ImplicitOps | VendorSpecific), D(ImplicitOps | Priv | VendorSpecific), + I(ImplicitOps | VendorSpecific, em_sysenter), + I(ImplicitOps | Priv | VendorSpecific, em_sysexit), N, N, N, N, N, N, N, N, N, N, /* 0x40 - 0x4F */ @@ -3931,9 +3933,6 @@ special_insn: case 0xc5: /* lds */ rc = emulate_load_segment(ctxt, VCPU_SREG_DS); break; - case 0xcb: /* ret far */ - rc = em_ret_far(ctxt); - break; case 0xcc: /* int3 */ irq = 3; goto do_interrupt; @@ -3948,9 +3947,6 @@ special_insn: goto do_interrupt; } break; - case 0xcf: /* iret */ - rc = em_iret(ctxt); - break; case 0xd0 ... 0xd1: /* Grp2 */ rc = em_grp2(ctxt); break; @@ -3982,12 +3978,7 @@ special_insn: break; } case 0xe9: /* jmp rel */ - goto jmp; - case 0xea: /* jmp far */ - rc = em_jmp_far(ctxt); - break; - case 0xeb: - jmp: /* jmp rel short */ + case 0xeb: /* jmp rel short */ jmp_rel(c, c->src.val); c->dst.type = OP_NONE; /* Disable writeback. */ break; @@ -4112,12 +4103,6 @@ done: twobyte_insn: switch (c->b) { - case 0x05: /* syscall */ - rc = em_syscall(ctxt); - break; - case 0x06: - rc = em_clts(ctxt); - break; case 0x09: /* wbinvd */ (ctxt->ops->wbinvd)(ctxt); break; @@ -4174,12 +4159,6 @@ twobyte_insn: } rc = X86EMUL_CONTINUE; break; - case 0x34: /* sysenter */ - rc = em_sysenter(ctxt); - break; - case 0x35: /* sysexit */ - rc = em_sysexit(ctxt); - break; case 0x40 ... 0x4f: /* cmov */ c->dst.val = c->dst.orig_val = c->src.val; if (!test_cc(c->b, ctxt->eflags))