From patchwork Tue Sep 22 15:05:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 521120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DC4781401DE for ; Wed, 23 Sep 2015 01:15:49 +1000 (AEST) Received: from localhost ([::1]:40668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePIJ-0000Ko-RT for incoming@patchwork.ozlabs.org; Tue, 22 Sep 2015 11:15:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePA9-0001zK-Ng for qemu-devel@nongnu.org; Tue, 22 Sep 2015 11:07:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePA7-00017N-Uo for qemu-devel@nongnu.org; Tue, 22 Sep 2015 11:07:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePA7-00017D-Ly for qemu-devel@nongnu.org; Tue, 22 Sep 2015 11:07:19 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 48FC5C0B9182; Tue, 22 Sep 2015 15:07:19 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MF6IoV027175; Tue, 22 Sep 2015 11:07:17 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 17:05:49 +0200 Message-Id: <1442934371-12567-27-git-send-email-pbonzini@redhat.com> In-Reply-To: <1442934371-12567-1-git-send-email-pbonzini@redhat.com> References: <1442934371-12567-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: "Denis V. Lunev" , =?UTF-8?q?Andreas=20F=C3=83=C2=A4rber?= , Pavel Butsykin Subject: [Qemu-devel] [PULL 26/48] hmp: added io apic dump state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 ioapic ioapic id=0x00 sel=0x26 (redir[11]) pin 0 0x0000000000010000 dest=0 vec=0 active-hi edge masked fixed physical pin 1 0x0000000000000031 dest=0 vec=49 active-hi edge fixed physical ... pin 23 0x0000000000010000 dest=0 vec=0 active-hi edge masked fixed physical IRR (none) Remote IRR (none) Signed-off-by: Pavel Butsykin Signed-off-by: Denis V. Lunev CC: Paolo Bonzini CC: Andreas Färber Message-Id: <1442927901-1084-9-git-send-email-den@openvz.org> Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 16 ++++++++++++ hw/i386/kvm/ioapic.c | 10 +++++++ hw/intc/ioapic_common.c | 55 +++++++++++++++++++++++++++++++++++++++ include/hw/i386/ioapic_internal.h | 2 ++ include/hw/i386/pc.h | 4 +++ include/monitor/hmp-target.h | 1 + target-i386/monitor.c | 9 +++++++ 7 files changed, 97 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index dba7839..b346fd1 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -128,6 +128,22 @@ STEXI Show local APIC state ETEXI +#if defined(TARGET_I386) + { + .name = "ioapic", + .args_type = "", + .params = "", + .help = "show io apic state", + .mhandler.cmd = hmp_info_io_apic, + }, +#endif + +STEXI +@item info ioapic +@findex ioapic +Show io APIC state +ETEXI + { .name = "cpus", .args_type = "", 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. */ +#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) } } +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 = IOAPIC_COMMON(dev); diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index 8b7d118..d78181e 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 . */ +#include "monitor/monitor.h" #include "hw/i386/ioapic.h" #include "hw/i386/ioapic_internal.h" #include "hw/sysbus.h" @@ -31,6 +32,60 @@ */ int ioapic_no; +static void ioapic_irr_dump(Monitor *mon, const char *name, uint32_t bitmap) +{ + int i; + + monitor_printf(mon, "%-10s ", name); + if (bitmap == 0) { + monitor_printf(mon, "(none)\n"); + return; + } + for (i = 0; i < IOAPIC_NUM_PINS; i++) { + if (bitmap & (1 << i)) { + monitor_printf(mon, "%-2u ", i); + } + } + monitor_printf(mon, "\n"); +} + +void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s) +{ + static const char *delm_str[] = { + "fixed", "lowest", "SMI", "...", "NMI", "INIT", "...", "extINT"}; + uint32_t remote_irr = 0; + int i; + + monitor_printf(mon, "ioapic id=0x%02x sel=0x%02x", s->id, s->ioregsel); + if (s->ioregsel) { + monitor_printf(mon, " (redir[%u])\n", + (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1); + } else { + monitor_printf(mon, "\n"); + } + for (i = 0; i < IOAPIC_NUM_PINS; i++) { + uint64_t entry = s->ioredtbl[i]; + uint32_t delm = (uint32_t)((entry & IOAPIC_LVT_DELIV_MODE) >> + IOAPIC_LVT_DELIV_MODE_SHIFT); + monitor_printf(mon, "pin %-2u 0x%016jx dest=%jx vec=%-3lu " + "%s %-5s %-6s %-6s %s\n", + i, entry, + (entry >> IOAPIC_LVT_DEST_SHIFT) & + (entry & IOAPIC_LVT_DEST_MODE ? 0xff : 0xf), + entry & IOAPIC_VECTOR_MASK, + entry & IOAPIC_LVT_POLARITY ? "active-lo" : "active-hi", + entry & IOAPIC_LVT_TRIGGER_MODE ? "level" : "edge", + entry & IOAPIC_LVT_MASKED ? "masked" : "", + delm_str[delm], + entry & IOAPIC_LVT_DEST_MODE ? "logical" : "physical"); + + remote_irr |= entry & IOAPIC_LVT_TRIGGER_MODE ? + (entry & IOAPIC_LVT_REMOTE_IRR ? (1 << i) : 0) : 0; + } + ioapic_irr_dump(mon, "IRR", s->irr); + ioapic_irr_dump(mon, "Remote IRR", remote_irr); +} + void ioapic_reset_common(DeviceState *dev) { IOAPICCommonState *s = IOAPIC_COMMON(dev); diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_internal.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 { void ioapic_reset_common(DeviceState *dev); +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); +/* ioapic.c */ + +void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict); + /* Global System Interrupts */ #define GSI_NUM_PINS IOAPIC_NUM_PINS diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h index be50577..213566c 100644 --- a/include/monitor/hmp-target.h +++ b/include/monitor/hmp-target.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_local_apic(Monitor *mon, const QDict *qdict); +void hmp_info_io_apic(Monitor *mon, const QDict *qdict); #endif /* MONITOR_COMMON */ diff --git a/target-i386/monitor.c b/target-i386/monitor.c index 9479a77..829fff9 100644 --- a/target-i386/monitor.c +++ b/target-i386/monitor.c @@ -24,6 +24,8 @@ #include "cpu.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h" +#include "hw/i386/pc.h" +#include "sysemu/kvm.h" #include "hmp.h" @@ -498,3 +500,10 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict) x86_cpu_dump_local_apic_state(mon_get_cpu(), (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); } + +void hmp_info_io_apic(Monitor *mon, const QDict *qdict) +{ + if (kvm_irqchip_in_kernel()) { + kvm_ioapic_dump_state(mon, qdict); + } +}