From nobody Sat Apr 27 11:43:03 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 1487703449731927.2338629356468; Tue, 21 Feb 2017 10:57:29 -0800 (PST) Received: from localhost ([::1]:47916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgFct-0008Iy-Gb for importer@patchew.org; Tue, 21 Feb 2017 13:57:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgFb3-0007Ea-HD for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgFb1-0006os-TB for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgFb1-0006nT-NL for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:31 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3DDBC05678C for ; Tue, 21 Feb 2017 18:55:31 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-60.ams2.redhat.com [10.36.117.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LItSLW014983; Tue, 21 Feb 2017 13:55:30 -0500 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 18:55:25 +0000 Message-Id: <20170221185527.3901-2-dgilbert@redhat.com> In-Reply-To: <20170221185527.3901-1-dgilbert@redhat.com> References: <20170221185527.3901-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 21 Feb 2017 18:55:31 +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 1/3] hmp: fix block_set_io_throttle 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: thuth@redhat.com, phrdina@redhat.com 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: Eric Blake Commit 7a9877a made the 'device' parameter to BlockIOThrottle optional, favoring 'id' instead. But it forgot to update the HMP usage to set has_device, which makes all attempts to change throttling via HMP fail with "Need exactly one of 'device' and 'id'" CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20170120230359.4244-1-eblake@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Dr. David Alan Gilbert --- hmp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hmp.c b/hmp.c index 2bc4f06..0c80596 100644 --- a/hmp.c +++ b/hmp.c @@ -1552,6 +1552,7 @@ void hmp_block_set_io_throttle(Monitor *mon, const QD= ict *qdict) { Error *err =3D NULL; BlockIOThrottle throttle =3D { + .has_device =3D true, .device =3D (char *) qdict_get_str(qdict, "device"), .bps =3D qdict_get_int(qdict, "bps"), .bps_rd =3D qdict_get_int(qdict, "bps_rd"), --=20 2.9.3 From nobody Sat Apr 27 11:43:03 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 1487703451287527.3035245172314; Tue, 21 Feb 2017 10:57:31 -0800 (PST) Received: from localhost ([::1]:47917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgFcu-0008KA-QG for importer@patchew.org; Tue, 21 Feb 2017 13:57:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgFb4-0007Eq-A0 for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgFb3-0006r8-DC for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgFb3-0006qH-4V for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:33 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27D98C04B956 for ; Tue, 21 Feb 2017 18:55:33 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-60.ams2.redhat.com [10.36.117.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LItSLX014983; Tue, 21 Feb 2017 13:55:31 -0500 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 18:55:26 +0000 Message-Id: <20170221185527.3901-3-dgilbert@redhat.com> In-Reply-To: <20170221185527.3901-1-dgilbert@redhat.com> References: <20170221185527.3901-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 21 Feb 2017 18:55:33 +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 2/3] monitor: add poll-* properties into query-iothreads result 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: thuth@redhat.com, phrdina@redhat.com 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: Pavel Hrdina IOthreads were recently extended by new properties that can enable/disable and configure aio polling. This will also allow other tools that uses QEMU to probe for existence of those new properties via query-qmp-schema. Signed-off-by: Pavel Hrdina Message-Id: <3163c16d6ab4257f7be9ad44fe9cc0ce8c359e5a.1486718555.git.phrdin= a@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Dr. David Alan Gilbert --- hmp.c | 9 +++++++-- iothread.c | 3 +++ qapi-schema.json | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index 0c80596..8b0c2b0 100644 --- a/hmp.c +++ b/hmp.c @@ -2149,10 +2149,15 @@ void hmp_info_iothreads(Monitor *mon, const QDict *= qdict) { IOThreadInfoList *info_list =3D qmp_query_iothreads(NULL); IOThreadInfoList *info; + IOThreadInfo *value; =20 for (info =3D info_list; info; info =3D info->next) { - monitor_printf(mon, "%s: thread_id=3D%" PRId64 "\n", - info->value->id, info->value->thread_id); + value =3D info->value; + monitor_printf(mon, "%s:\n", value->id); + monitor_printf(mon, " thread_id=3D%" PRId64 "\n", value->thread_i= d); + monitor_printf(mon, " poll-max-ns=3D%" PRId64 "\n", value->poll_m= ax_ns); + monitor_printf(mon, " poll-grow=3D%" PRId64 "\n", value->poll_gro= w); + monitor_printf(mon, " poll-shrink=3D%" PRId64 "\n", value->poll_s= hrink); } =20 qapi_free_IOThreadInfoList(info_list); diff --git a/iothread.c b/iothread.c index 257b01d..beeb870 100644 --- a/iothread.c +++ b/iothread.c @@ -268,6 +268,9 @@ static int query_one_iothread(Object *object, void *opa= que) info =3D g_new0(IOThreadInfo, 1); info->id =3D iothread_get_id(iothread); info->thread_id =3D iothread->thread_id; + info->poll_max_ns =3D iothread->poll_max_ns; + info->poll_grow =3D iothread->poll_grow; + info->poll_shrink =3D iothread->poll_shrink; =20 elem =3D g_new0(IOThreadInfoList, 1); elem->value =3D info; diff --git a/qapi-schema.json b/qapi-schema.json index e9a6364..f6ca18c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1427,10 +1427,23 @@ # # @thread-id: ID of the underlying host thread # +# @poll-max-ns: maximum polling time in ns, 0 means polling is disabled +# (since 2.9) +# +# @poll-grow: how many ns will be added to polling time, 0 means that it's= not +# configured (since 2.9) +# +# @poll-shrink: how many ns will be removed from polling time, 0 means that +# it's not configured (since 2.9) +# # Since: 2.0 ## { 'struct': 'IOThreadInfo', - 'data': {'id': 'str', 'thread-id': 'int'} } + 'data': {'id': 'str', + 'thread-id': 'int', + 'poll-max-ns': 'int', + 'poll-grow': 'int', + 'poll-shrink': 'int' } } =20 ## # @query-iothreads: --=20 2.9.3 From nobody Sat Apr 27 11:43:03 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 1487703732147575.4833959172917; Tue, 21 Feb 2017 11:02:12 -0800 (PST) Received: from localhost ([::1]:47947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgFhR-0004hd-0A for importer@patchew.org; Tue, 21 Feb 2017 14:02:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgFb6-0007GN-J2 for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgFb4-0006sQ-KC for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgFb4-0006rn-An for qemu-devel@nongnu.org; Tue, 21 Feb 2017 13:55:34 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6514AC05678C for ; Tue, 21 Feb 2017 18:55:34 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-60.ams2.redhat.com [10.36.117.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LItSLY014983; Tue, 21 Feb 2017 13:55:33 -0500 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 18:55:27 +0000 Message-Id: <20170221185527.3901-4-dgilbert@redhat.com> In-Reply-To: <20170221185527.3901-1-dgilbert@redhat.com> References: <20170221185527.3901-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 21 Feb 2017 18:55:34 +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 3/3] monitor: Fix crashes when using HMP commands without CPU 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: thuth@redhat.com, phrdina@redhat.com 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: Thomas Huth When running certain HMP commands ("info registers", "info cpustats", "info tlb", "nmi", "memsave" or dumping virtual memory) with the "none" machine, QEMU crashes with a segmentation fault. This happens because the "none" machine does not have any CPUs by default, but these HMP commands did not check for a valid CPU pointer yet. Add such checks now, so we get an error message about the missing CPU instead. Signed-off-by: Thomas Huth Message-Id: <1484309555-1935-1-git-send-email-thuth@redhat.com> Reviewed-by: Markus Armbruster Acked-by: David Gibson Signed-off-by: Dr. David Alan Gilbert --- hmp.c | 8 +++++++- monitor.c | 42 ++++++++++++++++++++++++++++++++++-------- target/i386/monitor.c | 16 +++++++++++++++- target/ppc/monitor.c | 4 ++++ target/sh4/monitor.c | 5 +++++ target/sparc/monitor.c | 4 ++++ target/xtensa/monitor.c | 4 ++++ 7 files changed, 73 insertions(+), 10 deletions(-) diff --git a/hmp.c b/hmp.c index 8b0c2b0..aba728f 100644 --- a/hmp.c +++ b/hmp.c @@ -1014,8 +1014,14 @@ void hmp_memsave(Monitor *mon, const QDict *qdict) const char *filename =3D qdict_get_str(qdict, "filename"); uint64_t addr =3D qdict_get_int(qdict, "val"); Error *err =3D NULL; + int cpu_index =3D monitor_get_cpu_index(); =20 - qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &err); + if (cpu_index < 0) { + monitor_printf(mon, "No CPU available\n"); + return; + } + + qmp_memsave(addr, size, filename, true, cpu_index, &err); hmp_handle_error(mon, &err); } =20 diff --git a/monitor.c b/monitor.c index 3cd72a9..5953fc9 100644 --- a/monitor.c +++ b/monitor.c @@ -1026,6 +1026,9 @@ int monitor_set_cpu(int cpu_index) CPUState *mon_get_cpu(void) { if (!cur_mon->mon_cpu) { + if (!first_cpu) { + return NULL; + } monitor_set_cpu(first_cpu->cpu_index); } cpu_synchronize_state(cur_mon->mon_cpu); @@ -1034,17 +1037,27 @@ CPUState *mon_get_cpu(void) =20 CPUArchState *mon_get_cpu_env(void) { - return mon_get_cpu()->env_ptr; + CPUState *cs =3D mon_get_cpu(); + + return cs ? cs->env_ptr : NULL; } =20 int monitor_get_cpu_index(void) { - return mon_get_cpu()->cpu_index; + CPUState *cs =3D mon_get_cpu(); + + return cs ? cs->cpu_index : UNASSIGNED_CPU_INDEX; } =20 static void hmp_info_registers(Monitor *mon, const QDict *qdict) { - cpu_dump_state(mon_get_cpu(), (FILE *)mon, monitor_fprintf, CPU_DUMP_F= PU); + CPUState *cs =3D mon_get_cpu(); + + if (!cs) { + monitor_printf(mon, "No CPU available\n"); + return; + } + cpu_dump_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); } =20 static void hmp_info_jit(Monitor *mon, const QDict *qdict) @@ -1077,7 +1090,13 @@ static void hmp_info_history(Monitor *mon, const QDi= ct *qdict) =20 static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) { - cpu_dump_statistics(mon_get_cpu(), (FILE *)mon, &monitor_fprintf, 0); + CPUState *cs =3D mon_get_cpu(); + + if (!cs) { + monitor_printf(mon, "No CPU available\n"); + return; + } + cpu_dump_statistics(cs, (FILE *)mon, &monitor_fprintf, 0); } =20 static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) @@ -1236,6 +1255,12 @@ static void memory_dump(Monitor *mon, int count, int= format, int wsize, int l, line_size, i, max_digits, len; uint8_t buf[16]; uint64_t v; + CPUState *cs =3D mon_get_cpu(); + + if (!cs && (format =3D=3D 'i' || !is_physical)) { + monitor_printf(mon, "Can not dump without CPU\n"); + return; + } =20 if (format =3D=3D 'i') { int flags =3D 0; @@ -1265,7 +1290,7 @@ static void memory_dump(Monitor *mon, int count, int = format, int wsize, flags =3D msr_le << 16; flags |=3D env->bfd_mach; #endif - monitor_disas(mon, mon_get_cpu(), addr, count, is_physical, flags); + monitor_disas(mon, cs, addr, count, is_physical, flags); return; } =20 @@ -1304,7 +1329,7 @@ static void memory_dump(Monitor *mon, int count, int = format, int wsize, if (is_physical) { cpu_physical_memory_read(addr, buf, l); } else { - if (cpu_memory_rw_debug(mon_get_cpu(), addr, buf, l, 0) < 0) { + if (cpu_memory_rw_debug(cs, addr, buf, l, 0) < 0) { monitor_printf(mon, " Cannot access memory\n"); break; } @@ -2189,11 +2214,12 @@ expr_error(Monitor *mon, const char *fmt, ...) static int get_monitor_def(target_long *pval, const char *name) { const MonitorDef *md =3D target_monitor_defs(); + CPUState *cs =3D mon_get_cpu(); void *ptr; uint64_t tmp =3D 0; int ret; =20 - if (md =3D=3D NULL) { + if (cs =3D=3D NULL || md =3D=3D NULL) { return -1; } =20 @@ -2220,7 +2246,7 @@ static int get_monitor_def(target_long *pval, const c= har *name) } } =20 - ret =3D target_get_monitor_def(mon_get_cpu(), name, &tmp); + ret =3D target_get_monitor_def(cs, name, &tmp); if (!ret) { *pval =3D (target_long) tmp; } diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 468aa07..77ead60 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -210,6 +210,10 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) CPUArchState *env; =20 env =3D mon_get_cpu_env(); + if (!env) { + monitor_printf(mon, "No CPU available\n"); + return; + } =20 if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); @@ -529,6 +533,10 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) CPUArchState *env; =20 env =3D mon_get_cpu_env(); + if (!env) { + monitor_printf(mon, "No CPU available\n"); + return; + } =20 if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); @@ -624,7 +632,13 @@ const MonitorDef *target_monitor_defs(void) =20 void hmp_info_local_apic(Monitor *mon, const QDict *qdict) { - x86_cpu_dump_local_apic_state(mon_get_cpu(), (FILE *)mon, monitor_fpri= ntf, + CPUState *cs =3D mon_get_cpu(); + + if (!cs) { + monitor_printf(mon, "No CPU available\n"); + return; + } + x86_cpu_dump_local_apic_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); } =20 diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c index c2d0806..b8f30e9 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/monitor.c @@ -62,6 +62,10 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 =3D mon_get_cpu_env(); =20 + if (!env1) { + monitor_printf(mon, "No CPU available\n"); + return; + } dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); } =20 diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c index 426e5d4..4c7f36c 100644 --- a/target/sh4/monitor.c +++ b/target/sh4/monitor.c @@ -44,6 +44,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) CPUArchState *env =3D mon_get_cpu_env(); int i; =20 + if (!env) { + monitor_printf(mon, "No CPU available\n"); + return; + } + monitor_printf (mon, "ITLB:\n"); for (i =3D 0 ; i < ITLB_SIZE ; i++) print_tlb (mon, i, &env->itlb[i]); diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c index 7cc1b0f..f3ca524 100644 --- a/target/sparc/monitor.c +++ b/target/sparc/monitor.c @@ -32,6 +32,10 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 =3D mon_get_cpu_env(); =20 + if (!env1) { + monitor_printf(mon, "No CPU available\n"); + return; + } dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); } =20 diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index f3fa4cd..2ee2b5b 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -31,5 +31,9 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 =3D mon_get_cpu_env(); =20 + if (!env1) { + monitor_printf(mon, "No CPU available\n"); + return; + } dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); } --=20 2.9.3