From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26D00D37E33 for ; Wed, 14 Jan 2026 14:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rjJ0doliNf6plVmMYQkV7IlLiBwqr6x+viyB7m/anSs=; b=STSLM2eyrXX2o99iaMnrwmI4L/ 8N6VdzIEPjA1trn9zpNTpWx+Kw9LOUGUNIHDTzXeJmticxUkFKzkJ3FJfqFEL2vLcY1evg/3U1eOx C5u85tzucnXM34+8GS7wmnt7A6JQ458igSTdir9XNd1kw5TNqVlNwPBWSaqBE5JKa0RiGuRbsPJH3 J8YavK+EtFCZaYvPb7C+x82EuxGIx9LzrX6pKxgCg/OQBVs6BzouMVnBtWoXx2BVdw89ZhWWYK533 4gOKsS4VCMf81hkrmpVzQyy/RyUkND18F7zqiKN1sDVIh5wHGPfcRA47yBGOqrpIkt4zvMlDO6ah+ RimJfV3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vg1m6-00000009W90-4Bl7; Wed, 14 Jan 2026 14:23:07 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vg1m4-00000009W7u-4514 for linux-um@lists.infradead.org; Wed, 14 Jan 2026 14:23:06 +0000 Received: by mail-wr1-x443.google.com with SMTP id ffacd0b85a97d-42fb0fc5aa4so6529847f8f.1 for ; Wed, 14 Jan 2026 06:23:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1768400583; x=1769005383; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rjJ0doliNf6plVmMYQkV7IlLiBwqr6x+viyB7m/anSs=; b=H1Kvte0j9gTLVCN4JyvXqA+w+HMg9muhphV6Iz+RFCptSYq2dwU/4pZxVVksPoJ3Aj S6AKHOGtxLEnkNYQd6vDd9gNQLWA6trS0N4IsPsmoPQSqpNvrsJuPWQ6H4GoP1DBbHm/ N0CRsgVnyPJrw+5VQ4yxGqTu8Ec0goBUzW2AFPGqKG2l2+5PAtzPqSSj9ic5zdIcAU2a LQqlVnYQftwytZ5eUKficI2A5HQsJpmH0bscez0n/cC85j5vx1lAkQdz+mUF6y1UZUzw byCE/XbdL7nWhbGl/44OF4aS1fZs6QESTLxhqm9aSlP9DoodKveRbhwe+8ewBiQlFKVu Klmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768400583; x=1769005383; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rjJ0doliNf6plVmMYQkV7IlLiBwqr6x+viyB7m/anSs=; b=rf88AdZ+vKOdqABPR36eBbWwXSDGrZInsUkvmQ1d9QmnNDiQQBN1L9DQtUNGIYX0Uu n2jMjYzmtI/EeFQQKI9ox/RIF5L3LZEhbX4FrQ2gccEbSnkBXgKmS516T2LKxsFqyAOK hVEq7XCV+ph2GAKOfj3AiSH6LYH9yflD9JzT2Oe/+nnAAQdgAbt+bY2bJiU2H4BfysD6 +7qCulATX/s0Q9LY+7Jqi6pNa/AGZX0j4uRYDsOgUSQEB6TuEPCZRb3IELfxcc2F0Tx5 dSqXTwoklszKOH8giocicPFgH+jHsayEBC658w3JbzB8JZA2Mk8Q8gfRWxnj13rMtazX Hb1w== X-Forwarded-Encrypted: i=1; AJvYcCUcnDTkW9aL5EqZFEvc6ENyiQeEFmdx6jBip1aGff7Vqsx/UOAJ5JyK9CgmSUe/p5VcqnQASWhsJQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwVhl/c95D4bdx44c0fi46R3i+rv8Ugg2z50m+VKlxnqhSjUzlZ 0OVkqzT16zTwfyj9s9vPMf489IglMM+jYBIuE8EB4sow/WnxSUuwFvhqbXfjbQ4EFMg= X-Gm-Gg: AY/fxX73U+BCwy1KKLaDsWdBk87i52txGB/glE9EWTiu5+r8TQ4SQ6gtXgLgg8VstsC ntIzqX0Qe9WXeqjbHcrCj1LZuDHq0i+AlcjPMFUmMvYka7SkHImhnoUeQfjg0MDVolRlLduYcet jHCBepWhlVZbokSQis+GuyryhMqQp0GYQZYa28JjlL+TR6hKqcMQ2Id6fwxfdSJAM7E0lBDSWCE a70RDo1bARllqXjmGwt287eBTcaKXIE8KtG8AiUkONPrmiAxWxQkBIxGl298u8yFTmd8/uXlq8M 5MDUPHBZBy6llenTuK97JUPyqukxkZFsTA6VqrJ4W1BhUsIoEC72GMXtnynHSzXug4nRnyJ2z+S 8KSVDN4bX7QHbcz1BxF6JkgXp0xRvTOPD2f1wztOgAZPQfsHwGv4kVqnk3oRmO/IrpP3DxTvT0K 1VrOnro8pliERw6A== X-Received: by 2002:a05:6000:3105:b0:431:104:6dd5 with SMTP id ffacd0b85a97d-4342c5728e2mr3256518f8f.58.1768400582935; Wed, 14 Jan 2026 06:23:02 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0dacd1sm49446446f8f.4.2026.01.14.06.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 06:23:02 -0800 (PST) Date: Wed, 14 Jan 2026 15:22:59 +0100 From: Petr Mladek To: Marcos Paulo de Souza Cc: Richard Weinberger , Anton Ivanov , Johannes Berg , Greg Kroah-Hartman , Jason Wessel , Daniel Thompson , Douglas Anderson , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jiri Slaby , Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Andreas Larsson , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Jacky Huang , Shan-Chun Hung , Laurentiu Tudor , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org, netdev@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-hardening@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 06/19] printk: Introduce register_console_force Message-ID: References: <20251227-printk-cleanup-part3-v1-0-21a291bcf197@suse.com> <20251227-printk-cleanup-part3-v1-6-21a291bcf197@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251227-printk-cleanup-part3-v1-6-21a291bcf197@suse.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260114_062305_059270_ECC09A54 X-CRM114-Status: GOOD ( 37.82 ) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.org On Sat 2025-12-27 09:16:13, Marcos Paulo de Souza wrote: > The register_console_force function will register a console even if it > wasn't specified on boot. The new function will act like all consoles > being registered were using the CON_ENABLED flag. I am a bit confused by the last sentence. It might be bacause I am not a native speaker. I wonder if the following is more clear: The register_console_force() function will register a console even if it wasn't preferred via the command line, SPCR, or device tree. Currently, certain drivers pre-set the CON_ENABLE flag to achieve this. > The CON_ENABLED flag will be removed in the following patches and the > drivers that use it will migrate to register_console_force instead. > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -3858,7 +3858,7 @@ static int console_call_setup(struct console *newcon, char *options) > * enabled such as netconsole > */ > static int try_enable_preferred_console(struct console *newcon, > - bool user_specified) > + bool user_specified, bool force) > { > struct console_cmdline *c; > int i, err; > @@ -3896,12 +3896,15 @@ static int try_enable_preferred_console(struct console *newcon, > return 0; > } > > + if (force) > + newcon->flags |= CON_ENABLED; > + This makes sense because the pre-enabled CON_ENABLED flag is handled right below. > /* > * Some consoles, such as pstore and netconsole, can be enabled even > * without matching. Accept the pre-enabled consoles only when match() > * and setup() had a chance to be called. > */ > - if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) > + if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) > return 0; But this location was not a good idea in the first place. It hides an unexpected side-effect into this function. It is easy to miss. A good example is the regression caused by the last patch in this patch set, see https://lore.kernel.org/all/89409a0f48e6998ff6dd2245691b9954f0e1e435.camel@suse.com/ I actually have a patch removing this side-effect: >From d24cd6b812967669900f9866f6202e8b0b65325a Mon Sep 17 00:00:00 2001 From: Petr Mladek Date: Mon, 24 Nov 2025 17:34:25 +0100 Subject: [PATCH] printk/console: Do not rely on try_enable_preferred_console() for pre-enabled consoles try_enable_preferred_console() has non-obvious side effects. It returns success for pre-enabled consoles. Move the check for pre-enabled consoles to register_console(). It makes the handling of pre-enabled consoles more obvious. Also it will allow call try_enable_preferred_console() only when there is an entry in preferred_consoles[] array. But it would need some more changes. It is part of the code clean up. It should not change the existing behavior. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index abf1b93de056..d6b1d0a26217 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3826,14 +3826,6 @@ static int try_enable_preferred_console(struct console *newcon, return 0; } - /* - * Some consoles, such as pstore and netconsole, can be enabled even - * without matching. Accept the pre-enabled consoles only when match() - * and setup() had a chance to be called. - */ - if (newcon->flags & CON_ENABLED && pc->user_specified == user_specified) - return 0; - return -ENOENT; } @@ -4022,6 +4014,14 @@ void register_console(struct console *newcon) if (err == -ENOENT) err = try_enable_preferred_console(newcon, false); + /* + * Some consoles, such as pstore and netconsole, can be enabled even + * without matching. Accept them at this stage when they had a chance + * to match() and call setup(). + */ + if (err == -ENOENT && (newcon->flags & CON_ENABLED)) + err = 0; + /* printk() messages are not printed to the Braille console. */ if (err || newcon->flags & CON_BRL) { if (newcon->flags & CON_NBCON) -- 2.52.0 It would be better to do the above change 1st. Then the @force parameter might be checked in __register_console() directly, like: /* * Some consoles, such as pstore and netconsole, can be enabled even * without matching. Accept them at this stage when they had a chance * to match() and call setup(). */ if (err == -ENOENT && (force || newcon->flags & CON_ENABLED)) err = 0; You might just remove the check of CON_ENABLED in the last patch. I think that this should actually fix the regression. It will handle also the case when the console was enabled by try_enable_default_console() and try_enable_preferred_console() returned -ENOENT. Note: I have some more patches which clean up this mess. But they are more complicated because of how the Braille console support is wired. They still need some love. Anyway, the above patch should be good enough for removing CON_ENABLED flag. Best Regards, Petr