Received: from eggs.gnu.org ([2001:4830:134:3::10]:55728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkwNi-0003L4-KU for qemu-devel@nongnu.org; Fri, 16 Sep 2016 12:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkwNd-0006lm-Jc for qemu-devel@nongnu.org; Fri, 16 Sep 2016 12:52:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkwNd-0006le-Df for qemu-devel@nongnu.org; Fri, 16 Sep 2016 12:52:49 -0400 Date: Fri, 16 Sep 2016 13:52:45 -0300 From: Eduardo Habkost Message-ID: <20160916165245.GM6002@thinpad.lan.raisama.net> References: <20160916144132.31416-1-marcandre.lureau@redhat.com> <20160916145637.GL6002@thinpad.lan.raisama.net> <1077308097.1320619.1474038394482.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1077308097.1320619.1474038394482.JavaMail.zimbra@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] RFC: linux-user-i386: crash on cpuid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau Cc: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau , qemu-devel@nongnu.org, pbonzini@redhat.com, rth@twiddle.net On Fri, Sep 16, 2016 at 11:06:34AM -0400, Marc-Andr=E9 Lureau wrote: > Hi >=20 > ----- Original Message ----- > > > =20 > > > -#ifndef CONFIG_USER_ONLY > > > +#ifdef CONFIG_USER_ONLY > > > + cs->nr_cores =3D smp_cores; > > > + cs->nr_threads =3D smp_threads; > > > +#else > >=20 > > On CONFIG_USER_ONLY, smp_cores and smp_threads are defined as: > >=20 > > /* *-user doesn't have configurable SMP topology */ > > #define smp_cores 1 > > #define smp_threads 1 > >=20 > > It sounds simpler to just set nr_cores and nr_threads to 1 by > > default in cpu_common_initfn(). (Preferably with a comment noting > > that the default value is changed by qemu_init_vcpu() for > > softmmu). >=20 > Any reason those define exists? It seems we could use cpu state values = instead, ex: Just because there was existing non-softmmu-specific code that used those variables. If we eliminate their usage (are the ones below the only cases?), we can remove the macros. >=20 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -2490,13 +2490,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t i= ndex, uint32_t count, > =20 > switch (count) { > case 0: > - *eax =3D apicid_core_offset(smp_cores, smp_threads); > - *ebx =3D smp_threads; > + *eax =3D apicid_core_offset(cs->nr_cores, cs->nr_threads); > + *ebx =3D cs->nr_threads; > *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; > break; > case 1: > - *eax =3D apicid_pkg_offset(smp_cores, smp_threads); > - *ebx =3D smp_cores * smp_threads; > + *eax =3D apicid_pkg_offset(cs->nr_cores, cs->nr_threads); > + *ebx =3D cs->nr_cores * cs->nr_threads; > *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; > break; >=20 --=20 Eduardo