From patchwork Mon Jul 31 23:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13335584 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D281C04A94 for ; Mon, 31 Jul 2023 23:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbjGaXbg (ORCPT ); Mon, 31 Jul 2023 19:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjGaXbe (ORCPT ); Mon, 31 Jul 2023 19:31:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4399D9D; Mon, 31 Jul 2023 16:31:33 -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)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC2416134A; Mon, 31 Jul 2023 23:31:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36C11C433C7; Mon, 31 Jul 2023 23:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690846292; bh=s85dfC0gVX9LRkZN5h09FQbiR2t0JYr2MrKPIlxbVnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F+rBgbTUY0UZIQvFwc+M/+SHf9TmnxFH13Z8YWu+NDbQLTPeTxWFlePv7HhNYMHza cA1i7W2AyLyQQ4sW/FpuD01ARyra/nEut90ycndCYet/ahqE9uFNLYt3VbrSYln32/ PATYHIknqclGbRhr7KHahVHmRIsqYYCIkzOOv3Yn20Hh7RW1Yy6ak1SHQfX4VVdEAG qefZ108MO80zOudxfXnIFFnaMzCPDyMITpTAtO+HclVc+9D94xdOAjGSZvkTu3bvWz icYZIkkyn24jvqw1A5r5RVc8JQa2gGhnVDRA50/2agG+5adJmayO/jTUDzSfJDq2QQ 7S5faM7jC59Aw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D90B2CE1065; Mon, 31 Jul 2023 16:31:31 -0700 (PDT) From: "Paul E. McKenney" To: akpm@linux-foundation.org, adobriyan@gmail.com, mhiramat@kernel.org Cc: arnd@kernel.org, ndesaulniers@google.com, paulmck@kernel.org, sfr@canb.auug.org.au, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Jonathan Corbet , Randy Dunlap Subject: [PATCH RFC v2 bootconfig 1/3] doc: Update /proc/cmdline documentation to include boot config Date: Mon, 31 Jul 2023 16:31:28 -0700 Message-Id: <20230731233130.424913-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Update the /proc/cmdline documentation to explicitly state that this file provides kernel boot parameters obtained via boot config from the kernel image as well as those supplied by the boot loader. Signed-off-by: Paul E. McKenney Cc: Masami Hiramatsu Cc: Jonathan Corbet Cc: Andrew Morton Cc: Randy Dunlap Cc: Stephen Rothwell Cc: Arnd Bergmann Acked-by: Masami Hiramatsu (Google) Reviewed-by: Randy Dunlap --- Documentation/filesystems/proc.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 7897a7dafcbc..75a8c899ebcc 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -686,7 +686,8 @@ files are there, and which are missing. apm Advanced power management info buddyinfo Kernel memory allocator information (see text) (2.5) bus Directory containing bus specific information - cmdline Kernel command line + cmdline Kernel command line, both from bootloader and embedded + in the kernel image. cpuinfo Info about the CPU devices Available devices (block and character) dma Used DMS channels From patchwork Mon Jul 31 23:31:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13335585 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D749BC001DE for ; Mon, 31 Jul 2023 23:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbjGaXbj (ORCPT ); Mon, 31 Jul 2023 19:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbjGaXbf (ORCPT ); Mon, 31 Jul 2023 19:31:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67C7DB0; Mon, 31 Jul 2023 16:31:33 -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)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ED6CD61344; Mon, 31 Jul 2023 23:31:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B9CBC433C8; Mon, 31 Jul 2023 23:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690846292; bh=oBlm+F0ijC5y9fHYb2ho/VBeeyMvwj2PDTDIl0glh0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLJjIaah3/akgIa59dh1oK+umdaeOkJa7PujX/sI4ogfjwWtneSQt8NYmf2LiITM1 tQ+Y3GPbMMKGw4odgc/2a9Ikw2j0fvzKhbYSIzGAvu9ecI6tQSB0n6XnxTRC5T7/iB v5PJrDo/8ZtGZGr64a+vulEx0oSH1nLnMtwC6PUQlP3CYYqa0yCe1FJ892NTUsCfod 8k//LrxEdlfLTDR078y69GN1kwj002Ol2TaUPj/HKH7tIG4fqcY6GIVgwZ7+zpo2fD CIgbi0YcxHint6U3kVnSZEuOKfQy/TvAv7yiO8x/vj13c2gCaRux+Nr5gQ4lcy+fai I3nLu02nMS5mw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DC2CBCE1066; Mon, 31 Jul 2023 16:31:31 -0700 (PDT) From: "Paul E. McKenney" To: akpm@linux-foundation.org, adobriyan@gmail.com, mhiramat@kernel.org Cc: arnd@kernel.org, ndesaulniers@google.com, paulmck@kernel.org, sfr@canb.auug.org.au, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH RFC v2 bootconfig 2/3] fs/proc: Add /proc/cmdline_load for boot loader arguments Date: Mon, 31 Jul 2023 16:31:29 -0700 Message-Id: <20230731233130.424913-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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. It is also useful when booting the next kernel via kexec(), in which case it is necessary to supply only those kernel command-line arguments from the boot loader, and most definitely not those that were embedded into the current kernel. Therefore, provide a /proc/cmdline_load file that shows only those kernel boot parameters supplied by the boot loader. 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. ] [ paulmck: Apply Randy Dunlap 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 Acked-by: Masami Hiramatsu (Google) Cc: Andrew Morton Cc: Alexey Dobriyan Cc: --- Documentation/filesystems/proc.rst | 1 + fs/proc/cmdline.c | 13 +++++++++++++ include/linux/init.h | 3 ++- init/main.c | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 75a8c899ebcc..c2aee55248a8 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -688,6 +688,7 @@ files are there, and which are missing. bus Directory containing bus specific information cmdline Kernel command line, both from bootloader and embedded in the kernel image. + cmdline_load Kernel command line obtained from kernel image (6.6) cpuinfo Info about the CPU devices Available devices (block and character) dma Used DMS channels 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[]; 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; From patchwork Mon Jul 31 23:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13335583 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 285EDC001DE for ; Mon, 31 Jul 2023 23:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjGaXbf (ORCPT ); Mon, 31 Jul 2023 19:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbjGaXbe (ORCPT ); Mon, 31 Jul 2023 19:31:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 713A2FB; Mon, 31 Jul 2023 16:31:33 -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)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0B8596135E; Mon, 31 Jul 2023 23:31:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61741C433CB; Mon, 31 Jul 2023 23:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690846292; bh=YpimYS7/JiWJ9sUlx73FOpDcr/5hAhkaCEvZwoTqg8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L7f0p3ZbbIPxqN+cnCzOLBFfIh3N2zyO1xrKCYs9SRe+1iyiKaDo2FvoeWuDlqqkY AsgWSqvKVRKUWFhD3TD76OCrahkPFztLGrP+H0AeByt+6KUVZGDFht1xGdh4FkjoSc XbELuDf8jAqYuQEKsBvaeQMUdNAx6gfq6tMUIY0U0HmUawT24apEysSUAN70RLnZ8z vtmLSL93ei02YvbmB4sGznaTlVmxWS3p+X1ShJRVJKJn3I/lMjueIBW4xyDH+zgpuW 2D9e/OrbaJDBxGrBqDDQ+tCVMimRUECgmiwVbe4SGdc5VXH0sQytOT7hSJFqpYmdiu GgsGnRJJUCtdw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DE949CE109C; Mon, 31 Jul 2023 16:31:31 -0700 (PDT) From: "Paul E. McKenney" To: akpm@linux-foundation.org, adobriyan@gmail.com, mhiramat@kernel.org Cc: arnd@kernel.org, ndesaulniers@google.com, paulmck@kernel.org, sfr@canb.auug.org.au, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH RFC v2 bootconfig 3/3] doc: Add /proc/bootconfig to proc.rst Date: Mon, 31 Jul 2023 16:31:30 -0700 Message-Id: <20230731233130.424913-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add /proc/bootconfig description to Documentation/filesystems/proc.rst. Reported-by: Masami Hiramatsu Signed-off-by: Paul E. McKenney Acked-by: Masami Hiramatsu (Google) --- Documentation/filesystems/proc.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index c2aee55248a8..4b9e9510a53f 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -684,6 +684,7 @@ files are there, and which are missing. File Content ============ =============================================================== apm Advanced power management info + bootconfig Kernel command line obtained from boot config (5.5) buddyinfo Kernel memory allocator information (see text) (2.5) bus Directory containing bus specific information cmdline Kernel command line, both from bootloader and embedded