qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/1] hw/core/cpu: always print cpu index with cpu state


From: Dongli Zhang
Subject: [PATCH 1/1] hw/core/cpu: always print cpu index with cpu state
Date: Mon, 6 Feb 2023 15:42:20 -0800

The cpu_dump_state() does not print the cpu index. When the
cpu_dump_state() is invoked due to the KVM failure, we are not able to tell
from which CPU the state is. The below is an example.

KVM internal error. Suberror: 764064
RAX=0000000000000002 RBX=ffff8a9e57c38400 RCX=00000000ffffffff 
RDX=ffff8a9cc00ba8a0
RSI=0000000000000003 RDI=ffff8a9e57c38400 RBP=ffffb6120c5b3c50 
RSP=ffffb6120c5b3c40
R8 =0000000000000000 R9 =ffff8a9cc00ba8a0 R10=ffffffff8e467350 
R11=0000000000000007
R12=000000000000000a R13=ffffffff8f987e25 R14=ffffffff8f988a01 
R15=0000000000000000
RIP=ffffffff8e51bb04 RFL=00010046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0000 0000000000000000 ffffffff 00c00000
CS =0010 0000000000000000 ffffffff 00a09b00 DPL=0 CS64 [-RA]
SS =0000 0000000000000000 ffffffff 00c00000
DS =0000 0000000000000000 ffffffff 00c00000
FS =0000 0000000000000000 ffffffff 00c00000
GS =0000 ffff8ac27fcc0000 ffffffff 00c00000
LDT=0000 0000000000000000 ffffffff 00c00000
TR =0040 fffffe0000096000 0000206f 00008b00 DPL=0 TSS64-busy
GDT=     fffffe0000094000 0000007f
IDT=     fffffe0000000000 00000fff
CR0=80050033 CR2=0000000000000000 CR3=00000010ca40a001 CR4=003606e0
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 
DR3=0000000000000000
DR6=00000000fffe0ff0 DR7=0000000000000400
EFER=0000000000000d01
Code=0f 1f ... ...

Print the cpu->cpu_index in cpu_dump_state() and remove it from the caller.

Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 hw/core/cpu-common.c      | 1 +
 monitor/hmp-cmds-target.c | 2 --
 softmmu/cpus.c            | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 5ccc3837b6..d2503f2d09 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -105,6 +105,7 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags)
 
     if (cc->dump_state) {
         cpu_synchronize_state(cpu);
+        qemu_fprintf(f, "\nCPU#%d\n", cpu->cpu_index);
         cc->dump_state(cpu, f, flags);
     }
 }
diff --git a/monitor/hmp-cmds-target.c b/monitor/hmp-cmds-target.c
index 0d3e84d960..f7dd354d2a 100644
--- a/monitor/hmp-cmds-target.c
+++ b/monitor/hmp-cmds-target.c
@@ -99,7 +99,6 @@ void hmp_info_registers(Monitor *mon, const QDict *qdict)
 
     if (all_cpus) {
         CPU_FOREACH(cs) {
-            monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
             cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
         }
     } else {
@@ -114,7 +113,6 @@ void hmp_info_registers(Monitor *mon, const QDict *qdict)
             return;
         }
 
-        monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
         cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
     }
 }
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 9cbc8172b5..f69bbe6abc 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -122,7 +122,6 @@ void hw_error(const char *fmt, ...)
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
     CPU_FOREACH(cpu) {
-        fprintf(stderr, "CPU #%d:\n", cpu->cpu_index);
         cpu_dump_state(cpu, stderr, CPU_DUMP_FPU);
     }
     va_end(ap);
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]