Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2517526rwb; Sat, 29 Jul 2023 08:15:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlGrAaaUzenKJeQxU1foC6JlxYDrPgDngzMEzSQUmV2B99qe1LmTSTKNPMF/GhHkNvNNNqUU X-Received: by 2002:a17:906:51d0:b0:993:f996:52d2 with SMTP id v16-20020a17090651d000b00993f99652d2mr2478747ejk.20.1690643743768; Sat, 29 Jul 2023 08:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690643743; cv=none; d=google.com; s=arc-20160816; b=BU31Gtuzp4idzTg90ZYj53O09QYuURhuJULXy7R/F0tSWb+Wpg7Tpd1DviSyIevBTQ zafFe+GeHpreM8Jcdi54Vs5VnYHGfYnTykanQdXQXQtiVpTeVHbkBnBhvAPNgg8D7FlP IM6qx7ygwxMC05QBtlNRqjPzuPhhI+9PO022Lz9JTtIgn2+h0RG5ynTfLXyZlzHtD04a fxg2LYxxZmOcETI47ZxnyrcedSN+JneWaAhoanbUiaiC2N8FbOS4KpMd96fwt8/HgMu8 kFxTBc/d//gnWMEBTLvlR9RdEwFvhkpTMTT6d+4dNLr4XxiBSJXA8GIzS5ec1zeZgnFP shHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=zvbrSGqLnWp5XoaN2UZH58DtSACxEo7O3E4xUTwz1rI=; fh=VwfRL9YZ3mT2pTbmzUasY41lVf8X333wlvdApSgNsRc=; b=KVY3BgY3nC23O6QPG+4ZcB/YM/At/72TlrKhoHtGmadkEuIdngMnnA+rn3FRVVfywe 4kWEHtP8u11lweleawl7oSVYaiTmsSTrZAPopx5/s8H6MshN7g0yY8oYIOPAKf0JEDL1 r0xceyB9l2vuk+/tf9zIMNQIRvzj6mxTYNxi3rx8uYM3ASvL8/PaJkpqiYKtLH6hMVaD UGUvZRgXLVjn973z5KveetnWeKvHZDQuohdo9j3V+Ayvj5haYiZTc7fG2tUyhSkhfW6l oC9z7C5PHPwvkgk34VQYTSzGv4E7mMLv8+yQR8pknRmln0cjmVqiY905VPrgvr4pev92 BGSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hBh7GFKC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a17090668ca00b00992c7f7356dsi931797ejr.8.2023.07.29.08.15.17; Sat, 29 Jul 2023 08:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hBh7GFKC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231922AbjG2O3n (ORCPT + 99 others); Sat, 29 Jul 2023 10:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjG2O3l (ORCPT ); Sat, 29 Jul 2023 10:29:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A284B35A2; Sat, 29 Jul 2023 07:29:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3FB2860C6D; Sat, 29 Jul 2023 14:29:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DBCAC433C7; Sat, 29 Jul 2023 14:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690640974; bh=cptqgmzc2MqsuyFTFU2BcvHCbSItKXjhvYX4h/bDNYA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hBh7GFKC5+Bijjx67ikbrA0bhNbcHACINAkFfi4Sc5TPplQARAktjuaHCkyZI3lF/ 0qofJZG8P1PCmnAYvGpqy5Wijn4H1P+EJB8vLTlCRm22GvBg9E7I3UzSWayje2CejI fMrGDfZSeg1uBSyU7nmk2w+ZE7cQcmFgUX+rFUEo9pnpEztK6KF61tPsvsO7nj9ts3 K/KWPcWNMbx/ozRx2v9W62OtglY+jDjjqpCRava0kTcdbpytTwx81RuftFgyv8uYpY XRop07KJ1Pim+c++hILTKFd3xD+QLWB9oKmU7fDKixV6Ttai8UpiKbryK69tm/A/YC nrUAdXHIMIsOg== Date: Sat, 29 Jul 2023 23:29:29 +0900 From: Masami Hiramatsu (Google) To: "Paul E. McKenney" Cc: akpm@linux-foundation.org, adobriyan@gmail.com, arnd@kernel.org, ndesaulniers@google.com, sfr@canb.auug.org.au, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments Message-Id: <20230729232929.a3e962f46c16973031bb466c@kernel.org> In-Reply-To: <20230728033701.817094-1-paulmck@kernel.org> References: <197cba95-3989-4d2f-a9f1-8b192ad08c49@paulmck-laptop> <20230728033701.817094-1-paulmck@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" wrote: > In kernels built with CONFIG_BOOT_CONFIG_FORCE=y, /proc/cmdline will > show all kernel boot parameters, both those supplied by the boot loader > and those embedded in the kernel image. This works well for those who > just want to see all of the kernel boot parameters, but is not helpful to > those who need to see only those parameters supplied by the boot loader. > This is especially important when these parameters are presented to the > boot loader by automation that might gather them from diverse sources. > > Therefore, provide a /proc/cmdline_load file that shows only those kernel > boot parameters supplied by the boot loader. If I understand correctly, /proc/cmdline_load is something like /proc/cmdline_load - `/proc/bootconfig | grep ^kernel\\.`. BTW, what about CONFIG_CMDLINE? We already have that Kconfig and it is also merged with the command line specified by boot loader. Should we also expose that? (when CONFIG_CMDLINE_OVERRIDE=y, we don't need it because cmdline is always overridden by the CONFIG_CMDLINE) Unfortunatelly, this option is implemented in each arch init, so we have to change all of them... Thank you, > > Why put this in /proc? Because it is quite similar to /proc/cmdline, so > it makes sense to put it in the same place that /proc/cmdline is located. > > [ sfr: Apply kernel test robot feedback. ] > > Co-developed-by: Stephen Rothwell > Signed-off-by: Stephen Rothwell > Co-developed-by: Arnd Bergmann > Signed-off-by: Arnd Bergmann > Signed-off-by: Paul E. McKenney > Reviewed-by: Nick Desaulniers > Cc: Andrew Morton > Cc: Alexey Dobriyan > Cc: Masami Hiramatsu > Cc: > --- > fs/proc/cmdline.c | 13 +++++++++++++ > include/linux/init.h | 3 ++- > init/main.c | 2 +- > 3 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c > index a6f76121955f..1d0ef9d2949d 100644 > --- a/fs/proc/cmdline.c > +++ b/fs/proc/cmdline.c > @@ -3,6 +3,7 @@ > #include > #include > #include > +#include > #include "internal.h" > > static int cmdline_proc_show(struct seq_file *m, void *v) > @@ -12,6 +13,13 @@ static int cmdline_proc_show(struct seq_file *m, void *v) > return 0; > } > > +static int cmdline_load_proc_show(struct seq_file *m, void *v) > +{ > + seq_puts(m, boot_command_line); > + seq_putc(m, '\n'); > + return 0; > +} > + > static int __init proc_cmdline_init(void) > { > struct proc_dir_entry *pde; > @@ -19,6 +27,11 @@ static int __init proc_cmdline_init(void) > pde = proc_create_single("cmdline", 0, NULL, cmdline_proc_show); > pde_make_permanent(pde); > pde->size = saved_command_line_len + 1; > + if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE)) { > + pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show); > + pde_make_permanent(pde); > + pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1; > + } > return 0; > } > fs_initcall(proc_cmdline_init); > diff --git a/include/linux/init.h b/include/linux/init.h > index 266c3e1640d4..29e75bbe7984 100644 > --- a/include/linux/init.h > +++ b/include/linux/init.h > @@ -112,6 +112,7 @@ > #define __REFCONST .section ".ref.rodata", "a" > > #ifndef __ASSEMBLY__ > + > /* > * Used for initialization calls.. > */ > @@ -143,7 +144,7 @@ struct file_system_type; > > /* Defined in init/main.c */ > extern int do_one_initcall(initcall_t fn); > -extern char __initdata boot_command_line[]; > +extern char boot_command_line[]; FYI, boot_command_line[] is mixture of built-in cmdline string with bootloader cmdline string. > extern char *saved_command_line; > extern unsigned int saved_command_line_len; > extern unsigned int reset_devices; > diff --git a/init/main.c b/init/main.c > index ad920fac325c..2121685c479a 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -135,7 +135,7 @@ EXPORT_SYMBOL(system_state); > void (*__initdata late_time_init)(void); > > /* Untouched command line saved by arch-specific code. */ > -char __initdata boot_command_line[COMMAND_LINE_SIZE]; > +char boot_command_line[COMMAND_LINE_SIZE] __ro_after_init; > /* Untouched saved command line (eg. for /proc) */ > char *saved_command_line __ro_after_init; > unsigned int saved_command_line_len __ro_after_init; > -- > 2.40.1 > -- Masami Hiramatsu (Google)