From nobody Fri Oct 31 16:00:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=proton.me Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1746382515385853.2395645584629; Sun, 4 May 2025 11:15:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.975645.1363001 (Exim 4.92) (envelope-from ) id 1uBdrS-00027U-Cb; Sun, 04 May 2025 18:14:46 +0000 Received: by outflank-mailman (output) from mailman id 975645.1363001; Sun, 04 May 2025 18:14:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBdrS-00026p-6s; Sun, 04 May 2025 18:14:46 +0000 Received: by outflank-mailman (input) for mailman id 975645; Sun, 04 May 2025 18:14:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBdrQ-00024w-EH for xen-devel@lists.xenproject.org; Sun, 04 May 2025 18:14:44 +0000 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a5718f84-2913-11f0-9ffb-bf95429c2676; Sun, 04 May 2025 20:14:40 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a5718f84-2913-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1746382479; x=1746641679; bh=0aRmvpa4fxwrMSGMYMT22HdGNClvlgiK8yFRqz28IYE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=O4phzPdQZXHTGF52PuaP2WEKwh4YzdCAjVoe75hQcQ5lvJd4CT86wPJBUsuFp01aU hFM6V5Pzf8+VJQoKoktQTFicHHS5t9fwVenGblughbtCx2kg0Y5tw68IZ0z8Syuv3p Sni+Q/p6hyzIaWFPsmmNO9ocwi8WVSTAjm6kZ74NrFkfaZU/ocb2sEfxODNvbcmAYM ZSExZzZn+zPWIv+swpT9LlpwPCKbxbaEG5hVV37uxoIh8/rlfOAzWn9hBR5/JAn2J5 gRbPi4COkH3nso6sb65NZJIgMkFkRWJEiVxRqKCH+BIq8wsxzkAAY8BD/fOQwyl/ts AZWsw54XZLMyw== Date: Sun, 04 May 2025 18:14:37 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v3 1/3] xen/console: cleanup conring management Message-ID: <20250504181423.2302345-2-dmukhin@ford.com> In-Reply-To: <20250504181423.2302345-1-dmukhin@ford.com> References: <20250504181423.2302345-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 9636db80b5fd8e160d9f8706508cfcd92eaee727 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1746382516347019000 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin Add new parameter to conring_puts() to trigger conring VIRQ when needed. That cleans up the conring management because it removes VIRQ tasklet code = from few places. Move conring tasklet code close to conring definitions in the console drive= r to enable symbols use in conring_puts(). While doing it, rename conring tasklet variables to match the code. No functional change. Signed-off-by: Denis Mukhin --- Changes since v2: - renamed notify_dom0_con_ring_ prefix to conring_ prefix for readability - renamed console_locks_busted to conring_no_notify for readability - added extra parameter to conring_puts() to trigger VIRQ_CON_RING --- xen/drivers/char/console.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index c3150fbdb7..20504060cb 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -325,7 +325,17 @@ static void cf_check do_dec_thresh(unsigned char key, = bool unused) * ******************************************************** */ =20 -static void conring_puts(const char *str, size_t len) +static void cf_check conring_notify(void *unused) +{ + send_global_virq(VIRQ_CON_RING); +} + +static DECLARE_SOFTIRQ_TASKLET(conring_tasklet, conring_notify, NULL); + +/* NB: Do not send conring VIRQs during panic. */ +static bool conring_no_notify; + +static void conring_puts(const char *str, size_t len, bool notify) { ASSERT(rspin_is_locked(&console_lock)); =20 @@ -334,6 +344,9 @@ static void conring_puts(const char *str, size_t len) =20 if ( conringp - conringc > conring_size ) conringc =3D conringp - conring_size; + + if ( notify ) + tasklet_schedule(&conring_tasklet); } =20 long read_console_ring(struct xen_sysctl_readconsole *op) @@ -594,13 +607,6 @@ static void cf_check serial_rx(char c) __serial_rx(c); } =20 -static void cf_check notify_dom0_con_ring(void *unused) -{ - send_global_virq(VIRQ_CON_RING); -} -static DECLARE_SOFTIRQ_TASKLET(notify_dom0_con_ring_tasklet, - notify_dom0_con_ring, NULL); - #ifdef CONFIG_X86 static inline void xen_console_write_debug_port(const char *buf, size_t le= n) { @@ -648,10 +654,7 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM= (char) buffer, #endif =20 if ( opt_console_to_ring ) - { - conring_puts(kbuf, kcount); - tasklet_schedule(¬ify_dom0_con_ring_tasklet); - } + conring_puts(kbuf, kcount, true); =20 nrspin_unlock_irq(&console_lock); } @@ -753,8 +756,6 @@ long do_console_io( * ***************************************************** */ =20 -static bool console_locks_busted; - static void __putstr(const char *str) { size_t len =3D strlen(str); @@ -774,10 +775,7 @@ static void __putstr(const char *str) } #endif =20 - conring_puts(str, len); - - if ( !console_locks_busted ) - tasklet_schedule(¬ify_dom0_con_ring_tasklet); + conring_puts(str, len, !conring_no_notify); } =20 static int printk_prefix_check(char *p, char **pp) @@ -1171,7 +1169,7 @@ void console_force_unlock(void) spin_debug_disable(); rspin_lock_init(&console_lock); serial_force_unlock(sercon_handle); - console_locks_busted =3D 1; + conring_no_notify =3D true; console_start_sync(); } =20 --=20 2.34.1 From nobody Fri Oct 31 16:00:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=proton.me Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1746382514774670.3786732904882; Sun, 4 May 2025 11:15:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.975646.1363017 (Exim 4.92) (envelope-from ) id 1uBdrV-0002X3-Jq; Sun, 04 May 2025 18:14:49 +0000 Received: by outflank-mailman (output) from mailman id 975646.1363017; Sun, 04 May 2025 18:14:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBdrV-0002Ww-Fk; Sun, 04 May 2025 18:14:49 +0000 Received: by outflank-mailman (input) for mailman id 975646; Sun, 04 May 2025 18:14:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBdrU-0002WI-J0 for xen-devel@lists.xenproject.org; Sun, 04 May 2025 18:14:48 +0000 Received: from mail-10630.protonmail.ch (mail-10630.protonmail.ch [79.135.106.30]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a8d4225d-2913-11f0-9eb4-5ba50f476ded; Sun, 04 May 2025 20:14:46 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a8d4225d-2913-11f0-9eb4-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1746382484; x=1746641684; bh=jf7ue76YeYbPS45zsnt2Hb+wcYuAiLcM/Jd2uGGzfFU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=dF8nbCWGoEg25pnlwC5izRVGyWMua1fqzESqPvhIw9KOagc31EEmGFgV/cQXKtYTf 8ADLFf8Ptjx9mLDbXusPrgfiGDv1HbJIFjEWD7oHX0z6jroto+C1LsvJqo2LI2Be50 BQqGZJdboXBs/4/mTOP6myC/p8FbPo3Fw1d5Z/Yd+Tudkhz+ca1KpJky90eWjtghUt iyulzeiDiLnLHL6wIcjMAf0ZH6QoXdhPMoUDt2GAsqz2a0WfyWZ3SOhd8EP5CfpqNN Pryk49Cd2Novd7uRKKmnv+Ld/tHApbkUCf284iibgmEKBOG24vyXqiFTToT+nIX8Ji Z2FM8cNvfARsg== Date: Sun, 04 May 2025 18:14:40 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v3 2/3] xen/console: introduce console_puts() Message-ID: <20250504181423.2302345-3-dmukhin@ford.com> In-Reply-To: <20250504181423.2302345-1-dmukhin@ford.com> References: <20250504181423.2302345-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: b40dda7706d8352a9e5e0b9586d29980cb6f07ce MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1746382515310116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin guest_console_write() duplicates the code from __putstr(), eliminate code duplication. Introduce console_puts() for writing a buffer to console devices. Also, introduce internal console flags to control which console devices should be used. No functional change intended. Signed-off-by: Denis Mukhin Reviewed-by: Stefano Stabellini --- Changes since v2: - added CONSOLE_RING_VIRQ flag - dropped locking changes --- xen/drivers/char/console.c | 123 ++++++++++++++++++++++++------------- 1 file changed, 79 insertions(+), 44 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 20504060cb..b788427aa5 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -41,6 +41,28 @@ #include #endif =20 +/* Internal console flags. */ +enum { + CONSOLE_SERIAL =3D BIT(0, U), /* Use serial device. */ + CONSOLE_PV =3D BIT(1, U), /* Use PV console. */ + CONSOLE_VIDEO =3D BIT(2, U), /* Use video device. */ + CONSOLE_DEBUG =3D BIT(3, U), /* Use debug device. */ + CONSOLE_RING =3D BIT(4, U), /* Use console ring. */ + CONSOLE_RING_VIRQ =3D BIT(5, U), /* Use console ring VIRQ. */ + + /* Default console flags. */ + CONSOLE_DEFAULT =3D CONSOLE_SERIAL | + CONSOLE_PV | + CONSOLE_VIDEO | + CONSOLE_RING_VIRQ | + CONSOLE_DEBUG, + + /* Use all known console devices. */ + CONSOLE_ALL =3D CONSOLE_DEFAULT | CONSOLE_RING, +}; + +static void console_puts(const char *str, size_t len, unsigned int flags); + /* console: comma-separated list of console outputs. */ static char __initdata opt_console[30] =3D OPT_CONSOLE_STR; string_param("console", opt_console); @@ -431,9 +453,6 @@ void console_serial_puts(const char *s, size_t nr) serial_steal_fn(s, nr); else serial_puts(sercon_handle, s, nr); - - /* Copy all serial output into PV console */ - pv_console_puts(s, nr); } =20 static void cf_check dump_console_ring_key(unsigned char key) @@ -467,8 +486,7 @@ static void cf_check dump_console_ring_key(unsigned cha= r key) c +=3D len; } =20 - console_serial_puts(buf, sofar); - video_puts(buf, sofar); + console_puts(buf, sofar, CONSOLE_SERIAL | CONSOLE_VIDEO | CONSOLE_PV); =20 free_xenheap_pages(buf, order); } @@ -617,11 +635,66 @@ static inline void xen_console_write_debug_port(const= char *buf, size_t len) } #endif =20 +static inline void console_debug_puts(const char *str, size_t len) +{ +#ifdef CONFIG_X86 + if ( opt_console_xen ) + { + if ( xen_guest ) + xen_hypercall_console_write(str, len); + else + xen_console_write_debug_port(str, len); + } +#endif +} + +/* + * Write buffer to all enabled console devices. + * + * That will handle all possible scenarios working w/ console + * - physical console (serial console, VGA console (x86 only)); + * - PV console; + * - debug console (x86 only): debug I/O port or __HYPERVISOR_console_io + * hypercall; + * - console ring. + */ +static void console_puts(const char *str, size_t len, unsigned int flags) +{ + if ( flags & CONSOLE_SERIAL ) + console_serial_puts(str, len); + + if ( flags & CONSOLE_PV ) + pv_console_puts(str, len); + + if ( flags & CONSOLE_VIDEO ) + video_puts(str, len); + + if ( flags & CONSOLE_DEBUG ) + console_debug_puts(str, len); + + if ( flags & CONSOLE_RING ) + conring_puts(str, len, !!(flags & CONSOLE_RING_VIRQ) ); +} + +static inline void __putstr(const char *str) +{ + unsigned int flags =3D CONSOLE_ALL; + + ASSERT(rspin_is_locked(&console_lock)); + + if ( conring_no_notify ) + flags &=3D ~CONSOLE_RING_VIRQ; + + console_puts(str, strlen(str), flags); +} + static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, unsigned int count) { char kbuf[128]; unsigned int kcount =3D 0; + unsigned int flags =3D opt_console_to_ring + ? CONSOLE_ALL : CONSOLE_DEFAULT; struct domain *cd =3D current->domain; =20 while ( count > 0 ) @@ -639,23 +712,7 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM= (char) buffer, { /* Use direct console output as it could be interactive */ nrspin_lock_irq(&console_lock); - - console_serial_puts(kbuf, kcount); - video_puts(kbuf, kcount); - -#ifdef CONFIG_X86 - if ( opt_console_xen ) - { - if ( xen_guest ) - xen_hypercall_console_write(kbuf, kcount); - else - xen_console_write_debug_port(kbuf, kcount); - } -#endif - - if ( opt_console_to_ring ) - conring_puts(kbuf, kcount, true); - + console_puts(kbuf, kcount, flags); nrspin_unlock_irq(&console_lock); } else @@ -756,28 +813,6 @@ long do_console_io( * ***************************************************** */ =20 -static void __putstr(const char *str) -{ - size_t len =3D strlen(str); - - ASSERT(rspin_is_locked(&console_lock)); - - console_serial_puts(str, len); - video_puts(str, len); - -#ifdef CONFIG_X86 - if ( opt_console_xen ) - { - if ( xen_guest ) - xen_hypercall_console_write(str, len); - else - xen_console_write_debug_port(str, len); - } -#endif - - conring_puts(str, len, !conring_no_notify); -} - static int printk_prefix_check(char *p, char **pp) { int loglvl =3D -1; --=20 2.34.1 From nobody Fri Oct 31 16:00:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=proton.me Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1746382512839185.50259242161258; Sun, 4 May 2025 11:15:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.975647.1363026 (Exim 4.92) (envelope-from ) id 1uBdrY-0002n6-P3; Sun, 04 May 2025 18:14:52 +0000 Received: by outflank-mailman (output) from mailman id 975647.1363026; Sun, 04 May 2025 18:14:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBdrY-0002mx-MS; Sun, 04 May 2025 18:14:52 +0000 Received: by outflank-mailman (input) for mailman id 975647; Sun, 04 May 2025 18:14:52 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBdrY-00024w-4r for xen-devel@lists.xenproject.org; Sun, 04 May 2025 18:14:52 +0000 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id aa2f3b1e-2913-11f0-9ffb-bf95429c2676; Sun, 04 May 2025 20:14:48 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: aa2f3b1e-2913-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1746382488; x=1746641688; bh=vUW5r0Dl4Az223I5ofUyyuhJuLavlDSA1r91qpjTtqk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=Cgsmta8guD4iZs6Mf+h7p4LB2Fqdl36V5qrd5awhBm/r6nayLekwyG2WRZSgnSA2H r4X5clAP8ofx73yBu0E/NiFQuK1erQ1ThhfNDY1lxTgguVU9K4JBmJsa31KuG115z2 kLKoJ45IjRQzjmHyf6XcMt5QSNRrWFTiKTG09/iO5XFGsoeVy4YO+FPCzS06eJ9JGd t7sIkgxWvgSI1M/vH51f5zLwNitfAl4qQQeSGdlflC+KbCcTwQqP6fXU5sHLwIfhA6 WEXkQLGgpvO1JGgvLhgA7rNOueFGapvysZVKRlgSpnEKCcbUJJBQhtU4HmMQumRjgL 50gZxore81ZuQ== Date: Sun, 04 May 2025 18:14:45 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v3 3/3] xen/console: introduce conring_flush() Message-ID: <20250504181423.2302345-4-dmukhin@ford.com> In-Reply-To: <20250504181423.2302345-1-dmukhin@ford.com> References: <20250504181423.2302345-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 83ee07173b30a3d7b88373a024dce807b7062f3a MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1746382513416116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin Introduce conring_flush() to ensure all messages kept in the internal console ring are sent to all physical consoles (serial, VGA (x86)) after their initialization is completed. Rename dump_console_ring_key to conring_dump_keyhandler to match the notation for conring management symbols. Resolves: https://gitlab.com/xen-project/xen/-/issues/184 Signed-off-by: Denis Mukhin Reviewed-by: Stefano Stabellini --- Changes since v2: - Kept Stefano's R-b --- xen/drivers/char/console.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index b788427aa5..a089d6e292 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -455,23 +455,19 @@ void console_serial_puts(const char *s, size_t nr) serial_puts(sercon_handle, s, nr); } =20 -static void cf_check dump_console_ring_key(unsigned char key) +/* + * Flush contents of the conring to the physical console devices. + */ +static int conring_flush(void) { uint32_t idx, len, sofar, c; unsigned int order; char *buf; =20 - printk("'%c' pressed -> dumping console ring buffer (dmesg)\n", key); - - /* create a buffer in which we'll copy the ring in the correct - order and NUL terminate */ order =3D get_order_from_bytes(conring_size + 1); buf =3D alloc_xenheap_pages(order, 0); if ( buf =3D=3D NULL ) - { - printk("unable to allocate memory!\n"); - return; - } + return -ENOMEM; =20 c =3D conringc; sofar =3D 0; @@ -489,6 +485,18 @@ static void cf_check dump_console_ring_key(unsigned ch= ar key) console_puts(buf, sofar, CONSOLE_SERIAL | CONSOLE_VIDEO | CONSOLE_PV); =20 free_xenheap_pages(buf, order); + + return 0; +} + +static void cf_check conring_dump_keyhandler(unsigned char key) +{ + int rc; + + printk("'%c' pressed -> dumping console ring buffer (dmesg)\n", key); + rc =3D conring_flush(); + if ( rc ) + printk("failed to dump console ring buffer: %d\n", rc); } =20 /* @@ -1058,6 +1066,9 @@ void __init console_init_preirq(void) serial_set_rx_handler(sercon_handle, serial_rx); pv_console_set_rx_handler(serial_rx); =20 + /* NB: send conring contents to all enabled physical consoles, if any = */ + conring_flush(); + /* HELLO WORLD --- start-of-day banner text. */ nrspin_lock(&console_lock); __putstr(xen_banner()); @@ -1148,7 +1159,7 @@ void __init console_endboot(void) if ( opt_conswitch[1] =3D=3D 'x' ) console_rx =3D max_console_rx; =20 - register_keyhandler('w', dump_console_ring_key, + register_keyhandler('w', conring_dump_keyhandler, "synchronously dump console ring buffer (dmesg)", = 0); register_irq_keyhandler('+', &do_inc_thresh, "increase log level threshold", 0); --=20 2.34.1