* [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) [not found] ` <20201111135450.11214-2-pmladek@suse.com> @ 2021-01-06 23:36 ` Vineet Gupta 2021-01-07 15:27 ` Yann E. MORIN [not found] ` <8735zdm86m.fsf@jogness.linutronix.de> 0 siblings, 2 replies; 6+ messages in thread From: Vineet Gupta @ 2021-01-06 23:36 UTC (permalink / raw) To: buildroot +CC Buildroot folks Hi Petr, On 11/11/20 5:54 AM, Petr Mladek wrote: > stdin, stdout, and stderr standard I/O stream are created for the init > process. They are not available when there is no console registered > for /dev/console. It might lead to a crash when the init process > tries to use them, see the commit 48021f98130880dd742 ("printk: handle > blank console arguments passed in."). > > Normally, ttySX and ttyX consoles are used as a fallback when no consoles > are defined via the command line, device tree, or SPCR. But there > will be no console registered when an invalid console name is configured > or when the configured consoles do not exist on the system. > > Users even try to avoid the console intentionally, for example, > by using console="" or console=null. It is used on production > systems where the serial port or terminal are not visible to > users. Pushing messages to these consoles would just unnecessary > slowdown the system. > > Make sure that stdin, stdout, stderr, and /dev/console are always > available by a fallback to the existing ttynull driver. It has > been implemented for exactly this purpose but it was used only > when explicitly configured. > > Signed-off-by: Petr Mladek <pmladek@suse.com> > --- a/init/main.c > +++ b/init/main.c > @@ -1470,8 +1470,14 @@ void __init console_on_rootfs(void) > struct file *file = filp_open("/dev/console", O_RDWR, 0); > > if (IS_ERR(file)) { > - pr_err("Warning: unable to open an initial console.\n"); > - return; > + pr_err("Warning: unable to open an initial console. Fallback to ttynull.\n"); > + register_ttynull_console(); > + > + file = filp_open("/dev/console", O_RDWR, 0); > + if (IS_ERR(file)) { > + pr_err("Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process!\n"); > + return; > + } This breaks ARC booting (no output on console). Our Buildroot based setup has dynamic /dev where /dev/console doesn't exist statically and there's a primoridla /init shell script which does following /bin/mount -t devtmpfs devtmpfs /dev exec 0</dev/console exec 1>/dev/console exec 2>/dev/console exec /sbin/init "$@" Buildroot has had this way of handling missing /dev/console since 2011 [1] and [2]. Please advise what needs to be done to unbork boot. Otherwise this seems like a kernel change which breaks user-space and needs to be backed-out (or perhaps conditionalize on CONFIG_NULL_TTY. I'm surprised it hasn't been reported by any other embedded folks Thx, -Vineet [1] http://lists.busybox.net/pipermail/buildroot/2011-July/044505.html [2] http://lists.busybox.net/pipermail/buildroot/2011-August/044832.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) 2021-01-06 23:36 ` [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) Vineet Gupta @ 2021-01-07 15:27 ` Yann E. MORIN [not found] ` <8735zdm86m.fsf@jogness.linutronix.de> 1 sibling, 0 replies; 6+ messages in thread From: Yann E. MORIN @ 2021-01-07 15:27 UTC (permalink / raw) To: buildroot Vineet, All, On 2021-01-06 15:36 -0800, Vineet Gupta spake thusly: > On 11/11/20 5:54 AM, Petr Mladek wrote: [--SNIP--] > >Make sure that stdin, stdout, stderr, and /dev/console are always > >available by a fallback to the existing ttynull driver. It has > >been implemented for exactly this purpose but it was used only > >when explicitly configured. > > > >Signed-off-by: Petr Mladek <pmladek@suse.com> > > >--- a/init/main.c > >+++ b/init/main.c > >@@ -1470,8 +1470,14 @@ void __init console_on_rootfs(void) > > struct file *file = filp_open("/dev/console", O_RDWR, 0); > > if (IS_ERR(file)) { > >- pr_err("Warning: unable to open an initial console.\n"); > >- return; > >+ pr_err("Warning: unable to open an initial console. Fallback to ttynull.\n"); > >+ register_ttynull_console(); > >+ > >+ file = filp_open("/dev/console", O_RDWR, 0); > >+ if (IS_ERR(file)) { > >+ pr_err("Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process!\n"); > >+ return; > >+ } > > This breaks ARC booting (no output on console). > > Our Buildroot based setup has dynamic /dev where /dev/console doesn't exist > statically and there's a primoridla /init shell script which does following > > /bin/mount -t devtmpfs devtmpfs /dev > exec 0</dev/console > exec 1>/dev/console > exec 2>/dev/console > exec /sbin/init "$@" I guess you are speaking about the initramfs (cpio) case, right? We've changed that code last August: https://git.buildroot.org/buildroot/commit/fs/cpio/init?id=b9026e83f I.e. if we can't do the redirection, then we don't redirect anything. The change was done for people who explicitly pass an empty console= on their kernel command line. Now, I haven't looked at nulltty yet, and I have (so far) no idea on how it works. Thanks for the hint, I'll have a look. > Buildroot has had this way of handling missing /dev/console since 2011 [1] > and [2]. See also more archaelogy on that topic, referenced in that commit: https://git.buildroot.org/buildroot/commit/fs/cpio/?id=98a6f1fc02e41 > Please advise what needs to be done to unbork boot. This has been present since the 2020.08 release, and has been backported to the maintenance branches: 2020.02.x (LTS) -> f1a83afe2df2a 2020.05.x -> 797f9e40224c9 > Otherwise this seems > like a kernel change which breaks user-space and needs to be backed-out (or > perhaps conditionalize on CONFIG_NULL_TTY. I'm surprised it hasn't been > reported by any other embedded folks I won't speak about whether this is a kernel regression or not, not my call. Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <8735zdm86m.fsf@jogness.linutronix.de>]
* [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) [not found] ` <8735zdm86m.fsf@jogness.linutronix.de> @ 2021-01-07 16:43 ` Vineet Gupta [not found] ` <X/c/ONCYz2QQdvOP@alley> 0 siblings, 1 reply; 6+ messages in thread From: Vineet Gupta @ 2021-01-07 16:43 UTC (permalink / raw) To: buildroot Hi John, On 1/7/21 1:02 AM, John Ogness wrote: > Hi Vineet, > > On 2021-01-06, Vineet Gupta <vgupta@synopsys.com> wrote: >> This breaks ARC booting (no output on console). > > Could you provide the kernel boot arguments that you use? This series is > partly about addressing users that have used boot arguments that are > technically incorrect (even if had worked). Seeing the boot arguments of > users that are not experiencing problems may help to reveal some of the > unusual console usages until now. Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8 console=ttyS0,115200n8 debug print-fatal-signals=1 And we do have serial driver built-in. Thx, -Vineet ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <X/c/ONCYz2QQdvOP@alley>]
* [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) [not found] ` <X/c/ONCYz2QQdvOP@alley> @ 2021-01-07 17:58 ` Vineet Gupta [not found] ` <X/fWGjYI5LapMdGW@jagdpanzerIV.localdomain> 2021-01-13 22:07 ` Peter Korsgaard 0 siblings, 2 replies; 6+ messages in thread From: Vineet Gupta @ 2021-01-07 17:58 UTC (permalink / raw) To: buildroot On 1/7/21 9:04 AM, Petr Mladek wrote: > On Thu 2021-01-07 08:43:16, Vineet Gupta wrote: >> Hi John, >> >> On 1/7/21 1:02 AM, John Ogness wrote: >>> Hi Vineet, >>> >>> On 2021-01-06, Vineet Gupta <vgupta@synopsys.com> wrote: >>>> This breaks ARC booting (no output on console). >>> >>> Could you provide the kernel boot arguments that you use? This series is >>> partly about addressing users that have used boot arguments that are >>> technically incorrect (even if had worked). Seeing the boot arguments of >>> users that are not experiencing problems may help to reveal some of the >>> unusual console usages until now. >> >> >> Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8 >> console=ttyS0,115200n8 debug print-fatal-signals=1 > > This is strange, the problematic patch should use ttynull > only as a fallback. It should not be used when a particular console > is defined on the command line. What happens in my case is console_on_rootfs() doesn't find /dev/console and switching to ttynull. /dev is not present because devtmpfs doesn't automount for initramfs. > The only explanation would be that ttyS0 gets registered too late > and ttynull is added as a fallback in the meantime. I don't know if ttyS0 console should have registered already but even if it did - the /dev node missing would not have helped ? > > Anyway, I propose the revert the problematic patch for 5.11-rc3, > see > https://lore.kernel.org/lkml/20210107164400.17904-2-pmladek at suse.com/ > This mystery is a good reason to avoid bigger changes at this stage. > > Best Regards, > Petr > ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <X/fWGjYI5LapMdGW@jagdpanzerIV.localdomain>]
* [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) [not found] ` <X/fWGjYI5LapMdGW@jagdpanzerIV.localdomain> @ 2021-01-08 5:18 ` Vineet Gupta 0 siblings, 0 replies; 6+ messages in thread From: Vineet Gupta @ 2021-01-08 5:18 UTC (permalink / raw) To: buildroot On 1/7/21 7:48 PM, Sergey Senozhatsky wrote: > On (21/01/07 09:58), Vineet Gupta wrote: >> On 1/7/21 9:04 AM, Petr Mladek wrote: >>> On Thu 2021-01-07 08:43:16, Vineet Gupta wrote: >>>> Hi John, >>>> >>>> On 1/7/21 1:02 AM, John Ogness wrote: >>>>> Hi Vineet, >>>>> >>>>> On 2021-01-06, Vineet Gupta <vgupta@synopsys.com> wrote: >>>>>> This breaks ARC booting (no output on console). >>>>> >>>>> Could you provide the kernel boot arguments that you use? This series is >>>>> partly about addressing users that have used boot arguments that are >>>>> technically incorrect (even if had worked). Seeing the boot arguments of >>>>> users that are not experiencing problems may help to reveal some of the >>>>> unusual console usages until now. >>>> >>>> >>>> Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8 >>>> console=ttyS0,115200n8 debug print-fatal-signals=1 >>> >>> This is strange, the problematic patch should use ttynull >>> only as a fallback. It should not be used when a particular console >>> is defined on the command line. >> >> What happens in my case is console_on_rootfs() doesn't find /dev/console and >> switching to ttynull. /dev is not present because devtmpfs doesn't automount >> for initramfs. > > I wonder if we'll move the nulltty fallback logic into printk code [1] > will it fix the problem? > > [1] https://lore.kernel.org/lkml/X6x%2FAxD1qanC6evJ at jagdpanzerIV.localdomain/ Your reasoning in the post above makes total sense. I tired the patch: adding register_ttynull_console() call in console_device(), removing from console_on_rootfs() band that works too. | Warning: unable to open an initial console. Fallback to ttynull. | Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process! | Freeing unused kernel memory: 3096K | This architecture does not have kernel memory protection. | Run /init as init process | with arguments: | /init | with environment: | HOME=/ | TERM=linux | Starting System logger (syslogd) | Bringing up loopback device | Starting inetd | Mounting Posix Mqueue filesys | CONFIG_INITRAMFS_SOURCE="~/arc/RAMFS/archs/ramfs_2011-GNU-2020-03-glibc-2.32-tiny" | ********************************************************************** | Welcome to ARCLinux | ********************************************************************** | [ARCLinux]# ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) 2021-01-07 17:58 ` Vineet Gupta [not found] ` <X/fWGjYI5LapMdGW@jagdpanzerIV.localdomain> @ 2021-01-13 22:07 ` Peter Korsgaard 1 sibling, 0 replies; 6+ messages in thread From: Peter Korsgaard @ 2021-01-13 22:07 UTC (permalink / raw) To: buildroot >>>>> "Vineet" == Vineet Gupta <vgupta@synopsys.com> writes: > On 1/7/21 9:04 AM, Petr Mladek wrote: >> On Thu 2021-01-07 08:43:16, Vineet Gupta wrote: >>> Hi John, >>> >>> On 1/7/21 1:02 AM, John Ogness wrote: >>>> Hi Vineet, >>>> >>>> On 2021-01-06, Vineet Gupta <vgupta@synopsys.com> wrote: >>>>> This breaks ARC booting (no output on console). >>>> >>>> Could you provide the kernel boot arguments that you use? This series is >>>> partly about addressing users that have used boot arguments that are >>>> technically incorrect (even if had worked). Seeing the boot arguments of >>>> users that are not experiencing problems may help to reveal some of the >>>> unusual console usages until now. >>> >>> >>> Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8 >>> console=ttyS0,115200n8 debug print-fatal-signals=1 >> >> This is strange, the problematic patch should use ttynull >> only as a fallback. It should not be used when a particular console >> is defined on the command line. > What happens in my case is console_on_rootfs() doesn't find > /dev/console and switching to ttynull. /dev is not present because > devtmpfs doesn't automount for initramfs. But our initramfs/cpio logic ensures that the initramfs has a static /dev/console device node, so how can that be? https://git.buildroot.net/buildroot/tree/fs/cpio/cpio.mk#n25 -- Bye, Peter Korsgaard ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-13 22:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20201111135450.11214-1-pmladek@suse.com>
[not found] ` <20201111135450.11214-2-pmladek@suse.com>
2021-01-06 23:36 ` [Buildroot] ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console) Vineet Gupta
2021-01-07 15:27 ` Yann E. MORIN
[not found] ` <8735zdm86m.fsf@jogness.linutronix.de>
2021-01-07 16:43 ` Vineet Gupta
[not found] ` <X/c/ONCYz2QQdvOP@alley>
2021-01-07 17:58 ` Vineet Gupta
[not found] ` <X/fWGjYI5LapMdGW@jagdpanzerIV.localdomain>
2021-01-08 5:18 ` Vineet Gupta
2021-01-13 22:07 ` Peter Korsgaard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox