Skip to contentSkip to conversation

hmp: fix "info cpu" segfault

PATCH In review Iwona Kotlarska 6 participants 7 messages Mar 30, 2017 – Mar 31, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 hmp: fix "info cpu" segfault

Running QEMU with "qemu-system-x86_64 -M none -nographic -m 256" and executing "dump-guest-memory /dev/null 0 8192" results in segfault.
Fix by checking if we have CPU.

---
 target/i386/arch_dump.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/i386/arch_dump.c +1 -2
index 5a2e4be5d0..fe0aa36932 100644
@@ -391,8 +391,7 @@ int cpu_get_dump_info(ArchDumpInfo *info,
 
 #ifdef TARGET_X86_64
     X86CPU *first_x86_cpu = X86_CPU(first_cpu);
-
-    lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);
+    lma = first_cpu && (first_x86_cpu->env.hflags & HF_LMA_MASK);
 #endif
 
     if (lma) {
Signature · 1 line
2.12.0
Reviewed-by on v3 1/1
#2 lore raw
In reply to Iwona Kotlarska
Quoted 6 lines · Iwona Kotlarska

Running QEMU with "qemu-system-x86_64 -M none -nographic -m 256" and executing "dump-guest-memory /dev/null 0 8192" results in segfault.
Fix by checking if we have CPU.

---

Hi Iwona,

Next time (this patch is OK) please add here,
after the "---" line a quick info on the version changes, e.g. :

v2 -> v3:
- Addressed Eduardo's comment and didn't split the assignment.
- ...

v1-> v2:

- ....

Quoted 9 lines
 target/i386/arch_dump.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/i386/arch_dump.c +0 -0
index 5a2e4be5d0..fe0aa36932 100644

target/i386/arch_dump.c int cpu_get_dump_info(ArchDumpInfo *info, · line 397

Quoted 9 lines
target/i386/arch_dump.c +1 -2
@@ -391,8 +391,7 @@ int cpu_get_dump_info(ArchDumpInfo *info,
 
 #ifdef TARGET_X86_64
     X86CPU *first_x86_cpu = X86_CPU(first_cpu);
-
-    lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);
+    lma = first_cpu && (first_x86_cpu->env.hflags & HF_LMA_MASK);
 #endif
 
     if (lma) {

Thanks,
Marcel

#4 lore raw
Quoted 5 lines · Eduardo Habkost
Quoted 4 lines · Iwona Kotlarska

Running QEMU with "qemu-system-x86_64 -M none -nographic -m 256" and executing "dump-guest-memory /dev/null 0 8192" results in segfault.
Fix by checking if we have CPU.

Quoted 7 lines
Quoted 1 line

Thanks!

Paolo, are you queueing x86 bug fixes for the next -rc?

This being HMP, I was leaving it to Dave, but I can queue it too since I have some memory API stuff to post too.

Paolo

#5 lore raw
Quoted 10 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 7 lines · Eduardo Habkost
Quoted 5 lines · Iwona Kotlarska

Running QEMU with "qemu-system-x86_64 -M none -nographic -m 256" and executing "dump-guest-memory /dev/null 0 8192" results in segfault.
Fix by checking if we have CPU.

Quoted 8 lines
Quoted 5 lines

Thanks!

Paolo, are you queueing x86 bug fixes for the next -rc?

This being HMP, I was leaving it to Dave, but I can queue it too since I have some memory API stuff to post too.

Yeh I'll take this.

Dave

Quoted 1 line

Paolo

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#6 lore raw
In reply to Iwona Kotlarska
Quoted 5 lines · * Iwona Kotlarska ([email protected]) wrote:

Running QEMU with "qemu-system-x86_64 -M none -nographic -m 256" and executing "dump-guest-memory /dev/null 0 8192" results in segfault.
Fix by checking if we have CPU.

Queued.

I've fixed up the title to
hmp: fix "dump-quest-memory" segfault

since that's the actual command it fixes.

Dave

Quoted 22 lines
---
 target/i386/arch_dump.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/i386/arch_dump.c +1 -2
index 5a2e4be5d0..fe0aa36932 100644
@@ -391,8 +391,7 @@ int cpu_get_dump_info(ArchDumpInfo *info,
 
 #ifdef TARGET_X86_64
     X86CPU *first_x86_cpu = X86_CPU(first_cpu);
-
-    lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);
+    lma = first_cpu && (first_x86_cpu->env.hflags & HF_LMA_MASK);
 #endif
 
     if (lma) {
Signature · 1 line
2.12.0

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK