From nobody Sat May 4 19:21:32 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 1501049014340433.20100852600297; Tue, 25 Jul 2017 23:03:34 -0700 (PDT) Received: from localhost ([::1]:36258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daFPw-0007Eq-JM for importer@patchew.org; Wed, 26 Jul 2017 02:03:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daFOI-0006QV-TM for qemu-devel@nongnu.org; Wed, 26 Jul 2017 02:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daFOG-0006CR-4c for qemu-devel@nongnu.org; Wed, 26 Jul 2017 02:01:50 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:56031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daFOF-0006B7-Gd for qemu-devel@nongnu.org; Wed, 26 Jul 2017 02:01:48 -0400 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 26 Jul 2017 06:00:14 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v6Q61RNv052145; Wed, 26 Jul 2017 14:01:27 +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 2017072614013083-17882 ; Wed, 26 Jul 2017 14:01:30 +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,20170726140014 From: Yi Wang To: dgilbert@redhat.com, armbru@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com, qemu-devel@nongnu.org Date: Wed, 26 Jul 2017 02:18:36 -0400 Message-Id: <1501049917-4701-2-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501049917-4701-1-git-send-email-wang.yi59@zte.com.cn> References: <1501049917-4701-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-26 14:01:30, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-26 14:01:19, Serialize complete at 2017-07-26 14:01:19 X-MAIL: mse01.zte.com.cn v6Q61RNv052145 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 202.103.147.172 Subject: [Qemu-devel] [PATCH v2 1/2] 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 --- target/i386/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/i386/helper.c b/target/i386/helper.c index f63eb3d..a52f300 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -416,6 +416,14 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf= _function cpu_fprintf, int eflags, i, nb; char cc_op_name[32]; static const char *seg_name[6] =3D { "ES", "CS", "SS", "DS", "FS", "GS= " }; + 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); =20 eflags =3D cpu_compute_eflags(env); #ifdef TARGET_X86_64 --=20 1.8.3.1 From nobody Sat May 4 19:21:32 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 1501049018323403.48887748851905; Tue, 25 Jul 2017 23:03:38 -0700 (PDT) Received: from localhost ([::1]:36259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daFPy-0007G8-Dc for importer@patchew.org; Wed, 26 Jul 2017 02:03:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daFOI-0006QU-TH for qemu-devel@nongnu.org; Wed, 26 Jul 2017 02:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daFOG-0006CM-3R for qemu-devel@nongnu.org; Wed, 26 Jul 2017 02:01:50 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:56040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daFOF-0006BR-G7 for qemu-devel@nongnu.org; Wed, 26 Jul 2017 02:01:48 -0400 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 26 Jul 2017 06:00:15 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v6Q61TUG052297; Wed, 26 Jul 2017 14:01:29 +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 2017072614013339-17887 ; Wed, 26 Jul 2017 14:01:33 +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,20170726140015 From: Yi Wang To: dgilbert@redhat.com, armbru@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com, qemu-devel@nongnu.org Date: Wed, 26 Jul 2017 02:18:37 -0400 Message-Id: <1501049917-4701-3-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501049917-4701-1-git-send-email-wang.yi59@zte.com.cn> References: <1501049917-4701-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-26 14:01:33, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-26 14:01:22, Serialize complete at 2017-07-26 14:01:22 X-MAIL: mse01.zte.com.cn v6Q61TUG052297 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 202.103.147.172 Subject: [Qemu-devel] [PATCH v2 2/2] 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 Signed-off-by: Eduardo Habkost Reviewed-by: Eduardo Habkost --- hmp-commands-info.hx | 7 ++++--- include/qom/cpu.h | 10 ++++++++++ qom/cpu.c | 11 ++++++++--- target/i386/monitor.c | 10 +++++++++- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index d9df238..4ab7fce 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -115,9 +115,10 @@ 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 which of current CPU)", + .cmd =3D hmp_info_local_apic, }, #endif diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 25eefea..b7ac949 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -755,6 +755,16 @@ CPUState *qemu_get_cpu(int index); bool cpu_exists(int64_t id); =20 /** + * cpu_by_arch_id: + * @id: Guest-exposed CPU ID of the CPU to obtain. + * + * Get a CPU with matching @id. + * + * Returns: The CPU or %NULL if there is no matching CPU. + */ +CPUState *cpu_by_arch_id(int64_t id); + +/** * cpu_throttle_set: * @new_throttle_pct: Percent of sleep time. Valid range is 1 to 99. * diff --git a/qom/cpu.c b/qom/cpu.c index 4f38db0..e6210d5 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -34,7 +34,7 @@ =20 CPUInterruptHandler cpu_interrupt_handler; =20 -bool cpu_exists(int64_t id) +CPUState *cpu_by_arch_id(int64_t id) { CPUState *cpu; =20 @@ -42,10 +42,15 @@ bool cpu_exists(int64_t id) CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 if (cc->get_arch_id(cpu) =3D=3D id) { - return true; + return cpu; } } - return false; + return NULL; +} + +bool cpu_exists(int64_t id) +{ + return !!cpu_by_arch_id(id); } =20 CPUState *cpu_generic_init(const char *typename, const char *cpu_model) diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 77ead60..fe7d57b 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -632,7 +632,15 @@ 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 cpu_by_arch_id(id); + } else { + cs =3D mon_get_cpu(); + } + =20 if (!cs) { monitor_printf(mon, "No CPU available\n"); --=20 1.8.3.1