qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/2] [PATCH] hmp: allow apic-id for "info lapic"


From: Yi Wang
Subject: [Qemu-devel] [PATCH 2/2] [PATCH] hmp: allow apic-id for "info lapic"
Date: Fri, 21 Jul 2017 03:38:56 -0400

Add [apic-id] support for hmp command "info lapic", which is
useful when debugging ipi and so on. Current behavior is not
changed when the parameter isn't specified.

Signed-off-by: Yi Wang <address@hidden>
Signed-off-by: Yun Liu <address@hidden>
---
 hmp-commands-info.hx  |  6 +++---
 target/i386/cpu.h     | 10 ++++++++++
 target/i386/helper.c  | 16 ++++++++++++++++
 target/i386/monitor.c |  9 ++++++++-
 4 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index d9df238..00623df 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -115,9 +115,9 @@ ETEXI
 #if defined(TARGET_I386)
     {
         .name       = "lapic",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show local apic state",
+        .args_type  = "apic-id:i?",
+        .params     = "[apic-id]",
+        .help       = "show local apic state (apic-id: local apic to read, 
default is 0)",
         .cmd        = hmp_info_local_apic,
     },
 #endif
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 31ad681..4da2ca2 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1712,6 +1712,16 @@ void enable_compat_apic_id_mode(void);
 #define APIC_DEFAULT_ADDRESS 0xfee00000
 #define APIC_SPACE_SIZE      0x100000
 
+/**
+ * x86_get_cpu_by_apic:
+ * @id: The apic-id of the specified CPU to obtain.
+ *
+ * Gets a CPU on which @id given of apic.
+ *
+ * Returns: The CPU or %NULL if there is no matching CPU.
+ */
+CPUState *x86_get_cpu_by_apic(int id);
+
 void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
                                    fprintf_function cpu_fprintf, int flags);
 
diff --git a/target/i386/helper.c b/target/i386/helper.c
index fd4f1af..6972833 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -398,6 +398,22 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
     }
     cpu_fprintf(f, " PPR 0x%02x\n", apic_get_ppr(s));
 }
+
+CPUState *x86_get_cpu_by_apic(int id)
+{
+    CPUState *cs;
+
+    CPU_FOREACH(cs) {
+        X86CPU *cpu = X86_CPU(cs);
+        APICCommonState *s = APIC_COMMON(cpu->apic_state);
+        if (id == s->id) {
+            return cs;
+        }
+    }
+
+    return NULL;
+}
+
 #else
 void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
                                    fprintf_function cpu_fprintf, int flags)
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 77ead60..e911a57 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -632,7 +632,14 @@ const MonitorDef *target_monitor_defs(void)
 
 void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 {
-    CPUState *cs = mon_get_cpu();
+    CPUState *cs;
+
+    if (qdict_haskey(qdict, "apic-id")) {
+        int id = qdict_get_try_int(qdict, "apic-id", 0);
+        cs = x86_get_cpu_by_apic(id);
+    } else {
+        cs = mon_get_cpu();
+    }
 
     if (!cs) {
         monitor_printf(mon, "No CPU available\n");
-- 
1.8.3.1





reply via email to

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