From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] x86 emulator: Add in/out instructions, opcodes (0xe4-0xe7, 0xec-0xef) Date: Mon, 11 Aug 2008 14:45:50 +0300 Message-ID: <48A0266E.9020201@qumranet.com> References: <20080804195719.GA7552@mohd-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, riel@surriel.com To: Mohammed Gamal Return-path: Received: from il.qumranet.com ([212.179.150.194]:38819 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750781AbYHKLpw (ORCPT ); Mon, 11 Aug 2008 07:45:52 -0400 In-Reply-To: <20080804195719.GA7552@mohd-laptop> Sender: kvm-owner@vger.kernel.org List-ID: Mohammed Gamal wrote: > This patch adds instructions 'in' and 'out' to the x86 emulator. > > + SrcNone | ByteOp | ImplicitOps, SrcNone |ImplicitOps, Missing blank. > case 0xe8: /* call (near) */ { > long int rel; > switch (c->op_bytes) { > @@ -1732,6 +1744,26 @@ special_insn: > jmp_rel(c, c->src.val); > c->dst.type = OP_NONE; /* Disable writeback. */ > break; > + case 0xec: /* in al,dx */ > + case 0xed: /* in (e/r)ax,dx */ > + port = c->regs[VCPU_REGS_RDX]; > + in: if(kvm_emulate_pio(ctxt->vcpu, NULL, 1, missing blank. > + (c->d & ByteOp) ? 1 : c->op_bytes, > + port) != 0) { > + c->eip = saved_eip; > + return -1; > + } > + return 0; > + case 0xee: /* out al,dx */ > + case 0xef: /* out (e/r)ax,dx */ > + port = c->regs[VCPU_REGS_RDX]; > + out: if(kvm_emulate_pio(ctxt->vcpu, NULL, 0, > + (c->d & ByteOp) ? 1 : c->op_bytes, > + port) != 0) { > + c->eip = saved_eip; > + return -1; goto cannot_emulate? > + } > + return 0; It would be simpler to fold the in and out implementations together (and extract the direction flag from the instruction byte).