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

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