Received: from eggs.gnu.org ([208.118.235.92]:45490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjZ9v-0002iW-DV for qemu-devel@nongnu.org; Fri, 14 Dec 2012 12:34:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjZ9t-0007jW-IB for qemu-devel@nongnu.org; Fri, 14 Dec 2012 12:34:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjZ9t-0007jM-9f for qemu-devel@nongnu.org; Fri, 14 Dec 2012 12:34:49 -0500 Date: Fri, 14 Dec 2012 15:36:22 -0200 From: Eduardo Habkost Message-ID: <20121214173622.GD17653@otherpad.lan.raisama.net> References: <1355350946-28010-1-git-send-email-ehabkost@redhat.com> <1355350946-28010-4-git-send-email-ehabkost@redhat.com> <50CB4258.3040709@suse.de> <20121214165235.GB3236@otherpad.lan.raisama.net> <50CB5FE9.3050703@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <50CB5FE9.3050703@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] target-i386: replace cpuid_*features fields with a feature word array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Igor Mammedov , qemu-devel@nongnu.org On Fri, Dec 14, 2012 at 06:20:41PM +0100, Andreas F=E4rber wrote: > Am 14.12.2012 17:52, schrieb Eduardo Habkost: > > On Fri, Dec 14, 2012 at 04:14:32PM +0100, Andreas F=E4rber wrote: > >> Am 12.12.2012 23:22, schrieb Eduardo Habkost: > >>> This replaces the feature-bit fields on both X86CPU and x86_def_t > >>> structs with an array. > >>> > >>> With this, we will be able to simplify code that simply does the sa= me > >>> operation on all feature words (e.g. kvm_check_features_against_hos= t(), > >>> filter_features_for_kvm(), add_flagname_to_bitmaps(), and CPU > >>> feature-bit property lookup/registration). > >>> > >>> Signed-off-by: Eduardo Habkost > >>> --- > >>> This patch was created solely using a sed script and no manual chan= ges, > >>> to try to avoid mistakes while converting the code, and make it eas= ier > >>> to rebase if necessary. The sed script can be seen at: > >>> https://gist.github.com/4271991 > >>> --- > >>> hw/kvm/clock.c | 2 +- > >>> linux-user/elfload.c | 2 +- > >>> linux-user/main.c | 4 +- > >>> target-i386/cpu.c | 578 +++++++++++++++++++++++-----------= ------------ > >>> target-i386/cpu.h | 30 +-- > >>> target-i386/helper.c | 4 +- > >>> target-i386/kvm.c | 5 +- > >>> target-i386/misc_helper.c | 14 +- > >>> target-i386/translate.c | 10 +- > >>> 9 files changed, 331 insertions(+), 318 deletions(-) > >> > >> I wonder, if we're touching all these lines anyway, can't we place t= he > >> new feature array directly into X86CPU? As far as I see the features= are > >> never changed at runtime, so the only reason to have them in the > >> instance is the command-line-supplied overrides. > >=20 > > You mean directly into X86CPUClass? [...] >=20 > No, I literally meant X86CPU rather than CPUX86State (i.e., the place > within the instance). OK. That makes sense. I believe that moving fields to X86CPU would be much easier if we change the code that will actually use those fields to use the QOM CPU class. >=20 > >> The clock code using first_cpu looks solvable; what about CR4 and MS= R > >> helpers, how performance-sensitive are they? (if they're not yet usi= ng > >> X86CPU for something else) > >=20 > > I guess any CPU-state code inside QEMU is not performance-sensitive, = as > > it woud already require switching between KVM kernelspace and QEMU > > userspace. >=20 > I mean target-i386/[misc_]helper.c and thus TCG, IIUC. :) Oh, right. I wonder how much performance impact it would have, if people are already using TCG. Anyway, would this really have any impact at all? I mean: ENV_GET_CPU(env) is basically subtracing an constant offset from 'env'. So I expect similar code to be generated, just using a different offset from 'env' to get the cpuid_features field. >=20 > > On the other hand, this cleanup will allow us to easily convert some > > code to deal with the feature array only (not requiring the full X86C= PU > > or x86_def_t struct), making it easier to have only one feature array= , > > in only one place, in the future. >=20 > The alternative line of thought is whether to group KVM stuff together. > Tying it into an array makes that harder. But personally I'm not oppose= d > to this array proposal. I don't think we would gain much from grouping KVM stuff together. It would just force us to add KVM special-cases to code that deal with feature bits. KVM feature bits are CPUID bits that work like all others. --=20 Eduardo