@@ -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
@@ -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);
@@ -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)
@@ -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");