From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkuc9-0000Nj-Fk for qemu-devel@nongnu.org; Fri, 16 Sep 2016 10:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkuc3-0001aF-K3 for qemu-devel@nongnu.org; Fri, 16 Sep 2016 10:59:40 -0400 Received: from mx5-phx2.redhat.com ([209.132.183.37]:47789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkuc3-0001Z4-B6 for qemu-devel@nongnu.org; Fri, 16 Sep 2016 10:59:35 -0400 Date: Fri, 16 Sep 2016 10:59:33 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <2133468536.1318341.1474037973023.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: 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: Eduardo Habkost Cc: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , qemu-devel@nongnu.org, pbonzini@redhat.com, rth@twiddle.net Hi ----- Original Message ----- > On Fri, Sep 16, 2016 at 06:41:32PM +0400, Marc-Andr=C3=A9 Lureau wrote: > > Running cpuid instructions with a simple run like: > > i386-linux-user/qemu-i386 tests/tcg/sha1-i386 > >=20 > > Results in the following assert: > > #0 0x00007ffff64246f5 in raise () from /lib64/libc.so.6 > > #1 0x00007ffff64262fa in abort () from /lib64/libc.so.6 > > #2 0x00007ffff7937ec5 in g_assertion_message () from > > /lib64/libglib-2.0.so.0 > > #3 0x00007ffff7937f5a in g_assertion_message_expr () from > > /lib64/libglib-2.0.so.0 > > #4 0x000055555561b54c in apicid_bitwidth_for_count (count=3D0) at > > /home/elmarco/src/qemu/include/hw/i386/topology.h:58 > > #5 0x000055555561b58a in apicid_smt_width (nr_cores=3D0, nr_threads= =3D0) at > > /home/elmarco/src/qemu/include/hw/i386/topology.h:67 > > #6 0x000055555561b5c3 in apicid_core_offset (nr_cores=3D0, nr_threads= =3D0) at > > /home/elmarco/src/qemu/include/hw/i386/topology.h:82 > > #7 0x000055555561b5e3 in apicid_pkg_offset (nr_cores=3D0, nr_threads= =3D0) at > > /home/elmarco/src/qemu/include/hw/i386/topology.h:89 > > #8 0x000055555561dd86 in cpu_x86_cpuid (env=3D0x555557999550, index= =3D4, > > count=3D3, eax=3D0x7fffffffcae8, ebx=3D0x7fffffffcaec, ecx=3D0x7ffffff= fcaf0, > > edx=3D0x7fffffffcaf4) at /home/elmarco/src/qemu/target-i386/cpu.c:2405 > > #9 0x0000555555638e8e in helper_cpuid (env=3D0x555557999550) at > > /home/elmarco/src/qemu/target-i386/misc_helper.c:106 > > #10 0x000055555599dc5e in static_code_gen_buffer () > > #11 0x00005555555952f8 in cpu_tb_exec (cpu=3D0x5555579912d0, > > itb=3D0x7ffff4371ab0) at /home/elmarco/src/qemu/cpu-exec.c:166 > > #12 0x0000555555595c8e in cpu_loop_exec_tb (cpu=3D0x5555579912d0, > > tb=3D0x7ffff4371ab0, last_tb=3D0x7fffffffd088, tb_exit=3D0x7fffffffd08= 4, > > sc=3D0x7fffffffd0a0) at /home/elmarco/src/qemu/cpu-exec.c:517 > > #13 0x0000555555595e50 in cpu_exec (cpu=3D0x5555579912d0) at > > /home/elmarco/src/qemu/cpu-exec.c:612 > > #14 0x00005555555c065b in cpu_loop (env=3D0x555557999550) at > > /home/elmarco/src/qemu/linux-user/main.c:297 > > #15 0x00005555555c25b2 in main (argc=3D2, argv=3D0x7fffffffd848, > > envp=3D0x7fffffffd860) at /home/elmarco/src/qemu/linux-user/main.c:480= 3 > >=20 > > The fields are set in qemu_init_vcpu() with softmmu, but it's a stub > > with linux-user. > >=20 > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > --- > > target-i386/cpu.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > >=20 > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > > index 5a5299a..ce8f798 100644 > > --- a/target-i386/cpu.c > > +++ b/target-i386/cpu.c > > @@ -3097,7 +3097,10 @@ static void x86_cpu_realizefn(DeviceState *dev, > > Error **errp) > > =20 > > mce_init(cpu); > > =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). Ok, I'll resend a patch thanks