From patchwork Tue Apr 12 15:31:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 701181 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 p3CFVVKI027556 for ; Tue, 12 Apr 2011 15:31:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757570Ab1DLPb3 (ORCPT ); Tue, 12 Apr 2011 11:31:29 -0400 Received: from mail-vw0-f46.google.com ([209.85.212.46]:53883 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756426Ab1DLPb2 (ORCPT ); Tue, 12 Apr 2011 11:31:28 -0400 Received: by vws1 with SMTP id 1so5135630vws.19 for ; Tue, 12 Apr 2011 08:31:27 -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=cG7cByGllWoQGYhEJBmsRWSPbgFfVspi44bY6fepC0w=; b=F98qcztL1tbSYE/RFfIpuKo4mrwvv3GYWnwhvSAvAH7BzyHGnqnG4kcN25tZpY1TdB tIAMOH0kPZqMArAKkDcWQsnhEhmzLKpObUUWRRsckE7/LyWEtvMxFKFlgxDNRQAsSx9o c1V8bytRrhJVJcH8CrNl96a7kmWxf7zVp8h9A= 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=E9QgLgwYjP6piOvMR6dW8Au5m2sDNFtJP3IZKB/3gvynlEoYaKjPXiN73O7ZcxyU4V GZAaM0jYFc7Jr8SC9aMPJUF/YdLS8SpVLQV51U9Csag23uiAmizIn8Jz+CV6kyOHn1G6 sDa+qj9uD6oTSC32lSPVMssWliFo/RfKp4qO0= Received: by 10.52.173.108 with SMTP id bj12mr933947vdc.177.1302622287503; Tue, 12 Apr 2011 08:31:27 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id q2sm445220vbv.22.2011.04.12.08.31.25 (version=SSLv3 cipher=OTHER); Tue, 12 Apr 2011 08:31:26 -0700 (PDT) Date: Wed, 13 Apr 2011 00:31:23 +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/3 new] KVM: x86 emulator: Use em_push() instead of emulate_push() Message-Id: <20110413003123.6b95cde2.takuya.yoshikawa@gmail.com> In-Reply-To: <20110413002455.f2160cd3.takuya.yoshikawa@gmail.com> References: <20110413002455.f2160cd3.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]); Tue, 12 Apr 2011 15:31:32 +0000 (UTC) From: Takuya Yoshikawa em_push() is a simple wrapper of emulate_push(). So this patch replaces emulate_push() with em_push() and removes the unnecessary former. In addition, the unused ops arguments are removed from emulate_pusha() and emulate_grp45(). Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/emulate.c | 42 +++++++++++++++++------------------------- 1 files changed, 17 insertions(+), 25 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index a09c91f..ef70af9 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1345,8 +1345,7 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt, return X86EMUL_CONTINUE; } -static int emulate_push(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops) +static int em_push(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; struct segmented_address addr; @@ -1426,7 +1425,7 @@ static int emulate_push_sreg(struct x86_emulate_ctxt *ctxt, c->src.val = ops->get_segment_selector(seg, ctxt->vcpu); - return emulate_push(ctxt, ops); + return em_push(ctxt); } static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt, @@ -1444,8 +1443,7 @@ static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt, return rc; } -static int emulate_pusha(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops) +static int emulate_pusha(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; unsigned long old_esp = c->regs[VCPU_REGS_RSP]; @@ -1456,7 +1454,7 @@ static int emulate_pusha(struct x86_emulate_ctxt *ctxt, (reg == VCPU_REGS_RSP) ? (c->src.val = old_esp) : (c->src.val = c->regs[reg]); - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); if (rc != X86EMUL_CONTINUE) return rc; @@ -1500,19 +1498,19 @@ int emulate_int_real(struct x86_emulate_ctxt *ctxt, /* TODO: Add limit checks */ c->src.val = ctxt->eflags; - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); if (rc != X86EMUL_CONTINUE) return rc; ctxt->eflags &= ~(EFLG_IF | EFLG_TF | EFLG_AC); c->src.val = ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu); - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); if (rc != X86EMUL_CONTINUE) return rc; c->src.val = c->eip; - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); if (rc != X86EMUL_CONTINUE) return rc; @@ -1701,8 +1699,7 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, return X86EMUL_CONTINUE; } -static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops) +static int emulate_grp45(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; int rc = X86EMUL_CONTINUE; @@ -1719,14 +1716,14 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, old_eip = c->eip; c->eip = c->src.val; c->src.val = old_eip; - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); break; } case 4: /* jmp abs */ c->eip = c->src.val; break; case 6: /* push */ - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); break; } return rc; @@ -2373,7 +2370,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, c->op_bytes = c->ad_bytes = (next_tss_desc.type & 8) ? 4 : 2; c->lock_prefix = 0; c->src.val = (unsigned long) error_code; - ret = emulate_push(ctxt, ops); + ret = em_push(ctxt); } return ret; @@ -2410,11 +2407,6 @@ static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned seg, op->addr.mem.seg = seg; } -static int em_push(struct x86_emulate_ctxt *ctxt) -{ - return emulate_push(ctxt, ctxt->ops); -} - static int em_das(struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; @@ -2472,12 +2464,12 @@ static int em_call_far(struct x86_emulate_ctxt *ctxt) memcpy(&c->eip, c->src.valptr, c->op_bytes); c->src.val = old_cs; - rc = emulate_push(ctxt, ctxt->ops); + rc = em_push(ctxt); if (rc != X86EMUL_CONTINUE) return rc; c->src.val = old_eip; - return emulate_push(ctxt, ctxt->ops); + return em_push(ctxt); } static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt) @@ -3666,7 +3658,7 @@ special_insn: rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes); break; case 0x60: /* pusha */ - rc = emulate_pusha(ctxt, ops); + rc = emulate_pusha(ctxt); break; case 0x61: /* popa */ rc = emulate_popa(ctxt, ops); @@ -3770,7 +3762,7 @@ special_insn: break; case 0x9c: /* pushf */ c->src.val = (unsigned long) ctxt->eflags; - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); break; case 0x9d: /* popf */ c->dst.type = OP_REG; @@ -3845,7 +3837,7 @@ special_insn: long int rel = c->src.val; c->src.val = (unsigned long) c->eip; jmp_rel(c, rel); - rc = emulate_push(ctxt, ops); + rc = em_push(ctxt); break; } case 0xe9: /* jmp rel */ @@ -3923,7 +3915,7 @@ special_insn: break; case 0xfe: /* Grp4 */ grp45: - rc = emulate_grp45(ctxt, ops); + rc = emulate_grp45(ctxt); break; case 0xff: /* Grp5 */ if (c->modrm_reg == 5)