From patchwork Mon Jun 29 19:25:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 489387 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 ACD7014076E for ; Tue, 30 Jun 2015 05:32:58 +1000 (AEST) Received: from localhost ([::1]:43700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9enY-0006gT-ML for incoming@patchwork.ozlabs.org; Mon, 29 Jun 2015 15:32:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9enD-0006Db-NP for qemu-devel@nongnu.org; Mon, 29 Jun 2015 15:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9enA-0007as-D3 for qemu-devel@nongnu.org; Mon, 29 Jun 2015 15:32:35 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:39431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9egG-0004if-0N for qemu-devel@nongnu.org; Mon, 29 Jun 2015 15:25:24 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t5TJPI00011119 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 29 Jun 2015 19:25:18 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t5TJPHVS032588 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 29 Jun 2015 19:25:17 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t5TJPHYI014506; Mon, 29 Jun 2015 19:25:17 GMT Received: from l.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Jun 2015 12:25:17 -0700 Received: by l.oracle.com (Postfix, from userid 1000) id 942A96A0270; Mon, 29 Jun 2015 15:25:15 -0400 (EDT) From: Konrad Rzeszutek Wilk To: stefano.stabellini@eu.citrix.com, xen-devel@lists.xenproject.org, qemu-devel@nongnu.org Date: Mon, 29 Jun 2015 15:25:13 -0400 Message-Id: <1435605913-23826-7-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1435605913-23826-1-git-send-email-konrad.wilk@oracle.com> References: <1435605913-23826-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 Cc: Konrad Rzeszutek Wilk Subject: [Qemu-devel] [PATCH RFC 6/6] xen: Add backtrace for serious issues. 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 When debugging issues that caused the emulator to kill itself or skipping certain operations (unable to write to host registers) an stack trace will most definitly aid in debugging the problem. As such this patch uses the most basic backtrace to print out details. Signed-off-by: Konrad Rzeszutek Wilk --- hw/xen/xen_pt.c | 3 +++ include/hw/xen/xen_common.h | 1 + xen-hvm.c | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index ea1ceda..1d256b9 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -407,6 +407,7 @@ out: if (rc < 0) { XEN_PT_ERR(d, "xen_host_pci_set_block failed. return value: %d.\n", rc); + xen_dump_stack(); } } } @@ -421,6 +422,7 @@ static uint64_t xen_pt_bar_read(void *o, hwaddr addr, * misconfiguration of the IOMMU. */ XEN_PT_ERR(d, "Should not read BAR through QEMU. @0x"TARGET_FMT_plx"\n", addr); + xen_dump_stack(); return 0; } static void xen_pt_bar_write(void *o, hwaddr addr, uint64_t val, @@ -430,6 +432,7 @@ static void xen_pt_bar_write(void *o, hwaddr addr, uint64_t val, /* Same comment as xen_pt_bar_read function */ XEN_PT_ERR(d, "Should not write BAR through QEMU. @0x"TARGET_FMT_plx"\n", addr); + xen_dump_stack(); } static const MemoryRegionOps ops = { diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 38f29fb..3983cfb 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -165,6 +165,7 @@ void destroy_hvm_domain(bool reboot); /* shutdown/destroy current domain because of an error */ void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void xen_dump_stack(void); #ifdef HVM_PARAM_VMPORT_REGS_PFN static inline int xen_get_vmport_regs_pfn(XenXC xc, domid_t dom, diff --git a/xen-hvm.c b/xen-hvm.c index a92bc14..8bf4a57 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -10,6 +10,7 @@ #include +#include #include "hw/pci/pci.h" #include "hw/i386/pc.h" #include "hw/xen/xen_common.h" @@ -1328,6 +1329,20 @@ void xen_register_framebuffer(MemoryRegion *mr) framebuffer = mr; } +void xen_dump_stack(void) +{ + int nptrs; +#define SIZE 1024 + void *buffer[SIZE]; + + nptrs = backtrace(buffer, SIZE); + if (!nptrs) + return; + + backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO); +#undef SIZE +} + void xen_shutdown_fatal_error(const char *fmt, ...) { va_list ap; @@ -1335,6 +1350,7 @@ void xen_shutdown_fatal_error(const char *fmt, ...) va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); + xen_dump_stack(); fprintf(stderr, "Will destroy the domain.\n"); /* destroy the domain */ qemu_system_shutdown_request();