linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Improve boot command line handling
@ 2019-04-02  9:08 Christophe Leroy
  2019-04-02  9:08 ` [PATCH 1/9] powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline Christophe Leroy
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

The purpose of this series is to improve and enhance the
handling of kernel boot arguments.

It is first focussed on powerpc but also extends the capability
for other arches.

This is based on suggestion from Daniel Walker <danielwa@cisco.com>

Christophe Leroy (9):
  powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline.
  Add generic function to build command line.
  drivers: of: use cmdline building function
  powerpc/prom_init: get rid of PROM_SCRATCH_SIZE
  powerpc: convert to generic builtin command line
  Add capability to prepend the command line
  powerpc: add capability to prepend default command line
  Gives arches opportunity to use generically defined boot cmdline
    manipulation
  powerpc: use generic CMDLINE manipulations

 arch/powerpc/Kconfig                   | 23 ++------------
 arch/powerpc/kernel/prom_init.c        | 38 ++++++++++-------------
 arch/powerpc/kernel/prom_init_check.sh |  2 +-
 drivers/of/fdt.c                       | 23 +++-----------
 include/linux/cmdline.h                | 37 ++++++++++++++++++++++
 init/Kconfig                           | 56 ++++++++++++++++++++++++++++++++++
 6 files changed, 117 insertions(+), 62 deletions(-)
 create mode 100644 include/linux/cmdline.h

-- 
2.13.3


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/9] powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline.
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 2/9] Add generic function to build command line Christophe Leroy
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

Today, powerpc defined CONFIG_CMDLINE for when bootloader doesn't
provide a command line or for overriding it.

On same way as ARM, this patch adds the option of appending the
CONFIG_CMDLINE to bootloader's provided command line.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/Kconfig                   | 21 ++++++++++++++++++++-
 arch/powerpc/kernel/prom_init.c        |  5 ++---
 arch/powerpc/kernel/prom_init_check.sh |  2 +-
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2d0be82c3061..2972348e52be 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -841,14 +841,33 @@ config CMDLINE
 	  some command-line options at build time by entering them here.  In
 	  most cases you will need to specify the root device here.
 
+choice
+	prompt "Kernel command line type" if CMDLINE != ""
+	default CMDLINE_FROM_BOOTLOADER
+	help
+	  Selects the way you want to use the default kernel arguments.
+
+config CMDLINE_FROM_BOOTLOADER
+	bool "Use bootloader kernel arguments if available"
+	help
+	  Uses the command-line options passed by the boot loader. If
+	  the boot loader doesn't provide any, the default kernel command
+	  string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+	bool "Extend bootloader kernel arguments"
+	help
+	  The default kernel command string will be appended to the
+	  command-line arguments provided during boot.
+
 config CMDLINE_FORCE
 	bool "Always use the default kernel command string"
-	depends on CMDLINE_BOOL
 	help
 	  Always use the default kernel command string, even if the boot
 	  loader passes other arguments to the kernel.
 	  This is useful if you cannot or don't want to change the
 	  command-line options your boot loader passes to the kernel.
+endchoice
 
 config EXTRA_TARGETS
 	string "Additional default image types"
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index f33ff4163a51..a6cd52240c58 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -638,9 +638,8 @@ static void __init early_cmdline_parse(void)
 	if ((long)prom.chosen > 0)
 		l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
 #ifdef CONFIG_CMDLINE
-	if (l <= 0 || p[0] == '\0') /* dbl check */
-		strlcpy(prom_cmd_line,
-			CONFIG_CMDLINE, sizeof(prom_cmd_line));
+	if (l <= 0 || p[0] == '\0' || IS_ENABLED(CONFIG_CMDLINE_EXTEND)) /* dbl check */
+		strlcat(prom_cmd_line, CONFIG_CMDLINE, sizeof(prom_cmd_line));
 #endif /* CONFIG_CMDLINE */
 	prom_printf("command line: %s\n", prom_cmd_line);
 
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 667df97d2595..cbcf18846392 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -19,7 +19,7 @@
 WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
 _end enter_prom memcpy memset reloc_offset __secondary_hold
 __secondary_hold_acknowledge __secondary_hold_spinloop __start
-strcmp strcpy strlcpy strlen strncmp strstr kstrtobool logo_linux_clut224
+strcmp strcpy strlcat strlen strncmp strstr kstrtobool logo_linux_clut224
 reloc_got2 kernstart_addr memstart_addr linux_banner _stext
 __prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
 
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/9] Add generic function to build command line.
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
  2019-04-02  9:08 ` [PATCH 1/9] powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 3/9] drivers: of: use cmdline building function Christophe Leroy
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

This code provides architectures with a way to build command line
based on what is built in the kernel and what is handed over by the
bootloader, based on selected compile-time options.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 include/linux/cmdline.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 include/linux/cmdline.h

diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
new file mode 100644
index 000000000000..8610ddf813ff
--- /dev/null
+++ b/include/linux/cmdline.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+/*
+ * This function will append a builtin command line to the command
+ * line provided by the bootloader. Kconfig options can be used to alter
+ * the behavior of this builtin command line.
+ * @dest: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one. Must not equal dest.
+ * @length: the length of dest buffer.
+ */
+static __always_inline void cmdline_build(char *dest, char *src, size_t length)
+{
+	if (length <= 0)
+		return;
+
+	dest[0] = 0;
+
+#ifdef CONFIG_CMDLINE
+	if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !src || !src[0]) {
+		strlcat(dest, CONFIG_CMDLINE, length);
+		return;
+	}
+#endif
+	if (dest != src)
+		strlcat(dest, src, length);
+#ifdef CONFIG_CMDLINE
+	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && sizeof(CONFIG_CMDLINE) > 1)
+		strlcat(dest, " " CONFIG_CMDLINE, length);
+#endif
+}
+
+#endif /* _LINUX_CMDLINE_H */
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/9] drivers: of: use cmdline building function
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
  2019-04-02  9:08 ` [PATCH 1/9] powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline Christophe Leroy
  2019-04-02  9:08 ` [PATCH 2/9] Add generic function to build command line Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 4/9] powerpc/prom_init: get rid of PROM_SCRATCH_SIZE Christophe Leroy
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

This patch uses the new cmdline building function to
concatenate the of provided cmdline with built-in parts
based on compile-time options.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/of/fdt.c        | 23 ++++-------------------
 include/linux/cmdline.h |  2 +-
 2 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 4734223ab702..c6d941785b37 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -24,6 +24,7 @@
 #include <linux/debugfs.h>
 #include <linux/serial_core.h>
 #include <linux/sysfs.h>
+#include <linux/cmdline.h>
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #include <asm/page.h>
@@ -1090,26 +1091,10 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
 
 	/* Retrieve command line */
 	p = of_get_flat_dt_prop(node, "bootargs", &l);
-	if (p != NULL && l > 0)
-		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
+	if (l <= 0)
+		p = NULL;
 
-	/*
-	 * CONFIG_CMDLINE is meant to be a default in case nothing else
-	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
-	 * is set in which case we override whatever was found earlier.
-	 */
-#ifdef CONFIG_CMDLINE
-#if defined(CONFIG_CMDLINE_EXTEND)
-	strlcat(data, " ", COMMAND_LINE_SIZE);
-	strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#elif defined(CONFIG_CMDLINE_FORCE)
-	strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#else
-	/* No arguments from boot loader, use kernel's  cmdl*/
-	if (!((char *)data)[0])
-		strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif
-#endif /* CONFIG_CMDLINE */
+	cmdline_build(data, p, COMMAND_LINE_SIZE);
 
 	pr_debug("Command line is: %s\n", (char*)data);
 
diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
index 8610ddf813ff..afcc00d7628d 100644
--- a/include/linux/cmdline.h
+++ b/include/linux/cmdline.h
@@ -10,7 +10,7 @@
  * @src: The starting string or NULL if there isn't one. Must not equal dest.
  * @length: the length of dest buffer.
  */
-static __always_inline void cmdline_build(char *dest, char *src, size_t length)
+static __always_inline void cmdline_build(char *dest, const char *src, size_t length)
 {
 	if (length <= 0)
 		return;
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/9] powerpc/prom_init: get rid of PROM_SCRATCH_SIZE
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (2 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 3/9] drivers: of: use cmdline building function Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-05-03  6:59   ` Michael Ellerman
  2019-04-02  9:08 ` [PATCH 5/9] powerpc: convert to generic builtin command line Christophe Leroy
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

PROM_SCRATCH_SIZE is same as sizeof(prom_scratch)

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/prom_init.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index a6cd52240c58..d4889ba04ddd 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -154,10 +154,8 @@ static struct prom_t __prombss prom;
 
 static unsigned long __prombss prom_entry;
 
-#define PROM_SCRATCH_SIZE 256
-
 static char __prombss of_stdout_device[256];
-static char __prombss prom_scratch[PROM_SCRATCH_SIZE];
+static char __prombss prom_scratch[256];
 
 static unsigned long __prombss dt_header_start;
 static unsigned long __prombss dt_struct_start, dt_struct_end;
@@ -1486,8 +1484,8 @@ static void __init prom_init_mem(void)
 		endp = p + (plen / sizeof(cell_t));
 
 #ifdef DEBUG_PROM
-		memset(path, 0, PROM_SCRATCH_SIZE);
-		call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
+		memset(path, 0, sizeof(prom_scratch));
+		call_prom("package-to-path", 3, 1, node, path, sizeof(prom_scratch) - 1);
 		prom_debug("  node %s :\n", path);
 #endif /* DEBUG_PROM */
 
@@ -1795,10 +1793,10 @@ static void __init prom_initialize_tce_table(void)
 			local_alloc_bottom = base;
 
 		/* It seems OF doesn't null-terminate the path :-( */
-		memset(path, 0, PROM_SCRATCH_SIZE);
+		memset(path, 0, sizeof(prom_scratch));
 		/* Call OF to setup the TCE hardware */
 		if (call_prom("package-to-path", 3, 1, node,
-			      path, PROM_SCRATCH_SIZE-1) == PROM_ERROR) {
+			      path, sizeof(prom_scratch) - 1) == PROM_ERROR) {
 			prom_printf("package-to-path failed\n");
 		}
 
@@ -2159,14 +2157,14 @@ static void __init prom_check_displays(void)
 
 		/* It seems OF doesn't null-terminate the path :-( */
 		path = prom_scratch;
-		memset(path, 0, PROM_SCRATCH_SIZE);
+		memset(path, 0, sizeof(prom_scratch));
 
 		/*
 		 * leave some room at the end of the path for appending extra
 		 * arguments
 		 */
 		if (call_prom("package-to-path", 3, 1, node, path,
-			      PROM_SCRATCH_SIZE-10) == PROM_ERROR)
+			      sizeof(prom_scratch) - 10) == PROM_ERROR)
 			continue;
 		prom_printf("found display   : %s, opening... ", path);
 		
@@ -2362,8 +2360,8 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
 
 	/* get it again for debugging */
 	path = prom_scratch;
-	memset(path, 0, PROM_SCRATCH_SIZE);
-	call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
+	memset(path, 0, sizeof(prom_scratch));
+	call_prom("package-to-path", 3, 1, node, path, sizeof(prom_scratch) - 1);
 
 	/* get and store all properties */
 	prev_name = "";
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/9] powerpc: convert to generic builtin command line
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (3 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 4/9] powerpc/prom_init: get rid of PROM_SCRATCH_SIZE Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 6/9] Add capability to prepend the " Christophe Leroy
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

This updates the powerpc code to use the new cmdline building function.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/prom_init.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index d4889ba04ddd..08f3db25b2f1 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/initrd.h>
 #include <linux/bitops.h>
+#include <linux/cmdline.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/page.h>
@@ -155,7 +156,7 @@ static struct prom_t __prombss prom;
 static unsigned long __prombss prom_entry;
 
 static char __prombss of_stdout_device[256];
-static char __prombss prom_scratch[256];
+static char __prombss prom_scratch[COMMAND_LINE_SIZE];
 
 static unsigned long __prombss dt_header_start;
 static unsigned long __prombss dt_struct_start, dt_struct_end;
@@ -627,18 +628,14 @@ static unsigned long prom_memparse(const char *ptr, const char **retptr)
 static void __init early_cmdline_parse(void)
 {
 	const char *opt;
+	int l = 0;
 
-	char *p;
-	int l __maybe_unused = 0;
-
-	prom_cmd_line[0] = 0;
-	p = prom_cmd_line;
 	if ((long)prom.chosen > 0)
-		l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
-#ifdef CONFIG_CMDLINE
-	if (l <= 0 || p[0] == '\0' || IS_ENABLED(CONFIG_CMDLINE_EXTEND)) /* dbl check */
-		strlcat(prom_cmd_line, CONFIG_CMDLINE, sizeof(prom_cmd_line));
-#endif /* CONFIG_CMDLINE */
+		l = prom_getprop(prom.chosen, "bootargs", prom_scratch,
+				 COMMAND_LINE_SIZE - 1);
+
+	cmdline_build(prom_cmd_line, l > 0 ? prom_scratch : NULL, sizeof(prom_scratch));
+
 	prom_printf("command line: %s\n", prom_cmd_line);
 
 #ifdef CONFIG_PPC64
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/9] Add capability to prepend the command line
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (4 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 5/9] powerpc: convert to generic builtin command line Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 7/9] powerpc: add capability to prepend default " Christophe Leroy
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

This patchs adds an option of prepend a text to the command
line instead of appending it.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 include/linux/cmdline.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
index afcc00d7628d..5caf3724c1ab 100644
--- a/include/linux/cmdline.h
+++ b/include/linux/cmdline.h
@@ -3,7 +3,7 @@
 #define _LINUX_CMDLINE_H
 
 /*
- * This function will append a builtin command line to the command
+ * This function will append or prepend a builtin command line to the command
  * line provided by the bootloader. Kconfig options can be used to alter
  * the behavior of this builtin command line.
  * @dest: The destination of the final appended/prepended string.
@@ -22,6 +22,9 @@ static __always_inline void cmdline_build(char *dest, const char *src, size_t le
 		strlcat(dest, CONFIG_CMDLINE, length);
 		return;
 	}
+
+	if (IS_ENABLED(CONFIG_CMDLINE_PREPEND) && sizeof(CONFIG_CMDLINE) > 1)
+		strlcat(dest, CONFIG_CMDLINE " ", length);
 #endif
 	if (dest != src)
 		strlcat(dest, src, length);
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/9] powerpc: add capability to prepend default command line
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (5 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 6/9] Add capability to prepend the " Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 8/9] Gives arches opportunity to use generically defined boot cmdline manipulation Christophe Leroy
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

This patch activates the capability to prepend default
arguments to the command line.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2972348e52be..22d6a48bd2ca 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -860,6 +860,12 @@ config CMDLINE_EXTEND
 	  The default kernel command string will be appended to the
 	  command-line arguments provided during boot.
 
+config CMDLINE_PREPEND
+	bool "Prepend bootloader kernel arguments"
+	help
+	  The default kernel command string will be prepend to the
+	  command-line arguments provided during boot.
+
 config CMDLINE_FORCE
 	bool "Always use the default kernel command string"
 	help
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/9] Gives arches opportunity to use generically defined boot cmdline manipulation
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (6 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 7/9] powerpc: add capability to prepend default " Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-04-02  9:08 ` [PATCH 9/9] powerpc: use generic CMDLINE manipulations Christophe Leroy
  2019-12-03  9:12 ` [PATCH 0/9] Improve boot command line handling Christophe Leroy
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

Most arches have similar boot command line manipulation options.
This patchs adds the definition in init/Kconfig, gated by
CONFIG_HAVE_CMDLINE that the arches can select to use them.

In order to use this, a few arches will have to change their
CONFIG options:
- riscv has to replace CMDLINE_FALLBACK by CMDLINE_FROM_BOOTLOADER
- arches using CONFIG_CMDLINE_OVERRIDE or CONFIG_CMDLINE_OVERWRITE
have to replace them by CONFIG_CMDLINE_FORCE

Arches also have to define CONFIG_DEFAULT_CMDLINE

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 init/Kconfig | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/init/Kconfig b/init/Kconfig
index 4592bf7997c0..83537603412c 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -80,6 +80,62 @@ config INIT_ENV_ARG_LIMIT
 	  Maximum of each of the number of arguments and environment
 	  variables passed to init from the kernel command line.
 
+config HAVE_CMDLINE
+	bool
+
+config CMDLINE_BOOL
+	bool "Default bootloader kernel arguments"
+	depends on HAVE_CMDLINE
+	help
+	  On some platforms, there is currently no way for the boot loader to
+	  pass arguments to the kernel. For these platforms, you can supply
+	  some command-line options at build time by entering them here.  In
+	  most cases you will need to specify the root device here.
+
+config CMDLINE
+	string "Initial kernel command string"
+	depends on CMDLINE_BOOL
+	default DEFAULT_CMDLINE
+	help
+	  On some platforms, there is currently no way for the boot loader to
+	  pass arguments to the kernel. For these platforms, you can supply
+	  some command-line options at build time by entering them here.  In
+	  most cases you will need to specify the root device here.
+
+choice
+	prompt "Kernel command line type" if CMDLINE != ""
+	default CMDLINE_FROM_BOOTLOADER
+	help
+	  Selects the way you want to use the default kernel arguments.
+
+config CMDLINE_FROM_BOOTLOADER
+	bool "Use bootloader kernel arguments if available"
+	help
+	  Uses the command-line options passed by the boot loader. If
+	  the boot loader doesn't provide any, the default kernel command
+	  string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+	bool "Extend bootloader kernel arguments"
+	help
+	  The default kernel command string will be appended to the
+	  command-line arguments provided during boot.
+
+config CMDLINE_PREPEND
+	bool "Prepend bootloader kernel arguments"
+	help
+	  The default kernel command string will be prepend to the
+	  command-line arguments provided during boot.
+
+config CMDLINE_FORCE
+	bool "Always use the default kernel command string"
+	help
+	  Always use the default kernel command string, even if the boot
+	  loader passes other arguments to the kernel.
+	  This is useful if you cannot or don't want to change the
+	  command-line options your boot loader passes to the kernel.
+endchoice
+
 config COMPILE_TEST
 	bool "Compile also drivers which will not load"
 	depends on !UML
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 9/9] powerpc: use generic CMDLINE manipulations
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (7 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 8/9] Gives arches opportunity to use generically defined boot cmdline manipulation Christophe Leroy
@ 2019-04-02  9:08 ` Christophe Leroy
  2019-12-03  9:12 ` [PATCH 0/9] Improve boot command line handling Christophe Leroy
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-04-02  9:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-kernel, linuxppc-dev, linux-arch

This patch moves powerpc to the centraly defined CMDLINE options.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/Kconfig | 48 +++---------------------------------------------
 1 file changed, 3 insertions(+), 45 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 22d6a48bd2ca..6a71d7c514cc 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -182,6 +182,7 @@ config PPC
 	select HAVE_CBPF_JIT			if !PPC64
 	select HAVE_STACKPROTECTOR		if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
 	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
+	select HAVE_CMDLINE
 	select HAVE_CONTEXT_TRACKING		if PPC64
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DEBUG_STACKOVERFLOW
@@ -828,52 +829,9 @@ config PPC_DENORMALISATION
 	  Add support for handling denormalisation of single precision
 	  values.  Useful for bare metal only.  If unsure say Y here.
 
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-
-config CMDLINE
-	string "Initial kernel command string"
-	depends on CMDLINE_BOOL
+config DEFAULT_CMDLINE
+	string
 	default "console=ttyS0,9600 console=tty0 root=/dev/sda2"
-	help
-	  On some platforms, there is currently no way for the boot loader to
-	  pass arguments to the kernel. For these platforms, you can supply
-	  some command-line options at build time by entering them here.  In
-	  most cases you will need to specify the root device here.
-
-choice
-	prompt "Kernel command line type" if CMDLINE != ""
-	default CMDLINE_FROM_BOOTLOADER
-	help
-	  Selects the way you want to use the default kernel arguments.
-
-config CMDLINE_FROM_BOOTLOADER
-	bool "Use bootloader kernel arguments if available"
-	help
-	  Uses the command-line options passed by the boot loader. If
-	  the boot loader doesn't provide any, the default kernel command
-	  string provided in CMDLINE will be used.
-
-config CMDLINE_EXTEND
-	bool "Extend bootloader kernel arguments"
-	help
-	  The default kernel command string will be appended to the
-	  command-line arguments provided during boot.
-
-config CMDLINE_PREPEND
-	bool "Prepend bootloader kernel arguments"
-	help
-	  The default kernel command string will be prepend to the
-	  command-line arguments provided during boot.
-
-config CMDLINE_FORCE
-	bool "Always use the default kernel command string"
-	help
-	  Always use the default kernel command string, even if the boot
-	  loader passes other arguments to the kernel.
-	  This is useful if you cannot or don't want to change the
-	  command-line options your boot loader passes to the kernel.
-endchoice
 
 config EXTRA_TARGETS
 	string "Additional default image types"
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/9] powerpc/prom_init: get rid of PROM_SCRATCH_SIZE
  2019-04-02  9:08 ` [PATCH 4/9] powerpc/prom_init: get rid of PROM_SCRATCH_SIZE Christophe Leroy
@ 2019-05-03  6:59   ` Michael Ellerman
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2019-05-03  6:59 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, danielwa
  Cc: linux-arch, linuxppc-dev, linux-kernel

On Tue, 2019-04-02 at 09:08:38 UTC, Christophe Leroy wrote:
> PROM_SCRATCH_SIZE is same as sizeof(prom_scratch)
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/d7fbe2a0439ce6f20917a65990a78c9e

cheers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/9] Improve boot command line handling
  2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
                   ` (8 preceding siblings ...)
  2019-04-02  9:08 ` [PATCH 9/9] powerpc: use generic CMDLINE manipulations Christophe Leroy
@ 2019-12-03  9:12 ` Christophe Leroy
  9 siblings, 0 replies; 12+ messages in thread
From: Christophe Leroy @ 2019-12-03  9:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, danielwa
  Cc: linux-arch, linuxppc-dev, linux-kernel



Le 02/04/2019 à 11:08, Christophe Leroy a écrit :
> The purpose of this series is to improve and enhance the
> handling of kernel boot arguments.
> 
> It is first focussed on powerpc but also extends the capability
> for other arches.
> 
> This is based on suggestion from Daniel Walker <danielwa@cisco.com>

Looks like nobody has been interested in that series.

It doesn't apply anymore and I don't plan to rebase it, I'll retire it.

Christophe


> 
> Christophe Leroy (9):
>    powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline.
>    Add generic function to build command line.
>    drivers: of: use cmdline building function
>    powerpc/prom_init: get rid of PROM_SCRATCH_SIZE
>    powerpc: convert to generic builtin command line
>    Add capability to prepend the command line
>    powerpc: add capability to prepend default command line
>    Gives arches opportunity to use generically defined boot cmdline
>      manipulation
>    powerpc: use generic CMDLINE manipulations
> 
>   arch/powerpc/Kconfig                   | 23 ++------------
>   arch/powerpc/kernel/prom_init.c        | 38 ++++++++++-------------
>   arch/powerpc/kernel/prom_init_check.sh |  2 +-
>   drivers/of/fdt.c                       | 23 +++-----------
>   include/linux/cmdline.h                | 37 ++++++++++++++++++++++
>   init/Kconfig                           | 56 ++++++++++++++++++++++++++++++++++
>   6 files changed, 117 insertions(+), 62 deletions(-)
>   create mode 100644 include/linux/cmdline.h
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-12-03  9:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02  9:08 [PATCH 0/9] Improve boot command line handling Christophe Leroy
2019-04-02  9:08 ` [PATCH 1/9] powerpc: enable appending of CONFIG_CMDLINE to bootloader's cmdline Christophe Leroy
2019-04-02  9:08 ` [PATCH 2/9] Add generic function to build command line Christophe Leroy
2019-04-02  9:08 ` [PATCH 3/9] drivers: of: use cmdline building function Christophe Leroy
2019-04-02  9:08 ` [PATCH 4/9] powerpc/prom_init: get rid of PROM_SCRATCH_SIZE Christophe Leroy
2019-05-03  6:59   ` Michael Ellerman
2019-04-02  9:08 ` [PATCH 5/9] powerpc: convert to generic builtin command line Christophe Leroy
2019-04-02  9:08 ` [PATCH 6/9] Add capability to prepend the " Christophe Leroy
2019-04-02  9:08 ` [PATCH 7/9] powerpc: add capability to prepend default " Christophe Leroy
2019-04-02  9:08 ` [PATCH 8/9] Gives arches opportunity to use generically defined boot cmdline manipulation Christophe Leroy
2019-04-02  9:08 ` [PATCH 9/9] powerpc: use generic CMDLINE manipulations Christophe Leroy
2019-12-03  9:12 ` [PATCH 0/9] Improve boot command line handling Christophe Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).