From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCHv4 4/5] KVM: emulator: make linearize() callable from outside of emulator Date: Thu, 19 Jul 2012 13:32:59 +0300 Message-ID: <5007E25B.3060207@redhat.com> References: <1342683653-32114-1-git-send-email-gleb@redhat.com> <1342683653-32114-5-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2851 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854Ab2GSKdC (ORCPT ); Thu, 19 Jul 2012 06:33:02 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6JAX2Bi023080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Jul 2012 06:33:02 -0400 In-Reply-To: <1342683653-32114-5-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/19/2012 10:40 AM, Gleb Natapov wrote: > The function will be used outside of the emulator. > > Signed-off-by: Gleb Natapov > --- > arch/x86/include/asm/kvm_emulate.h | 16 +++++ > arch/x86/kvm/emulate.c | 114 ++++++++++++++++++++---------------- > 2 files changed, 79 insertions(+), 51 deletions(-) > > diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h > index 7c276ca..9ce651b 100644 > --- a/arch/x86/include/asm/kvm_emulate.h > +++ b/arch/x86/include/asm/kvm_emulate.h > @@ -374,6 +374,21 @@ enum x86_intercept { > nr_x86_intercepts > }; > > +struct x86_linearize_params > +{ > + enum x86emul_mode mode; > + ulong ea; > + unsigned size; > + unsigned seg; > + struct desc_struct desc; > + u16 sel; > + bool usable; > + bool write; > + bool fetch; > + u8 ad_bytes; > + unsigned cpl; > +}; > + > @@ -470,14 +470,6 @@ static void set_seg_override(struct x86_emulate_ctxt *ctxt, int seg) > ctxt->seg_override = seg; > } > > -static unsigned long seg_base(struct x86_emulate_ctxt *ctxt, int seg) > -{ > - if (ctxt->mode == X86EMUL_MODE_PROT64 && seg < VCPU_SREG_FS) > - return 0; > - > - return ctxt->ops->get_cached_segment_base(ctxt, seg); > -} > - > +int x86_linearize(struct x86_linearize_params *p, ulong *linear) > { > - struct desc_struct desc; > - bool usable; > ulong la; > u32 lim; > - u16 sel; > unsigned cpl, rpl; > > - la = seg_base(ctxt, addr.seg) + addr.ea; > - switch (ctxt->mode) { > + la = get_desc_base(&p->desc) + p->ea; This makes 64-bit mode slower, since before the patch it avoided reading the segment base for non-fs/gs segments, and only read the segment base for fs/gs. After the patch we always execute 4 VMREADs (and decode the results). -- error compiling committee.c: too many arguments to function