From patchwork Sat May 14 15:57:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 785092 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 p4EFvp2k012727 for ; Sat, 14 May 2011 15:57:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758195Ab1ENP5t (ORCPT ); Sat, 14 May 2011 11:57:49 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:54603 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757560Ab1ENP5s (ORCPT ); Sat, 14 May 2011 11:57:48 -0400 Received: by pwi15 with SMTP id 15so1561683pwi.19 for ; Sat, 14 May 2011 08:57:48 -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=JUto4KaxJeWvi+tOTQ2YsoitVbcIVsxFgUnl6sVDtQ0=; b=r9Sr54AuvGOe1H281wusee2olAsSITJcevhWNu+eQmxGGZFkN8ayrjqU3MCj1ldZcZ cX6T1/SdHgf/C38/VGyWyUdTMuf0wvAt3KEhZuFWG80r/PtKcFBVI3ke3jbm6YqVdOZp cq9cbZypGMAxWydSSJIzJ4443hVjsfaIstb7I= 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=YNQx0Tci77IncS1GwqWa7eyISzX4dDGsEvr3W1McGRFnzeXic8nz9r5BlFAggHyIdp 73ZD6z5FFjT2jRVjvkHHAQstuInknnYYFiY1jwL5UReBj7IU52TNtPX/kPRxxfiWYks9 p0AvfnFWTbh5yrLliDieBWnRZe83RzHOOfBq4= Received: by 10.142.240.9 with SMTP id n9mr1022427wfh.104.1305388668139; Sat, 14 May 2011 08:57:48 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id w14sm3078213wfh.20.2011.05.14.08.57.45 (version=SSLv3 cipher=OTHER); Sat, 14 May 2011 08:57:47 -0700 (PDT) Date: Sun, 15 May 2011 00:57:43 +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/3] KVM: x86 emulator: Stop passing ctxt->ops as arg of decode helpers Message-Id: <20110515005743.b78d4140.takuya.yoshikawa@gmail.com> In-Reply-To: <20110515005458.9964c7b8.takuya.yoshikawa@gmail.com> References: <20110515005458.9964c7b8.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]); Sat, 14 May 2011 15:57:52 +0000 (UTC) From: Takuya Yoshikawa Dereference it in the actual users: only do_insn_fetch_byte(). This is consistent with the way __linearize() dereferences it. Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/emulate.c | 23 ++++++++--------------- 1 files changed, 8 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 9df0895..614f3d8 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -653,7 +653,6 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt, } static int do_insn_fetch_byte(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, unsigned long eip, u8 *dest) { struct fetch_cache *fc = &ctxt->decode.fetch; @@ -668,8 +667,8 @@ static int do_insn_fetch_byte(struct x86_emulate_ctxt *ctxt, rc = __linearize(ctxt, addr, size, false, true, &linear); if (rc != X86EMUL_CONTINUE) return rc; - rc = ops->fetch(ctxt, linear, fc->data + cur_size, - size, &ctxt->exception); + rc = ctxt->ops->fetch(ctxt, linear, fc->data + cur_size, + size, &ctxt->exception); if (rc != X86EMUL_CONTINUE) return rc; fc->end += size; @@ -679,7 +678,6 @@ static int do_insn_fetch_byte(struct x86_emulate_ctxt *ctxt, } static int do_insn_fetch(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, unsigned long eip, void *dest, unsigned size) { int rc; @@ -688,7 +686,7 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt, if (eip + size - ctxt->eip > 15) return X86EMUL_UNHANDLEABLE; while (size--) { - rc = do_insn_fetch_byte(ctxt, ops, eip++, dest++); + rc = do_insn_fetch_byte(ctxt, eip++, dest++); if (rc != X86EMUL_CONTINUE) return rc; } @@ -698,7 +696,7 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt, /* Fetch next part of the instruction being emulated. */ #define insn_fetch(_type, _size, _eip) \ ({ unsigned long _x; \ - rc = do_insn_fetch(ctxt, ops, (_eip), &_x, (_size)); \ + rc = do_insn_fetch(ctxt, (_eip), &_x, (_size)); \ if (rc != X86EMUL_CONTINUE) \ goto done; \ (_eip) += (_size); \ @@ -706,7 +704,7 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt, }) #define insn_fetch_arr(_arr, _size, _eip) \ -({ rc = do_insn_fetch(ctxt, ops, (_eip), _arr, (_size)); \ +({ rc = do_insn_fetch(ctxt, (_eip), _arr, (_size)); \ if (rc != X86EMUL_CONTINUE) \ goto done; \ (_eip) += (_size); \ @@ -885,7 +883,6 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt, } static int decode_modrm(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, struct operand *op) { struct decode_cache *c = &ctxt->decode; @@ -1012,7 +1009,6 @@ done: } static int decode_abs(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, struct operand *op) { struct decode_cache *c = &ctxt->decode; @@ -3325,7 +3321,6 @@ static int decode_imm(struct x86_emulate_ctxt *ctxt, struct operand *op, unsigned size, bool sign_extension) { struct decode_cache *c = &ctxt->decode; - struct x86_emulate_ops *ops = ctxt->ops; int rc = X86EMUL_CONTINUE; op->type = OP_IMM; @@ -3360,10 +3355,8 @@ done: return rc; } -int -x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) +int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) { - struct x86_emulate_ops *ops = ctxt->ops; struct decode_cache *c = &ctxt->decode; int rc = X86EMUL_CONTINUE; int mode = ctxt->mode; @@ -3529,11 +3522,11 @@ done_prefixes: /* ModRM and SIB bytes. */ if (c->d & ModRM) { - rc = decode_modrm(ctxt, ops, &memop); + rc = decode_modrm(ctxt, &memop); if (!c->has_seg_override) set_seg_override(c, c->modrm_seg); } else if (c->d & MemAbs) - rc = decode_abs(ctxt, ops, &memop); + rc = decode_abs(ctxt, &memop); if (rc != X86EMUL_CONTINUE) goto done;