From 854e67fea6a6f181163a5467fc9ba04de8d181bb Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Fri, 13 Jan 2017 13:12:35 +0100 Subject: monitor: Fix crashes when using HMP commands without CPU 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 --- target/ppc/monitor.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'target/ppc/monitor.c') diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c index c2d0806dd1..b8f30e9eaf 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 = mon_get_cpu_env(); + if (!env1) { + monitor_printf(mon, "No CPU available\n"); + return; + } dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); } -- cgit v1.2.3