From patchwork Wed Feb 24 12:23:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 8405831 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 155129F52D for ; Wed, 24 Feb 2016 12:26:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2628B2035D for ; Wed, 24 Feb 2016 12:26:10 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F105B2034C for ; Wed, 24 Feb 2016 12:26:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYYTv-0006T9-SJ; Wed, 24 Feb 2016 12:23:51 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYYTu-0006SJ-IL for xen-devel@lists.xensource.com; Wed, 24 Feb 2016 12:23:50 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id FB/CF-03109-5D0ADC65; Wed, 24 Feb 2016 12:23:49 +0000 X-Env-Sender: prvs=8552d504b=Stefano.Stabellini@citrix.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1456316626!24163005!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30856 invoked from network); 24 Feb 2016 12:23:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2016 12:23:48 -0000 X-IronPort-AV: E=Sophos;i="5.22,493,1449532800"; d="scan'208";a="340691252" From: Stefano Stabellini To: Date: Wed, 24 Feb 2016 12:23:09 +0000 Message-ID: <1456316590-20020-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: boris.ostrovsky@oracle.com, david.vrabel@citrix.com, linux-kernel@vger.kernel.org, Stefano Stabellini Subject: [Xen-devel] [PATCH 1/2] hvc_xen: add earlycon support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce EARLYCON support in hvc_xen, useful for early debugging on arm and arm64, where xen early_printk is not available. Differently from xenboot_write_console on x86, we won't just return if !xen_pv_domain(), because arm and arm64 guests are actually xen_hvm_domain() from linux pov, and also because we want to capture all possible writes, including the ones earlier than xen_early_init(). Signed-off-by: Stefano Stabellini --- drivers/tty/hvc/hvc_xen.c | 48 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index fa816b7..34e8e9f 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -597,21 +598,11 @@ static int xen_cons_init(void) } console_initcall(xen_cons_init); -#ifdef CONFIG_EARLY_PRINTK -static void xenboot_write_console(struct console *console, const char *string, - unsigned len) +static void domU_write_early_console(const char *string, unsigned len) { unsigned int linelen, off = 0; const char *pos; - if (!xen_pv_domain()) - return; - - dom0_write_console(0, string, len); - - if (xen_initial_domain()) - return; - domU_write_console(0, "(early) ", 8); while (off < len && NULL != (pos = strchr(string+off, '\n'))) { linelen = pos-string+off; @@ -625,6 +616,21 @@ static void xenboot_write_console(struct console *console, const char *string, domU_write_console(0, string+off, len-off); } +#ifdef CONFIG_EARLY_PRINTK +static void xenboot_write_console(struct console *console, const char *string, + unsigned len) +{ + if (!xen_pv_domain()) + return; + + dom0_write_console(0, string, len); + + if (xen_initial_domain()) + return; + + domU_write_early_console(string, len); +} + struct console xenboot_console = { .name = "xenboot", .write = xenboot_write_console, @@ -664,3 +670,23 @@ void xen_raw_printk(const char *fmt, ...) xen_raw_console_write(buf); } + +static void xenboot_earlycon_write(struct console *console, + const char *string, + unsigned len) +{ + dom0_write_console(0, string, len); + + if (xen_initial_domain()) + return; + + domU_write_early_console(string, len); +} + +static int __init xenboot_earlycon_setup(struct earlycon_device *device, + const char *opt) +{ + device->con->write = xenboot_earlycon_write; + return 0; +} +EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup);