The last console= argument is not used by the kernel

Bug #1807140 reported by Dmitrii Shcherbakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

I ran into a problem with the console argument handling on a physical system with a BMC (Dell R610) and also reproduced the same behavior on a QEMU/KVM VM with multiple serial ports.

The kernel documentation notes that the last entry will be used for /dev/console
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-tty
"What: /sys/class/tty/console/active
         Shows the list of currently configured console devices, like 'tty1 ttyS0'. The last entry in the file is the active device connected to /dev/console.
         The file supports poll() to detect virtual console switches."

https://elixir.bootlin.com/linux/v4.15.18/source/kernel/printk/printk.c#L1960
"The last preferred console added will be used for kernel messages and stdin/out/err for init."

The actual behavior is different and the console specified in the last console argument does not become an active one. As a result, SOL functionality is not possible to use unless only one ttyS<n> argument is specified in the kernel command line arguments. Setting the arguments to only contain the right one results in a proper behavior and I can see rx counters increasing in /proc/tty/driver/serial for the relevant port after I type something via the BMC.

$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-4.15.0-42-generic root=UUID=580a3c58-1040-4c7d-b94f-93230874caf5 ro console=tty0 console=ttyS0,115200 console=ttyS1,115200

journalctl -k | grep ttyS
Dec 03 21:42:41 ubuntu kernel: Command line: BOOT_IMAGE=/vmlinuz-4.15.0-42-generic root=UUID=580a3c58-1040-4c7d-b94f-93230874caf5 ro console=tty0 console=ttyS0,115200 console=ttyS1,115200
Dec 03 21:42:41 ubuntu kernel: Kernel command line: BOOT_IMAGE=/vmlinuz-4.15.0-42-generic root=UUID=580a3c58-1040-4c7d-b94f-93230874caf5 ro console=tty0 console=ttyS0,115200 console=ttyS1,115200
Dec 03 21:42:41 ubuntu kernel: console [ttyS0] enabled
Dec 03 21:42:41 ubuntu kernel: 00:02: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
Dec 03 21:42:41 ubuntu kernel: 00:03: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
Dec 03 21:42:41 ubuntu kernel: tty ttyS3: hash matches

Full dmesg: http://paste.ubuntu.com/p/bV2pDc4Hdw/

$ cat /sys/class/tty/console/active
ttyS0 tty0

$ sudo cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:78 rx:0 RTS|DTR
1: uart:16550A port:000002F8 irq:3 tx:0 rx:0 CTS|DSR|CD
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3
# ...

~~~
GRUB setttings:

# the ones that override /etc/default/grub
$ cat /etc/default/grub.d/50-curtin-settings.cfg
cat: cat: No such file or directory
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200 console=ttyS1,115200"
# disable grub os prober that might find other OS installs.
GRUB_DISABLE_OS_PROBER=true
GRUB_TERMINAL=console

/etc/default/grub: https://paste.ubuntu.com/p/sdWQrY7JwN/

# grub.cfg: http://paste.ubuntu.com/p/zKGTqDh6sR/
# two entries, both with the proper arg and properly sent to the kernel cmdline based on /proc/cmdline
grep ttyS grub.cfg
        linux /vmlinuz-4.15.0-42-generic root=UUID=580a3c58-1040-4c7d-b94f-93230874caf5 ro console=tty0 console=ttyS0,115200 console=ttyS1,115200
         linux /vmlinuz-4.15.0-42-generic root=UUID=580a3c58-1040-4c7d-b94f-93230874caf5 ro console=tty0 console=ttyS0,115200 console=ttyS1,115200

~~~

I managed to reproduce the exact same behavior on a VM with multiple 8250 serial ports.

ubuntu@maas-vhost5:~$ cat /sys/class/tty/console/active
ttyS0

ubuntu@maas-vhost5:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS0,115200 console=ttyS2,115200 console=ttyS1,115200

ubuntu@maas-vhost5:~$ grep -RP ttyS /boot/grub/grub.cfg
        linux /boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS0,115200 console=ttyS2,115200 console=ttyS1,115200
         linux /boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS0,115200 console=ttyS2,115200 console=ttyS1,115200
         linux /boot/vmlinuz-4.15.0-39-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS0,115200 console=ttyS2,115200 console=ttyS1,115200

