qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hmp: fix "info cpu" segfault
@ 2017-03-29 16:52 Iwona Kotlarska
  2017-03-29 17:38 ` Marcel Apfelbaum
  0 siblings, 1 reply; 2+ messages in thread
From: Iwona Kotlarska @ 2017-03-29 16:52 UTC (permalink / raw)
  Cc: qemu-devel, marcel, pbonzini, rth, ehabkost, Iwona Kotlarska

Running "dump-guest-memory /dev/null 0 8192" results in segfault.
Fix by checking if we have CPU.

Signed-off-by: Iwona Kotlarska <iwona260909@gmail.com>
---
 target/i386/arch_dump.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
index 5a2e4be5d0..45cda6afb1 100644
--- a/target/i386/arch_dump.c
+++ b/target/i386/arch_dump.c
@@ -390,9 +390,10 @@ int cpu_get_dump_info(ArchDumpInfo *info,
     GuestPhysBlock *block;
 
 #ifdef TARGET_X86_64
-    X86CPU *first_x86_cpu = X86_CPU(first_cpu);
-
-    lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);
+    X86CPU *first_x86_cpu = NULL;
+    first_x86_cpu = X86_CPU(first_cpu);
+    if (first_cpu != NULL)
+        lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);
 #endif
 
     if (lma) {
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] hmp: fix "info cpu" segfault
  2017-03-29 16:52 [Qemu-devel] [PATCH] hmp: fix "info cpu" segfault Iwona Kotlarska
@ 2017-03-29 17:38 ` Marcel Apfelbaum
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Apfelbaum @ 2017-03-29 17:38 UTC (permalink / raw)
  To: Iwona Kotlarska; +Cc: qemu-devel, pbonzini, rth, ehabkost

On 03/29/2017 07:52 PM, Iwona Kotlarska wrote:
> Running "dump-guest-memory /dev/null 0 8192" results in segfault.
> Fix by checking if we have CPU.
>

Hi Iwona,
Thank you for contributing to the QEMU project.

Please state the whole command line that causes the problem,
not only the hmp command:

    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 this by...

> Signed-off-by: Iwona Kotlarska <iwona260909@gmail.com>
> ---
>  target/i386/arch_dump.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
> index 5a2e4be5d0..45cda6afb1 100644
> --- a/target/i386/arch_dump.c
> +++ b/target/i386/arch_dump.c
> @@ -390,9 +390,10 @@ int cpu_get_dump_info(ArchDumpInfo *info,
>      GuestPhysBlock *block;
>
>  #ifdef TARGET_X86_64
> -    X86CPU *first_x86_cpu = X86_CPU(first_cpu);
> -
> -    lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);
> +    X86CPU *first_x86_cpu = NULL;
> +    first_x86_cpu = X86_CPU(first_cpu);

You didn't need to break the above in two lines,
but is not a big issue either.

> +    if (first_cpu != NULL)
> +        lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);

Please run: ./scripts/checkpatch.pl on the patch before you
submit to ensure coding style.
   You will see that we always use if { }; the patch has "DOS line endings".


You are welcome to submit the patch again.
In the meantime:
     Tested-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

>  #endif
>
>      if (lma) {
>

-- 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-29 17:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-29 16:52 [Qemu-devel] [PATCH] hmp: fix "info cpu" segfault Iwona Kotlarska
2017-03-29 17:38 ` Marcel Apfelbaum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).