From nobody Thu May 2 21:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494600044209338.22658253691; Fri, 12 May 2017 07:40:44 -0700 (PDT) Received: from localhost ([::1]:54067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BkI-0006vC-Tl for importer@patchew.org; Fri, 12 May 2017 10:40:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Bi6-0005Mx-02 for qemu-devel@nongnu.org; Fri, 12 May 2017 10:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9Bi4-0005Oy-Ux for qemu-devel@nongnu.org; Fri, 12 May 2017 10:38:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d9Bi4-0005No-Ls for qemu-devel@nongnu.org; Fri, 12 May 2017 10:38:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BF987F7A7; Fri, 12 May 2017 14:38:23 +0000 (UTC) Received: from localhost (ovpn-116-191.ams2.redhat.com [10.36.116.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id A43137D533; Fri, 12 May 2017 14:38:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8BF987F7A7 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8BF987F7A7 From: Stefan Hajnoczi To: Date: Fri, 12 May 2017 10:38:12 -0400 Message-Id: <20170512143812.31067-2-stefanha@redhat.com> In-Reply-To: <20170512143812.31067-1-stefanha@redhat.com> References: <20170512143812.31067-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 12 May 2017 14:38:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.9 1/1] trace: add sanity check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Anthony Xu , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Anthony Xu If trace backend is set to TRACE_NOP, trace_get_vcpu_event_count returns 0, cause bitmap_new call abort. The abort can be triggered as follows: $ ./configure --enable-trace-backend=3Dnop --target-list=3Dx86_64-softmmu $ gdb ./x86_64-softmmu/qemu-system-x86_64 -M q35,accel=3Dkvm -m 1G (gdb) bt #0 0x00007ffff04e25f7 in raise () from /lib64/libc.so.6 #1 0x00007ffff04e3ce8 in abort () from /lib64/libc.so.6 #2 0x00005555559de905 in bitmap_new (nbits=3D) at /home/root/git/qemu2.git/include/qemu/bitmap.h:96 #3 cpu_common_initfn (obj=3D0x555556621d30) at qom/cpu.c:399 #4 0x0000555555a11869 in object_init_with_type (obj=3D0x555556621d30, ti= =3D0x55555656bbb0) at qom/object.c:341 #5 0x0000555555a11869 in object_init_with_type (obj=3D0x555556621d30, ti= =3D0x55555656bd30) at qom/object.c:341 #6 0x0000555555a11efc in object_initialize_with_type (data=3Ddata@entry= =3D0x555556621d30, size=3D76560, type=3Dtype@entry=3D0x55555656bd30) at qom/object.c:376 #7 0x0000555555a12061 in object_new_with_type (type=3D0x55555656bd30) at= qom/object.c:484 #8 0x0000555555a121c5 in object_new (typename=3Dtypename@entry=3D0x55555= 6550340 "qemu64-x86_64-cpu") at qom/object.c:494 #9 0x00005555557f6e3d in pc_new_cpu (typename=3Dtypename@entry=3D0x55555= 6550340 "qemu64-x86_64-cpu", apic_id=3D0, errp=3Derrp@entry=3D0x5555565391b0 ) at /home/root/git/q= emu2.git/hw/i386/pc.c:1101 #10 0x00005555557fa33e in pc_cpus_init (pcms=3Dpcms@entry=3D0x5555565f969= 0) at /home/root/git/qemu2.git/hw/i386/pc.c:1184 #11 0x00005555557fe0f6 in pc_q35_init (machine=3D0x5555565f9690) at /home= /root/git/qemu2.git/hw/i386/pc_q35.c:121 #12 0x000055555574fbad in main (argc=3D, argv=3D, envp=3D) at vl.c:4562 Signed-off-by: Anthony Xu Message-id: 1494369432-15418-1-git-send-email-anthony.xu@intel.com Signed-off-by: Stefan Hajnoczi --- qom/cpu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qom/cpu.c b/qom/cpu.c index f02e9c0..f9111a0 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -382,6 +382,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Er= ror **errp) =20 static void cpu_common_initfn(Object *obj) { + uint32_t count; CPUState *cpu =3D CPU(obj); CPUClass *cc =3D CPU_GET_CLASS(obj); =20 @@ -396,7 +397,10 @@ static void cpu_common_initfn(Object *obj) QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); =20 - cpu->trace_dstate =3D bitmap_new(trace_get_vcpu_event_count()); + count =3D trace_get_vcpu_event_count(); + if (count) { + cpu->trace_dstate =3D bitmap_new(count); + } =20 cpu_exec_initfn(cpu); } --=20 2.9.3