# changed to the following config with only ttyS1 present:
ubuntu@maas-vhost5:~$ grep -RP ttyS /boot/grub/grub.cfg
        linux /boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS1,115200
         linux /boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS1,115200
         linux /boot/vmlinuz-4.15.0-39-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS1,115200

# 1 tty passed only
ubuntu@maas-vhost5:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS1,115200

# now it's shown as active
ubuntu@maas-vhost5:~$ cat /sys/class/tty/console/active
ttyS1

ubuntu@maas-vhost5:~$ sudo cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0 CTS|DSR|CD
1: uart:16550A port:000002F8 irq:3 tx:14763 rx:0 RTS|CTS|DTR|DSR|CD
2: uart:16550A port:000003E8 irq:4 tx:0 rx:0 CTS|DSR|CD

~~~~

Relevant code:
https://elixir.bootlin.com/linux/v4.15.18/source/kernel/printk/printk.c#L2379
https://elixir.bootlin.com/linux/v4.15.18/source/kernel/printk/printk.c#L1916
https://elixir.bootlin.com/linux/v4.15.18/source/kernel/printk/printk.c#L1961
https://elixir.bootlin.com/linux/v4.15.18/source/kernel/printk/printk.c#L1886
---
ProblemType: Bug
AlsaDevices:
 total 0
 crw-rw---- 1 root audio 116, 1 Dec 6 14:38 seq
 crw-rw---- 1 root audio 116, 33 Dec 6 14:38 timer
AplayDevices: Error: [Errno 2] No such file or directory: 'aplay': 'aplay'
ApportVersion: 2.20.9-0ubuntu7.5
Architecture: amd64
ArecordDevices: Error: [Errno 2] No such file or directory: 'arecord': 'arecord'
AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/seq', '/dev/snd/timer'] failed with exit code 1:
DistroRelease: Ubuntu 18.04
IwConfig: Error: [Errno 2] No such file or directory: 'iwconfig': 'iwconfig'
Lsusb:
 Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
MachineType: QEMU Standard PC (Q35 + ICH9, 2009)
Package: linux (not installed)
PciMultimedia:

ProcFB: 0 qxldrmfb
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.15.0-42-generic root=UUID=a60217c2-6752-4c69-afb9-55f86a2b6c1d ro console=ttyS0,115200 console=ttyS1,115200
ProcVersionSignature: User Name 4.15.0-42.45-generic 4.15.18
RelatedPackageVersions:
 linux-restricted-modules-4.15.0-42-generic N/A
 linux-backports-modules-4.15.0-42-generic N/A
 linux-firmware 1.173.2
RfKill: Error: [Errno 2] No such file or directory: 'rfkill': 'rfkill'
Tags: bionic uec-images
Uname: Linux 4.15.0-42-generic x86_64
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm audio cdrom dialout dip floppy lxd netdev plugdev sudo video
_MarkForUpload: True
dmi.bios.date: 04/01/2014
dmi.bios.vendor: SeaBIOS
dmi.bios.version: 1.10.2-1ubuntu1
dmi.chassis.type: 1
dmi.chassis.vendor: QEMU
dmi.chassis.version: pc-q35-2.11
dmi.modalias: dmi:bvnSeaBIOS:bvr1.10.2-1ubuntu1:bd04/01/2014:svnQEMU:pnStandardPC(Q35+ICH9,2009):pvrpc-q35-2.11:cvnQEMU:ct1:cvrpc-q35-2.11:
dmi.product.name: Standard PC (Q35 + ICH9, 2009)
dmi.product.version: pc-q35-2.11
dmi.sys.vendor: QEMU

description: updated
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 1807140

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
tags: added: bionic
Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : CRDA.txt

apport information

tags: added: apport-collected uec-images
description: updated
Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : CurrentDmesg.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : Lspci.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : ProcCpuinfo.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : ProcCpuinfoMinimal.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : ProcEnviron.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : ProcInterrupts.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : ProcModules.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : UdevDb.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : WifiSyslog.txt

apport information

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

The information above is from a VM with a reproducer.

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Brad Figg (brad-figg)
tags: added: cscc
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.