Messages in this thread Patch in this message | | | Subject | [RFC PATCH 2/3] vt: Set as preferred console when a non-dummy backend, is bound | From | Alper Nebi Yasak <> | Date | Mon, 23 Mar 2020 13:50:03 +0300 |
| |
When a machine's device-tree has a "chosen" node with a "stdout-path" property that specified console is added as the preferred console by of_console_check via an add_preferred_console call. The property is quite common in kernel device-tree definitions. As far as I can tell, it is set to provide a reasonable default value for earlycon, and the (usually serial) console is set as preferred to avoid output going to VT's dummy backend instead of a working console.
However, a chosen stdout-path property is included even in device-trees of systems that are designed to be used with a built-in display, e.g. several ARM Chromebooks. In these cases where CONFIG_VT_CONSOLE is enabled and no console argument is given on the kernel commandline, tty0 is still registered (presumably based on the order of of_console_check and vt's register_console calls) but ends up not being the preferred console.
As a result, it is possible for early userspace prompts (encryption passphrase requests, emergency shells) to end up in a console that the user doesn't expect or even have access to.
This patch tries to set tty0 as the /dev/console whenever a non-dummy backend tries to register as its default, unless the preferred console was set from the kernel commandline arguments.
On a Samsung Chromebook Plus (Google Kevin, rk3399-gru-kevin.dts), boot messages are still visible on the framebuffer without this patch, but it isn't the preferred console due to the device-tree having a stdout-path property (from rk3399-gru.dtsi):
$ sudo dmesg | grep -i "console\|printk" [ 0.000000] printk: bootconsole [uart0] enabled [ 0.010232] Console: colour dummy device 80x25 [ 0.015107] printk: console [tty0] enabled [ 0.019601] printk: bootconsole [uart0] disabled [ 7.145478] printk: console [ttyS2] enabled [ 9.316094] Console: switching to colour frame buffer device 300x100
$ cat /proc/consoles ttyS2 -W- (EC p a) 4:66 tty0 -WU (E ) 4:7
And on the same machine, with this patch:
$ sudo dmesg | grep -i "console\|printk" [ 0.000000] printk: bootconsole [uart0] enabled [ 0.010257] Console: colour dummy device 80x25 [ 0.015132] printk: console [tty0] enabled [ 0.019626] printk: bootconsole [uart0] disabled [ 4.741120] printk: console [ttyS2] enabled [ 6.779994] Console: switching to colour frame buffer device 300x100 [ 6.836117] printk: switching to console [tty0]
$ cat /proc/consoles tty0 -WU (EC ) 4:7 ttyS2 -W- (E p a) 4:66
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> --- drivers/tty/vt/vt.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index bbc26d73209..0fc462ae8b2 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3566,6 +3566,13 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last, pr_cont("to %s\n", desc); } +#ifdef CONFIG_VT_CONSOLE + if (!console_set_on_cmdline && deflt && conswitchp != &dummy_con) { + add_preferred_console("tty", 0, NULL); + update_console_to_preferred(); + } +#endif + retval = 0; err: module_put(owner); -- 2.26.0.rc2
| |