public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Mohammed Gamal <m.gamal005@gmail.com>
To: kvm@vger.kernel.org
Cc: avi@qumranet.com
Subject: [PATCH] x86 emulator: Simplify String I/O emulation
Date: Sat, 6 Sep 2008 17:44:01 +0300	[thread overview]
Message-ID: <20080906144401.GA8541@mohd-laptop> (raw)

Simplify ins/insb and outs/outsb instructions

Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
 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



             reply	other threads:[~2008-09-06 14:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-06 14:44 Mohammed Gamal [this message]
2008-09-07  7:21 ` [PATCH] x86 emulator: Simplify String I/O emulation Avi Kivity
2008-09-07 13:29 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080906144401.GA8541@mohd-laptop \
    --to=m.gamal005@gmail.com \
    --cc=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox