From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkuf9-0006B7-5z for qemu-devel@nongnu.org; Thu, 15 May 2014 08:21:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wkuf1-0000lX-MK for qemu-devel@nongnu.org; Thu, 15 May 2014 08:21:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42830 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkuf1-0000lB-CI for qemu-devel@nongnu.org; Thu, 15 May 2014 08:21:19 -0400 Message-ID: <5374B138.80805@suse.de> Date: Thu, 15 May 2014 14:21:12 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1398876525-28831-1-git-send-email-ehabkost@redhat.com> <1398876525-28831-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1398876525-28831-3-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 02/18] target-i386: Simplify reporting of unavailable features List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , Marcelo Tosatti , Aurelien Jarno , Igor Mammedov Am 30.04.2014 18:48, schrieb Eduardo Habkost: > Instead of checking and calling unavailable_host_feature() once for eac= h > bit, simply call the function (now renamed to > report_unavailable_features()) once for each feature word. >=20 > Signed-off-by: Eduardo Habkost > --- > Changes v1 -> v2: > * Rebase to latest qom-cpu (commit 90c5d39c) > Changes v2 -> v3: > * Trivial rebase after QEMU 2.0 (onto commit 2d03b49) > --- > target-i386/cpu.c | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) >=20 > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 7ec706f..9cd0039 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -1236,11 +1236,11 @@ static const TypeInfo host_x86_cpu_type_info =3D= { > =20 > #endif > =20 > -static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask) > +static int report_unavailable_features(FeatureWordInfo *f, uint32_t ma= sk) > { > int i; > =20 > - for (i =3D 0; i < 32; ++i) > + for (i =3D 0; i < 32; ++i) { > if (1 << i & mask) { > const char *reg =3D get_register_name_32(f->cpuid_reg); > assert(reg); > @@ -1249,8 +1249,8 @@ static int unavailable_host_feature(FeatureWordIn= fo *f, uint32_t mask) > f->cpuid_eax, reg, > f->feat_names[i] ? "." : "", > f->feat_names[i] ? f->feat_names[i] : "", i); > - break; > } > + } > return 0; > } > =20 > @@ -1274,12 +1274,10 @@ static int kvm_check_features_against_host(KVMS= tate *s, X86CPU *cpu) > uint32_t host_feat =3D kvm_arch_get_supported_cpuid(s, wi->cpu= id_eax, > wi->cpuid= _ecx, > wi->cpuid= _reg); > - uint32_t mask; > - for (mask =3D 1; mask; mask <<=3D 1) { > - if (guest_feat & mask && !(host_feat & mask)) { > - unavailable_host_feature(wi, mask); > - rv =3D 1; > - } > + uint32_t unavailable_features =3D guest_feat & ~host_feat; > + if (unavailable_features) { > + report_unavailable_features(wi, unavailable_features); > + rv =3D 1; > } > } > return rv; Both before and after your patch the return value is never checked. Shall we/I change it to void? Regards, Andreas diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 3c4f327..d095c7d 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1236,7 +1236,7 @@ static const TypeInfo host_x86_cpu_type_info =3D { #endif -static int report_unavailable_features(FeatureWordInfo *f, uint32_t mask= ) +static void report_unavailable_features(FeatureWordInfo *f, uint32_t mas= k) { int i; @@ -1251,7 +1251,6 @@ static int report_unavailable_features(FeatureWordInfo *f, uint32_t mask) f->feat_names[i] ? f->feat_names[i] : "", i); } } - return 0; } /* Check if all requested cpu flags are making their way to the guest --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg