From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mohammed Gamal Subject: [PATCH] x86 emulator: Simplify String I/O emulation Date: Sat, 6 Sep 2008 17:44:01 +0300 Message-ID: <20080906144401.GA8541@mohd-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@qumranet.com To: kvm@vger.kernel.org Return-path: Received: from mu-out-0910.google.com ([209.85.134.185]:57125 "EHLO mu-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751790AbYIFOoI (ORCPT ); Sat, 6 Sep 2008 10:44:08 -0400 Received: by mu-out-0910.google.com with SMTP id g7so697828muf.1 for ; Sat, 06 Sep 2008 07:44:07 -0700 (PDT) Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Simplify ins/insb and outs/outsb instructions Signed-off-by: Mohammed Gamal --- arch/x86/kvm/x86_emulate.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c index aef619a..97d60f5 100644 --- a/arch/x86/kvm/x86_emulate.c +++ b/arch/x86/kvm/x86_emulate.c @@ -1434,24 +1434,14 @@ special_insn: break; case 0x6c: /* insb */ case 0x6d: /* insw/insd */ - if (kvm_emulate_pio_string(ctxt->vcpu, NULL, - 1, - (c->d & ByteOp) ? 1 : c->op_bytes, - c->rep_prefix ? - address_mask(c, c->regs[VCPU_REGS_RCX]) : 1, - (ctxt->eflags & EFLG_DF), - register_address(c, es_base(ctxt), - c->regs[VCPU_REGS_RDI]), - c->rep_prefix, - c->regs[VCPU_REGS_RDX]) == 0) { - c->eip = saved_eip; - return -1; - } - return 0; + io_direction = 1; + goto do_string_io; case 0x6e: /* outsb */ case 0x6f: /* outsw/outsd */ + io_direction = 0; + do_string_io: if (kvm_emulate_pio_string(ctxt->vcpu, NULL, - 0, + io_direction, (c->d & ByteOp) ? 1 : c->op_bytes, c->rep_prefix ? address_mask(c, c->regs[VCPU_REGS_RCX]) : 1, @@ -1462,7 +1452,7 @@ special_insn: c->rep_prefix, c->regs[VCPU_REGS_RDX]) == 0) { c->eip = saved_eip; - return -1; + goto cannot_emulate; } return 0; case 0x70 ... 0x7f: /* jcc (short) */ { -- 1.5.4.3