From 1c20c65ea03293bcb08765d320ae32a27b56224b Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Thu, 5 Oct 2023 10:17:45 -0700 Subject: [PATCH 1/3] doc: Update /proc/cmdline documentation to include boot config 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. Link: https://lore.kernel.org/all/20231005171747.541123-1-paulmck@kernel.org/ Signed-off-by: Paul E. McKenney Acked-by: Masami Hiramatsu (Google) Reviewed-by: Randy Dunlap Cc: Jonathan Corbet Cc: Andrew Morton Cc: Stephen Rothwell Cc: Arnd Bergmann Signed-off-by: Masami Hiramatsu (Google) --- 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 2b59cff8be17..36da7038a1c9 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -691,7 +691,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 717c7c894d4b885e879790f14afbe630802d77d7 Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Thu, 5 Oct 2023 10:17:46 -0700 Subject: [PATCH 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig 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, add comments to /proc/bootconfig of the form: # Parameters from bootloader: # root=UUID=ac0f0548-a69d-43ca-a06b-7db01bcbd5ad ro quiet ... The second added line shows only those kernel boot parameters supplied by the boot loader. Link: https://lore.kernel.org/all/20231005171747.541123-2-paulmck@kernel.org/ Link: https://lore.kernel.org/all/CAHk-=wjpVAW3iRq_bfKnVfs0ZtASh_aT67bQBG11b4W6niYVUw@mail.gmail.com/ Link: https://lore.kernel.org/all/20230731233130.424913-1-paulmck@kernel.org/ Co-developed-by: Masami Hiramatsu Signed-off-by: Paul E. McKenney Cc: Linus Torvalds Cc: Stephen Rothwell Cc: Arnd Bergmann Cc: Nick Desaulniers Cc: Alexey Dobriyan Cc: Andrew Morton Cc: Kees Cook Cc: Cc: Acked-by: Masami Hiramatsu (Google) Signed-off-by: Masami Hiramatsu (Google) --- fs/proc/bootconfig.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c index 2e244ada1f97..902b326e1e56 100644 --- a/fs/proc/bootconfig.c +++ b/fs/proc/bootconfig.c @@ -62,6 +62,12 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size) break; dst += ret; } + if (ret >= 0 && boot_command_line[0]) { + ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n", + boot_command_line); + if (ret > 0) + dst += ret; + } } out: kfree(key); From acbc3ecb806e24eb9c0cafc29e0884490dda6169 Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Thu, 5 Oct 2023 10:17:47 -0700 Subject: [PATCH 3/3] doc: Add /proc/bootconfig to proc.rst Add /proc/bootconfig description to Documentation/filesystems/proc.rst. Link: https://lore.kernel.org/all/20231005171747.541123-3-paulmck@kernel.org/ Reported-by: Masami Hiramatsu Signed-off-by: Paul E. McKenney Acked-by: Masami Hiramatsu (Google) Signed-off-by: Masami Hiramatsu (Google) --- Documentation/filesystems/proc.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 36da7038a1c9..49ef12df631b 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -689,6 +689,11 @@ files are there, and which are missing. File Content ============ =============================================================== apm Advanced power management info + bootconfig Kernel command line obtained from boot config, + and, if there were kernel parameters from the + boot loader, a "# Parameters from bootloader:" + line followed by a line containing those + parameters prefixed by "# ". (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