lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231205073255.20562-5-tony@atomide.com>
Date:   Tue,  5 Dec 2023 09:32:36 +0200
From:   Tony Lindgren <tony@...mide.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        Petr Mladek <pmladek@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        John Ogness <john.ogness@...utronix.de>,
        Sergey Senozhatsky <senozhatsky@...omium.org>
Cc:     "David S . Miller" <davem@...emloft.net>,
        Andy Shevchenko <andriy.shevchenko@...el.com>,
        Dhruva Gole <d-gole@...com>,
        Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
        Johan Hovold <johan@...nel.org>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Vignesh Raghavendra <vigneshr@...com>,
        linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org
Subject: [PATCH v4 4/4] serial: 8250: Add preferred console in serial8250_isa_init_ports()

Prepare 8250 isa ports to drop kernel command line serial console
handling from console_setup().

We need to set the preferred console in serial8250_isa_init_ports().
Otherwise the console gets initialized only later on when the hardware
specific driver takes over, and console_setup() is no longer handling
the ttyS related quirks.

Note that this mostly affects x86 as this happens based on define
SERIAL_PORT_DFNS.

Signed-off-by: Tony Lindgren <tony@...mide.com>
---
 drivers/tty/serial/8250/8250_core.c | 32 +++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/cleanup.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ioport.h>
@@ -517,6 +518,35 @@ static struct uart_8250_port *serial8250_setup_port(int index)
 	return up;
 }
 
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+
+/*
+ * There is no struct device at this point, so let's not try to use
+ * serial_base_add_preferred_console().
+ */
+static void __init serial8250_isa_init_preferred_console(int idx)
+{
+	const char *name __free(kfree);
+	int ret;
+
+	name = kasprintf(GFP_KERNEL, "%s%i", serial8250_reg.dev_name, idx);
+	ret = add_preferred_console_match(name, serial8250_reg.dev_name, idx);
+	if (!ret || ret == -ENOENT)
+		return;
+
+	pr_err("Could not add preferred console for %s idx %i\n",
+	       serial8250_reg.dev_name, idx);
+}
+
+#else
+
+static inline void serial8250_isa_init_preferred_console(struct uart_port *port,
+							 int idx)
+{
+}
+
+#endif
+
 static void __init serial8250_isa_init_ports(void)
 {
 	struct uart_8250_port *up;
@@ -563,6 +593,8 @@ static void __init serial8250_isa_init_ports(void)
 		port->irqflags |= irqflag;
 		if (serial8250_isa_config != NULL)
 			serial8250_isa_config(i, &up->port, &up->capabilities);
+
+		serial8250_isa_init_preferred_console(i);
 	}
 }
 
-- 
2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