From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCHv4 4/5] KVM: emulator: make linearize() callable from outside of emulator Date: Thu, 19 Jul 2012 15:54:23 +0300 Message-ID: <20120719125423.GC26120@redhat.com> References: <1342683653-32114-1-git-send-email-gleb@redhat.com> <1342683653-32114-5-git-send-email-gleb@redhat.com> <5007E25B.3060207@redhat.com> <20120719105158.GV26120@redhat.com> <500802FF.3030909@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58759 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750778Ab2GSMyZ (ORCPT ); Thu, 19 Jul 2012 08:54:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6JCsPuf026751 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Jul 2012 08:54:25 -0400 Content-Disposition: inline In-Reply-To: <500802FF.3030909@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Jul 19, 2012 at 03:52:15PM +0300, Avi Kivity wrote: > On 07/19/2012 01:51 PM, Gleb Natapov wrote: > > >> > +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). > >> > > That's easy to fix by making caller prepare fake desc if mode is 64-bit > > and segment is non-fs/gs. The question is if this even measurable? > > I'm sure it will be measurable, esp. on older processors. Why not > measure it? > > It is easier to just fix it :) Will do and resend if you are agree with general approach. -- Gleb.