From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: wrong placement of RIP-relative address computing Date: Sun, 19 Jun 2011 14:38:38 +0300 Message-ID: <4DFDDFBE.8000202@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "kvm@vger.kernel.org" To: "Li, Xin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50985 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753476Ab1FSLiq (ORCPT ); Sun, 19 Jun 2011 07:38:46 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 06/16/2011 02:00 PM, Li, Xin wrote: > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > > index 6df88c7..e269d20 100644 > > --- a/arch/x86/kvm/emulate.c > > +++ b/arch/x86/kvm/emulate.c > > @@ -3547,9 +3547,6 @@ done_prefixes: > > if (memop.type == OP_MEM&& c->ad_bytes != 8) > > memop.addr.mem.ea = (u32)memop.addr.mem.ea; > > > > - if (memop.type == OP_MEM&& c->rip_relative) > > - memop.addr.mem.ea += c->eip; > > - > > /* > > * Decode and fetch the source operand: register, memory > > * or immediate. > > @@ -3704,6 +3701,9 @@ done_prefixes: > > } > > > > done: > > It's not correct to move here, I saw some other problem. > > > + if (memop.type == OP_MEM&& c->rip_relative) > > + memop.addr.mem.ea += c->eip; > > + > > return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : > > EMULATION_OK; > There's the "return 0" in the previous switch, but otherwise I think it's correct. We didn't take into account the complete instruction length. -- error compiling committee.c: too many arguments to function