From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Date: Thu, 25 Feb 2010 15:40:36 +0200 Message-ID: <4B867DD4.1060205@redhat.com> References: <1267007307-11276-1-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:26493 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932508Ab0BYNki (ORCPT ); Thu, 25 Feb 2010 08:40:38 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1PDeclM012658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Feb 2010 08:40:38 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1PDebfH013880 for ; Thu, 25 Feb 2010 08:40:37 -0500 In-Reply-To: <1267007307-11276-1-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 02/24/2010 12:28 PM, Gleb Natapov wrote: > Add decoding of Ep type of argument used by callf/jmpf. > > Signed-off-by: Gleb Natapov > --- > arch/x86/kvm/emulate.c | 16 ++++++++++++++++ > 1 files changed, 16 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > index c9f604b..d288107 100644 > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -85,6 +85,7 @@ > #define Src2ImmByte (2<<29) > #define Src2One (3<<29) > #define Src2Imm16 (4<<29) > +#define Src2Mem16 (5<<29) > #define Src2Mask (7<<29) > > enum { > @@ -1163,6 +1164,10 @@ done_prefixes: > c->src2.bytes = 1; > c->src2.val = 1; > break; > + case Src2Mem16: > + c->src2.bytes = 2; > + c->src2.type = OP_MEM; > + break; > } > > /* Decode and fetch the destination operand: register or memory. */ > @@ -1881,6 +1886,17 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) > c->src.orig_val = c->src.val; > } > > + if (c->src2.type == OP_MEM) { > + c->src2.ptr = (unsigned long *)(memop + c->src.bytes); > + c->src2.val = 0; > + rc = ops->read_emulated((unsigned long)c->src2.ptr, > + &c->src2.val, > + c->src2.bytes, > + ctxt->vcpu); > + if (rc != X86EMUL_CONTINUE) > + goto done; > + } > + > This introduces a dependency between src and src2. The alternative is to have an offset+segment operand type, but that introduces all types of complications, so I guess the dependency is worth it. But at least document it when you define Src2Mem16. -- error compiling committee.c: too many arguments to function