From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkuiu-0002sH-NW for qemu-devel@nongnu.org; Fri, 16 Sep 2016 11:06:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkuip-00068u-Tt for qemu-devel@nongnu.org; Fri, 16 Sep 2016 11:06:40 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:45910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkuip-00068T-KA for qemu-devel@nongnu.org; Fri, 16 Sep 2016 11:06:35 -0400 Date: Fri, 16 Sep 2016 11:06:34 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <1077308097.1320619.1474038394482.JavaMail.zimbra@redhat.com> In-Reply-To: <20160916145637.GL6002@thinpad.lan.raisama.net> References: <20160916144132.31416-1-marcandre.lureau@redhat.com> <20160916145637.GL6002@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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: Eduardo Habkost Cc: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , qemu-devel@nongnu.org, pbonzini@redhat.com, rth@twiddle.net Hi ----- Original Message ----- > > > > -#ifndef CONFIG_USER_ONLY > > +#ifdef CONFIG_USER_ONLY > > + cs->nr_cores = smp_cores; > > + cs->nr_threads = smp_threads; > > +#else > > On CONFIG_USER_ONLY, smp_cores and smp_threads are defined as: > > /* *-user doesn't have configurable SMP topology */ > #define smp_cores 1 > #define smp_threads 1 > > 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). Any reason those define exists? It seems we could use cpu state values instead, ex: --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2490,13 +2490,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, switch (count) { case 0: - *eax = apicid_core_offset(smp_cores, smp_threads); - *ebx = smp_threads; + *eax = apicid_core_offset(cs->nr_cores, cs->nr_threads); + *ebx = cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax = apicid_pkg_offset(smp_cores, smp_threads); - *ebx = smp_cores * smp_threads; + *eax = apicid_pkg_offset(cs->nr_cores, cs->nr_threads); + *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break;