From nobody Wed May 1 23:07:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500621782119249.4110381829163; Fri, 21 Jul 2017 00:23:02 -0700 (PDT) Received: from localhost ([::1]:41506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYSH6-0005yi-Hv for importer@patchew.org; Fri, 21 Jul 2017 03:23:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYSFl-0005F9-7e for qemu-devel@nongnu.org; Fri, 21 Jul 2017 03:21:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYSFg-0001cB-Cw for qemu-devel@nongnu.org; Fri, 21 Jul 2017 03:21:37 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:55582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYSFf-0001b8-My for qemu-devel@nongnu.org; Fri, 21 Jul 2017 03:21:32 -0400 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 21 Jul 2017 07:11:06 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v6L7LGjs014856; Fri, 21 Jul 2017 15:21:16 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017072115212285-4479990 ; Fri, 21 Jul 2017 15:21:22 +0800 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170721151106 From: Yi Wang To: dgilbert@redhat.com, armbru@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, qemu-devel@nongnu.org Date: Fri, 21 Jul 2017 03:38:55 -0400 Message-Id: <1500622736-20865-2-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1500622736-20865-1-git-send-email-wang.yi59@zte.com.cn> References: <1500622736-20865-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-21 15:21:22, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-21 15:21:01, Serialize complete at 2017-07-21 15:21:01 X-MAIL: mse01.zte.com.cn v6L7LGjs014856 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 63.217.80.70 Subject: [Qemu-devel] [PATCH 1/2] [PATCH] hmp: dump ids including socket-id, core-id and so on for 'info registers' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wang.yi59@zte.com.cn, liu.yunh@zte.com.cn, Liu.Jianjun3@zte.com.cn Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch add output of CPUs' socket-id, core-id, thread-id and apic-id for 'info registers', which can be used for querying other hmp commands. Signed-off-by: Yi Wang Signed-off-by: Yun Liu --- include/qom/cpu.h | 12 ++++++++++++ monitor.c | 1 + qom/cpu.c | 10 ++++++++++ target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/helper.c | 13 +++++++++++++ 6 files changed, 38 insertions(+) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 25eefea..4717bd7 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -92,6 +92,7 @@ struct TranslationBlock; * CPUs can use the default implementation of this method. This method sho= uld * not be used by any callers other than the pre-1.0 virtio devices. * @memory_rw_debug: Callback for GDB memory access. + * @dump_ids: Callback for dumping ids. * @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID. @@ -156,6 +157,7 @@ typedef struct CPUClass { bool (*virtio_is_big_endian)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); + void (*dump_ids)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf); void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprint= f, int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu); @@ -518,6 +520,16 @@ enum CPUDumpFlags { }; =20 /** + * cpu_dump_ids: + * @cpu: The CPU whose state is to be dumped. + * @f: File to dump to. + * @cpu_fprintf: Function to dump with. + * + * Dumps CPU socket-id, core-id, thread-id and apic-id. + */ +void cpu_dump_ids(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf); + +/** * cpu_dump_state: * @cpu: The CPU whose state is to be dumped. * @f: File to dump to. diff --git a/monitor.c b/monitor.c index 6d040e6..30f898c 100644 --- a/monitor.c +++ b/monitor.c @@ -1085,6 +1085,7 @@ static void hmp_info_registers(Monitor *mon, const QD= ict *qdict) if (all_cpus) { CPU_FOREACH(cs) { monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); + cpu_dump_ids(cs, (FILE *)mon, monitor_fprintf); cpu_dump_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); } } else { diff --git a/qom/cpu.c b/qom/cpu.c index 4f38db0..a9df661 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -242,6 +242,16 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cp= u) return res; } =20 +void cpu_dump_ids(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->dump_ids) { + cpu_synchronize_state(cpu); + cc->dump_ids(cpu, f, cpu_fprintf); + } +} + void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags) { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0bbda76..0aa488f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4120,6 +4120,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) cc->do_interrupt =3D x86_cpu_do_interrupt; cc->cpu_exec_interrupt =3D x86_cpu_exec_interrupt; #endif + cc->dump_ids =3D x86_cpu_dump_ids; cc->dump_state =3D x86_cpu_dump_state; cc->get_crash_info =3D x86_cpu_get_crash_info; cc->set_pc =3D x86_cpu_set_pc; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0518673..31ad681 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1316,6 +1316,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunctio= n f, CPUState *cpu, void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, Error **errp); =20 +void x86_cpu_dump_ids(CPUState *cs, FILE *f, fprintf_function cpu_fprintf); void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, int flags); =20 diff --git a/target/i386/helper.c b/target/i386/helper.c index f63eb3d..fd4f1af 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -408,6 +408,19 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, FILE = *f, #define DUMP_CODE_BYTES_TOTAL 50 #define DUMP_CODE_BYTES_BACKWARD 20 =20 +void x86_cpu_dump_ids(CPUState *cs, FILE *f, fprintf_function cpu_fprintf) +{ + X86CPU *cpu =3D X86_CPU(cs); + APICCommonState *s =3D APIC_COMMON(cpu->apic_state); + if (!s) { + cpu_fprintf(f, "local apic state not available\n"); + return; + } + + cpu_fprintf(f, "(socket-id:%d core-id:%d thread-id:%d apic-id:%d)\n", + cpu->socket_id, cpu->core_id, cpu->thread_id, s->id); +} + void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, int flags) { --=20 1.8.3.1 From nobody Wed May 1 23:07:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500621808932985.2957676925241; Fri, 21 Jul 2017 00:23:28 -0700 (PDT) Received: from localhost ([::1]:41508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYSHX-0006KZ-6Z for importer@patchew.org; Fri, 21 Jul 2017 03:23:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYSG6-0005TV-P1 for qemu-devel@nongnu.org; Fri, 21 Jul 2017 03:21:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYSG2-0001nb-15 for qemu-devel@nongnu.org; Fri, 21 Jul 2017 03:21:58 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:55662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYSG1-0001mO-Bx for qemu-devel@nongnu.org; Fri, 21 Jul 2017 03:21:53 -0400 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 21 Jul 2017 07:11:27 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v6L7LatT015596; Fri, 21 Jul 2017 15:21:36 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017072115214252-4480149 ; Fri, 21 Jul 2017 15:21:42 +0800 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170721151127 From: Yi Wang To: dgilbert@redhat.com, armbru@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, qemu-devel@nongnu.org Date: Fri, 21 Jul 2017 03:38:56 -0400 Message-Id: <1500622736-20865-3-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1500622736-20865-1-git-send-email-wang.yi59@zte.com.cn> References: <1500622736-20865-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-21 15:21:42, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-21 15:21:20, Serialize complete at 2017-07-21 15:21:20 X-MAIL: mse01.zte.com.cn v6L7LatT015596 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 63.217.80.70 Subject: [Qemu-devel] [PATCH 2/2] [PATCH] hmp: allow apic-id for "info lapic" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wang.yi59@zte.com.cn, liu.yunh@zte.com.cn, Liu.Jianjun3@zte.com.cn Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Yun Liu --- 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 =3D "lapic", - .args_type =3D "", - .params =3D "", - .help =3D "show local apic state", + .args_type =3D "apic-id:i?", + .params =3D "[apic-id]", + .help =3D "show local apic state (apic-id: local apic to rea= d, default is 0)", .cmd =3D 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 =20 +/** + * 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= ); =20 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 =3D X86_CPU(cs); + APICCommonState *s =3D APIC_COMMON(cpu->apic_state); + if (id =3D=3D 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) =20 void hmp_info_local_apic(Monitor *mon, const QDict *qdict) { - CPUState *cs =3D mon_get_cpu(); + CPUState *cs; + + if (qdict_haskey(qdict, "apic-id")) { + int id =3D qdict_get_try_int(qdict, "apic-id", 0); + cs =3D x86_get_cpu_by_apic(id); + } else { + cs =3D mon_get_cpu(); + } =20 if (!cs) { monitor_printf(mon, "No CPU available\n"); --=20 1.8.3.1