From patchwork Thu Aug 7 12:44:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 35047 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8335921137 for ; Thu, 7 Aug 2014 14:40:05 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wn1sf16273685obc.2 for ; Thu, 07 Aug 2014 07:40:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:in-reply-to:message-id :references:user-agent:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type; bh=4uMUC1TZ1bO1RRiwP1Q5BJzrYS/OHy72EbpwKpKr2IQ=; b=JN8Uj33ucrpDEmZ8rvpozeaQNORPe0SNcn6/2qHJDa84OXgA+pYSgnoL8nY66gM81T /ROcOb9gQ1IHnLGNfgCeaFvw5nLz9w/xmRO/8e51FsHgChdPfO2pVCkQ/DN2iCHVMblo 8rGgfZdO7D60kevgPjJxjBjqjtriNsZmtcAHzAN4f5S/e+GWHOZUyFOUQ+l85EprHynj gPw7gK2wpe5xcV3jE2UY1xEBZJteLuHyD3UjGntKNfqHV210xTzPCpuB+YpsTgOP+owN 0pUBDHe3zF4o3Q0vgoF0yUZVscqNlDVU+vO9lZ3l6hSN+XRmiVD2dRxSVQvyRZgN6NfE dOIA== X-Gm-Message-State: ALoCoQndh3OTSwzdvQ4fBABd7GniSVgvdF2PNgdyWNXqtgkmXVIG6o+BWQ6W08fFska3El0cooaP X-Received: by 10.50.73.168 with SMTP id m8mr19771397igv.7.1407422405011; Thu, 07 Aug 2014 07:40:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.202 with SMTP id w68ls157840qge.4.gmail; Thu, 07 Aug 2014 07:40:04 -0700 (PDT) X-Received: by 10.220.172.8 with SMTP id j8mr16689964vcz.32.1407422404895; Thu, 07 Aug 2014 07:40:04 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id uh4si1849289vcb.27.2014.08.07.07.40.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Aug 2014 07:40:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so6265574vcb.25 for ; Thu, 07 Aug 2014 07:40:04 -0700 (PDT) X-Received: by 10.52.5.201 with SMTP id u9mr500447vdu.85.1407422404796; Thu, 07 Aug 2014 07:40:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp35610vcb; Thu, 7 Aug 2014 07:40:04 -0700 (PDT) X-Received: by 10.50.79.232 with SMTP id m8mr6486370igx.0.1407422404170; Thu, 07 Aug 2014 07:40:04 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id h1si10970577icz.77.2014.08.07.07.40.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Aug 2014 07:40:04 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XFN4X-0000XS-EC; Thu, 07 Aug 2014 12:45:33 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XFN4W-0000XN-4N for xen-devel@lists.xenproject.org; Thu, 07 Aug 2014 12:45:32 +0000 Received: from [193.109.254.147:35269] by server-12.bemta-14.messagelabs.com id 4F/52-23840-BE473E35; Thu, 07 Aug 2014 12:45:31 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1407415529!14329211!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5584 invoked from network); 7 Aug 2014 12:45:30 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-12.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 7 Aug 2014 12:45:30 -0000 X-IronPort-AV: E=Sophos;i="5.01,818,1400025600"; d="scan'208";a="160262635" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Thu, 7 Aug 2014 08:45:28 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XFN4S-0002PU-66; Thu, 07 Aug 2014 13:45:28 +0100 Date: Thu, 7 Aug 2014 13:44:15 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: manish jaggi In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-DLP: MIA2 Cc: xen-devel@lists.xenproject.org, manish.jaggi@caviumnetworks.com, stefano.stabellini@citrix.com, Vijay Kilari Subject: Re: [Xen-devel] How to display dom0 kernel printk on hvc0 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: On Thu, 7 Aug 2014, manish jaggi wrote: > Hi Stefano, > > I am debugging a kernel crash when I start xencommons. If I add prints in kernel the prints are only visible in > dmesg and not on dom0 console. This makes it difficult to view kernel printks at the time of crash. > > I tried xen_raw_printks but the print only comes when you press a key, so while a crash is happening you cannot > press a key. > > Is there a way to enable printks on hvc0  > OR > is there a way to dump __logbuf of linux from xen shell. You can hack printk and/or early_printk so that everything will go via the Xen console, see below. Of course this is very hacky, don't tell anybody that I wrote this patch ;-) diff --git a/arch/arm64/kernel/early_printk.c b/arch/arm64/kernel/early_printk.c index 2dc36d0..38bcf29 100644 --- a/arch/arm64/kernel/early_printk.c +++ b/arch/arm64/kernel/early_printk.c @@ -31,16 +31,16 @@ static void __iomem *early_base; static void (*printch)(char ch); +void xen_raw_console_write(const char *str); /* * PL011 single character TX. */ static void pl011_printch(char ch) { - while (readl_relaxed(early_base + UART01x_FR) & UART01x_FR_TXFF) - ; - writeb_relaxed(ch, early_base + UART01x_DR); - while (readl_relaxed(early_base + UART01x_FR) & UART01x_FR_BUSY) - ; + char buf[2]; + buf[0] = ch; + buf[1] = '\0'; + xen_raw_console_write(buf); } /* diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 2dc2831..1f586b3 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -630,7 +630,7 @@ void xen_raw_console_write(const char *str) ssize_t len = strlen(str); int rc = 0; - if (xen_domain()) { + if (1||xen_domain()) { rc = dom0_write_console(0, str, len); #ifdef CONFIG_X86 if (rc == -ENOSYS && xen_hvm_domain()) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7228258..e035871 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1674,24 +1674,18 @@ EXPORT_SYMBOL(printk_emit); * * See the vsnprintf() documentation for format string extensions over C99. */ +void xen_raw_console_write(const char *str); asmlinkage __visible int printk(const char *fmt, ...) { va_list args; - int r; + static char buf[512]; -#ifdef CONFIG_KGDB_KDB - if (unlikely(kdb_trap_printk)) { - va_start(args, fmt); - r = vkdb_printf(fmt, args); - va_end(args); - return r; - } -#endif va_start(args, fmt); - r = vprintk_emit(0, -1, NULL, 0, fmt, args); + vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); - return r; + xen_raw_console_write(buf); + return 1; } EXPORT_SYMBOL(printk);