From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmSX-0000jX-2O for qemu-devel@nongnu.org; Tue, 15 Sep 2015 05:23:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbmSV-0006F2-NL for qemu-devel@nongnu.org; Tue, 15 Sep 2015 05:23:29 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:44729 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmSV-0006Cn-2b for qemu-devel@nongnu.org; Tue, 15 Sep 2015 05:23:27 -0400 From: "Denis V. Lunev" Date: Tue, 15 Sep 2015 12:23:07 +0300 Message-Id: <1442308988-653-9-git-send-email-den@openvz.org> In-Reply-To: <1442308988-653-1-git-send-email-den@openvz.org> References: <1442308988-653-1-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 8/9] hmp: added io apic dump state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Denis V. Lunev" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Paolo Bonzini , qemu-devel@nongnu.org, Pavel Butsykin From: Pavel Butsykin Added the hmp command to query io apic state, may be usefull after guest crashes to understand IRQ routing in guest. Implementation is only for kvm here. The dump will look like (qemu) info apic-io ioapic ID=3D00 IRR=3D00000000 SEL=3D18 ioapic 00 00000000000100ff: int=3Dff delmod=3D0:Fixed P.H.EM dest=3D0 ioapic 01 0300000000000993: int=3D93 delmod=3D1:LowPri L.H.E. dest=3D3 ... ioapic 23 00000000000100ff: int=3Dff delmod=3D0:Fixed P.H.EM dest=3D0 Signed-off-by: Pavel Butsykin Signed-off-by: Denis V. Lunev CC: Andreas F=C3=A4rber CC: Paolo Bonzini --- hmp-commands-info.hx | 16 ++++++++++++++++ hw/i386/kvm/ioapic.c | 10 ++++++++++ hw/intc/ioapic_common.c | 31 +++++++++++++++++++++++++++++++ include/hw/i386/ioapic_internal.h | 2 ++ include/hw/i386/pc.h | 4 ++++ include/monitor/monitor-common.h | 1 + target-i386/monitor.c | 9 +++++++++ 7 files changed, 73 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 5ffc181..c65b7d2 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -128,6 +128,22 @@ STEXI Show local APIC state ETEXI =20 +#if defined(TARGET_I386) + { + .name =3D "apic-io", + .args_type =3D "", + .params =3D "", + .help =3D "show io apic state", + .mhandler.cmd =3D hmp_info_apic_io, + }, +#endif + +STEXI +@item info apic-io +@findex apic-io +Show io APIC state +ETEXI + { .name =3D "cpus", .args_type =3D "", diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index d2a6c4c..b7390ca 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -10,6 +10,7 @@ * See the COPYING file in the top-level directory. */ =20 +#include "monitor/monitor.h" #include "hw/i386/pc.h" #include "hw/i386/ioapic_internal.h" #include "hw/i386/apic_internal.h" @@ -110,6 +111,15 @@ static void kvm_ioapic_put(IOAPICCommonState *s) } } =20 +void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict) +{ + IOAPICCommonState s; + + kvm_ioapic_get(&s); + + ioapic_print_redtbl(mon, &s); +} + static void kvm_ioapic_reset(DeviceState *dev) { IOAPICCommonState *s =3D IOAPIC_COMMON(dev); diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index 8b7d118..83edf69 100644 --- a/hw/intc/ioapic_common.c +++ b/hw/intc/ioapic_common.c @@ -19,6 +19,7 @@ * License along with this library; if not, see . */ =20 +#include "monitor/monitor.h" #include "hw/i386/ioapic.h" #include "hw/i386/ioapic_internal.h" #include "hw/sysbus.h" @@ -31,6 +32,36 @@ */ int ioapic_no; =20 +void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s) +{ + static const char *delm_str[] =3D { + "Fixed", "LowPri", "SMI", "...", "NMI", "INIT", "...", "ExtINT"}= ; + int i; + + monitor_printf(mon, "ioapic ID=3D%02x IRR=3D%08x SEL=3D%02x\n", + s->id, s->irr, s->ioregsel); + + for (i =3D 0; i < IOAPIC_NUM_PINS; i++) { + uint64_t entry =3D s->ioredtbl[i]; + uint32_t delm =3D (uint32_t)((entry & IOAPIC_LVT_DELIV_MODE) >> + IOAPIC_LVT_DELIV_MODE_SHIFT); + monitor_printf(mon, "ioapic %02u %016jx: int=3D%02jx " + "delmod=3D%x:%-6s %c%c%c%c%c%c dest=3D%jx\n", + i, entry, + entry & IOAPIC_VECTOR_MASK, + delm, + delm_str[delm], + entry & IOAPIC_LVT_DEST_MODE ? 'L' : 'P', + entry & IOAPIC_LVT_DELIV_STATUS ? 'P' : '.', + entry & IOAPIC_LVT_POLARITY ? 'L' : 'H', + entry & IOAPIC_LVT_REMOTE_IRR ? 'R' : '.', + entry & IOAPIC_LVT_TRIGGER_MODE ? 'L' : 'E', + entry & IOAPIC_LVT_MASKED ? 'M' : '.', + (entry >> IOAPIC_LVT_DEST_SHIFT) & + (entry & IOAPIC_LVT_DEST_MODE ? 0xff : 0xf))= ; + } +} + void ioapic_reset_common(DeviceState *dev) { IOAPICCommonState *s =3D IOAPIC_COMMON(dev); diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_i= nternal.h index 4f7764e..797ed47 100644 --- a/include/hw/i386/ioapic_internal.h +++ b/include/hw/i386/ioapic_internal.h @@ -105,4 +105,6 @@ struct IOAPICCommonState { =20 void ioapic_reset_common(DeviceState *dev); =20 +void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s); + #endif /* !QEMU_IOAPIC_INTERNAL_H */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 3e002c9..539cf64 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -123,6 +123,10 @@ int pic_get_output(DeviceState *d); void hmp_info_pic(Monitor *mon, const QDict *qdict); void hmp_info_irq(Monitor *mon, const QDict *qdict); =20 +/* ioapic.c */ + +void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict); + /* Global System Interrupts */ =20 #define GSI_NUM_PINS IOAPIC_NUM_PINS diff --git a/include/monitor/monitor-common.h b/include/monitor/monitor-c= ommon.h index 462c35e..71f224b 100644 --- a/include/monitor/monitor-common.h +++ b/include/monitor/monitor-common.h @@ -43,5 +43,6 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict); void hmp_info_tlb(Monitor *mon, const QDict *qdict); void hmp_mce(Monitor *mon, const QDict *qdict); void hmp_info_apic_local(Monitor *mon, const QDict *qdict); +void hmp_info_apic_io(Monitor *mon, const QDict *qdict); =20 #endif /* MONITOR_COMMON */ diff --git a/target-i386/monitor.c b/target-i386/monitor.c index fbc9fcd..797ea2d 100644 --- a/target-i386/monitor.c +++ b/target-i386/monitor.c @@ -24,6 +24,8 @@ #include "cpu.h" #include "monitor/monitor.h" #include "monitor/monitor-common.h" +#include "hw/i386/pc.h" +#include "sysemu/kvm.h" #include "hmp.h" =20 =20 @@ -498,3 +500,10 @@ void hmp_info_apic_local(Monitor *mon, const QDict *= qdict) x86_cpu_dump_apic_local_state(mon_get_cpu(), (FILE *)mon, monitor_fp= rintf, CPU_DUMP_FPU); } + +void hmp_info_apic_io(Monitor *mon, const QDict *qdict) +{ + if (kvm_irqchip_in_kernel()) { + kvm_ioapic_dump_state(mon, qdict); + } +} --=20 2.1.4