Blame SOURCES/0035-hmp-fix-dump-quest-memory-segfault-arm.patch

4a2fec
From 14dc40db1b710c64fbb2eeccde1afefa0a37cd1e Mon Sep 17 00:00:00 2001
4a2fec
From: Laurent Vivier <lvivier@redhat.com>
4a2fec
Date: Wed, 13 Sep 2017 16:20:34 +0200
4a2fec
Subject: hmp: fix "dump-quest-memory" segfault (arm)
4a2fec
4a2fec
Running QEMU with
4a2fec
    qemu-system-aarch64 -M none -nographic -m 256
4a2fec
and executing
4a2fec
    dump-guest-memory /dev/null 0 8192
4a2fec
results in segfault
4a2fec
4a2fec
Fix by checking if we have CPU, and exit with
4a2fec
error if there is no CPU:
4a2fec
4a2fec
    (qemu) dump-guest-memory /dev/null
4a2fec
    this feature or command is not currently supported
4a2fec
4a2fec
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
Reviewed-by: Thomas Huth <thuth@redhat.com>
4a2fec
Reviewed-by: Greg Kurz <groug@kaod.org>
4a2fec
Message-Id: <20170913142036.2469-3-lvivier@redhat.com>
4a2fec
Reviewed-by: Eric Auger <eric.auger@redhat.com>
4a2fec
Tested-by: Eric Auger <eric.auger@redhat.com>
4a2fec
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4a2fec
(cherry picked from commit 6dba634097d54db60017f10c160a052e46bdf60d)
4a2fec
---
4a2fec
 target/arm/arch_dump.c | 11 +++++++++--
4a2fec
 1 file changed, 9 insertions(+), 2 deletions(-)
4a2fec
4a2fec
diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c
4a2fec
index 1a9861f..9e5b2fb 100644
4a2fec
--- a/target/arm/arch_dump.c
4a2fec
+++ b/target/arm/arch_dump.c
4a2fec
@@ -273,11 +273,18 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
4a2fec
 int cpu_get_dump_info(ArchDumpInfo *info,
4a2fec
                       const GuestPhysBlockList *guest_phys_blocks)
4a2fec
 {
4a2fec
-    ARMCPU *cpu = ARM_CPU(first_cpu);
4a2fec
-    CPUARMState *env = &cpu->env;
4a2fec
+    ARMCPU *cpu;
4a2fec
+    CPUARMState *env;
4a2fec
     GuestPhysBlock *block;
4a2fec
     hwaddr lowest_addr = ULLONG_MAX;
4a2fec
 
4a2fec
+    if (first_cpu == NULL) {
4a2fec
+        return -1;
4a2fec
+    }
4a2fec
+
4a2fec
+    cpu = ARM_CPU(first_cpu);
4a2fec
+    env = &cpu->env;
4a2fec
+
4a2fec
     /* Take a best guess at the phys_base. If we get it wrong then crash
4a2fec
      * will need '--machdep phys_offset=<phys-offset>' added to its command
4a2fec
      * line, which isn't any worse than assuming we can use zero, but being
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec