Skip to contentSkip to conversation

Distinguish bootloader and embedded kernel parameters

RFC PATCH Superseded Paul E. McKenney 5 participants 36 messages Jul 28, 2023 – Aug 20, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Distinguish bootloader and embedded kernel parameters

Hello!

This series provides /proc interfaces parallel to /proc/cmdline that provide only those kernel boot parameters that were provided by the bootloader (/proc/cmdline_load) and only those parameters that were embedded in the kernel image (/proc/cmdline_image, in boot-config format). This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources, and also when a kexec-based reboot process pulls the kernel boot parameters from /proc. If such a reboot process uses /proc/cmdline, the kernel parameters from the image are replicated on every reboot, which can be frustrating when the new kernel has different embedded kernel boot parameters.

Why put these in /proc? Because they is quite similar to /proc/cmdline, so it makes sense to put it in the same place that /proc/cmdline is located.

1. fs/proc: Add /proc/cmdline_load for boot loader arguments.

2. fs/proc: Add /proc/cmdline_image for embedded arguments.

Thanx, Paul

------------------------------------------------------------------------

 b/fs/proc/cmdline.c    |   13 +++++++++++++
 b/include/linux/init.h |    3 ++-
 b/init/main.c          |    2 +-
 fs/proc/cmdline.c      |   12 ++++++++++++
 include/linux/init.h   |   11 ++++++-----
 init/main.c            |    9 +++++++++
 6 files changed, 43 insertions(+), 7 deletions(-)
#1 lore raw

RFC PATCH 1/1 2/2] fs/proc: Add /proc/cmdline_image for embedded arguments

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 that were embedded into the kernel image. This is especially important in situations where there are many kernel images for different kernel versions and kernel configurations, all of which opens the door to a great deal of human error.

Therefore, provide a /proc/cmdline_image file that shows only those kernel boot parameters that were embedded in the kernel image. The output is in boot-image format, which allows easy reconcilation against the boot-config source file.

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.

Cc Andrew Morton <[email protected]>
Cc Alexey Dobriyan <[email protected]>
Cc Masami Hiramatsu <[email protected]>
---
 fs/proc/cmdline.c    | 12 ++++++++++++
 include/linux/init.h | 11 ++++++-----
 init/main.c          |  9 +++++++++
 3 files changed, 27 insertions(+), 5 deletions(-)
fs/proc/cmdline.c +12 -0
index 1d0ef9d2949d..4ab5223198cb 100644
@@ -20,6 +20,15 @@ static int cmdline_load_proc_show(struct seq_file *m, void *v)
 	return 0;
 }
 
+static int cmdline_image_proc_show(struct seq_file *m, void *v)
+{
+#ifdef CONFIG_BOOT_CONFIG_FORCE
+	seq_puts(m, saved_bootconfig_string);
+	seq_putc(m, '\n');
+#endif
+	return 0;
+}
+
 static int __init proc_cmdline_init(void)
 {
 	struct proc_dir_entry *pde;
@@ -31,6 +40,9 @@ static int __init proc_cmdline_init(void)
 		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;
+		pde = proc_create_single("cmdline_image", 0, NULL, cmdline_image_proc_show);
+		pde_make_permanent(pde);
+		pde->size = strnlen(saved_bootconfig_string, COMMAND_LINE_SIZE) + 1;
 	}
 	return 0;
 }
include/linux/init.h +6 -5
index 29e75bbe7984..c075983c5015 100644
@@ -14,7 +14,7 @@
 #define __noinitretpoline
 #endif
 
-/* These macros are used to mark some functions or 
+/* These macros are used to mark some functions or
  * initialized data (doesn't apply to uninitialized data)
  * as `initialization' functions. The kernel can take this
  * as hint that the function is used only during the initialization
@@ -22,7 +22,7 @@
  *
  * Usage:
  * For functions:
- * 
+ *
  * You should add __init immediately before the function name, like:
  *
  * static void __init initme(int x, int y)
@@ -148,6 +148,7 @@ extern char boot_command_line[];
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
+extern char saved_bootconfig_string[];
 
 /* used by init/main.c */
 void setup_arch(char **);
@@ -184,7 +185,7 @@ extern void (*late_time_init)(void);
 extern bool initcall_debug;
 
 #endif
-  
+
 #ifndef MODULE
 
 #ifndef __ASSEMBLY__
@@ -192,8 +193,8 @@ extern bool initcall_debug;
 /*
  * initcalls are now grouped by functionality into separate
  * subsections. Ordering inside the subsections is determined
- * by link order. 
- * For backwards compatibility, initcall() puts the call in 
+ * by link order.
+ * For backwards compatibility, initcall() puts the call in
  * the device init subsection.
  *
  * The `id' arg to __define_initcall() is needed so that multiple initcalls
init/main.c +9 -0
index 2121685c479a..981170da0b1c 100644
@@ -146,6 +146,11 @@ static char *extra_command_line;
 /* Extra init arguments */
 static char *extra_init_args;
 
+/* Untouched boot-config string */
+#ifdef CONFIG_BOOT_CONFIG_FORCE
+char saved_bootconfig_string[COMMAND_LINE_SIZE] __ro_after_init;
+#endif
+
 #ifdef CONFIG_BOOT_CONFIG
 /* Is bootconfig on command line? */
 static bool bootconfig_found;
@@ -435,6 +440,10 @@ static void __init setup_boot_config(void)
 		return;
 	}
 
+#ifdef CONFIG_BOOT_CONFIG_FORCE
+	strncpy(saved_bootconfig_string, data, COMMAND_LINE_SIZE);
+#endif
+
 	if (size >= XBC_DATA_MAX) {
 		pr_err("bootconfig size %ld greater than max size %d\n",
 			(long)size, XBC_DATA_MAX);
Signature · 1 line
2.40.1
#2 lore raw

Re: [PATCH RFC bootconfig] 2/2] fs/proc: Add /proc/cmdline_image for embedded arguments

Hi Paul,

Quoted 8 lines · On Thu, 27 Jul 2023 20:37:01 -0700 "Paul E. McKenney" <[email protected]>…

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 that were embedded into the kernel image. This is especially important in situations where there are many kernel images for different kernel versions and kernel configurations, all of which opens the door to a great deal of human error.

There is /proc/bootconfig file which shows all bootconfig entries and is formatted as easily filter by grep (or any other line-based commands). (e.g. grep ^kernel\\. /proc/cmdline will filter all kernel cmdline parameters in the bootconfig)
Could you clarify the reason why you need a dump of bootconfig file?

Thank you,

Quoted 132 lines

Therefore, provide a /proc/cmdline_image file that shows only those kernel boot parameters that were embedded in the kernel image. The output is in boot-image format, which allows easy reconcilation against the boot-config source file.

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.

Cc Andrew Morton <[email protected]>
Cc Alexey Dobriyan <[email protected]>
Cc Masami Hiramatsu <[email protected]>
---
 fs/proc/cmdline.c    | 12 ++++++++++++
 include/linux/init.h | 11 ++++++-----
 init/main.c          |  9 +++++++++
 3 files changed, 27 insertions(+), 5 deletions(-)
fs/proc/cmdline.c +12 -0
index 1d0ef9d2949d..4ab5223198cb 100644
@@ -20,6 +20,15 @@ static int cmdline_load_proc_show(struct seq_file *m, void *v)
 	return 0;
 }
 
+static int cmdline_image_proc_show(struct seq_file *m, void *v)
+{
+#ifdef CONFIG_BOOT_CONFIG_FORCE
+	seq_puts(m, saved_bootconfig_string);
+	seq_putc(m, '\n');
+#endif
+	return 0;
+}
+
 static int __init proc_cmdline_init(void)
 {
 	struct proc_dir_entry *pde;
@@ -31,6 +40,9 @@ static int __init proc_cmdline_init(void)
 		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;
+		pde = proc_create_single("cmdline_image", 0, NULL, cmdline_image_proc_show);
+		pde_make_permanent(pde);
+		pde->size = strnlen(saved_bootconfig_string, COMMAND_LINE_SIZE) + 1;
 	}
 	return 0;
 }
include/linux/init.h +6 -5
index 29e75bbe7984..c075983c5015 100644
@@ -14,7 +14,7 @@
 #define __noinitretpoline
 #endif
 
-/* These macros are used to mark some functions or 
+/* These macros are used to mark some functions or
  * initialized data (doesn't apply to uninitialized data)
  * as `initialization' functions. The kernel can take this
  * as hint that the function is used only during the initialization
@@ -22,7 +22,7 @@
  *
  * Usage:
  * For functions:
- * 
+ *
  * You should add __init immediately before the function name, like:
  *
  * static void __init initme(int x, int y)
@@ -148,6 +148,7 @@ extern char boot_command_line[];
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
+extern char saved_bootconfig_string[];
 
 /* used by init/main.c */
 void setup_arch(char **);
@@ -184,7 +185,7 @@ extern void (*late_time_init)(void);
 extern bool initcall_debug;
 
 #endif
-  
+
 #ifndef MODULE
 
 #ifndef __ASSEMBLY__
@@ -192,8 +193,8 @@ extern bool initcall_debug;
 /*
  * initcalls are now grouped by functionality into separate
  * subsections. Ordering inside the subsections is determined
- * by link order. 
- * For backwards compatibility, initcall() puts the call in 
+ * by link order.
+ * For backwards compatibility, initcall() puts the call in
  * the device init subsection.
  *
  * The `id' arg to __define_initcall() is needed so that multiple initcalls
init/main.c +9 -0
index 2121685c479a..981170da0b1c 100644
@@ -146,6 +146,11 @@ static char *extra_command_line;
 /* Extra init arguments */
 static char *extra_init_args;
 
+/* Untouched boot-config string */
+#ifdef CONFIG_BOOT_CONFIG_FORCE
+char saved_bootconfig_string[COMMAND_LINE_SIZE] __ro_after_init;
+#endif
+
 #ifdef CONFIG_BOOT_CONFIG
 /* Is bootconfig on command line? */
 static bool bootconfig_found;
@@ -435,6 +440,10 @@ static void __init setup_boot_config(void)
 		return;
 	}
 
+#ifdef CONFIG_BOOT_CONFIG_FORCE
+	strncpy(saved_bootconfig_string, data, COMMAND_LINE_SIZE);
+#endif
+
 	if (size >= XBC_DATA_MAX) {
 		pr_err("bootconfig size %ld greater than max size %d\n",
 			(long)size, XBC_DATA_MAX);
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#3 lore raw

Re: [PATCH RFC bootconfig] 2/2] fs/proc: Add /proc/cmdline_image for embedded arguments

Quoted 14 lines · Masami Hiramatsu

Hi Paul,

Quoted 8 lines · On Thu, 27 Jul 2023 20:37:01 -0700 "Paul E. McKenney" <[email protected]>…

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 that were embedded into the kernel image. This is especially important in situations where there are many kernel images for different kernel versions and kernel configurations, all of which opens the door to a great deal of human error.

Quoted 5 lines

There is /proc/bootconfig file which shows all bootconfig entries and is formatted as easily filter by grep (or any other line-based commands). (e.g. grep ^kernel\\. /proc/cmdline will filter all kernel cmdline parameters in the bootconfig)
Could you clarify the reason why you need a dump of bootconfig file?

Because I was unaware of /proc/bootconfig? ;-)

So how about if I replace this patch of mine with the following?

And thank you for pointing me at /proc/bootconfig.

Thanx, Paul

------------------------------------------------------------------------

Documentation/filesystems/proc.rst +1 -0
index 98c43c5ef1ee..832d66d4e396 100644
@@ -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
#4 lore raw

Re: [PATCH RFC bootconfig] 2/2] fs/proc: Add /proc/cmdline_image for embedded arguments

Quoted 15 lines · On Sat, 29 Jul 2023 08:41:46 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 14 lines · Masami Hiramatsu

Hi Paul,

Quoted 8 lines · On Thu, 27 Jul 2023 20:37:01 -0700 "Paul E. McKenney" <[email protected]>…

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 that were embedded into the kernel image. This is especially important in situations where there are many kernel images for different kernel versions and kernel configurations, all of which opens the door to a great deal of human error.

Quoted 7 lines
Quoted 5 lines

There is /proc/bootconfig file which shows all bootconfig entries and is formatted as easily filter by grep (or any other line-based commands). (e.g. grep ^kernel\\. /proc/cmdline will filter all kernel cmdline parameters in the bootconfig)
Could you clarify the reason why you need a dump of bootconfig file?

Because I was unaware of /proc/bootconfig? ;-)

Oh :)

Quoted 2 lines

So how about if I replace this patch of mine with the following?

Yes, I missed to update the proc.rst. Thanks!

Quoted 19 lines

And thank you for pointing me at /proc/bootconfig.

Thanx, Paul

------------------------------------------------------------------------

Documentation/filesystems/proc.rst +1 -0
index 98c43c5ef1ee..832d66d4e396 100644
@@ -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
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#5 lore raw

Re: [PATCH RFC bootconfig] 2/2] fs/proc: Add /proc/cmdline_image for embedded arguments

In reply to Paul E. McKenney
Quoted 23 lines · Paul E. McKenney

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 that were embedded into the kernel image. This is especially important in situations where there are many kernel images for different kernel versions and kernel configurations, all of which opens the door to a great deal of human error.

Therefore, provide a /proc/cmdline_image file that shows only those kernel boot parameters that were embedded in the kernel image. The output is in boot-image format, which allows easy reconcilation against the boot-config source file.

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.

Cc Andrew Morton <[email protected]>
Cc Alexey Dobriyan <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Quoted 5 lines
---
 fs/proc/cmdline.c    | 12 ++++++++++++
 include/linux/init.h | 11 ++++++-----
 init/main.c          |  9 +++++++++

Same thing,

Please if possible put /proc/x into fs/proc/x.c so that it is easier to find source. Not all /proc follows this convention but still.

I don't like this name too (but less than the other one).
Is it Boot Image Format (BIF). If yes, maybe add it as /proc/cmdline.bif ?

I don't know what's the good name.

#6 lore raw

Re: [PATCH RFC bootconfig] 2/2] fs/proc: Add /proc/cmdline_image for embedded arguments

Quoted 32 lines · Alexey Dobriyan
Quoted 23 lines · Paul E. McKenney

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 that were embedded into the kernel image. This is especially important in situations where there are many kernel images for different kernel versions and kernel configurations, all of which opens the door to a great deal of human error.

Therefore, provide a /proc/cmdline_image file that shows only those kernel boot parameters that were embedded in the kernel image. The output is in boot-image format, which allows easy reconcilation against the boot-config source file.

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.

Cc Andrew Morton <[email protected]>
Cc Alexey Dobriyan <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Quoted 5 lines
---
 fs/proc/cmdline.c    | 12 ++++++++++++
 include/linux/init.h | 11 ++++++-----
 init/main.c          |  9 +++++++++

Same thing,

Quoted 7 lines

Please if possible put /proc/x into fs/proc/x.c so that it is easier to find source. Not all /proc follows this convention but still.

I don't like this name too (but less than the other one).
Is it Boot Image Format (BIF). If yes, maybe add it as /proc/cmdline.bif ?

I don't know what's the good name.

It turns out that the already existing /proc/bootconfig makes this new /proc/bootconfig_image unnecessary, so I have dropped this patch. Imagine my embarrassment upon learning that /proc/bootconfig has been around since v5.5! ;-)

Thanx, Paul

#7 lore raw

RFC PATCH 1/1 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

In reply to Paul E. McKenney

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.

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. ]

---
 fs/proc/cmdline.c    | 13 +++++++++++++
 include/linux/init.h |  3 ++-
 init/main.c          |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)
fs/proc/cmdline.c +13 -0
index a6f76121955f..1d0ef9d2949d 100644
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <asm/setup.h>
 #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);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
2.40.1
#8 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Hi Paul,

Just a couple of nits:

Quoted 2 lines · On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" <[email protected]>…

[ sfr: Apply kernel test robot feedback. ]

This was a fix for my own build testing (I am not a bot (yet) :-)).

include/linux/init.h line 115

Quoted 9 lines
include/linux/init.h +1 -0
index 266c3e1640d4..29e75bbe7984 100644
@@ -112,6 +112,7 @@
 #define __REFCONST       .section       ".ref.rodata", "a"
 
 #ifndef __ASSEMBLY__
+

Please remove this added blank line.

Signature · 2 lines
Cheers,
Stephen Rothwell
#9 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 9 lines · Stephen Rothwell

Hi Paul,

Just a couple of nits:

Quoted 2 lines · On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" <[email protected]>…

[ sfr: Apply kernel test robot feedback. ]

This was a fix for my own build testing (I am not a bot (yet) :-)).

Ah!

This says "Stephen Rothwell made a change in response to kernel test robot feedback". I saw your change and saw the kernel test robot complaint, and gave the robot the benefit of the doubt.

But if you saw this build bug yourself and object to crediting kernel test robot for also spotting it, please let me know and I will remove this line.

Quoted 11 lines

include/linux/init.h line 115

Quoted 9 lines
include/linux/init.h +1 -0
index 266c3e1640d4..29e75bbe7984 100644
@@ -112,6 +112,7 @@
 #define __REFCONST       .section       ".ref.rodata", "a"
 
 #ifndef __ASSEMBLY__
+

Please remove this added blank line.

Good eyes, done!

I should also split out the modifications to include/linux/init.h, which are now whitespace-only, shouldn't I?

Thanx, Paul

#10 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

In reply to Paul E. McKenney

Hi Paul,

Quoted 10 lines · On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" <[email protected]>…

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,

Quoted 73 lines

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. ]

---
 fs/proc/cmdline.c    | 13 +++++++++++++
 include/linux/init.h |  3 ++-
 init/main.c          |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)
fs/proc/cmdline.c +13 -0
index a6f76121955f..1d0ef9d2949d 100644
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <asm/setup.h>
 #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);
include/linux/init.h +1 -0
index 266c3e1640d4..29e75bbe7984 100644
@@ -112,6 +112,7 @@
 #define __REFCONST       .section       ".ref.rodata", "a"
 
 #ifndef __ASSEMBLY__
+
 /*
  * Used for initialization calls..
  */

include/linux/init.h struct file_system_type; · line 147

Quoted 5 lines
include/linux/init.h +1 -1
@@ -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.

Quoted 19 lines
include/linux/init.h +0 -0
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#11 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 13 lines · Masami Hiramatsu

Hi Paul,

Quoted 8 lines · On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" <[email protected]>…

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.

Quoted 5 lines
Quoted 2 lines

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\\..

Yes, very much something like that.

For one use case, suppose you have a kernel that gets some boot parameters from the boot loader and some from bootconfig. If you want to kexec() into a new kernel, you must tell kexec() what the kernel boot parameters are. However, you must *not* tell kexec() about any of the current kernel's parameters that came from bootconfig, because those should instead be supplied by the new kernel being kexec()ed into.

So you must pass in only those parameters that came from the boot loader, hence my proposed /proc/cmdline_load.

Quoted 5 lines

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...

The use case is embedded systems, right? I have no idea whether they have a use case requiring this. Do those sorts of embedded systems use kexec()? (I don't know of any that do, but then again, I haven't been looking.)

This arch init is in setup_arch(), correct? If so, one option is to make start_kernel() or something that it invokes make a copy of the command line just before invoking setup_arch(). Full disclosure: I have not yet looked at all the ins and outs of CONFIG_CMDLINE, so this suggestion should be viewed with appropriate skepticism.

Quoted 76 lines

Thank you,

Quoted 74 lines

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. ]

---
 fs/proc/cmdline.c    | 13 +++++++++++++
 include/linux/init.h |  3 ++-
 init/main.c          |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)
fs/proc/cmdline.c +13 -0
index a6f76121955f..1d0ef9d2949d 100644
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <asm/setup.h>
 #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);
include/linux/init.h +1 -0
index 266c3e1640d4..29e75bbe7984 100644
@@ -112,6 +112,7 @@
 #define __REFCONST       .section       ".ref.rodata", "a"
 
 #ifndef __ASSEMBLY__
+
 /*
  * Used for initialization calls..
  */
@@ -143,7 +144,7 @@ struct file_system_type;
 
Quoted 7 lines

include/linux/init.h struct file_system_type; · line 147

Quoted 4 lines
include/linux/init.h +1 -1
 /* 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.

So if we also need to separate out the CONFIG_CMDLINE arguments, then /proc/cmdline_load will need to come from some string saved off before the CONFIG_CMDLINE processing, correct? I would expect that to be a separate patch series, but if it is needed, I would be happy to look into setting it up, as long as I am in the area.

My tests indicate that boot_command_line[] doesn't contain any bootconfig (and opposed to CONFIG_CMDLINE) arguments, but I could easily have missed some other corner-case configuration.

And thank you for looking this over!

Thanx, Paul

Quoted 23 lines
Quoted 19 lines
include/linux/init.h +0 -0
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#12 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 14 lines · On Sat, 29 Jul 2023 09:16:56 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 13 lines · Masami Hiramatsu

Hi Paul,

Quoted 8 lines · On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" <[email protected]>…

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.

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

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\\..

^^^ /proc/cmdline - /proc/bootconfig | grep ^kernel\\.

Quoted 10 lines

Yes, very much something like that.

For one use case, suppose you have a kernel that gets some boot parameters from the boot loader and some from bootconfig. If you want to kexec() into a new kernel, you must tell kexec() what the kernel boot parameters are. However, you must *not* tell kexec() about any of the current kernel's parameters that came from bootconfig, because those should instead be supplied by the new kernel being kexec()ed into.

Quoted 2 lines

So you must pass in only those parameters that came from the boot loader, hence my proposed /proc/cmdline_load.

Ah, I got it. Indeed, for kexec, we need to drop the options from the bootconfig.

Quoted 11 lines
Quoted 6 lines

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...

The use case is embedded systems, right? I have no idea whether they have a use case requiring this. Do those sorts of embedded systems use kexec()? (I don't know of any that do, but then again, I haven't been looking.)

Not sure, I guess it is possible to use kexec() for kdump or warm reboot, but it should be rare and we can expand this if someone need it.

Quoted 6 lines

This arch init is in setup_arch(), correct? If so, one option is to make start_kernel() or something that it invokes make a copy of the command line just before invoking setup_arch(). Full disclosure: I have not yet looked at all the ins and outs of CONFIG_CMDLINE, so this suggestion should be viewed with appropriate skepticism.

Yeah, maybe it is the best way to do.
Anyway, I understand the reason why we need this interface.

Thank you!

Quoted 122 lines
Quoted 77 lines

Thank you,

Quoted 74 lines

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. ]

---
 fs/proc/cmdline.c    | 13 +++++++++++++
 include/linux/init.h |  3 ++-
 init/main.c          |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)
fs/proc/cmdline.c +13 -0
index a6f76121955f..1d0ef9d2949d 100644
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <asm/setup.h>
 #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);
include/linux/init.h +1 -0
index 266c3e1640d4..29e75bbe7984 100644
@@ -112,6 +112,7 @@
 #define __REFCONST       .section       ".ref.rodata", "a"
 
 #ifndef __ASSEMBLY__
+
 /*
  * Used for initialization calls..
  */
@@ -143,7 +144,7 @@ struct file_system_type;
 
Quoted 7 lines

include/linux/init.h struct file_system_type; · line 147

Quoted 4 lines
include/linux/init.h +1 -1
 /* 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.

So if we also need to separate out the CONFIG_CMDLINE arguments, then /proc/cmdline_load will need to come from some string saved off before the CONFIG_CMDLINE processing, correct? I would expect that to be a separate patch series, but if it is needed, I would be happy to look into setting it up, as long as I am in the area.

My tests indicate that boot_command_line[] doesn't contain any bootconfig (and opposed to CONFIG_CMDLINE) arguments, but I could easily have missed some other corner-case configuration.

And thank you for looking this over!

Thanx, Paul

Quoted 23 lines
Quoted 19 lines
include/linux/init.h +0 -0
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#13 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 17 lines · Masami Hiramatsu
Quoted 14 lines · On Sat, 29 Jul 2023 09:16:56 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 13 lines · Masami Hiramatsu

Hi Paul,

Quoted 8 lines · On Thu, 27 Jul 2023 20:37:00 -0700 "Paul E. McKenney" <[email protected]>…

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.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

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\\..

^^^ /proc/cmdline - /proc/bootconfig | grep ^kernel\\.

Heh! My mind autocorrected without me noticing. ;-)

Quoted 21 lines
Quoted 11 lines

Yes, very much something like that.

For one use case, suppose you have a kernel that gets some boot parameters from the boot loader and some from bootconfig. If you want to kexec() into a new kernel, you must tell kexec() what the kernel boot parameters are. However, you must *not* tell kexec() about any of the current kernel's parameters that came from bootconfig, because those should instead be supplied by the new kernel being kexec()ed into.

So you must pass in only those parameters that came from the boot loader, hence my proposed /proc/cmdline_load.

Ah, I got it. Indeed, for kexec, we need to drop the options from the bootconfig.

Quoted 6 lines
Quoted 5 lines

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...

Quoted 7 lines
Quoted 4 lines

The use case is embedded systems, right? I have no idea whether they have a use case requiring this. Do those sorts of embedded systems use kexec()? (I don't know of any that do, but then again, I haven't been looking.)

Not sure, I guess it is possible to use kexec() for kdump or warm reboot, but it should be rare and we can expand this if someone need it.

Works for me!

Quoted 10 lines
Quoted 5 lines

This arch init is in setup_arch(), correct? If so, one option is to make start_kernel() or something that it invokes make a copy of the command line just before invoking setup_arch(). Full disclosure: I have not yet looked at all the ins and outs of CONFIG_CMDLINE, so this suggestion should be viewed with appropriate skepticism.

Yeah, maybe it is the best way to do.
Anyway, I understand the reason why we need this interface.

Thank you! I will apply your Acked-by on my next rebase.

Thanx, Paul

Quoted 128 lines

Thank you!

Quoted 122 lines
Quoted 77 lines

Thank you,

Quoted 74 lines

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. ]

---
 fs/proc/cmdline.c    | 13 +++++++++++++
 include/linux/init.h |  3 ++-
 init/main.c          |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)
fs/proc/cmdline.c +13 -0
index a6f76121955f..1d0ef9d2949d 100644
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <asm/setup.h>
 #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);
include/linux/init.h +1 -0
index 266c3e1640d4..29e75bbe7984 100644
@@ -112,6 +112,7 @@
 #define __REFCONST       .section       ".ref.rodata", "a"
 
 #ifndef __ASSEMBLY__
+
 /*
  * Used for initialization calls..
  */
@@ -143,7 +144,7 @@ struct file_system_type;
 
Quoted 7 lines

include/linux/init.h struct file_system_type; · line 147

