From patchwork Thu Feb 25 12:10:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 8423261 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2AA3BC0553 for ; Thu, 25 Feb 2016 12:14:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7680A2034A for ; Thu, 25 Feb 2016 12:14:03 +0000 (UTC) Received: from lists.xen.org (unknown [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B36FB202EB for ; Thu, 25 Feb 2016 12:14:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aYulc-0003yE-Qy; Thu, 25 Feb 2016 12:11:36 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aYulb-0003xT-VX for xen-devel@lists.xensource.com; Thu, 25 Feb 2016 12:11:36 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id F4/53-02983-77FEEC65; Thu, 25 Feb 2016 12:11:35 +0000 X-Env-Sender: prvs=856006447=Stefano.Stabellini@citrix.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1456402291!12665322!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 53654 invoked from network); 25 Feb 2016 12:11:34 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2016 12:11:34 -0000 X-IronPort-AV: E=Sophos;i="5.22,498,1449532800"; d="scan'208";a="341041047" From: Stefano Stabellini To: Date: Thu, 25 Feb 2016 12:10:39 +0000 Message-ID: <1456402239-4179-3-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: MIA2 Cc: boris.ostrovsky@oracle.com, david.vrabel@citrix.com, linux-kernel@vger.kernel.org, Stefano Stabellini Subject: [Xen-devel] [PATCH v2 3/3] hvc_xen: make early_printk work with HVM guests X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, UNPARSEABLE_RELAY autolearn=no 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 Refactor the existing code in xen_raw_console_write to get the generic early_printk console work with HVM guests. Take the opportunity to replace the outb loop with a single outsb call to reduce the number of vmexit. Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky --- drivers/tty/hvc/hvc_xen.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index bf787aa..a1c3746 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -605,6 +605,16 @@ static int xen_cons_init(void) } console_initcall(xen_cons_init); +#ifdef CONFIG_X86 +static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) +{ + if (xen_cpuid_base()) + outsb(0xe9, str, len); +} +#else +static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) { } +#endif + #ifdef CONFIG_EARLY_PRINTK static int __init xenboot_setup_console(struct console *console, char *string) { @@ -624,8 +634,10 @@ static void xenboot_write_console(struct console *console, const char *string, unsigned int linelen, off = 0; const char *pos; - if (!xen_pv_domain()) + if (!xen_pv_domain()) { + xen_hvm_early_write(0, string, len); return; + } dom0_write_console(0, string, len); @@ -661,17 +673,10 @@ void xen_raw_console_write(const char *str) if (xen_domain()) { rc = dom0_write_console(0, str, len); -#ifdef CONFIG_X86 - if (rc == -ENOSYS && xen_hvm_domain()) - goto outb_print; - - } else if (xen_cpuid_base()) { - int i; -outb_print: - for (i = 0; i < len; i++) - outb(str[i], 0xe9); -#endif + if (rc != -ENOSYS || !xen_hvm_domain()) + return; } + xen_hvm_early_write(0, str, len); } void xen_raw_printk(const char *fmt, ...)