[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] console: Do not duplicate early printk messages on conring flush


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 17 Jun 2025 09:19:40 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lbDd2DpkJV2lGbpCrWTmXsmmQtaUABV0UM6Kmtyx9Io=; b=RV9BUt2KexIOIvvwxRvNzkrEWI/OgZyn/b4S3MOWpevQjufpjXXIbLHhy05J4mmkzlKp6tTwQOMe6lhElP9HJjjd4FXWDpbUM69jLONoYyl9nju9YA5gqyt0K3Bh0fpqtjCYSDEhOijieayQDe3dlFR1+fjB/pbDBQlrXn+J92XkMBM0HpS3n4pN9D4cHeXQxP7+We7TknUJppyIOK4e8bcivXg7nCv9Mabc800cVYgfmpq7YM47CEiPKDLejS3fxW98XCMWCRe7UzbSP0aKybYBK9vyjj2eV4/w2TnYFiLa1O+vi7K+1fRdzzax2aMt1MXEshIP5XHUQ/yy7xvOKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CmRtaVZWqTppZYoHtwJlDKOlq4dBxMlb7JWuohon6/XIx/GmYBSAhlkr3S4KJ3NGTCo5d75Ct4MzWLenz3SilaPd7F7va4Qx0/byWoVgYb9HE23LZQ4/bg4aOVfMEqZs+1d1R+uE/WzceilUcPKiBAYoEedgQn6U0aV2Q98hVE6Cs0E7u+NyDiaVoaea/J6atfTDyDS2bWDYGMzZQNuBA/7Shcg482H20ESliX5VQ9XXDdzlTPh/zBEYOiKBl6EtyYFWGCUKk6Wo8wbA4No9tl7hXNr8kP6IKZs44DHmfzJ18kwS/gMIeisO64mXsOaH7zH2Fr7NByS7aCI9JfOXsQ==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>
  • Delivery-date: Tue, 17 Jun 2025 07:19:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Commit f6d1bfa16052 introduced flushing conring in console_init_preirq().
However, when CONFIG_EARLY_PRINTK is enabled, the early boot messages
had already been sent to serial before main console initialization. This
results in all the early boot messages being duplicated.

Change conring_flush() to accept argument listing devices to which to
flush conring. We don't want to send to serial at console initialization
when using early printk, but we want these messages to be send at conring
dump triggered by keyhandler.

Fixes: f6d1bfa16052 ("xen/console: introduce conring_flush()")
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/drivers/char/console.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 9a9836ba91e7..5879e31786ba 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -453,9 +453,9 @@ void console_serial_puts(const char *s, size_t nr)
 }
 
 /*
- * Flush contents of the conring to the physical console devices.
+ * Flush contents of the conring to the selected console devices.
  */
-static int conring_flush(void)
+static int conring_flush(unsigned int flags)
 {
     uint32_t idx, len, sofar, c;
     unsigned int order;
@@ -479,7 +479,7 @@ static int conring_flush(void)
         c += len;
     }
 
-    console_send(buf, sofar, CONSOLE_SERIAL | CONSOLE_VIDEO | CONSOLE_PV);
+    console_send(buf, sofar, flags);
 
     free_xenheap_pages(buf, order);
 
@@ -491,7 +491,7 @@ static void cf_check conring_dump_keyhandler(unsigned char 
key)
     int rc;
 
     printk("'%c' pressed -> dumping console ring buffer (dmesg)\n", key);
-    rc = conring_flush();
+    rc = conring_flush(CONSOLE_SERIAL | CONSOLE_VIDEO | CONSOLE_PV);
     if ( rc )
         printk("failed to dump console ring buffer: %d\n", rc);
 }
@@ -1042,6 +1042,7 @@ void __init console_init_preirq(void)
 {
     char *p;
     int sh;
+    unsigned int flags = CONSOLE_SERIAL | CONSOLE_VIDEO | CONSOLE_PV;
 
     serial_init_preirq();
 
@@ -1084,8 +1085,15 @@ void __init console_init_preirq(void)
     serial_set_rx_handler(sercon_handle, serial_rx);
     pv_console_set_rx_handler(serial_rx);
 
-    /* NB: send conring contents to all enabled physical consoles, if any */
-    conring_flush();
+    /*
+     * NB: send conring contents to all enabled physical consoles, if any.
+     * Skip serial if CONFIG_EARLY_PRINTK is enabled, which means the early
+     * messages have already been sent to serial.
+     */
+    if ( IS_ENABLED(CONFIG_EARLY_PRINTK) )
+        flags &= ~CONSOLE_SERIAL;
+
+    conring_flush(flags);
 
     /* HELLO WORLD --- start-of-day banner text. */
     nrspin_lock(&console_lock);
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.