Quoted 4 lines
include/linux/init.h +1 -1
 /* 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.

So if we also need to separate out the CONFIG_CMDLINE arguments, then /proc/cmdline_load will need to come from some string saved off before the CONFIG_CMDLINE processing, correct? I would expect that to be a separate patch series, but if it is needed, I would be happy to look into setting it up, as long as I am in the area.

My tests indicate that boot_command_line[] doesn't contain any bootconfig (and opposed to CONFIG_CMDLINE) arguments, but I could easily have missed some other corner-case configuration.

And thank you for looking this over!

Thanx, Paul

Quoted 23 lines
Quoted 19 lines
include/linux/init.h +0 -0
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#14 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

In reply to Paul E. McKenney
Quoted 22 lines · Paul E. McKenney

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.

fs/proc/cmdline.c +7 -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;

fs/proc/cmdline.c static int __init proc_cmdline_init(void) · line 34

Quoted 8 lines
fs/proc/cmdline.c +5 -0
@@ -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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

#15 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/cmdline.c +7 -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;
Quoted 8 lines

fs/proc/cmdline.c static int __init proc_cmdline_init(void) · line 34

Quoted 5 lines
fs/proc/cmdline.c +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

Thanx, Paul

#16 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 36 lines · Paul E. McKenney
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

(quoted diff) +7 -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;
Quoted 8 lines

Review static int __init proc_cmdline_init(void) · line 34

Quoted 5 lines
(quoted diff) +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Quoted 1 line

Thank you, will do!

And here is an untested sneak preview, which I will fold into the original after testing.

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

fs/proc/Makefile +1 -0
index bd08616ed8ba..094f3102eb9f 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= cmdline_load.o
fs/proc/cmdline.c +0 -12
index 1d0ef9d2949d..082def2c1cc6 100644
@@ -13,13 +13,6 @@ 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;
@@ -27,11 +20,6 @@ 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);
fs/proc/cmdline_load.c new file +25 -0
new file mode 100644
index 000000000000..e3dccb3441ce
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+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_load_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	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_load_init);
#17 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

In reply to Paul E. McKenney
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/cmdline.c +7 -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;
Quoted 8 lines

fs/proc/cmdline.c static int __init proc_cmdline_init(void) · line 34

Quoted 5 lines
fs/proc/cmdline.c +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

Thank you,

Quoted 2 lines

Thanx, Paul

Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#18 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 44 lines · Masami Hiramatsu
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/cmdline.c +7 -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;
Quoted 8 lines

fs/proc/cmdline.c static int __init proc_cmdline_init(void) · line 34

Quoted 5 lines
fs/proc/cmdline.c +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 8 lines
Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

That would work of me!

Any objections to /proc/raw_cmdline?

Going once...

Thanx, Paul

#19 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 52 lines · Paul E. McKenney
Quoted 51 lines · Masami Hiramatsu
Quoted 47 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/cmdline.c +7 -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;
Quoted 8 lines

fs/proc/cmdline.c static int __init proc_cmdline_init(void) · line 34

Quoted 5 lines
fs/proc/cmdline.c +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

Quoted 7 lines
Quoted 1 line

What about "/proc/raw_cmdline" ?

That would work of me!

Any objections to /proc/raw_cmdline?

Going once...

Going twice...

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

Thanx, Paul

author Reviewed-by Nick Desaulniers Acked-by Masami Hiramatsu (Google)
#20 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 57 lines · Paul E. McKenney
Quoted 56 lines · Paul E. McKenney
Quoted 44 lines · Masami Hiramatsu
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

(quoted diff) +7 -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;
Quoted 8 lines

Review static int __init proc_cmdline_init(void) · line 34

Quoted 5 lines
(quoted diff) +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 8 lines
Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

That would work of me!

Quoted 7 lines
Quoted 3 lines

Any objections to /proc/raw_cmdline?

Going once...

Going twice...

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

And gone!

Please see below for the updated version.

Thanx, Paul

------------------------------------------------------------------------

commit 0fe10f0d1873a6f6e287c0c5b45e9203b0e33c83

Author: Paul E. McKenney <[email protected]>
Date:   Fri Jul 21 16:05:38 2023 -0700

fs/proc: Add /proc/raw_cmdline for boot loader arguments

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/raw_cmdline 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, and /proc/bootconfig, so it makes sense to put it in the same place that those files are located.

[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
[ paulmck: Apply naming feedback from Alexey Dobriyan and Masami Hiramatsu. ]

Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..61419270c38f 100644
@@ -723,6 +723,7 @@ files are there, and which are missing.
  partitions   Table of partitions known to the system
  pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
               decoupled by lspci				(2.4)
+ raw_cmdline  Kernel command line obtained from kernel image	(6.6)
  rtc          Real time clock
  scsi         SCSI info (see text)
  slabinfo     Slab pool info
fs/proc/Makefile +1 -0
index bd08616ed8ba..6182296f3c6b 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= raw_cmdline.o
fs/proc/raw_cmdline.c new file +25 -0
new file mode 100644
index 000000000000..2e19eb89fc8e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int raw_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_puts(m, boot_command_line);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+static int __init proc_raw_cmdline_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	pde = proc_create_single("raw_cmdline", 0, NULL, raw_cmdline_proc_show);
+	pde_make_permanent(pde);
+	pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+	return 0;
+}
+fs_initcall(proc_raw_cmdline_init);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
#21 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 62 lines · On Mon, 14 Aug 2023 16:08:29 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 61 lines · Paul E. McKenney
Quoted 59 lines · Paul E. McKenney
Quoted 44 lines · Masami Hiramatsu
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/raw_cmdline.c new file +7 -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;
Quoted 8 lines

fs/proc/raw_cmdline.c line 24

Quoted 5 lines
fs/proc/raw_cmdline.c new file +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 8 lines
Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

That would work of me!

Any objections to /proc/raw_cmdline?

Going once...

Quoted 7 lines
Quoted 3 lines

Going twice...

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

And gone!

Please see below for the updated version.

OK, I'll pick this.

Thanks!

Quoted 131 lines

Thanx, Paul

------------------------------------------------------------------------

commit 0fe10f0d1873a6f6e287c0c5b45e9203b0e33c83

Author: Paul E. McKenney <[email protected]>
Date:   Fri Jul 21 16:05:38 2023 -0700

fs/proc: Add /proc/raw_cmdline for boot loader arguments

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/raw_cmdline 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, and /proc/bootconfig, so it makes sense to put it in the same place that those files are located.

[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
[ paulmck: Apply naming feedback from Alexey Dobriyan and Masami Hiramatsu. ]

Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..61419270c38f 100644
@@ -723,6 +723,7 @@ files are there, and which are missing.
  partitions   Table of partitions known to the system
  pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
               decoupled by lspci				(2.4)
+ raw_cmdline  Kernel command line obtained from kernel image	(6.6)
  rtc          Real time clock
  scsi         SCSI info (see text)
  slabinfo     Slab pool info
fs/proc/Makefile +1 -0
index bd08616ed8ba..6182296f3c6b 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= raw_cmdline.o
fs/proc/raw_cmdline.c new file +25 -0
new file mode 100644
index 000000000000..2e19eb89fc8e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int raw_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_puts(m, boot_command_line);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+static int __init proc_raw_cmdline_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	pde = proc_create_single("raw_cmdline", 0, NULL, raw_cmdline_proc_show);
+	pde_make_permanent(pde);
+	pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+	return 0;
+}
+fs_initcall(proc_raw_cmdline_init);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#22 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 67 lines · On Wed, 16 Aug 2023 18:40:03 +0900 Masami Hiramatsu (Google)…
Quoted 64 lines · On Mon, 14 Aug 2023 16:08:29 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 63 lines · Paul E. McKenney
Quoted 52 lines · Paul E. McKenney
Quoted 51 lines · Masami Hiramatsu
Quoted 47 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/raw_cmdline.c new file +7 -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;
Quoted 8 lines

fs/proc/raw_cmdline.c line 24

Quoted 5 lines
fs/proc/raw_cmdline.c new file +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

Quoted 7 lines
Quoted 1 line

What about "/proc/raw_cmdline" ?

That would work of me!

Any objections to /proc/raw_cmdline?

Going once...

Going twice...

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

And gone!

Please see below for the updated version.

OK, I'll pick this.

Wait, is it OK to push this through bootconfig tree? Since this is not directly related to the bootconfig, fsdevel maintainer can pick this.
I would like to ping to fsdevel people at first.

Thank you,

Quoted 138 lines

Thanks!

Quoted 131 lines

Thanx, Paul

------------------------------------------------------------------------

commit 0fe10f0d1873a6f6e287c0c5b45e9203b0e33c83

Author: Paul E. McKenney <[email protected]>
Date:   Fri Jul 21 16:05:38 2023 -0700

fs/proc: Add /proc/raw_cmdline for boot loader arguments

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/raw_cmdline 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, and /proc/bootconfig, so it makes sense to put it in the same place that those files are located.

[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
[ paulmck: Apply naming feedback from Alexey Dobriyan and Masami Hiramatsu. ]

Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..61419270c38f 100644
@@ -723,6 +723,7 @@ files are there, and which are missing.
  partitions   Table of partitions known to the system
  pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
               decoupled by lspci				(2.4)
+ raw_cmdline  Kernel command line obtained from kernel image	(6.6)
  rtc          Real time clock
  scsi         SCSI info (see text)
  slabinfo     Slab pool info
fs/proc/Makefile +1 -0
index bd08616ed8ba..6182296f3c6b 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= raw_cmdline.o
fs/proc/raw_cmdline.c new file +25 -0
new file mode 100644
index 000000000000..2e19eb89fc8e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int raw_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_puts(m, boot_command_line);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+static int __init proc_raw_cmdline_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	pde = proc_create_single("raw_cmdline", 0, NULL, raw_cmdline_proc_show);
+	pde_make_permanent(pde);
+	pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+	return 0;
+}
+fs_initcall(proc_raw_cmdline_init);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#23 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 71 lines · Masami Hiramatsu
Quoted 69 lines · On Wed, 16 Aug 2023 18:40:03 +0900 Masami Hiramatsu (Google)…
Quoted 67 lines · On Mon, 14 Aug 2023 16:08:29 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 56 lines · Paul E. McKenney
Quoted 55 lines · Paul E. McKenney
Quoted 43 lines · Masami Hiramatsu
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/raw_cmdline.c new file +7 -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;
Quoted 8 lines

fs/proc/raw_cmdline.c line 24

Quoted 5 lines
fs/proc/raw_cmdline.c new file +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 8 lines
Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

That would work of me!

Quoted 7 lines
Quoted 3 lines

Any objections to /proc/raw_cmdline?

Going once...

Going twice...

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

And gone!

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Please see below for the updated version.

OK, I'll pick this.

Wait, is it OK to push this through bootconfig tree? Since this is not directly related to the bootconfig, fsdevel maintainer can pick this.
I would like to ping to fsdevel people at first.

Whichever path works best works for me!

Here are the three commits I have queued, just please let me know when any of them are pulled into some other tree and I will drop them from -rcu.

97edd1291847 ("doc: Update /proc/cmdline documentation to include boot config") 0fe10f0d1873 ("fs/proc: Add /proc/raw_cmdline for boot loader arguments") 9192c6ac7516 ("doc: Add /proc/bootconfig to proc.rst")

Thanx, Paul

Quoted 144 lines

Thank you,

Quoted 138 lines

Thanks!

Quoted 131 lines

Thanx, Paul

------------------------------------------------------------------------

commit 0fe10f0d1873a6f6e287c0c5b45e9203b0e33c83

Author: Paul E. McKenney <[email protected]>
Date:   Fri Jul 21 16:05:38 2023 -0700

fs/proc: Add /proc/raw_cmdline for boot loader arguments

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/raw_cmdline 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, and /proc/bootconfig, so it makes sense to put it in the same place that those files are located.

[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
[ paulmck: Apply naming feedback from Alexey Dobriyan and Masami Hiramatsu. ]

Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..61419270c38f 100644
@@ -723,6 +723,7 @@ files are there, and which are missing.
  partitions   Table of partitions known to the system
  pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
               decoupled by lspci				(2.4)
+ raw_cmdline  Kernel command line obtained from kernel image	(6.6)
  rtc          Real time clock
  scsi         SCSI info (see text)
  slabinfo     Slab pool info
fs/proc/Makefile +1 -0
index bd08616ed8ba..6182296f3c6b 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= raw_cmdline.o
fs/proc/raw_cmdline.c new file +25 -0
new file mode 100644
index 000000000000..2e19eb89fc8e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int raw_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_puts(m, boot_command_line);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+static int __init proc_raw_cmdline_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	pde = proc_create_single("raw_cmdline", 0, NULL, raw_cmdline_proc_show);
+	pde_make_permanent(pde);
+	pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+	return 0;
+}
+fs_initcall(proc_raw_cmdline_init);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#24 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 80 lines · On Wed, 16 Aug 2023 09:13:30 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 71 lines · Masami Hiramatsu
Quoted 69 lines · On Wed, 16 Aug 2023 18:40:03 +0900 Masami Hiramatsu (Google)…
Quoted 67 lines · On Mon, 14 Aug 2023 16:08:29 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 56 lines · Paul E. McKenney
Quoted 55 lines · Paul E. McKenney
Quoted 43 lines · Masami Hiramatsu
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/raw_cmdline.c new file +7 -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;
Quoted 8 lines

fs/proc/raw_cmdline.c line 24

Quoted 5 lines
fs/proc/raw_cmdline.c new file +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 8 lines
Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

That would work of me!

Quoted 7 lines
Quoted 3 lines

Any objections to /proc/raw_cmdline?

Going once...

Going twice...

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

And gone!

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Please see below for the updated version.

OK, I'll pick this.

Wait, is it OK to push this through bootconfig tree? Since this is not directly related to the bootconfig, fsdevel maintainer can pick this.
I would like to ping to fsdevel people at first.

Quoted 8 lines

Whichever path works best works for me!

Here are the three commits I have queued, just please let me know when any of them are pulled into some other tree and I will drop them from -rcu.

97edd1291847 ("doc: Update /proc/cmdline documentation to include boot config") 0fe10f0d1873 ("fs/proc: Add /proc/raw_cmdline for boot loader arguments") 9192c6ac7516 ("doc: Add /proc/bootconfig to proc.rst")

OK, I picked and pushed to linux-trace's bootconfig/for-next branch.

Thank you!

Quoted 147 lines

Thanx, Paul

Quoted 144 lines

Thank you,

Quoted 138 lines

Thanks!

Quoted 131 lines

Thanx, Paul

------------------------------------------------------------------------

commit 0fe10f0d1873a6f6e287c0c5b45e9203b0e33c83

Author: Paul E. McKenney <[email protected]>
Date:   Fri Jul 21 16:05:38 2023 -0700

fs/proc: Add /proc/raw_cmdline for boot loader arguments

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/raw_cmdline 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, and /proc/bootconfig, so it makes sense to put it in the same place that those files are located.

[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
[ paulmck: Apply naming feedback from Alexey Dobriyan and Masami Hiramatsu. ]

Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..61419270c38f 100644
@@ -723,6 +723,7 @@ files are there, and which are missing.
  partitions   Table of partitions known to the system
  pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
               decoupled by lspci				(2.4)
+ raw_cmdline  Kernel command line obtained from kernel image	(6.6)
  rtc          Real time clock
  scsi         SCSI info (see text)
  slabinfo     Slab pool info
fs/proc/Makefile +1 -0
index bd08616ed8ba..6182296f3c6b 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= raw_cmdline.o
fs/proc/raw_cmdline.c new file +25 -0
new file mode 100644
index 000000000000..2e19eb89fc8e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int raw_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_puts(m, boot_command_line);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+static int __init proc_raw_cmdline_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	pde = proc_create_single("raw_cmdline", 0, NULL, raw_cmdline_proc_show);
+	pde_make_permanent(pde);
+	pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+	return 0;
+}
+fs_initcall(proc_raw_cmdline_init);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#25 lore raw

Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments

Quoted 84 lines · Masami Hiramatsu
Quoted 82 lines · On Wed, 16 Aug 2023 09:13:30 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 71 lines · Masami Hiramatsu
Quoted 69 lines · On Wed, 16 Aug 2023 18:40:03 +0900 Masami Hiramatsu (Google)…
Quoted 67 lines · On Mon, 14 Aug 2023 16:08:29 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 56 lines · Paul E. McKenney
Quoted 55 lines · Paul E. McKenney
Quoted 43 lines · Masami Hiramatsu
Quoted 41 lines · On Fri, 4 Aug 2023 10:36:17 -0700 "Paul E. McKenney" <[email protected]> wrote:
Quoted 26 lines · Alexey Dobriyan
Quoted 25 lines · Paul E. McKenney

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.

fs/proc/raw_cmdline.c new file +7 -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;
Quoted 8 lines

fs/proc/raw_cmdline.c line 24

Quoted 5 lines
fs/proc/raw_cmdline.c new file +5 -0
+	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;
+	}

Please add it as separate fs/proc/cmdline_load.c file so that name of the file matches name of the /proc file.

Thank you, will do!

Quoted 2 lines

The name "cmdline_load" is kind of non-descriptive. Mentioning "bootloader" somewhere should improve things.

Quoted 8 lines
Quoted 6 lines

If we can all quickly come to agreement on a name, I can of course easily change it.

/proc/cmdline_bootloader? Better than /proc/cmdline_from_bootloader, I suppose. /proc/cmdline_bootldr? /proc/bootloader by analogy with /proc/bootconfig? Something else?

What about "/proc/raw_cmdline" ?

That would work of me!

Quoted 7 lines
Quoted 3 lines

Any objections to /proc/raw_cmdline?

Going once...

Going twice...

If I don't hear otherwise, /proc/raw_cmdline is is on Monday August 14 PDT.

And gone!

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Please see below for the updated version.

OK, I'll pick this.

Wait, is it OK to push this through bootconfig tree? Since this is not directly related to the bootconfig, fsdevel maintainer can pick this.
I would like to ping to fsdevel people at first.

Whichever path works best works for me!

Quoted 8 lines
Quoted 6 lines

Here are the three commits I have queued, just please let me know when any of them are pulled into some other tree and I will drop them from -rcu.

97edd1291847 ("doc: Update /proc/cmdline documentation to include boot config") 0fe10f0d1873 ("fs/proc: Add /proc/raw_cmdline for boot loader arguments") 9192c6ac7516 ("doc: Add /proc/bootconfig to proc.rst")

OK, I picked and pushed to linux-trace's bootconfig/for-next branch.

Thank you, and I will drop them from -rcu on my next rebase.

Thanx, Paul

Quoted 148 lines
Quoted 144 lines
Quoted 144 lines

Thank you,

Quoted 138 lines

Thanks!

Quoted 131 lines

Thanx, Paul

------------------------------------------------------------------------

commit 0fe10f0d1873a6f6e287c0c5b45e9203b0e33c83

Author: Paul E. McKenney <[email protected]>
Date:   Fri Jul 21 16:05:38 2023 -0700

fs/proc: Add /proc/raw_cmdline for boot loader arguments

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/raw_cmdline 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, and /proc/bootconfig, so it makes sense to put it in the same place that those files are located.

[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
[ paulmck: Apply naming feedback from Alexey Dobriyan and Masami Hiramatsu. ]

Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..61419270c38f 100644
@@ -723,6 +723,7 @@ files are there, and which are missing.
  partitions   Table of partitions known to the system
  pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
               decoupled by lspci				(2.4)
+ raw_cmdline  Kernel command line obtained from kernel image	(6.6)
  rtc          Real time clock
  scsi         SCSI info (see text)
  slabinfo     Slab pool info
fs/proc/Makefile +1 -0
index bd08616ed8ba..6182296f3c6b 100644
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
 proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE)	+= raw_cmdline.o
fs/proc/raw_cmdline.c new file +25 -0
new file mode 100644
index 000000000000..2e19eb89fc8e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int raw_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_puts(m, boot_command_line);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+static int __init proc_raw_cmdline_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	pde = proc_create_single("raw_cmdline", 0, NULL, raw_cmdline_proc_show);
+	pde_make_permanent(pde);
+	pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+	return 0;
+}
+fs_initcall(proc_raw_cmdline_init);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
reviewer
#26 lore raw
In reply to Paul E. McKenney
Quoted 18 lines · Paul E. McKenney

Hello!

This series provides /proc interfaces parallel to /proc/cmdline that provide only those kernel boot parameters that were provided by the bootloader (/proc/cmdline_load) and only those parameters that were embedded in the kernel image (/proc/cmdline_image, in boot-config format). This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources, and also when a kexec-based reboot process pulls the kernel boot parameters from /proc. If such a reboot process uses /proc/cmdline, the kernel parameters from the image are replicated on every reboot, which can be frustrating when the new kernel has different embedded kernel boot parameters.

Why put these in /proc? Because they is quite similar to /proc/cmdline, so it makes sense to put it in the same place that /proc/cmdline is located.

Quoted 6 lines

1. fs/proc: Add /proc/cmdline_load for boot loader arguments.

2. fs/proc: Add /proc/cmdline_image for embedded arguments.

Thanx, Paul

Hi Paul,

This series seems to be missing updates to
Documentation/filesystems/proc.rst.

Please add them.
Thanks.

Quoted 9 lines

------------------------------------------------------------------------

 b/fs/proc/cmdline.c    |   13 +++++++++++++
 b/include/linux/init.h |    3 ++-
 b/init/main.c          |    2 +-
 fs/proc/cmdline.c      |   12 ++++++++++++
 include/linux/init.h   |   11 ++++++-----
 init/main.c            |    9 +++++++++
 6 files changed, 43 insertions(+), 7 deletions(-)
Signature · 1 line
~Randy
#27 lore raw
Quoted 28 lines · Randy Dunlap
Quoted 18 lines · Paul E. McKenney

Hello!

This series provides /proc interfaces parallel to /proc/cmdline that provide only those kernel boot parameters that were provided by the bootloader (/proc/cmdline_load) and only those parameters that were embedded in the kernel image (/proc/cmdline_image, in boot-config format). This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources, and also when a kexec-based reboot process pulls the kernel boot parameters from /proc. If such a reboot process uses /proc/cmdline, the kernel parameters from the image are replicated on every reboot, which can be frustrating when the new kernel has different embedded kernel boot parameters.

Why put these in /proc? Because they is quite similar to /proc/cmdline, so it makes sense to put it in the same place that /proc/cmdline is located.

Quoted 6 lines

1. fs/proc: Add /proc/cmdline_load for boot loader arguments.

2. fs/proc: Add /proc/cmdline_image for embedded arguments.

Thanx, Paul

Quoted 6 lines

Hi Paul,

This series seems to be missing updates to
Documentation/filesystems/proc.rst.

Please add them.

Good catch, thank you!

I will fold the diff below into the three respective commits on my next rebase, but in the meantime, please let me know what you think.

Thanx, Paul

Documentation/filesystems/proc.rst +4 -1
index 7897a7dafcbc..98c43c5ef1ee 100644
@@ -686,7 +686,10 @@ 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
+ cmdline_image Kernel command line obtained from boot loader	(6.6)
+ 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
#28 lore raw

v2 cover Distinguish bootloader and embedded kernel parameters

In reply to Paul E. McKenney

On Thu, Jul 27, 2023 at 08:35:10PM -0700, Paul E. McKenney wrote:
Hello!

This series provides a /proc interface parallel to /proc/cmdline that provides only those kernel boot parameters that were provided by the bootloader in a new /proc/cmdline_load. This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources, and also when a kexec-based reboot process pulls the kernel boot parameters from /proc. If such a reboot process uses /proc/cmdline, the kernel parameters from the image are replicated on every reboot, which can be frustrating when the new kernel has different embedded kernel boot parameters.

Why put these in /proc? Because they is quite similar to /proc/cmdline, so it makes sense to put it in the same place that /proc/cmdline is located.

1. Update /proc/cmdline documentation to include boot config.

2. fs/proc: Add /proc/cmdline_load for boot loader arguments.

3. Add /proc/bootconfig to proc.rst.

Changes since v1:

o Dropped /proc/cmdline_image in favor of the existing
/proc/bootconfig.

o Pulled in fixes from Stephen and Arnd.

o Added documentation for /proc/bootconfig.

Thanx, Paul

------------------------------------------------------------------------

 Documentation/filesystems/proc.rst   |    2 ++
 b/Documentation/filesystems/proc.rst |    3 ++-
 b/fs/proc/cmdline.c                  |   13 +++++++++++++
 b/include/linux/init.h               |    3 ++-
 b/init/main.c                        |    2 +-
 5 files changed, 20 insertions(+), 3 deletions(-)
#29 lore raw

RFC PATCH v2 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.

Cc Masami Hiramatsu <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 Documentation/filesystems/proc.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/filesystems/proc.rst +2 -1
index 7897a7dafcbc..75a8c899ebcc 100644
@@ -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
Signature · 1 line
2.40.1
Acked-by on v2 1/3
#30 lore raw

Re: [PATCH RFC v2 bootconfig 1/3] doc: Update /proc/cmdline documentation to include boot config

Quoted 11 lines · On Mon, 31 Jul 2023 16:31:28 -0700 "Paul E. McKenney" <[email protected]>…

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.

Cc Masami Hiramatsu <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Arnd Bergmann <[email protected]>

Looks good to me.

Thank you!

Quoted 21 lines
---
 Documentation/filesystems/proc.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/filesystems/proc.rst +2 -1
index 7897a7dafcbc..75a8c899ebcc 100644
@@ -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
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
reviewer Reviewed-by on v2 1/3
#31 lore raw

Re: [PATCH RFC v2 bootconfig 1/3] doc: Update /proc/cmdline documentation to include boot config

In reply to Paul E. McKenney
Quoted 11 lines · Paul E. McKenney

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.

Cc Masami Hiramatsu <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Arnd Bergmann <[email protected]>

Thanks.

Quoted 18 lines
---
 Documentation/filesystems/proc.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/filesystems/proc.rst +2 -1
index 7897a7dafcbc..75a8c899ebcc 100644
@@ -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
Signature · 1 line
~Randy
#32 lore raw

Re: [PATCH RFC v2 bootconfig 1/3] doc: Update /proc/cmdline documentation to include boot config

Quoted 13 lines · Randy Dunlap
Quoted 11 lines · Paul E. McKenney

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.

Cc Masami Hiramatsu <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Arnd Bergmann <[email protected]>
Quoted 1 line

Thank you both! I will apply these on my next rebase.

Thanx, Paul

Quoted 23 lines

Thanks.

Quoted 18 lines
---
 Documentation/filesystems/proc.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/filesystems/proc.rst +2 -1
index 7897a7dafcbc..75a8c899ebcc 100644
@@ -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
Signature · 1 line
~Randy
#33 lore raw

RFC PATCH v2 2/3 fs/proc: Add /proc/cmdline_load for boot loader arguments

In reply to Paul E. McKenney

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. ]

---
 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(-)
Documentation/filesystems/proc.rst +1 -0
index 75a8c899ebcc..c2aee55248a8 100644
@@ -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
fs/proc/cmdline.c +13 -0
index a6f76121955f..1d0ef9d2949d 100644
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <asm/setup.h>
 #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);
include/linux/init.h +2 -1
index 266c3e1640d4..29e75bbe7984 100644
@@ -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;
init/main.c +1 -1
index ad920fac325c..2121685c479a 100644
@@ -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;
Signature · 1 line
2.40.1
#34 lore raw

RFC PATCH v2 3/3 doc: Add /proc/bootconfig to proc.rst

In reply to Paul E. McKenney

Add /proc/bootconfig description to Documentation/filesystems/proc.rst.

---
 Documentation/filesystems/proc.rst | 1 +
 1 file changed, 1 insertion(+)
Documentation/filesystems/proc.rst +1 -0
index c2aee55248a8..4b9e9510a53f 100644
@@ -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
Signature · 1 line
2.40.1
Acked-by on v2 3/3
#35 lore raw

Re: [PATCH RFC v2 bootconfig 3/3] doc: Add /proc/bootconfig to proc.rst

Quoted 2 lines · On Mon, 31 Jul 2023 16:31:30 -0700 "Paul E. McKenney" <[email protected]>…

Add /proc/bootconfig description to Documentation/filesystems/proc.rst.

Looks good to me.

Thank you!

Quoted 21 lines
---
 Documentation/filesystems/proc.rst | 1 +
 1 file changed, 1 insertion(+)
Documentation/filesystems/proc.rst +1 -0
index c2aee55248a8..4b9e9510a53f 100644
@@ -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
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>