Skip to contentSkip to conversation

Implement GENERIC_CMDLINE

PATCH Superseded Christophe Leroy 7 participants 40 messages Mar 26, 2021 – Apr 2, 2021

Subsystems (16)
Arm (32-bit) x86 PowerPC MIPS +12 more subsystems

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Implement GENERIC_CMDLINE

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 <[email protected]>

Main changes in V3:
- Also accept destination equal to source in cmdline_build() by setting a tmp buffer in __initdata. Powerpc provides different source and destination and call __cmdline_build() directly.
- Taken comments received from Will and Rob
- Converted all architectures (Only tested on powerpc)

Christophe Leroy (17):
cmdline: Add generic function to build command line.
drivers: of: use cmdline building function
cmdline: Gives architectures opportunity to use generically defined
boot cmdline manipulation
powerpc: Convert to GENERIC_CMDLINE
arm: Convert to GENERIC_CMDLINE
arm64: Convert to GENERIC_CMDLINE
hexagon: Convert to GENERIC_CMDLINE
microblaze: Convert to GENERIC_CMDLINE
nios2: Convert to GENERIC_CMDLINE
openrisc: Convert to GENERIC_CMDLINE
riscv: Convert to GENERIC_CMDLINE
sh: Convert to GENERIC_CMDLINE
sparc: Convert to GENERIC_CMDLINE
xtensa: Convert to GENERIC_CMDLINE
x86: Convert to GENERIC_CMDLINE
mips: Convert to GENERIC_CMDLINE
cmdline: Remove CONFIG_CMDLINE_EXTEND

 arch/arm/Kconfig                            | 38 +-------------
 arch/arm/kernel/atags_parse.c               | 15 ++----
 arch/arm64/Kconfig                          | 33 +-----------
 arch/arm64/kernel/idreg-override.c          |  9 ++--
 arch/hexagon/Kconfig                        | 11 +---
 arch/hexagon/kernel/setup.c                 | 10 +---
 arch/microblaze/Kconfig                     | 24 +--------
 arch/microblaze/configs/mmu_defconfig       |  2 +-
 arch/microblaze/kernel/head.S               |  4 +-
 arch/mips/Kconfig                           |  1 +
 arch/mips/Kconfig.debug                     | 44 ----------------
 arch/mips/configs/ar7_defconfig             |  1 -
 arch/mips/configs/bcm47xx_defconfig         |  1 -
 arch/mips/configs/bcm63xx_defconfig         |  1 -
 arch/mips/configs/bmips_be_defconfig        |  1 -
 arch/mips/configs/bmips_stb_defconfig       |  1 -
 arch/mips/configs/capcella_defconfig        |  1 -
 arch/mips/configs/ci20_defconfig            |  1 -
 arch/mips/configs/cu1000-neo_defconfig      |  1 -
 arch/mips/configs/cu1830-neo_defconfig      |  1 -
 arch/mips/configs/e55_defconfig             |  1 -
 arch/mips/configs/generic_defconfig         |  1 -
 arch/mips/configs/gpr_defconfig             |  1 -
 arch/mips/configs/loongson3_defconfig       |  1 -
 arch/mips/configs/mpc30x_defconfig          |  1 -
 arch/mips/configs/rt305x_defconfig          |  1 -
 arch/mips/configs/tb0219_defconfig          |  1 -
 arch/mips/configs/tb0226_defconfig          |  1 -
 arch/mips/configs/tb0287_defconfig          |  1 -
 arch/mips/configs/workpad_defconfig         |  1 -
 arch/mips/configs/xway_defconfig            |  1 -
 arch/mips/kernel/relocate.c                 |  4 +-
 arch/mips/kernel/setup.c                    | 40 +--------------
 arch/mips/pic32/pic32mzda/early_console.c   |  2 +-
 arch/mips/pic32/pic32mzda/init.c            |  2 -
 arch/nios2/Kconfig                          | 24 +--------
 arch/nios2/kernel/setup.c                   | 13 ++---
 arch/openrisc/Kconfig                       | 10 +---
 arch/powerpc/Kconfig                        | 37 +------------
 arch/powerpc/kernel/prom_init.c             | 17 +++---
 arch/riscv/Kconfig                          | 44 +---------------
 arch/riscv/kernel/setup.c                   |  5 +-
 arch/sh/Kconfig                             | 30 +----------
 arch/sh/configs/ap325rxa_defconfig          |  2 +-
 arch/sh/configs/dreamcast_defconfig         |  2 +-
 arch/sh/configs/ecovec24-romimage_defconfig |  2 +-
 arch/sh/configs/ecovec24_defconfig          |  2 +-
 arch/sh/configs/edosk7760_defconfig         |  2 +-
 arch/sh/configs/espt_defconfig              |  2 +-
 arch/sh/configs/j2_defconfig                |  2 +-
 arch/sh/configs/kfr2r09-romimage_defconfig  |  2 +-
 arch/sh/configs/kfr2r09_defconfig           |  2 +-
 arch/sh/configs/lboxre2_defconfig           |  2 +-
 arch/sh/configs/microdev_defconfig          |  2 +-
 arch/sh/configs/migor_defconfig             |  2 +-
 arch/sh/configs/polaris_defconfig           |  2 +-
 arch/sh/configs/r7780mp_defconfig           |  2 +-
 arch/sh/configs/r7785rp_defconfig           |  2 +-
 arch/sh/configs/rsk7201_defconfig           |  2 +-
 arch/sh/configs/rsk7203_defconfig           |  2 +-
 arch/sh/configs/rts7751r2d1_defconfig       |  2 +-
 arch/sh/configs/rts7751r2dplus_defconfig    |  2 +-
 arch/sh/configs/sdk7780_defconfig           |  2 +-
 arch/sh/configs/sdk7786_defconfig           |  2 +-
 arch/sh/configs/se7206_defconfig            |  2 +-
 arch/sh/configs/se7343_defconfig            |  2 +-
 arch/sh/configs/se7712_defconfig            |  2 +-
 arch/sh/configs/se7721_defconfig            |  2 +-
 arch/sh/configs/se7724_defconfig            |  2 +-
 arch/sh/configs/se7751_defconfig            |  2 +-
 arch/sh/configs/se7780_defconfig            |  2 +-
 arch/sh/configs/sh03_defconfig              |  2 +-
 arch/sh/configs/sh2007_defconfig            |  2 +-
 arch/sh/configs/sh7757lcr_defconfig         |  2 +-
 arch/sh/configs/sh7763rdp_defconfig         |  2 +-
 arch/sh/configs/shmin_defconfig             |  2 +-
 arch/sh/configs/shx3_defconfig              |  2 +-
 arch/sh/configs/titan_defconfig             |  2 +-
 arch/sh/configs/ul2_defconfig               |  2 +-
 arch/sh/kernel/setup.c                      | 11 +---
 arch/sparc/Kconfig                          | 18 +------
 arch/sparc/prom/bootstr_64.c                |  2 +-
 arch/x86/Kconfig                            | 45 +---------------
 arch/x86/kernel/setup.c                     | 17 +-----
 arch/xtensa/Kconfig                         | 15 +-----
 arch/xtensa/configs/audio_kc705_defconfig   |  1 -
 arch/xtensa/configs/common_defconfig        |  1 -
 arch/xtensa/configs/generic_kc705_defconfig |  1 -
 arch/xtensa/configs/iss_defconfig           |  1 -
 arch/xtensa/configs/nommu_kc705_defconfig   |  1 -
 arch/xtensa/configs/smp_lx200_defconfig     |  1 -
 arch/xtensa/configs/virt_defconfig          |  1 -
 arch/xtensa/configs/xip_kc705_defconfig     |  1 -
 arch/xtensa/kernel/setup.c                  | 10 +---
 drivers/firmware/efi/libstub/x86-stub.c     | 26 +++++-----
 drivers/of/fdt.c                            | 23 ++-------
 include/linux/cmdline.h                     | 57 +++++++++++++++++++++
 init/Kconfig                                | 46 +++++++++++++++++
 98 files changed, 209 insertions(+), 580 deletions(-)
 create mode 100644 include/linux/cmdline.h
Signature · 1 line
2.25.0
#1 lore raw

PATCH v3 1/17 cmdline: Add generic function to build command line.

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.

---
v3:
- Addressed comments from Will
- Added capability to have src == dst

---
 include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 include/linux/cmdline.h
include/linux/cmdline.h new file +57 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */
+static __always_inline void __cmdline_build(char *dst, const char *src, size_t len)
+{
+	if (!len || src == dst)
+		return;
+
+	if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !src) {
+		dst[0] = 0;
+		cmdline_strlcat(dst, CONFIG_CMDLINE, len);
+		return;
+	}
+
+	if (dst != src)
+		dst[0] = 0;
+
+	if (IS_ENABLED(CONFIG_CMDLINE_PREPEND))
+		cmdline_strlcat(dst, CONFIG_CMDLINE " ", len);
+
+	cmdline_strlcat(dst, src, len);
+
+	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+		cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
+}
+
+#define cmdline_build(dst, src, len) do {				\
+	char *__c_dst = (dst);						\
+	const char *__c_src = (src);					\
+									\
+	if (__c_src == __c_dst) {					\
+		static char __c_tmp[COMMAND_LINE_SIZE] __initdata = "";	\
+									\
+		cmdline_strlcat(__c_tmp, __c_src, COMMAND_LINE_SIZE);	\
+		__cmdline_build(__c_dst, __c_tmp, (len));		\
+	} else {							\
+		__cmdline_build(__c_dst, __c_src, (len));		\
+	}								\
+} while (0)
+
+#endif /* _LINUX_CMDLINE_H */
Signature · 1 line
2.25.0
maintainer
#2 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

Quoted 4 lines · Christophe Leroy

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.

Note that I have this patch pending:

https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/

It's going to need to be adapted for this. I've held off applying to see if this gets settled.

Quoted 46 lines

---
v3:
- Addressed comments from Will
- Added capability to have src == dst

---
 include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 include/linux/cmdline.h
include/linux/cmdline.h new file +29 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */
+static __always_inline void __cmdline_build(char *dst, const char *src, size_t len)
+{
+       if (!len || src == dst)
+               return;
+
+       if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !src) {
+               dst[0] = 0;
+               cmdline_strlcat(dst, CONFIG_CMDLINE, len);
+               return;
+       }

include/linux/cmdline.h line 39

Quoted 10 lines
include/linux/cmdline.h new file +10 -0
+
+       if (dst != src)
+               dst[0] = 0;
+
+       if (IS_ENABLED(CONFIG_CMDLINE_PREPEND))
+               cmdline_strlcat(dst, CONFIG_CMDLINE " ", len);
+
+       cmdline_strlcat(dst, src, len);
+
+       if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))

Should be APPEND.

include/linux/cmdline.h line 43

Quoted 4 lines
include/linux/cmdline.h new file +4 -0
+               cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
+}
+
+#define cmdline_build(dst, src, len) do {                              \

Perhaps a comment why we need this to be a define.

Quoted 17 lines
include/linux/cmdline.h new file +14 -1
+       char *__c_dst = (dst);                                          \
+       const char *__c_src = (src);                                    \
+                                                                       \
+       if (__c_src == __c_dst) {                                       \
+               static char __c_tmp[COMMAND_LINE_SIZE] __initdata = ""; \
+                                                                       \
+               cmdline_strlcat(__c_tmp, __c_src, COMMAND_LINE_SIZE);   \
+               __cmdline_build(__c_dst, __c_tmp, (len));               \
+       } else {                                                        \
+               __cmdline_build(__c_dst, __c_src, (len));               \
+       }                                                               \
+} while (0)
+
+#endif /* _LINUX_CMDLINE_H */
--

2.25.0

#3 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

Le 26/03/2021 à 16:42, Rob Herring a écrit :

Quoted 7 lines
Quoted 4 lines · Christophe Leroy

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.

Quoted 6 lines

Note that I have this patch pending:

https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/

It's going to need to be adapted for this. I've held off applying to see if this gets settled.

good point.

Hope we can't have things like

option="beautiful weather"

Quoted 51 lines
Quoted 51 lines

---
v3:
- Addressed comments from Will
- Added capability to have src == dst

---
  include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 57 insertions(+)

create mode 100644 include/linux/cmdline.h

include/linux/cmdline.h new file +33 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */
+static __always_inline void __cmdline_build(char *dst, const char *src, size_t len)
+{
+       if (!len || src == dst)
+               return;
+
+       if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !src) {
+               dst[0] = 0;
+               cmdline_strlcat(dst, CONFIG_CMDLINE, len);
+               return;
+       }
+
+       if (dst != src)
+               dst[0] = 0;
+
Quoted 8 lines

include/linux/cmdline.h line 39

Quoted 6 lines
include/linux/cmdline.h new file +6 -0
+       if (IS_ENABLED(CONFIG_CMDLINE_PREPEND))
+               cmdline_strlcat(dst, CONFIG_CMDLINE " ", len);
+
+       cmdline_strlcat(dst, src, len);
+
+       if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))

Should be APPEND.

Not yet. For the time being all architectures use EXTEND only.

In patch 3 it is changed to:

- if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+ if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || IS_ENABLED(CONFIG_CMDLINE_APPEND))

Then in last patch, I forgot but I should have done:

- if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || IS_ENABLED(CONFIG_CMDLINE_APPEND))
+ if (IS_ENABLED(CONFIG_CMDLINE_APPEND))

Quoted 7 lines

include/linux/cmdline.h line 43

Quoted 5 lines
include/linux/cmdline.h new file +4 -0
+               cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
+}
+
+#define cmdline_build(dst, src, len) do {                              \

Perhaps a comment why we need this to be a define.

Probably we don't need anymore as I finally decided to use COMMAND_LINE_SIZE instead of 'len' as the size of the temporary buffer.

Quoted 10 lines
Quoted 10 lines
include/linux/cmdline.h new file +9 -0
+       char *__c_dst = (dst);                                          \
+       const char *__c_src = (src);                                    \
+                                                                       \
+       if (__c_src == __c_dst) {                                       \
+               static char __c_tmp[COMMAND_LINE_SIZE] __initdata = ""; \
+                                                                       \
+               cmdline_strlcat(__c_tmp, __c_src, COMMAND_LINE_SIZE);   \
+               __cmdline_build(__c_dst, __c_tmp, (len));               \
+       } else {                                                        \
Quoted 8 lines
Quoted 8 lines
include/linux/cmdline.h new file +5 -1
+               __cmdline_build(__c_dst, __c_src, (len));               \
+       }                                                               \
+} while (0)
+
+#endif /* _LINUX_CMDLINE_H */
--

2.25.0

Christophe

#4 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

In reply to Rob Herring

Le 26/03/2021 à 16:42, Rob Herring a écrit :

Quoted 7 lines
Quoted 4 lines · Christophe Leroy

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.

Quoted 6 lines

Note that I have this patch pending:

https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/

It's going to need to be adapted for this. I've held off applying to see if this gets settled.

When reworking EFI, I found out that they are a similar handling, which in addition takes care of space inside quotes.

I added something similar now in cmdline_build() function.

Quoted 84 lines
Quoted 47 lines

---
v3:
- Addressed comments from Will
- Added capability to have src == dst

---
  include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 57 insertions(+)

create mode 100644 include/linux/cmdline.h

include/linux/cmdline.h new file +29 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */
+static __always_inline void __cmdline_build(char *dst, const char *src, size_t len)
+{
+       if (!len || src == dst)
+               return;
+
+       if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !src) {
+               dst[0] = 0;
+               cmdline_strlcat(dst, CONFIG_CMDLINE, len);
+               return;
+       }

include/linux/cmdline.h line 39

Quoted 10 lines
include/linux/cmdline.h new file +10 -0
+
+       if (dst != src)
+               dst[0] = 0;
+
+       if (IS_ENABLED(CONFIG_CMDLINE_PREPEND))
+               cmdline_strlcat(dst, CONFIG_CMDLINE " ", len);
+
+       cmdline_strlcat(dst, src, len);
+
+       if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))

Should be APPEND.

include/linux/cmdline.h line 43

Quoted 4 lines
include/linux/cmdline.h new file +4 -0
+               cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
+}
+
+#define cmdline_build(dst, src, len) do {                              \

Perhaps a comment why we need this to be a define.

Quoted 17 lines
include/linux/cmdline.h new file +14 -1
+       char *__c_dst = (dst);                                          \
+       const char *__c_src = (src);                                    \
+                                                                       \
+       if (__c_src == __c_dst) {                                       \
+               static char __c_tmp[COMMAND_LINE_SIZE] __initdata = ""; \
+                                                                       \
+               cmdline_strlcat(__c_tmp, __c_src, COMMAND_LINE_SIZE);   \
+               __cmdline_build(__c_dst, __c_tmp, (len));               \
+       } else {                                                        \
+               __cmdline_build(__c_dst, __c_src, (len));               \
+       }                                                               \
+} while (0)
+
+#endif /* _LINUX_CMDLINE_H */
--

2.25.0

#5 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

In reply to Christophe Leroy
Quoted 29 lines · Christophe Leroy

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.

---
v3:
- Addressed comments from Will
- Added capability to have src == dst

---
 include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 include/linux/cmdline.h
include/linux/cmdline.h new file +9 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat

include/linux/cmdline.h line 19

Quoted 10 lines
include/linux/cmdline.h new file +10 -0
+#endif
+
+/*
+ * 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.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */

Append or prepend ? Cisco requires both at the same time. This is why my implementation provides both. I can't use this with both at once.

Daniel

#6 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

Quoted 38 lines

Am 30.03.2021 um 19:27 schrieb Daniel Walker <[email protected]>:

Quoted 34 lines · Christophe Leroy

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.

---
v3:
- Addressed comments from Will
- Added capability to have src == dst
---
include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++

1 file changed, 57 insertions(+)

create mode 100644 include/linux/cmdline.h

include/linux/cmdline.h new file +14 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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
Quoted 8 lines

include/linux/cmdline.h line 19

Quoted 5 lines
include/linux/cmdline.h new file +5 -0
+ * the behavior of this builtin command line.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */

Append or prepend ? Cisco requires both at the same time. This is why my implementation provides both. I can't use this with both at once.

Just an idea: what about defining CMDLINE as a pattern where e.g. "$$" or "%%" is replaced by the boot loader command line?

Then you can formulate replace, prepend, append, prepend+append with a single CONFIG setting.

It may be a little more complex in code (scanning for the pattern and replacing it and take care to temporary memory) but IMHO it could be worth to consider.

BR,
Nikolaus Schaller

#7 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

Quoted 47 lines · H. Nikolaus Schaller
Quoted 38 lines

Am 30.03.2021 um 19:27 schrieb Daniel Walker <[email protected]>:

Quoted 34 lines · Christophe Leroy

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.

---
v3:
- Addressed comments from Will
- Added capability to have src == dst
---
include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++

1 file changed, 57 insertions(+)

create mode 100644 include/linux/cmdline.h

include/linux/cmdline.h new file +14 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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
Quoted 8 lines

include/linux/cmdline.h line 19

Quoted 5 lines
include/linux/cmdline.h new file +5 -0
+ * the behavior of this builtin command line.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */

Append or prepend ? Cisco requires both at the same time. This is why my implementation provides both. I can't use this with both at once.

Quoted 8 lines

Just an idea: what about defining CMDLINE as a pattern where e.g. "$$" or "%%" is replaced by the boot loader command line?

Then you can formulate replace, prepend, append, prepend+append with a single CONFIG setting.

It may be a little more complex in code (scanning for the pattern and replacing it and take care to temporary memory) but IMHO it could be worth to consider.

In some cases this code could be used extremely early in boot up. For example in the prom_init.c powerpc code, or in efi changes. The flexibility to find and replace like that is not always an option due to the nature of the environment. It's not impossible of course.

Daniel

#8 lore raw

Re: [PATCH v3 01/17] cmdline: Add generic function to build command line.

In reply to Daniel Walker

Le 30/03/2021 à 19:27, Daniel Walker a écrit :

Quoted 35 lines · Christophe Leroy
Quoted 34 lines

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.

---
v3:
- Addressed comments from Will
- Added capability to have src == dst

---
  include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 57 insertions(+)

create mode 100644 include/linux/cmdline.h

include/linux/cmdline.h new file +14 -0
new file mode 100644
index 000000000000..dea87edd41be
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * 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
Quoted 9 lines

include/linux/cmdline.h line 19

Quoted 5 lines
include/linux/cmdline.h new file +5 -0
+ * the behavior of this builtin command line.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */

Append or prepend ? Cisco requires both at the same time. This is why my implementation provides both. I can't use this with both at once.

I think it can be added as a second step if dimmed necessary. The feeling I have from all the discussion is that it's not what people from the community are looking for at the moment.

Anyway, once all architectures are moved to generic handling, I believe it is then easier to split CONFIG_CMDLINE in two configuration items in order to provide both appending and prepending at the same time.

I see some concerns about risk of double changes, but I have focussed in changing as little as possible the existing configuration items, in order to minimise that.

#9 lore raw

PATCH v3 2/17 drivers: of: use cmdline building function

In reply to Christophe Leroy

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

---
 drivers/of/fdt.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/of/fdt.c +4 -19
index dcc1dd96911a..cf2b95b8f298 100644
@@ -25,6 +25,7 @@
 #include <linux/serial_core.h>
 #include <linux/sysfs.h>
 #include <linux/random.h>
+#include <linux/cmdline.h>
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #include <asm/page.h>
@@ -1050,26 +1051,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(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);
 
Signature · 1 line
2.25.0
#10 lore raw

PATCH v3 3/17 cmdline: Gives architectures opportunity to use generically defined boot cmdline manipulation

In reply to Christophe Leroy

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

CONFIG_CMDLINE_EXTEND is understood differently by architectures. For some of them it appends built-in CMDLINE to bootloader provided line. For others it appends the bootloader provided CMDLINE to the built-in one.
To avoid confusion, this commit brings to different options:
- CONFIG_CMDLINE_APPEND to append the built-in CMDLINE to the bootloader line.
- CONFIG_CMDLINE_PREPEND to prepend the built-in CMDLINE in front of the bootloader line.

For compatibility with existing architecture which uses CONFIG_OF, as OF has already been converted to generic cmdline, we keep CONFIG_CMDLINE_EXTEND as a synonym to CONFIG_CMDLINE_APPEND until arm, powerpc, riscv and sh architectures have been converted.

A few differences are identified and will have to be taken into account when converting the architecture to generic cmdline:
- riscv has CMDLINE_FALLBACK instead of CMDLINE_FROM_BOOTLOADER
- Some architectures are using CONFIG_CMDLINE_OVERRIDE or CONFIG_CMDLINE_OVERWRITE instead of CONFIG_CMDLINE_FORCE.

---
v3:
- Comments from Will.
- Remove CONFIG_CMDLINE_BOOL. Using CONFIG_CMDLINE != "" instead, like arm and powerpc.
- Changed EXTEND to APPEND. Keep EXTEND for backward compatibility.

---
 include/linux/cmdline.h |  2 +-
 init/Kconfig            | 52 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
include/linux/cmdline.h +1 -1
index dea87edd41be..38306c109041 100644
@@ -36,7 +36,7 @@ static __always_inline void __cmdline_build(char *dst, const char *src, size_t l
 
 	cmdline_strlcat(dst, src, len);
 
-	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || IS_ENABLED(CONFIG_CMDLINE_APPEND))
 		cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
 }
 
init/Kconfig +52 -0

58 lines not on this page · raw message

Signature · 1 line
2.25.0
#11 lore raw

PATCH v3 4/17 powerpc: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

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

---
 arch/powerpc/Kconfig            | 37 +--------------------------------
 arch/powerpc/kernel/prom_init.c | 17 +++++++--------
 2 files changed, 8 insertions(+), 46 deletions(-)
arch/powerpc/Kconfig +1 -36
index 386ae12d8523..5181efd7757e 100644
@@ -167,6 +167,7 @@ config PPC
 	select EDAC_SUPPORT
 	select GENERIC_ATOMIC64			if PPC32
 	select GENERIC_CLOCKEVENTS_BROADCAST	if SMP
+	select GENERIC_CMDLINE
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES	if PPC_BARRIER_NOSPEC
@@ -886,42 +887,6 @@ config PPC_DENORMALISATION
 	  Add support for handling denormalisation of single precision
 	  values.  Useful for bare metal only.  If unsure say Y here.
 
-config CMDLINE
-	string "Initial kernel command string"
-	default ""
-	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
-
-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 command-line arguments provided by the boot loader will be
-	  appended to the default kernel command string.
-
-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"
 	help
arch/powerpc/kernel/prom_init.c +7 -10
index ccf77b985c8f..157d508e9fe9 100644
@@ -152,7 +152,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;
@@ -765,22 +765,19 @@ static unsigned long prom_memparse(const char *ptr, const char **retptr)
  * Early parsing of the command line passed to the kernel, used for
  * "mem=x" and the options that affect the iommu
  */
+#define cmdline_strlcat prom_strlcat
+#include <linux/cmdline.h>
+
 static void __init early_cmdline_parse(void)
 {
 	const char *opt;
-
-	char *p;
 	int l = 0;
 
-	prom_cmd_line[0] = 0;
-	p = prom_cmd_line;
-
 	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && (long)prom.chosen > 0)
-		l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
+		l = prom_getprop(prom.chosen, "bootargs", prom_scratch,
+				 COMMAND_LINE_SIZE - 1);
 
-	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || l <= 0 || p[0] == '\0')
-		prom_strlcat(prom_cmd_line, " " CONFIG_CMDLINE,
-			     sizeof(prom_cmd_line));
+	__cmdline_build(prom_cmd_line, l > 0 ? prom_scratch : NULL, sizeof(prom_scratch));
 
 	prom_printf("command line: %s\n", prom_cmd_line);
 
Signature · 1 line
2.25.0
#12 lore raw

PATCH v3 5/17 arm: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/arm/Kconfig              | 38 +----------------------------------
 arch/arm/kernel/atags_parse.c | 15 +++++---------
 2 files changed, 6 insertions(+), 47 deletions(-)
arch/arm/Kconfig +1 -37
index 5da96f5df48f..67bc75f2da81 100644
@@ -50,6 +50,7 @@ config ARM
 	select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
 	select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
 	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+	select GENERIC_CMDLINE if ATAGS
 	select GENERIC_IRQ_IPI if SMP
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_EARLY_IOREMAP
@@ -1740,43 +1741,6 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
 
 endchoice
 
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	help
-	  On some architectures (e.g. CATS), there is currently no way
-	  for the boot loader to pass arguments to the kernel. For these
-	  architectures, you should supply some command-line options at build
-	  time by entering them here. As a minimum, you should specify the
-	  memory size and the root device (e.g., mem=64M root=/dev/nfs).
-
-choice
-	prompt "Kernel command line type" if CMDLINE != ""
-	default CMDLINE_FROM_BOOTLOADER
-	depends on ATAGS
-
-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 command-line arguments provided by the boot loader will be
-	  appended to the default kernel command string.
-
-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 XIP_KERNEL
 	bool "Kernel Execute-In-Place from ROM"
 	depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
arch/arm/kernel/atags_parse.c +5 -10
index 373b61f9a4f0..3d5bd52ee458 100644
@@ -14,6 +14,7 @@
  * is not parsed in any way).
  */
 
+#include <linux/cmdline.h>
 #include <linux/init.h>
 #include <linux/initrd.h>
 #include <linux/kernel.h>
@@ -120,16 +121,10 @@ __tagtable(ATAG_REVISION, parse_tag_revision);
 
 static int __init parse_tag_cmdline(const struct tag *tag)
 {
-#if defined(CONFIG_CMDLINE_EXTEND)
-	strlcat(default_command_line, " ", COMMAND_LINE_SIZE);
-	strlcat(default_command_line, tag->u.cmdline.cmdline,
-		COMMAND_LINE_SIZE);
-#elif defined(CONFIG_CMDLINE_FORCE)
-	pr_warn("Ignoring tag cmdline (using the default kernel command line)\n");
-#else
-	strlcpy(default_command_line, tag->u.cmdline.cmdline,
-		COMMAND_LINE_SIZE);
-#endif
+	cmdline_build(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);
+
+	if IS_ENABLED(CONFIG_CMDLINE_FORCE)
+		pr_warn("Ignoring tag cmdline (using the default kernel command line)\n");
 	return 0;
 }
 
Signature · 1 line
2.25.0
maintainer
#13 lore raw

Re: [PATCH v3 05/17] arm: Convert to GENERIC_CMDLINE

Quoted 14 lines · Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/arm/Kconfig              | 38 +----------------------------------
 arch/arm/kernel/atags_parse.c | 15 +++++---------
 2 files changed, 6 insertions(+), 47 deletions(-)
arch/arm/Kconfig +0 -0
index 5da96f5df48f..67bc75f2da81 100644

arch/arm/Kconfig config ARM · line 53

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -50,6 +50,7 @@ config ARM
        select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
        select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
        select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+       select GENERIC_CMDLINE if ATAGS

Don't we need this enabled for !ATAGS (i.e. DT boot)?

Can we always enable GENERIC_CMDLINE for OF_EARLY_FLATTREE?

Rob

#14 lore raw

Re: [PATCH v3 05/17] arm: Convert to GENERIC_CMDLINE

Le 26/03/2021 à 16:47, Rob Herring a écrit :

Quoted 23 lines
Quoted 14 lines · Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
  arch/arm/Kconfig              | 38 +----------------------------------
  arch/arm/kernel/atags_parse.c | 15 +++++---------
  2 files changed, 6 insertions(+), 47 deletions(-)
arch/arm/Kconfig +0 -0
index 5da96f5df48f..67bc75f2da81 100644

arch/arm/Kconfig config ARM · line 53

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -50,6 +50,7 @@ config ARM
         select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
         select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
         select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+       select GENERIC_CMDLINE if ATAGS

Don't we need this enabled for !ATAGS (i.e. DT boot)?

Quoted 2 lines

Can we always enable GENERIC_CMDLINE for OF_EARLY_FLATTREE?

Don't know.

Today ARM has:

choice

	prompt "Kernel command line type" if CMDLINE != ""
	default CMDLINE_FROM_BOOTLOADER
	depends on ATAGS

Christophe

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#15 lore raw

Re: [PATCH v3 05/17] arm: Convert to GENERIC_CMDLINE

+Nico who added the line in question.

Quoted 30 lines · Christophe Leroy
Quoted 23 lines · Rob Herring
Quoted 14 lines · Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
  arch/arm/Kconfig              | 38 +----------------------------------
  arch/arm/kernel/atags_parse.c | 15 +++++---------
  2 files changed, 6 insertions(+), 47 deletions(-)
arch/arm/Kconfig +0 -0
index 5da96f5df48f..67bc75f2da81 100644

arch/arm/Kconfig config ARM · line 53

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -50,6 +50,7 @@ config ARM
         select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
         select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
         select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+       select GENERIC_CMDLINE if ATAGS

Don't we need this enabled for !ATAGS (i.e. DT boot)?

Quoted 2 lines

Can we always enable GENERIC_CMDLINE for OF_EARLY_FLATTREE?

Quoted 8 lines

Don't know.

Today ARM has:

choice
prompt "Kernel command line type" if CMDLINE != "" default CMDLINE_FROM_BOOTLOADER
depends on ATAGS

I think that's a mistake. In a DT only case (no ATAGS), we'll get different behaviour (in fdt.c) depending if CONFIG_ATAGS is enabled or not. Note that at the time (2012) the above was added, the DT code only supported CONFIG_CMDLINE and CONFIG_CMDLINE_FORCE. CONFIG_CMDLINE_EXTEND was only added in 2016. And that has different behavior for ATAGS vs. DT. In summary, it's a mess. We should drop the depends either before this patch or just as part of this patch IMO. I'd go with the latter given CONFIG_ATAGS is default y and enabled for common configs. Without that, it looks like CONFIG_CMDLINE disappears from menuconfig for at91_dt_defconfig.

Also, I think this code should be refactored a bit to eliminate default_command_line. Instead, we should just save a pointer to the ATAGS command line string, and then call cmdline_build here instead of doing the extra copy:

        /* parse_early_param needs a boot_command_line */
        strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);

Rob

#16 lore raw

Re: [PATCH v3 05/17] arm: Convert to GENERIC_CMDLINE

In reply to Rob Herring

Le 26/03/2021 à 16:47, Rob Herring a écrit :

Quoted 23 lines
Quoted 14 lines · Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
  arch/arm/Kconfig              | 38 +----------------------------------
  arch/arm/kernel/atags_parse.c | 15 +++++---------
  2 files changed, 6 insertions(+), 47 deletions(-)
arch/arm/Kconfig +0 -0
index 5da96f5df48f..67bc75f2da81 100644

arch/arm/Kconfig config ARM · line 53

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -50,6 +50,7 @@ config ARM
         select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
         select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
         select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+       select GENERIC_CMDLINE if ATAGS

Don't we need this enabled for !ATAGS (i.e. DT boot)?

Quoted 2 lines

Can we always enable GENERIC_CMDLINE for OF_EARLY_FLATTREE?

Done in v4

#17 lore raw

Re: [PATCH v3 05/17] arm: Convert to GENERIC_CMDLINE

In reply to Rob Herring

Le 26/03/2021 à 16:47, Rob Herring a écrit :

Quoted 23 lines
Quoted 14 lines · Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
  arch/arm/Kconfig              | 38 +----------------------------------
  arch/arm/kernel/atags_parse.c | 15 +++++---------
  2 files changed, 6 insertions(+), 47 deletions(-)
arch/arm/Kconfig +0 -0
index 5da96f5df48f..67bc75f2da81 100644

arch/arm/Kconfig config ARM · line 53

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -50,6 +50,7 @@ config ARM
         select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
         select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
         select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+       select GENERIC_CMDLINE if ATAGS

Don't we need this enabled for !ATAGS (i.e. DT boot)?

Quoted 2 lines

Can we always enable GENERIC_CMDLINE for OF_EARLY_FLATTREE?

Yes missed it in v3 after your comment on v2. Done in v4.

#18 lore raw

PATCH v3 6/17 arm64: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/arm64/Kconfig                 | 33 +-----------------------------
 arch/arm64/kernel/idreg-override.c |  9 ++++----
 2 files changed, 5 insertions(+), 37 deletions(-)
arch/arm64/Kconfig +1 -32
index 5656e7aacd69..eeff7730ccf0 100644
@@ -105,6 +105,7 @@ config ARM64
 	select GENERIC_ALLOCATOR
 	select GENERIC_ARCH_TOPOLOGY
 	select GENERIC_CLOCKEVENTS_BROADCAST
+	select GENERIC_CMDLINE
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
@@ -1831,38 +1832,6 @@ config ARM64_ACPI_PARKING_PROTOCOL
 	  protocol even if the corresponding data is present in the ACPI
 	  MADT table.
 
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	help
-	  Provide a set of default command-line options at build time by
-	  entering them here. As a minimum, you should specify the the
-	  root device (e.g. root=/dev/nfs).
-
-choice
-	prompt "Kernel command line type" if CMDLINE != ""
-	default CMDLINE_FROM_BOOTLOADER
-	help
-	  Choose how the kernel will handle the provided default kernel
-	  command line string.
-
-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_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 EFI_STUB
 	bool
 
arch/arm64/kernel/idreg-override.c +4 -5
index 83f1c4b92095..8bc955cdcf82 100644
@@ -9,6 +9,7 @@
 #include <linux/ctype.h>
 #include <linux/kernel.h>
 #include <linux/libfdt.h>
+#include <linux/cmdline.h>
 
 #include <asm/cacheflush.h>
 #include <asm/cpufeature.h>
@@ -187,12 +188,10 @@ static __init const u8 *get_bootargs_cmdline(void)
 static __init void parse_cmdline(void)
 {
 	const u8 *prop = get_bootargs_cmdline();
+	static char __initdata cmdline[COMMAND_LINE_SIZE];
 
-	if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop)
-		__parse_cmdline(CONFIG_CMDLINE, true);
-
-	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && prop)
-		__parse_cmdline(prop, true);
+	cmdline_build(cmdline, prop, COMMAND_LINE_SIZE);
+	__parse_cmdline(cmdline, true);
 }
 
 /* Keep checkers quiet */
Signature · 1 line
2.25.0
#19 lore raw

PATCH v3 7/17 hexagon: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/hexagon/Kconfig        | 11 +----------
 arch/hexagon/kernel/setup.c | 10 ++--------
 2 files changed, 3 insertions(+), 18 deletions(-)
arch/hexagon/Kconfig +1 -10
index 44a409967af1..1e69c99bae6b 100644
@@ -18,6 +18,7 @@ config HEXAGON
 	select HAVE_PERF_EVENTS
 	# GENERIC_ALLOCATOR is used by dma_alloc_coherent()
 	select GENERIC_ALLOCATOR
+	select GENERIC_CMDLINE
 	select GENERIC_IRQ_SHOW
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
@@ -91,16 +92,6 @@ config HEXAGON_ARCH_VERSION
 	int "Architecture version"
 	default 2
 
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	help
-	  On some platforms, there is currently no way for the boot loader
-	  to pass arguments to the kernel. For these, you should supply some
-	  command-line options at build time by entering them here.  At a
-	  minimum, you should specify the memory size and the root device
-	  (e.g., mem=64M root=/dev/nfs).
-
 config SMP
 	bool "Multi-Processing support"
 	help
arch/hexagon/kernel/setup.c +2 -8
index 1880d9beaf2b..be586cea4076 100644
@@ -13,6 +13,7 @@
 #include <linux/seq_file.h>
 #include <linux/console.h>
 #include <linux/of_fdt.h>
+#include <linux/cmdline.h>
 #include <asm/io.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
@@ -22,7 +23,6 @@
 #include <asm/time.h>
 
 char cmd_line[COMMAND_LINE_SIZE];
-static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 
 int on_simulator;
 
@@ -38,8 +38,6 @@ void calibrate_delay(void)
 
 void __init setup_arch(char **cmdline_p)
 {
-	char *p = &external_cmdline_buffer;
-
 	/*
 	 * These will eventually be pulled in via either some hypervisor
 	 * or devicetree description.  Hardwiring for now.
@@ -65,11 +63,7 @@ void __init setup_arch(char **cmdline_p)
 	else
 		on_simulator = 0;
 
-	if (p[0] != '\0')
-		strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
-	else
-		strlcpy(boot_command_line, default_command_line,
-			COMMAND_LINE_SIZE);
+	cmdline_build(boot_command_line, external_cmdline_buffer, COMMAND_LINE_SIZE);
 
 	/*
 	 * boot_command_line and the value set up by setup_arch
Signature · 1 line
2.25.0
#20 lore raw

PATCH v3 8/17 microblaze: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/microblaze/Kconfig               | 24 +-----------------------
 arch/microblaze/configs/mmu_defconfig |  2 +-
 arch/microblaze/kernel/head.S         |  4 ++--
 3 files changed, 4 insertions(+), 26 deletions(-)
arch/microblaze/Kconfig +1 -23
index 0660f47012bc..1242f34bc2a2 100644
@@ -15,6 +15,7 @@ config MICROBLAZE
 	select COMMON_CLK
 	select DMA_DIRECT_REMAP
 	select GENERIC_ATOMIC64
+	select GENERIC_CMDLINE
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IRQ_PROBE
@@ -93,29 +94,6 @@ source "kernel/Kconfig.hz"
 config MMU
 	def_bool y
 
-comment "Boot options"
-
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-
-config CMDLINE
-	string "Default kernel command string"
-	depends on CMDLINE_BOOL
-	default "console=ttyUL0,115200"
-	help
-	  On some architectures there is currently no way for the boot loader
-	  to pass arguments to the kernel. For these architectures, you should
-	  supply some command-line options at build time by entering them
-	  here.
-
-config CMDLINE_FORCE
-	bool "Force default kernel command string"
-	depends on CMDLINE_BOOL
-	default n
-	help
-	  Set this to have arguments from the default kernel command string
-	  override those passed by the boot loader.
-
 endmenu
 
 menu "Kernel features"
arch/microblaze/configs/mmu_defconfig +1 -1
index 51337fffb947..b4d2219d0a8f 100644
@@ -16,7 +16,7 @@ CONFIG_XILINX_MICROBLAZE0_USE_DIV=1
 CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL=2
 CONFIG_XILINX_MICROBLAZE0_USE_FPU=2
 CONFIG_HZ_100=y
-CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttyUL0,115200"
 CONFIG_CMDLINE_FORCE=y
 CONFIG_HIGHMEM=y
 CONFIG_PCI_XILINX=y
arch/microblaze/kernel/head.S +2 -2
index ec2fcb545e64..605b18c86ac8 100644
@@ -105,7 +105,7 @@ _copy_fdt:
 	addik	r3, r3, -4 /* descrement loop */
 no_fdt_arg:
 
-#ifndef CONFIG_CMDLINE_BOOL
+#if CONFIG_CMDLINE == ""
 /*
  * handling command line
  * copy command line directly to cmd_line placed in data section.
@@ -126,7 +126,7 @@ _copy_command_line:
 	addik	r5, r4, 0		/* add new space for command line */
 	tovirt(r5,r5)
 skip:
-#endif /* CONFIG_CMDLINE_BOOL */
+#endif /* CONFIG_CMDLINE */
 
 #ifdef NOT_COMPILE
 /* save bram context */
Signature · 1 line
2.25.0
#21 lore raw

PATCH v3 9/17 nios2: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/nios2/Kconfig        | 24 +-----------------------
 arch/nios2/kernel/setup.c | 13 ++++---------
 2 files changed, 5 insertions(+), 32 deletions(-)
arch/nios2/Kconfig +1 -23
index c24955c81c92..f66c97b15813 100644
@@ -90,31 +90,9 @@ config NIOS2_ALIGNMENT_TRAP
 
 comment "Boot options"
 
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-	default y
-
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	depends on CMDLINE_BOOL
-	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
-	  other cases you can specify kernel args so that you don't have
-	  to set them up in board prom initialization routines.
-
-config CMDLINE_FORCE
-	bool "Force default kernel command string"
-	depends on CMDLINE_BOOL
-	help
-	  Set this to have arguments from the default kernel command string
-	  override those passed by the boot loader.
-
 config NIOS2_CMDLINE_IGNORE_DTB
 	bool "Ignore kernel command string from DTB"
-	depends on CMDLINE_BOOL
+	depends on CMDLINE != ""
 	depends on !CMDLINE_FORCE
 	default y
 	help
arch/nios2/kernel/setup.c +4 -9
index d2f21957e99c..42464f457a6d 100644
@@ -20,6 +20,7 @@
 #include <linux/initrd.h>
 #include <linux/of_fdt.h>
 #include <linux/screen_info.h>
+#include <linux/cmdline.h>
 
 #include <asm/mmu_context.h>
 #include <asm/sections.h>
@@ -108,7 +109,7 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
 				       unsigned r7)
 {
 	unsigned dtb_passed = 0;
-	char cmdline_passed[COMMAND_LINE_SIZE] __maybe_unused = { 0, };
+	char cmdline_passed[COMMAND_LINE_SIZE] = { 0, };
 
 #if defined(CONFIG_NIOS2_PASS_CMDLINE)
 	if (r4 == 0x534f494e) { /* r4 is magic NIOS */
@@ -127,14 +128,8 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
 
 	early_init_devtree((void *)dtb_passed);
 
-#ifndef CONFIG_CMDLINE_FORCE
-	if (cmdline_passed[0])
-		strlcpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
-#ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB
-	else
-		strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif
-#endif
+	if (cmdline_passed[0] || IS_ENABLED(CONFIG_NIOS2_CMDLINE_IGNORE_DTB))
+		cmdline_build(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
 
 	parse_early_param();
 }
Signature · 1 line
2.25.0
#22 lore raw

RE: [PATCH v3 09/17] nios2: Convert to GENERIC_CMDLINE

Quoted 52 lines

-----Original Message-----
From: Christophe Leroy <[email protected]>
Sent: Friday, March 26, 2021 9:45 PM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linuxppc- [email protected]; [email protected]; linuxppc- [email protected]; [email protected]; microblaze <[email protected]>; [email protected]; Tan, Ley Foon <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 09/17] nios2: Convert to GENERIC_CMDLINE

This converts the architecture to GENERIC_CMDLINE.

---
 arch/nios2/Kconfig        | 24 +-----------------------
 arch/nios2/kernel/setup.c | 13 ++++---------
 2 files changed, 5 insertions(+), 32 deletions(-)
arch/nios2/Kconfig index renamed from arch/nios2/Kconfig +0 -0

c24955c81c92..f66c97b15813 100644

arch/nios2/Kconfig +0 -19
@@ -90,31 +90,9 @@ config NIOS2_ALIGNMENT_TRAP
 
 comment "Boot options"
 
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-	default y
-
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	depends on CMDLINE_BOOL
-	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
-	  other cases you can specify kernel args so that you don't have
-	  to set them up in board prom initialization routines.
-
-config CMDLINE_FORCE
-	bool "Force default kernel command string"
-	depends on CMDLINE_BOOL
-	help

arch/nios2/Kconfig config NIOS2_ALIGNMENT_TRAP · line 98

Quoted 10 lines
arch/nios2/Kconfig +1 -4
-	  Set this to have arguments from the default kernel command string
-	  override those passed by the boot loader.
-
 config NIOS2_CMDLINE_IGNORE_DTB
 	bool "Ignore kernel command string from DTB"
-	depends on CMDLINE_BOOL
+	depends on CMDLINE != ""
 	depends on !CMDLINE_FORCE
 	default y
 	help

Missing " select GENERIC_CMDLINE" ?

Quoted 46 lines
arch/nios2/kernel/setup.c index renamed from arch/nios2/kernel/setup.c +0 -0

d2f21957e99c..42464f457a6d 100644

arch/nios2/kernel/setup.c +2 -1
@@ -20,6 +20,7 @@
 #include <linux/initrd.h>
 #include <linux/of_fdt.h>
 #include <linux/screen_info.h>
+#include <linux/cmdline.h>
 
 #include <asm/mmu_context.h>
 #include <asm/sections.h>
@@ -108,7 +109,7 @@ asmlinkage void __init nios2_boot_init(unsigned r4,
 unsigned r5, unsigned r6,
 				       unsigned r7)
 {
 	unsigned dtb_passed = 0;
-	char cmdline_passed[COMMAND_LINE_SIZE] __maybe_unused =
 { 0, };
+	char cmdline_passed[COMMAND_LINE_SIZE] = { 0, };
 

#if defined(CONFIG_NIOS2_PASS_CMDLINE)
if (r4 == 0x534f494e) { /* r4 is magic NIOS */ @@ -127,14 +128,8 @@
asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,

arch/nios2/kernel/setup.c +0 -3
 	early_init_devtree((void *)dtb_passed);
 
-#ifndef CONFIG_CMDLINE_FORCE
-	if (cmdline_passed[0])
-		strlcpy(boot_command_line, cmdline_passed,

COMMAND_LINE_SIZE);

arch/nios2/kernel/setup.c +0 -3
-#ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB
-	else
-		strlcpy(boot_command_line, CONFIG_CMDLINE,

COMMAND_LINE_SIZE);

arch/nios2/kernel/setup.c +1 -2
-#endif
-#endif
+	if (cmdline_passed[0] ||

IS_ENABLED(CONFIG_NIOS2_CMDLINE_IGNORE_DTB))

arch/nios2/kernel/setup.c +1 -0
+		cmdline_build(boot_command_line, cmdline_passed,

COMMAND_LINE_SIZE);

parse_early_param();
}
--
2.25.0

#23 lore raw

Re: [PATCH v3 09/17] nios2: Convert to GENERIC_CMDLINE

Le 29/03/2021 à 03:35, Tan, Ley Foon a écrit :

Quoted 56 lines
Quoted 56 lines

-----Original Message-----
From: Christophe Leroy <[email protected]>
Sent: Friday, March 26, 2021 9:45 PM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linuxppc- [email protected]; [email protected]; linuxppc- [email protected]; [email protected]; microblaze <[email protected]>; [email protected]; Tan, Ley Foon <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 09/17] nios2: Convert to GENERIC_CMDLINE

This converts the architecture to GENERIC_CMDLINE.

---
  arch/nios2/Kconfig        | 24 +-----------------------
  arch/nios2/kernel/setup.c | 13 ++++---------
  2 files changed, 5 insertions(+), 32 deletions(-)
arch/nios2/Kconfig index renamed from arch/nios2/Kconfig +0 -0

c24955c81c92..f66c97b15813 100644

arch/nios2/Kconfig +0 -22
@@ -90,31 +90,9 @@ config NIOS2_ALIGNMENT_TRAP
 
  comment "Boot options"
 
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-	default y
-
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	depends on CMDLINE_BOOL
-	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
-	  other cases you can specify kernel args so that you don't have
-	  to set them up in board prom initialization routines.
-
-config CMDLINE_FORCE
-	bool "Force default kernel command string"
-	depends on CMDLINE_BOOL
-	help
-	  Set this to have arguments from the default kernel command string
-	  override those passed by the boot loader.
-
  config NIOS2_CMDLINE_IGNORE_DTB
Quoted 8 lines

arch/nios2/Kconfig config NIOS2_ALIGNMENT_TRAP · line 98

Quoted 6 lines
arch/nios2/Kconfig +1 -1
  	bool "Ignore kernel command string from DTB"
-	depends on CMDLINE_BOOL
+	depends on CMDLINE != ""
  	depends on !CMDLINE_FORCE
  	default y
  	help

Missing " select GENERIC_CMDLINE" ?

Added in v4

Thanks
Christophe

#24 lore raw

PATCH v3 10/17 openrisc: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/openrisc/Kconfig | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/openrisc/Kconfig +1 -9
index 591acc5990dc..ca1d0f18fe16 100644
@@ -25,6 +25,7 @@ config OPENRISC
 	select HAVE_UID16
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS_BROADCAST
+	select GENERIC_CMDLINE
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
@@ -162,15 +163,6 @@ config OPENRISC_HAVE_SHADOW_GPRS
 	  On SMP systems, this feature is mandatory.
 	  On a unicore system it's safe to say N here if you are unsure.
 
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	help
-	  On some architectures there is currently no way for the boot loader
-	  to pass arguments to the kernel. For these architectures, you should
-	  supply some command-line options at build time by entering them
-	  here.
-
 menu "Debugging options"
 
 config JUMP_UPON_UNHANDLED_EXCEPTION
Signature · 1 line
2.25.0
#25 lore raw

PATCH v3 11/17 riscv: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/riscv/Kconfig        | 44 +--------------------------------------
 arch/riscv/kernel/setup.c |  5 ++---
 2 files changed, 3 insertions(+), 46 deletions(-)
arch/riscv/Kconfig +1 -43
index 87d7b52f278f..3dbd50bed037 100644
@@ -39,6 +39,7 @@ config RISCV
 	select EDAC_SUPPORT
 	select GENERIC_ARCH_TOPOLOGY if SMP
 	select GENERIC_ATOMIC64 if !64BIT
+	select GENERIC_CMDLINE
 	select GENERIC_EARLY_IOREMAP
 	select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
 	select GENERIC_IOREMAP
@@ -390,49 +391,6 @@ endmenu
 
 menu "Boot options"
 
-config CMDLINE
-	string "Built-in kernel command line"
-	help
-	  For most platforms, the arguments for the kernel's command line
-	  are provided at run-time, during boot. However, there are cases
-	  where either no arguments are being provided or the provided
-	  arguments are insufficient or even invalid.
-
-	  When that occurs, it is possible to define a built-in command
-	  line here and choose how the kernel should use it later on.
-
-choice
-	prompt "Built-in command line usage" if CMDLINE != ""
-	default CMDLINE_FALLBACK
-	help
-	  Choose how the kernel will handle the provided built-in command
-	  line.
-
-config CMDLINE_FALLBACK
-	bool "Use bootloader kernel arguments if available"
-	help
-	  Use the built-in command line as fallback in case we get nothing
-	  during boot. This is the default behaviour.
-
-config CMDLINE_EXTEND
-	bool "Extend bootloader kernel arguments"
-	help
-	  The command-line arguments provided during boot will be
-	  appended to the built-in command line. This is useful in
-	  cases where the provided arguments are insufficient and
-	  you don't want to or cannot modify them.
-
-
-config CMDLINE_FORCE
-	bool "Always use the default kernel command string"
-	help
-	  Always use the built-in command line, even if we get one during
-	  boot. This is useful in case you need to override the provided
-	  command line on systems where you don't have or want control
-	  over it.
-
-endchoice
-
 config EFI_STUB
 	bool
 
arch/riscv/kernel/setup.c +2 -3
index f8f15332caa2..e7c91ee478d1 100644
@@ -20,6 +20,7 @@
 #include <linux/swiotlb.h>
 #include <linux/smp.h>
 #include <linux/efi.h>
+#include <linux/cmdline.h>
 
 #include <asm/cpu_ops.h>
 #include <asm/early_ioremap.h>
@@ -228,10 +229,8 @@ static void __init parse_dtb(void)
 	}
 
 	pr_err("No DTB passed to the kernel\n");
-#ifdef CONFIG_CMDLINE_FORCE
-	strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+	cmdline_build(boot_command_line, NULL, COMMAND_LINE_SIZE);
 	pr_info("Forcing kernel command line to: %s\n", boot_command_line);
-#endif
 }
 
 void __init setup_arch(char **cmdline_p)
Signature · 1 line
2.25.0
#26 lore raw

Re: [PATCH v3 11/17] riscv: Convert to GENERIC_CMDLINE

Quoted 13 lines · Christophe Leroy
arch/riscv/kernel/setup.c +1 -0
index f8f15332caa2..e7c91ee478d1 100644
@@ -20,6 +20,7 @@
 #include <linux/swiotlb.h>
 #include <linux/smp.h>
 #include <linux/efi.h>
+#include <linux/cmdline.h>
 
 #include <asm/cpu_ops.h>
 #include <asm/early_ioremap.h>

arch/riscv/kernel/setup.c static void __init parse_dtb(void) · line 233

Quoted 7 lines
arch/riscv/kernel/setup.c +1 -2
@@ -228,10 +229,8 @@ static void __init parse_dtb(void)
 	}
 
 	pr_err("No DTB passed to the kernel\n");
-#ifdef CONFIG_CMDLINE_FORCE
-	strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+	cmdline_build(boot_command_line, NULL, COMMAND_LINE_SIZE);
 	pr_info("Forcing kernel command line to: %s\n", boot_command_line);

Shouldn't that message become conditional in some way?

Andreas.

Signature · 8 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#27 lore raw

Re: [PATCH v3 11/17] riscv: Convert to GENERIC_CMDLINE

Le 26/03/2021 à 15:08, Andreas Schwab a écrit :

Quoted 17 lines · Christophe Leroy
Quoted 16 lines
arch/riscv/kernel/setup.c +1 -0
index f8f15332caa2..e7c91ee478d1 100644
@@ -20,6 +20,7 @@
  #include <linux/swiotlb.h>
  #include <linux/smp.h>
  #include <linux/efi.h>
+#include <linux/cmdline.h>
 
  #include <asm/cpu_ops.h>
  #include <asm/early_ioremap.h>
@@ -228,10 +229,8 @@ static void __init parse_dtb(void)
  	}
 
Quoted 8 lines

arch/riscv/kernel/setup.c static void __init parse_dtb(void) · line 233

Quoted 5 lines
arch/riscv/kernel/setup.c +1 -2
  	pr_err("No DTB passed to the kernel\n");
-#ifdef CONFIG_CMDLINE_FORCE
-	strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+	cmdline_build(boot_command_line, NULL, COMMAND_LINE_SIZE);
  	pr_info("Forcing kernel command line to: %s\n", boot_command_line);

Shouldn't that message become conditional in some way?

You are right, I did something similar on ARM but looks like I missed it on RISCV.

Christophe

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#28 lore raw

Re: [PATCH v3 11/17] riscv: Convert to GENERIC_CMDLINE

Quoted 30 lines · Christophe Leroy
Quoted 17 lines · Andreas Schwab
Quoted 15 lines · Christophe Leroy
arch/riscv/kernel/setup.c +1 -0
index f8f15332caa2..e7c91ee478d1 100644
@@ -20,6 +20,7 @@
  #include <linux/swiotlb.h>
  #include <linux/smp.h>
  #include <linux/efi.h>
+#include <linux/cmdline.h>
 
  #include <asm/cpu_ops.h>
  #include <asm/early_ioremap.h>
@@ -228,10 +229,8 @@ static void __init parse_dtb(void)
     }
 
Quoted 8 lines

arch/riscv/kernel/setup.c static void __init parse_dtb(void) · line 233

Quoted 5 lines
arch/riscv/kernel/setup.c +1 -2
     pr_err("No DTB passed to the kernel\n");
-#ifdef CONFIG_CMDLINE_FORCE
-    strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+    cmdline_build(boot_command_line, NULL, COMMAND_LINE_SIZE);
     pr_info("Forcing kernel command line to: %s\n", boot_command_line);

Shouldn't that message become conditional in some way?

Quoted 1 line

You are right, I did something similar on ARM but looks like I missed it on RISCV.

How is this hunk even useful? Under what conditions can you boot without a DTB? Even with a built-in DTB, the DT cmdline handling would be called.

Rob

#29 lore raw

Re: [PATCH v3 11/17] riscv: Convert to GENERIC_CMDLINE

Στις 2021-03-26 17:26, Rob Herring έγραψε:

Quoted 32 lines
Quoted 30 lines · Christophe Leroy
Quoted 25 lines · Andreas Schwab
Quoted 13 lines · Christophe Leroy
arch/riscv/kernel/setup.c +1 -0
index f8f15332caa2..e7c91ee478d1 100644
@@ -20,6 +20,7 @@
  #include <linux/swiotlb.h>
  #include <linux/smp.h>
  #include <linux/efi.h>
+#include <linux/cmdline.h>
 
  #include <asm/cpu_ops.h>
  #include <asm/early_ioremap.h>

arch/riscv/kernel/setup.c static void __init parse_dtb(void) · line 233

Quoted 7 lines
arch/riscv/kernel/setup.c +1 -2
@@ -228,10 +229,8 @@ static void __init parse_dtb(void)
     }
 
     pr_err("No DTB passed to the kernel\n");
-#ifdef CONFIG_CMDLINE_FORCE
-    strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+    cmdline_build(boot_command_line, NULL, COMMAND_LINE_SIZE);
     pr_info("Forcing kernel command line to: %s\n", boot_command_line);

Shouldn't that message become conditional in some way?

Quoted 8 lines
Quoted 1 line

You are right, I did something similar on ARM but looks like I missed it on RISCV.

How is this hunk even useful? Under what conditions can you boot without a DTB? Even with a built-in DTB, the DT cmdline handling would be called.

Rob

cced Paul who introduced this:
https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git/commit/arch/riscv/kernel/setup.c?id=8fd6e05c7463b635e51ec7df0a1858c1b5a6e350

#30 lore raw

Re: [PATCH v3 11/17] riscv: Convert to GENERIC_CMDLINE

In reply to Rob Herring

Le 26/03/2021 à 16:26, Rob Herring a écrit :

Quoted 32 lines
Quoted 30 lines · Christophe Leroy
Quoted 25 lines · Andreas Schwab
Quoted 13 lines · Christophe Leroy
arch/riscv/kernel/setup.c +1 -0
index f8f15332caa2..e7c91ee478d1 100644
@@ -20,6 +20,7 @@
   #include <linux/swiotlb.h>
   #include <linux/smp.h>
   #include <linux/efi.h>
+#include <linux/cmdline.h>
 
   #include <asm/cpu_ops.h>
   #include <asm/early_ioremap.h>

arch/riscv/kernel/setup.c static void __init parse_dtb(void) · line 233

Quoted 7 lines
arch/riscv/kernel/setup.c +1 -2
@@ -228,10 +229,8 @@ static void __init parse_dtb(void)
      }
 
      pr_err("No DTB passed to the kernel\n");
-#ifdef CONFIG_CMDLINE_FORCE
-    strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+    cmdline_build(boot_command_line, NULL, COMMAND_LINE_SIZE);
      pr_info("Forcing kernel command line to: %s\n", boot_command_line);

Shouldn't that message become conditional in some way?

Quoted 6 lines
Quoted 1 line

You are right, I did something similar on ARM but looks like I missed it on RISCV.

How is this hunk even useful? Under what conditions can you boot without a DTB? Even with a built-in DTB, the DT cmdline handling would be called.

Don't know, I wanted to keep as is today.

Do you think the hunk should be completely removed ?

#31 lore raw

PATCH v3 12/17 sh: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/sh/Kconfig                             | 30 +--------------------
 arch/sh/configs/ap325rxa_defconfig          |  2 +-
 arch/sh/configs/dreamcast_defconfig         |  2 +-
 arch/sh/configs/ecovec24-romimage_defconfig |  2 +-
 arch/sh/configs/ecovec24_defconfig          |  2 +-
 arch/sh/configs/edosk7760_defconfig         |  2 +-
 arch/sh/configs/espt_defconfig              |  2 +-
 arch/sh/configs/j2_defconfig                |  2 +-
 arch/sh/configs/kfr2r09-romimage_defconfig  |  2 +-
 arch/sh/configs/kfr2r09_defconfig           |  2 +-
 arch/sh/configs/lboxre2_defconfig           |  2 +-
 arch/sh/configs/microdev_defconfig          |  2 +-
 arch/sh/configs/migor_defconfig             |  2 +-
 arch/sh/configs/polaris_defconfig           |  2 +-
 arch/sh/configs/r7780mp_defconfig           |  2 +-
 arch/sh/configs/r7785rp_defconfig           |  2 +-
 arch/sh/configs/rsk7201_defconfig           |  2 +-
 arch/sh/configs/rsk7203_defconfig           |  2 +-
 arch/sh/configs/rts7751r2d1_defconfig       |  2 +-
 arch/sh/configs/rts7751r2dplus_defconfig    |  2 +-
 arch/sh/configs/sdk7780_defconfig           |  2 +-
 arch/sh/configs/sdk7786_defconfig           |  2 +-
 arch/sh/configs/se7206_defconfig            |  2 +-
 arch/sh/configs/se7343_defconfig            |  2 +-
 arch/sh/configs/se7712_defconfig            |  2 +-
 arch/sh/configs/se7721_defconfig            |  2 +-
 arch/sh/configs/se7724_defconfig            |  2 +-
 arch/sh/configs/se7751_defconfig            |  2 +-
 arch/sh/configs/se7780_defconfig            |  2 +-
 arch/sh/configs/sh03_defconfig              |  2 +-
 arch/sh/configs/sh2007_defconfig            |  2 +-
 arch/sh/configs/sh7757lcr_defconfig         |  2 +-
 arch/sh/configs/sh7763rdp_defconfig         |  2 +-
 arch/sh/configs/shmin_defconfig             |  2 +-
 arch/sh/configs/shx3_defconfig              |  2 +-
 arch/sh/configs/titan_defconfig             |  2 +-
 arch/sh/configs/ul2_defconfig               |  2 +-
 arch/sh/kernel/setup.c                      | 11 ++------
 38 files changed, 39 insertions(+), 74 deletions(-)
arch/sh/Kconfig +1 -29
index e798e55915c2..fab84f62448c 100644
@@ -16,6 +16,7 @@ config SUPERH
 	select CPU_NO_EFFICIENT_FFS
 	select DMA_DECLARE_COHERENT
 	select GENERIC_ATOMIC64
+	select GENERIC_CMDLINE
 	select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IRQ_SHOW
@@ -742,35 +743,6 @@ config ROMIMAGE_MMCIF
 	  first part of the romImage which in turn loads the rest the kernel
 	  image to RAM using the MMCIF hardware block.
 
-choice
-	prompt "Kernel command line"
-	optional
-	default CMDLINE_OVERWRITE
-	help
-	  Setting this option allows the kernel command line arguments
-	  to be set.
-
-config CMDLINE_OVERWRITE
-	bool "Overwrite bootloader kernel arguments"
-	help
-	  Given string will overwrite any arguments passed in by
-	  a bootloader.
-
-config CMDLINE_EXTEND
-	bool "Extend bootloader kernel arguments"
-	help
-	  Given string will be concatenated with arguments passed in
-	  by a bootloader.
-
-endchoice
-
-config CMDLINE
-	string "Kernel command line arguments string"
-	depends on CMDLINE_OVERWRITE || CMDLINE_EXTEND
-	default "console=ttySC1,115200"
-
-endmenu
-
 menu "Bus options"
 
 config SUPERHYWAY
arch/sh/configs/ap325rxa_defconfig +1 -1
index 5193b3e099b9..3997aa49c75b 100644
@@ -15,7 +15,7 @@ CONFIG_SH_AP325RXA=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_SECCOMP=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty1 console=ttySC5,38400 root=/dev/nfs ip=dhcp"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/dreamcast_defconfig +1 -1
index 6a82c7b8ff32..ac030c1a351e 100644
@@ -22,7 +22,7 @@ CONFIG_NR_DMA_CHANNELS_BOOL=y
 CONFIG_NR_DMA_CHANNELS=9
 CONFIG_SECCOMP=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 panic=3"
 CONFIG_MAPLE=y
 CONFIG_PCI=y
arch/sh/configs/ecovec24-romimage_defconfig +1 -1
index 5c60e71d839e..db78857ae30f 100644
@@ -14,7 +14,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_ECOVEC=y
 # CONFIG_SH_TIMER_TMU is not set
 CONFIG_KEXEC=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200"
 # CONFIG_SUSPEND is not set
 CONFIG_NET=y
arch/sh/configs/ecovec24_defconfig +1 -1
index 03cb916819fa..f6f7d2e1840d 100644
@@ -16,7 +16,7 @@ CONFIG_SH_ECOVEC=y
 CONFIG_HEARTBEAT=y
 CONFIG_SECCOMP=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty0, console=ttySC0,115200 root=/dev/nfs ip=dhcp mem=248M memchunk.vpu=8m memchunk.veu0=4m"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/edosk7760_defconfig +1 -1
index d77f54e906fd..1ac8eb89c550 100644
@@ -19,7 +19,7 @@ CONFIG_HIGH_RES_TIMERS=y
 CONFIG_SH_DMA=y
 CONFIG_SH_DMA_API=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="mem=64M console=ttySC2,115200 root=/dev/nfs rw nfsroot=192.168.0.3:/scripts/filesys ip=192.168.0.4"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/espt_defconfig +1 -1
index 2804cb760a76..1bffacbaba3d 100644
@@ -14,7 +14,7 @@ CONFIG_MEMORY_START=0x0c000000
 CONFIG_SH_ESPT=y
 CONFIG_SH_PCLK_FREQ=66666666
 CONFIG_SECCOMP=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/nfs ip=bootp"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/j2_defconfig +1 -1
index 2eb81ebe3888..983c62e936eb 100644
@@ -10,7 +10,7 @@ CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_SH_DEVICE_TREE=y
 CONFIG_SH_JCORE_SOC=y
 CONFIG_HZ_100=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttyUL0 earlycon"
 CONFIG_BINFMT_ELF_FDPIC=y
 CONFIG_BINFMT_FLAT=y
arch/sh/configs/kfr2r09-romimage_defconfig +1 -1
index 04436b4fbd76..8418c1f0c1ce 100644
@@ -15,7 +15,7 @@ CONFIG_SH_KFR2R09=y
 # CONFIG_SH_TIMER_TMU is not set
 CONFIG_HZ_100=y
 CONFIG_KEXEC=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 quiet"
 # CONFIG_SUSPEND is not set
 CONFIG_NET=y
arch/sh/configs/kfr2r09_defconfig +1 -1
index 833404490cfe..0b04d179ebba 100644
@@ -19,7 +19,7 @@ CONFIG_NO_HZ=y
 CONFIG_HZ_1000=y
 CONFIG_KEXEC=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty0 console=ttySC1,115200"
 # CONFIG_SUSPEND is not set
 CONFIG_CPU_IDLE=y
arch/sh/configs/lboxre2_defconfig +1 -1
index 05e4ac6fed5f..498c88953d2a 100644
@@ -12,7 +12,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_LBOX_RE2=y
 CONFIG_SH_PCLK_FREQ=40000000
 CONFIG_KEXEC=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 root=/dev/sda1"
 CONFIG_PCI=y
 CONFIG_PCCARD=y
arch/sh/configs/microdev_defconfig +1 -1
index e9825196dd66..8467de1d3092 100644
@@ -11,7 +11,7 @@ CONFIG_SH_DMA=y
 CONFIG_SH_DMA_API=y
 CONFIG_HEARTBEAT=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/hda1"
 CONFIG_SUPERHYWAY=y
 CONFIG_NET=y
arch/sh/configs/migor_defconfig +1 -1
index 4859cd30cfc4..e43fb2a63f1f 100644
@@ -15,7 +15,7 @@ CONFIG_NUMA=y
 CONFIG_SH_MIGOR=y
 # CONFIG_SH_TIMER_CMT is not set
 CONFIG_SECCOMP=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty0 console=ttySC0,115200 earlyprintk=serial ip=on root=/dev/nfs ip=dhcp"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/polaris_defconfig +1 -1
index 246408ec7462..2fc2bdc0e002 100644
@@ -25,7 +25,7 @@ CONFIG_SH_DMA_API=y
 CONFIG_HEARTBEAT=y
 CONFIG_HZ_100=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 root=/dev/mtdblock2 rootfstype=jffs2 mem=63M mtdparts=physmap-flash.0:0x00100000(bootloader)ro,0x00500000(Kernel)ro,0x00A00000(Filesystem)"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/r7780mp_defconfig +1 -1
index f823cc6b18f9..9e2438114890 100644
@@ -20,7 +20,7 @@ CONFIG_SH_PCLK_FREQ=33333333
 CONFIG_PUSH_SWITCH=y
 CONFIG_KEXEC=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda1"
 CONFIG_PCI=y
 CONFIG_NET=y
arch/sh/configs/r7785rp_defconfig +1 -1
index f96bc20d4b1a..c1c92f154694 100644
@@ -26,7 +26,7 @@ CONFIG_HEARTBEAT=y
 CONFIG_PUSH_SWITCH=y
 CONFIG_KEXEC=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda1"
 CONFIG_PCI=y
 CONFIG_BINFMT_MISC=m
arch/sh/configs/rsk7201_defconfig +1 -1
index e41526120be1..65f3d695bc78 100644
@@ -21,7 +21,7 @@ CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_SH_RSK=y
 CONFIG_SH_PCLK_FREQ=40000000
 CONFIG_HZ_1000=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel"
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
arch/sh/configs/rsk7203_defconfig +1 -1
index 6af08fa1ddf8..33f608c54b85 100644
@@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y
 CONFIG_SH_CPU_FREQ=y
 CONFIG_HEARTBEAT=y
 CONFIG_HZ_1000=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel"
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
arch/sh/configs/rts7751r2d1_defconfig +1 -1
index 96263a4912b7..131699a6daa7 100644
@@ -11,7 +11,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_RTS7751R2D=y
 CONFIG_RTS7751R2D_1=y
 CONFIG_HEARTBEAT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 root=/dev/sda1"
 CONFIG_PCI=y
 CONFIG_HOTPLUG_PCI=y
arch/sh/configs/rts7751r2dplus_defconfig +1 -1
index 92e586e6c974..ffa76ad8efaa 100644
@@ -11,7 +11,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_RTS7751R2D=y
 CONFIG_RTS7751R2D_PLUS=y
 CONFIG_HEARTBEAT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 root=/dev/sda1"
 CONFIG_PCI=y
 CONFIG_HOTPLUG_PCI=y
arch/sh/configs/sdk7780_defconfig +1 -1
index 6c719ab4332a..a33f81c41a13 100644
@@ -22,7 +22,7 @@ CONFIG_SH_DMA=y
 CONFIG_SH_DMA_API=y
 CONFIG_HEARTBEAT=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="mem=128M console=tty0 console=ttySC0,115200 ip=bootp root=/dev/nfs nfsroot=192.168.0.1:/home/rootfs"
 CONFIG_PCI=y
 CONFIG_PCI_DEBUG=y
arch/sh/configs/sdk7786_defconfig +1 -1
index f776a1d0d277..1daf3dbffc16 100644
@@ -70,7 +70,7 @@ CONFIG_HOTPLUG_CPU=y
 CONFIG_PREEMPT=y
 CONFIG_INTC_USERIMASK=y
 CONFIG_INTC_BALANCING=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 earlyprintk=sh-sci.1,115200 root=/dev/sda1 nmi_debug=state,debounce rootdelay=5 pmb=iomap ignore_loglevel"
 CONFIG_PCI=y
 CONFIG_PCIEPORTBUS=y
arch/sh/configs/se7206_defconfig +1 -1
index 315b04a8dd2f..c729ddb5d2c8 100644
@@ -36,7 +36,7 @@ CONFIG_SH_CPU_FREQ=y
 CONFIG_HEARTBEAT=y
 CONFIG_HZ_1000=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC3,115200 ignore_loglevel earlyprintk=serial"
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
arch/sh/configs/se7343_defconfig +1 -1
index 5d6c19338ebf..32fedfd8ae81 100644
@@ -17,7 +17,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_7343_SOLUTION_ENGINE=y
 # CONFIG_SH_TIMER_CMT is not set
 CONFIG_HEARTBEAT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/se7712_defconfig +1 -1
index ee6d28ae08de..02a8dcb898db 100644
@@ -22,7 +22,7 @@ CONFIG_SH_SOLUTION_ENGINE=y
 CONFIG_SH_PCLK_FREQ=66666666
 CONFIG_HEARTBEAT=y
 CONFIG_PREEMPT_VOLUNTARY=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda1"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/se7721_defconfig +1 -1
index bad921bc10f8..a0ce6eca3bf5 100644
@@ -22,7 +22,7 @@ CONFIG_SH_7721_SOLUTION_ENGINE=y
 CONFIG_SH_PCLK_FREQ=33333333
 CONFIG_HEARTBEAT=y
 CONFIG_PREEMPT_VOLUNTARY=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda2"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/se7724_defconfig +1 -1
index a26f7f1841c7..9cd50acd959d 100644
@@ -17,7 +17,7 @@ CONFIG_SH_DMA_API=y
 CONFIG_HEARTBEAT=y
 CONFIG_SECCOMP=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=tty1 console=ttySC3,115200 root=/dev/nfs ip=dhcp memchunk.vpu=4m"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/se7751_defconfig +1 -1
index 4a024065bb75..8c2beb3677e2 100644
@@ -12,7 +12,7 @@ CONFIG_MEMORY_START=0x0c000000
 CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_7751_SOLUTION_ENGINE=y
 CONFIG_HEARTBEAT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,38400"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/se7780_defconfig +1 -1
index dcd85b858ac8..3be23f65c38e 100644
@@ -14,7 +14,7 @@ CONFIG_MEMORY_SIZE=0x08000000
 CONFIG_SH_7780_SOLUTION_ENGINE=y
 CONFIG_SH_PCLK_FREQ=33333333
 CONFIG_HEARTBEAT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda1"
 CONFIG_PCI=y
 CONFIG_NET=y
arch/sh/configs/sh03_defconfig +1 -1
index ff502683132e..87e9805b76d0 100644
@@ -16,7 +16,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_SH03=y
 CONFIG_HEARTBEAT=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 mem=64M root=/dev/nfs"
 CONFIG_PCI=y
 CONFIG_HOTPLUG_PCI=y
arch/sh/configs/sh2007_defconfig +1 -1
index 99975db461d8..8e92c58316db 100644
@@ -20,7 +20,7 @@ CONFIG_SH_DMA=y
 CONFIG_SH_DMA_API=y
 CONFIG_NR_DMA_CHANNELS_BOOL=y
 CONFIG_HZ_100=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 ip=dhcp root=/dev/nfs rw nfsroot=/nfs/rootfs,rsize=1024,wsize=1024 earlyprintk=sh-sci.1"
 CONFIG_PCCARD=y
 CONFIG_BINFMT_MISC=y
arch/sh/configs/sh7757lcr_defconfig +1 -1
index a2700ab165af..a15877daff16 100644
@@ -21,7 +21,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_SH_SH7757LCR=y
 CONFIG_HEARTBEAT=y
 CONFIG_SECCOMP=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC2,115200 root=/dev/nfs ip=dhcp"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/sh7763rdp_defconfig +1 -1
index 8a6a446f9eb8..351ccabac8a6 100644
@@ -14,7 +14,7 @@ CONFIG_MEMORY_START=0x0c000000
 CONFIG_SH_SH7763RDP=y
 CONFIG_SH_PCLK_FREQ=66666666
 CONFIG_SECCOMP=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC2,115200 root=/dev/sda1 rootdelay=10"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/configs/shmin_defconfig +1 -1
index c0b6f40d01cc..7cc8725951f5 100644
@@ -18,7 +18,7 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SH_ADC is not set
 CONFIG_SH_SHMIN=y
 CONFIG_SH_PCLK_FREQ=32000000
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,115200 root=1f01 mtdparts=phys_mapped_flash:64k(firm)ro,-(sys) netdev=34,0x300,eth0 "
 CONFIG_NET=y
 CONFIG_UNIX=y
arch/sh/configs/shx3_defconfig +1 -1
index 32ec6eb1eabc..36cac3067cef 100644
@@ -47,7 +47,7 @@ CONFIG_KEXEC=y
 CONFIG_SECCOMP=y
 CONFIG_SMP=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=bios ignore_loglevel"
 CONFIG_BINFMT_MISC=y
 CONFIG_NET=y
arch/sh/configs/titan_defconfig +1 -1
index ba887f1351be..5aa513d54df0 100644
@@ -20,7 +20,7 @@ CONFIG_SH_PCLK_FREQ=30000000
 CONFIG_SH_DMA=y
 CONFIG_SH_DMA_API=y
 CONFIG_PREEMPT_VOLUNTARY=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC1,38400N81 root=/dev/nfs ip=:::::eth1:autoconf rw"
 CONFIG_PCI=y
 CONFIG_HOTPLUG_PCI=y
arch/sh/configs/ul2_defconfig +1 -1
index 103b81ec1ffb..8d8b6787302f 100644
@@ -18,7 +18,7 @@ CONFIG_HIGH_RES_TIMERS=y
 CONFIG_HZ_100=y
 CONFIG_KEXEC=y
 CONFIG_PREEMPT=y
-CONFIG_CMDLINE_OVERWRITE=y
+CONFIG_CMDLINE_FORCE=y
 CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/nfs ip=dhcp"
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/sh/kernel/setup.c +2 -9
index 4144be650d41..303b8658a870 100644
@@ -32,6 +32,7 @@
 #include <linux/of.h>
 #include <linux/of_fdt.h>
 #include <linux/uaccess.h>
+#include <linux/cmdline.h>
 #include <uapi/linux/mount.h>
 #include <asm/io.h>
 #include <asm/page.h>
@@ -306,15 +307,7 @@ void __init setup_arch(char **cmdline_p)
 	bss_resource.start = virt_to_phys(__bss_start);
 	bss_resource.end = virt_to_phys(__bss_stop)-1;
 
-#ifdef CONFIG_CMDLINE_OVERWRITE
-	strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line));
-#else
-	strlcpy(command_line, COMMAND_LINE, sizeof(command_line));
-#ifdef CONFIG_CMDLINE_EXTEND
-	strlcat(command_line, " ", sizeof(command_line));
-	strlcat(command_line, CONFIG_CMDLINE, sizeof(command_line));
-#endif
-#endif
+	cmdline_build(command_line, COMMAND_LINE, sizeof(command_line));
 
 	/* Save unparsed command line copy for /proc/cmdline */
 	memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
Signature · 1 line
2.25.0
#32 lore raw

Re: [PATCH v3 12/17] sh: Convert to GENERIC_CMDLINE

Le 26/03/2021 à 14:44, Christophe Leroy a écrit :

Quoted 40 lines

This converts the architecture to GENERIC_CMDLINE.

---

arch/sh/Kconfig +1 -19
index e798e55915c2..fab84f62448c 100644
@@ -16,6 +16,7 @@ config SUPERH
  	select CPU_NO_EFFICIENT_FFS
  	select DMA_DECLARE_COHERENT
  	select GENERIC_ATOMIC64
+	select GENERIC_CMDLINE
  	select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST
  	select GENERIC_IDLE_POLL_SETUP
  	select GENERIC_IRQ_SHOW
@@ -742,35 +743,6 @@ config ROMIMAGE_MMCIF
  	  first part of the romImage which in turn loads the rest the kernel
  	  image to RAM using the MMCIF hardware block.
 
-choice
-	prompt "Kernel command line"
-	optional
-	default CMDLINE_OVERWRITE
-	help
-	  Setting this option allows the kernel command line arguments
-	  to be set.
-
-config CMDLINE_OVERWRITE
-	bool "Overwrite bootloader kernel arguments"
-	help
-	  Given string will overwrite any arguments passed in by
-	  a bootloader.
-
-config CMDLINE_EXTEND
-	bool "Extend bootloader kernel arguments"
-	help
-	  Given string will be concatenated with arguments passed in
-	  by a bootloader.

arch/sh/Kconfig config ROMIMAGE_MMCIF · line 773

Quoted 10 lines
arch/sh/Kconfig +0 -10
-
-endchoice
-
-config CMDLINE
-	string "Kernel command line arguments string"
-	depends on CMDLINE_OVERWRITE || CMDLINE_EXTEND
-	default "console=ttySC1,115200"
-
-endmenu
-

That "endmenu" shall not be removed.

Fixed in v4,

Thanks to Rob L. for the report.
Christophe

Quoted 3 lines
arch/sh/Kconfig +0 -0
  menu "Bus options"
 
  config SUPERHYWAY
#33 lore raw

PATCH v3 13/17 sparc: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/sparc/Kconfig           | 18 +-----------------
 arch/sparc/prom/bootstr_64.c |  2 +-
 2 files changed, 2 insertions(+), 18 deletions(-)
arch/sparc/Kconfig +1 -16
index 164a5254c91c..2a197f3a2549 100644
@@ -50,6 +50,7 @@ config SPARC
 	select NEED_DMA_MAP_STATE
 	select NEED_SG_DMA_LENGTH
 	select SET_FS
+	select GENERIC_CMDLINE if SPARC64
 
 config SPARC32
 	def_bool !64BIT
@@ -313,23 +314,6 @@ config SCHED_MC
 	  making when dealing with multi-core CPU chips at a cost of slightly
 	  increased overhead in some places. If unsure say N here.
 
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-	depends on SPARC64
-
-config CMDLINE
-	string "Initial kernel command string"
-	depends on CMDLINE_BOOL
-	default "console=ttyS0,9600 root=/dev/sda1"
-	help
-	  Say Y here if you want to be able to pass default arguments to
-	  the kernel. This will be overridden by the bootloader, if you
-	  use one (such as SILO). This is most useful if you want to boot
-	  a kernel from TFTP, and want default options to be available
-	  with having them passed on the command line.
-
-	  NOTE: This option WILL override the PROM bootargs setting!
#34 lore raw

PATCH v3 14/17 xtensa: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/xtensa/Kconfig                         | 15 +--------------
 arch/xtensa/configs/audio_kc705_defconfig   |  1 -
 arch/xtensa/configs/common_defconfig        |  1 -
 arch/xtensa/configs/generic_kc705_defconfig |  1 -
 arch/xtensa/configs/iss_defconfig           |  1 -
 arch/xtensa/configs/nommu_kc705_defconfig   |  1 -
 arch/xtensa/configs/smp_lx200_defconfig     |  1 -
 arch/xtensa/configs/virt_defconfig          |  1 -
 arch/xtensa/configs/xip_kc705_defconfig     |  1 -
 arch/xtensa/kernel/setup.c                  | 10 ++--------
 10 files changed, 3 insertions(+), 30 deletions(-)
arch/xtensa/Kconfig +1 -14
index 9ad6b7b82707..42309f5e9cda 100644
@@ -16,6 +16,7 @@ config XTENSA
 	select COMMON_CLK
 	select DMA_REMAP if MMU
 	select GENERIC_ATOMIC64
+	select GENERIC_CMDLINE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
@@ -353,20 +354,6 @@ config GENERIC_CALIBRATE_DELAY
 	help
 	  The BogoMIPS value can easily be derived from the CPU frequency.
 
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-
-config CMDLINE
-	string "Initial kernel command string"
-	depends on CMDLINE_BOOL
-	default "console=ttyS0,38400 root=/dev/ram"
-	help
-	  On some architectures (EBSA110 and CATS), there is currently no way
-	  for the boot loader to pass arguments to the kernel. For these
-	  architectures, you should supply some command-line options at build
-	  time by entering them here. As a minimum, you should specify the
-	  memory size and the root device (e.g., mem=64M root=/dev/nfs).
-
 config USE_OF
 	bool "Flattened Device Tree support"
 	select OF
arch/xtensa/configs/audio_kc705_defconfig +0 -1
index 3be62da8089b..5f8661a33ab4 100644
@@ -27,7 +27,6 @@ CONFIG_PREEMPT=y
 CONFIG_HIGHMEM=y
 # CONFIG_PCI is not set
 CONFIG_XTENSA_PLATFORM_XTFPGA=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000@0"
 CONFIG_USE_OF=y
 CONFIG_BUILTIN_DTB_SOURCE="kc705"
arch/xtensa/configs/common_defconfig +0 -1
index fa9389869154..6467ebcbb080 100644
@@ -6,7 +6,6 @@ CONFIG_MODULES=y
 CONFIG_MODVERSIONS=y
 CONFIG_XTENSA_PLATFORM_XT2000=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,38400 ip=bootp root=nfs nfsroot=/opt/montavista/pro/devkit/xtensa/linux_be/target memmap=128M@0"
 CONFIG_BINFMT_MISC=y
 CONFIG_NET=y
arch/xtensa/configs/generic_kc705_defconfig +0 -1
index e9d6b6f6eca1..8984c4e68a42 100644
@@ -26,7 +26,6 @@ CONFIG_PREEMPT=y
 CONFIG_HIGHMEM=y
 # CONFIG_PCI is not set
 CONFIG_XTENSA_PLATFORM_XTFPGA=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000@0"
 CONFIG_USE_OF=y
 CONFIG_BUILTIN_DTB_SOURCE="kc705"
arch/xtensa/configs/iss_defconfig +0 -1
index 32ce8fb068f0..996ad115264d 100644
@@ -2,7 +2,6 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 # CONFIG_PCI is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,38400 eth0=tuntap,,tap0 ip=192.168.168.5:192.168.168.1 root=nfs nfsroot=192.168.168.1:/opt/montavista/pro/devkit/xtensa/linux_be/target memmap=128M@0"
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_NET=y
arch/xtensa/configs/nommu_kc705_defconfig +0 -1
index 88b2e222d4bf..54250bc74885 100644
@@ -33,7 +33,6 @@ CONFIG_PREEMPT=y
 CONFIG_MEMMAP_CACHEATTR=0xfff2442f
 # CONFIG_PCI is not set
 CONFIG_XTENSA_PLATFORM_XTFPGA=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0x9d050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=256M@0x60000000"
 CONFIG_USE_OF=y
 CONFIG_BUILTIN_DTB_SOURCE="kc705_nommu"
arch/xtensa/configs/smp_lx200_defconfig +0 -1
index a47c85638ec1..58b284fd627f 100644
@@ -30,7 +30,6 @@ CONFIG_HOTPLUG_CPU=y
 # CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX is not set
 # CONFIG_PCI is not set
 CONFIG_XTENSA_PLATFORM_XTFPGA=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=96M@0"
 CONFIG_USE_OF=y
 CONFIG_BUILTIN_DTB_SOURCE="lx200mx"
arch/xtensa/configs/virt_defconfig +0 -1
index 6d1387dfa96f..fb4dce2c70a3 100644
@@ -21,7 +21,6 @@ CONFIG_XTENSA_VARIANT_DC233C=y
 CONFIG_XTENSA_UNALIGNED_USER=y
 CONFIG_XTENSA_KSEG_512M=y
 CONFIG_HIGHMEM=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x80000000@0"
 CONFIG_USE_OF=y
 CONFIG_BUILTIN_DTB_SOURCE="virt"
arch/xtensa/configs/xip_kc705_defconfig +0 -1
index 4f1ff9531f6a..ae4427773af2 100644
@@ -26,7 +26,6 @@ CONFIG_KERNEL_LOAD_ADDRESS=0xf6000000
 CONFIG_XTENSA_KSEG_512M=y
 CONFIG_HIGHMEM=y
 CONFIG_XTENSA_PLATFORM_XTFPGA=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000@0"
 CONFIG_USE_OF=y
 CONFIG_BUILTIN_DTB_SOURCE="kc705"
arch/xtensa/kernel/setup.c +2 -8
index ed184106e4cf..9703c23a9c3f 100644
@@ -25,6 +25,7 @@
 #include <linux/cpu.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
+#include <linux/cmdline.h>
 
 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
 # include <linux/console.h>
@@ -73,10 +74,6 @@ extern unsigned long loops_per_jiffy;
 
 static char __initdata command_line[COMMAND_LINE_SIZE];
 
-#ifdef CONFIG_CMDLINE_BOOL
-static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
-#endif
-
 #ifdef CONFIG_PARSE_BOOTPARAM
 /*
  * Boot parameter parsing.
@@ -257,10 +254,7 @@ void __init init_arch(bp_tag_t *bp_start)
 	early_init_devtree(dtb_start);
 #endif
 
-#ifdef CONFIG_CMDLINE_BOOL
-	if (!command_line[0])
-		strlcpy(command_line, default_command_line, COMMAND_LINE_SIZE);
-#endif
+	cmdline(command_line, command_line, COMMAND_LINE_SIZE);
 
 	/* Early hook for platforms */
 
Signature · 1 line
2.25.0
#35 lore raw

PATCH v3 15/17 x86: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/x86/Kconfig                        | 45 ++-----------------------
 arch/x86/kernel/setup.c                 | 17 ++--------
 drivers/firmware/efi/libstub/x86-stub.c | 26 +++++++-------
 3 files changed, 18 insertions(+), 70 deletions(-)
arch/x86/Kconfig +2 -43
index 2792879d398e..66b384228ca3 100644
@@ -104,6 +104,7 @@ config X86
 	select ARCH_USE_QUEUED_SPINLOCKS
 	select ARCH_USE_SYM_ANNOTATIONS
 	select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
+	select ARCH_WANT_CMDLINE_PREPEND_BY_DEFAULT
 	select ARCH_WANT_DEFAULT_BPF_JIT	if X86_64
 	select ARCH_WANTS_DYNAMIC_TASK_STRUCT
 	select ARCH_WANT_HUGE_PMD_SHARE
@@ -118,6 +119,7 @@ config X86
 	select EDAC_SUPPORT
 	select GENERIC_CLOCKEVENTS_BROADCAST	if X86_64 || (X86_32 && X86_LOCAL_APIC)
 	select GENERIC_CLOCKEVENTS_MIN_ADJUST
+	select GENERIC_CMDLINE
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
@@ -2358,49 +2360,6 @@ choice
 
 endchoice
 
-config CMDLINE_BOOL
-	bool "Built-in kernel command line"
-	help
-	  Allow for specifying boot arguments to the kernel at
-	  build time.  On some systems (e.g. embedded ones), it is
-	  necessary or convenient to provide some or all of the
-	  kernel boot arguments with the kernel itself (that is,
-	  to not rely on the boot loader to provide them.)
-
-	  To compile command line arguments into the kernel,
-	  set this option to 'Y', then fill in the
-	  boot arguments in CONFIG_CMDLINE.
-
-	  Systems with fully functional boot loaders (i.e. non-embedded)
-	  should leave this option set to 'N'.
-
-config CMDLINE
-	string "Built-in kernel command string"
-	depends on CMDLINE_BOOL
-	default ""
-	help
-	  Enter arguments here that should be compiled into the kernel
-	  image and used at boot time.  If the boot loader provides a
-	  command line at boot time, it is appended to this string to
-	  form the full kernel command line, when the system boots.
-
-	  However, you can use the CONFIG_CMDLINE_OVERRIDE option to
-	  change this behavior.
-
-	  In most cases, the command line (whether built-in or provided
-	  by the boot loader) should specify the device for the root
-	  file system.
-
-config CMDLINE_OVERRIDE
-	bool "Built-in command line overrides boot loader arguments"
-	depends on CMDLINE_BOOL && CMDLINE != ""
-	help
-	  Set this option to 'Y' to have the kernel ignore the boot loader
-	  command line, and use ONLY the built-in command line.
-
-	  This is used to work around broken boot loaders.  This should
-	  be set to 'N' under normal conditions.
-
 config MODIFY_LDT_SYSCALL
 	bool "Enable the LDT (local descriptor table)" if EXPERT
 	default y
arch/x86/kernel/setup.c +2 -15
index d883176ef2ce..93ac57ea3e64 100644
@@ -5,6 +5,7 @@
  * This file contains the setup_arch() code, which handles the architecture-dependent
  * parts of early kernel initialization.
  */
+#include <linux/cmdline.h>
 #include <linux/console.h>
 #include <linux/crash_dump.h>
 #include <linux/dma-map-ops.h>
@@ -161,9 +162,6 @@ unsigned long saved_video_mode;
 #define RAMDISK_LOAD_FLAG		0x4000
 
 static char __initdata command_line[COMMAND_LINE_SIZE];
-#ifdef CONFIG_CMDLINE_BOOL
-static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
-#endif
 
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
 struct edd edd;
@@ -883,18 +881,7 @@ void __init setup_arch(char **cmdline_p)
 	bss_resource.start = __pa_symbol(__bss_start);
 	bss_resource.end = __pa_symbol(__bss_stop)-1;
 
-#ifdef CONFIG_CMDLINE_BOOL
-#ifdef CONFIG_CMDLINE_OVERRIDE
-	strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-#else
-	if (builtin_cmdline[0]) {
-		/* append boot loader cmdline to builtin */
-		strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
-		strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-		strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-	}
-#endif
-#endif
+	cmdline_build(boot_command_line, boot_command_line, COMMAND_LINE_SIZE);
 
 	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
drivers/firmware/efi/libstub/x86-stub.c +14 -12
index f14c4ff5839f..5413aff010ec 100644
@@ -6,6 +6,7 @@
  *
  * ----------------------------------------------------------------------- */
 
+#include <linux/cmdline.h>
 #include <linux/efi.h>
 #include <linux/pci.h>
 #include <linux/stddef.h>
@@ -674,6 +675,7 @@ unsigned long efi_main(efi_handle_t handle,
 	unsigned long buffer_start, buffer_end;
 	struct setup_header *hdr = &boot_params->hdr;
 	efi_status_t status;
+	char *cmdline;
 
 	efi_system_table = sys_table_arg;
 
@@ -735,22 +737,22 @@ unsigned long efi_main(efi_handle_t handle,
 		image_offset = 0;
 	}
 
-#ifdef CONFIG_CMDLINE_BOOL
-	status = efi_parse_options(CONFIG_CMDLINE);
+	cmdline = kzalloc(COMMAND_LINE_SIZE, GFP_KERNEL);
+	if (cmdline) {
+		unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
+					       ((u64)boot_params->ext_cmd_line_ptr << 32));
+
+		cmdline_build(cmdline, (char *)cmdline_paddr, COMMAND_LINE_SIZE);
+		status = efi_parse_options(cmdline);
+		kfree(cmdline);
+	} else {
+		efi_err("Failed to allocate memory\n");
+		goto fail;
+	}
 	if (status != EFI_SUCCESS) {
 		efi_err("Failed to parse options\n");
 		goto fail;
 	}
-#endif
-	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
-		unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
-					       ((u64)boot_params->ext_cmd_line_ptr << 32));
-		status = efi_parse_options((char *)cmdline_paddr);
-		if (status != EFI_SUCCESS) {
-			efi_err("Failed to parse options\n");
-			goto fail;
-		}
-	}
 
 	/*
 	 * At this point, an initrd may already have been loaded by the
Signature · 1 line
2.25.0
#36 lore raw

PATCH v3 16/17 mips: Convert to GENERIC_CMDLINE

In reply to Christophe Leroy

This converts the architecture to GENERIC_CMDLINE.

---
 arch/mips/Kconfig                         |  1 +
 arch/mips/Kconfig.debug                   | 44 -----------------------
 arch/mips/configs/ar7_defconfig           |  1 -
 arch/mips/configs/bcm47xx_defconfig       |  1 -
 arch/mips/configs/bcm63xx_defconfig       |  1 -
 arch/mips/configs/bmips_be_defconfig      |  1 -
 arch/mips/configs/bmips_stb_defconfig     |  1 -
 arch/mips/configs/capcella_defconfig      |  1 -
 arch/mips/configs/ci20_defconfig          |  1 -
 arch/mips/configs/cu1000-neo_defconfig    |  1 -
 arch/mips/configs/cu1830-neo_defconfig    |  1 -
 arch/mips/configs/e55_defconfig           |  1 -
 arch/mips/configs/generic_defconfig       |  1 -
 arch/mips/configs/gpr_defconfig           |  1 -
 arch/mips/configs/loongson3_defconfig     |  1 -
 arch/mips/configs/mpc30x_defconfig        |  1 -
 arch/mips/configs/rt305x_defconfig        |  1 -
 arch/mips/configs/tb0219_defconfig        |  1 -
 arch/mips/configs/tb0226_defconfig        |  1 -
 arch/mips/configs/tb0287_defconfig        |  1 -
 arch/mips/configs/workpad_defconfig       |  1 -
 arch/mips/configs/xway_defconfig          |  1 -
 arch/mips/kernel/relocate.c               |  4 +--
 arch/mips/kernel/setup.c                  | 40 ++-------------------
 arch/mips/pic32/pic32mzda/early_console.c |  2 +-
 arch/mips/pic32/pic32mzda/init.c          |  2 --
 26 files changed, 5 insertions(+), 108 deletions(-)
arch/mips/Kconfig +1 -0
index d89efba3d8a4..a65ce9ddbfce 100644
@@ -24,6 +24,7 @@ config MIPS
 	select CPU_NO_EFFICIENT_FFS if (TARGET_ISA_REV < 1)
 	select CPU_PM if CPU_IDLE
 	select GENERIC_ATOMIC64 if !64BIT
+	select GENERIC_CMDLINE
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_GETTIMEOFDAY
arch/mips/Kconfig.debug +0 -44

50 lines not on this page · raw message

arch/mips/configs/ar7_defconfig +0 -1
index cf9c6329b807..5e8adcd799d0 100644
@@ -120,5 +120,4 @@ CONFIG_SQUASHFS=y
 # CONFIG_ENABLE_MUST_CHECK is not set
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_DEBUG_FS=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
arch/mips/configs/bcm47xx_defconfig +0 -1
index 91ce75edbfb4..690f423509f0 100644
@@ -77,5 +77,4 @@ CONFIG_DEBUG_INFO_REDUCED=y
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200"
arch/mips/configs/bcm63xx_defconfig +0 -1
index 861f680184b9..19b15424f669 100644
@@ -65,5 +65,4 @@ CONFIG_PROC_KCORE=y
 # CONFIG_NETWORK_FILESYSTEMS is not set
 # CONFIG_CRYPTO_HW is not set
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200"
arch/mips/configs/bmips_be_defconfig +0 -1
index 032bb51defe8..2db7712acc5d 100644
@@ -75,5 +75,4 @@ CONFIG_NLS_ISO8859_1=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon"
arch/mips/configs/bmips_stb_defconfig +0 -1
index 625bd2d7e685..bc1659d43ca7 100644
@@ -86,5 +86,4 @@ CONFIG_NLS_ISO8859_1=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon"
arch/mips/configs/capcella_defconfig +0 -1
index 7bf8971af53b..300032a5caa0 100644
@@ -87,5 +87,4 @@ CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRYPTO_DEFLATE=m
 # CONFIG_CRYPTO_HW is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="mem=32M console=ttyVR0,38400"
arch/mips/configs/ci20_defconfig +0 -1
index ab7ebb066834..f874e421b54f 100644
@@ -203,5 +203,4 @@ CONFIG_PANIC_TIMEOUT=10
 # CONFIG_DEBUG_PREEMPT is not set
 CONFIG_STACKTRACE=y
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon console=ttyS4,115200 clk_ignore_unused"
arch/mips/configs/cu1000-neo_defconfig +0 -1
index 9d75f5b77d5d..03cb524967e7 100644
@@ -123,5 +123,4 @@ CONFIG_PANIC_TIMEOUT=10
 # CONFIG_DEBUG_PREEMPT is not set
 CONFIG_STACKTRACE=y
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon clk_ignore_unused"
arch/mips/configs/cu1830-neo_defconfig +0 -1
index 29decd0003c6..d733ccab494e 100644
@@ -126,5 +126,4 @@ CONFIG_PANIC_TIMEOUT=10
 # CONFIG_DEBUG_PREEMPT is not set
 CONFIG_STACKTRACE=y
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon clk_ignore_unused"
arch/mips/configs/e55_defconfig +0 -1
index fd82b858a8f0..ffc964d1bae7 100644
@@ -33,5 +33,4 @@ CONFIG_AUTOFS4_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyVR0,19200 ide0=0x1f0,0x3f6,40 mem=8M"
arch/mips/configs/generic_defconfig +0 -1
index 714169e411cf..6003f6c7aa09 100644
@@ -88,5 +88,4 @@ CONFIG_DEBUG_INFO_REDUCED=y
 CONFIG_DEBUG_FS=y
 # CONFIG_SCHED_DEBUG is not set
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon"
arch/mips/configs/gpr_defconfig +0 -1
index 5cb91509bb7c..8998d28b94c8 100644
@@ -306,5 +306,4 @@ CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRYPTO_DEFLATE=m
 # CONFIG_ENABLE_MUST_CHECK is not set
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
arch/mips/configs/loongson3_defconfig +0 -1
index 0e79f81217bc..c4f9a236bd1f 100644
@@ -408,5 +408,4 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_SCHED_DEBUG is not set
 # CONFIG_DEBUG_PREEMPT is not set
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="ieee754=relaxed"
arch/mips/configs/mpc30x_defconfig +0 -1
index d4e038802510..6ecef2a666fc 100644
@@ -49,5 +49,4 @@ CONFIG_AUTOFS4_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_CONFIGFS_FS=m
 CONFIG_NFS_FS=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="mem=32M console=ttyVR0,19200 ide0=0x170,0x376,73"
arch/mips/configs/rt305x_defconfig +0 -1
index fec5851c164b..c34441ce6621 100644
@@ -147,4 +147,3 @@ CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_SCHED_DEBUG is not set
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
arch/mips/configs/tb0219_defconfig +0 -1
index 6547f84750b5..ccf20bd156a1 100644
@@ -73,5 +73,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="cca=3 mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
arch/mips/configs/tb0226_defconfig +0 -1
index 7e099f7c2286..9f78fd00a4f6 100644
@@ -68,5 +68,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NFSD=m
 CONFIG_NFSD_V3=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="cca=3 mem=32M console=ttyVR0,115200"
arch/mips/configs/tb0287_defconfig +0 -1
index 0d881dd862c0..5529d0dacf94 100644
@@ -81,5 +81,4 @@ CONFIG_NFSD_V3=y
 CONFIG_FONTS=y
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="cca=3 mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
arch/mips/configs/workpad_defconfig +0 -1
index 891a5f77305d..ee712f7b5575 100644
@@ -61,5 +61,4 @@ CONFIG_TMPFS_POSIX_ACL=y
 CONFIG_NFS_FS=m
 CONFIG_NFSD=m
 CONFIG_NFSD_V3=y
-CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyVR0,19200 ide0=0x170,0x376,49 mem=16M"
arch/mips/configs/xway_defconfig +0 -1
index 9abbc0debc2a..ebd8dbdb0695 100644
@@ -153,4 +153,3 @@ CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_SCHED_DEBUG is not set
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
arch/mips/kernel/relocate.c +1 -3
index 499a5357c09f..13c955027696 100644
@@ -244,15 +244,13 @@ static inline __init unsigned long get_random_boot(void)
 static inline __init bool kaslr_disabled(void)
 {
 	char *str;
-
-#if defined(CONFIG_CMDLINE_BOOL)
 	const char *builtin_cmdline = CONFIG_CMDLINE;
 
 	str = strstr(builtin_cmdline, "nokaslr");
 	if (str == builtin_cmdline ||
 	    (str > builtin_cmdline && *(str - 1) == ' '))
 		return true;
-#endif
+
 	str = strstr(arcs_cmdline, "nokaslr");
 	if (str == arcs_cmdline || (str > arcs_cmdline && *(str - 1) == ' '))
 		return true;
arch/mips/kernel/setup.c +2 -38
index 279be0153f8b..e1ba44843c49 100644
@@ -29,6 +29,7 @@
 #include <linux/of_fdt.h>
 #include <linux/dmi.h>
 #include <linux/crash_dump.h>
+#include <linux/cmdline.h>
 
 #include <asm/addrspace.h>
 #include <asm/bootinfo.h>
@@ -66,12 +67,6 @@ EXPORT_SYMBOL(mips_machtype);
 static char __initdata command_line[COMMAND_LINE_SIZE];
 char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
 
-#ifdef CONFIG_CMDLINE_BOOL
-static const char builtin_cmdline[] __initconst = CONFIG_CMDLINE;
-#else
-static const char builtin_cmdline[] __initconst = "";
-#endif
-
 /*
  * mips_io_port_base is the begin of the address space to which x86 style
  * I/O ports are mapped.
@@ -546,28 +541,6 @@ static void __init bootcmdline_init(void)
 {
 	bool dt_bootargs = false;
 
-	/*
-	 * If CMDLINE_OVERRIDE is enabled then initializing the command line is
-	 * trivial - we simply use the built-in command line unconditionally &
-	 * unmodified.
-	 */
-	if (IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
-		strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-		return;
-	}
-
-	/*
-	 * If the user specified a built-in command line &
-	 * MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is
-	 * prepended to arguments from the bootloader or DT so we'll copy them
-	 * to the start of boot_command_line here. Otherwise, empty
-	 * boot_command_line to undo anything early_init_dt_scan_chosen() did.
-	 */
-	if (IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
-		strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-	else
-		boot_command_line[0] = 0;
-
 #ifdef CONFIG_OF_EARLY_FLATTREE
 	/*
 	 * If we're configured to take boot arguments from DT, look for those
@@ -585,16 +558,7 @@ static void __init bootcmdline_init(void)
 	 * plat_mem_setup() should have filled arcs_cmdline with arguments from
 	 * the bootloader.
 	 */
-	if (IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND) || !dt_bootargs)
-		bootcmdline_append(arcs_cmdline, COMMAND_LINE_SIZE);
-
-	/*
-	 * If the user specified a built-in command line & we didn't already
-	 * prepend it, we append it to boot_command_line here.
-	 */
-	if (IS_ENABLED(CONFIG_CMDLINE_BOOL) &&
-	    !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
-		bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE);
+	cmdline_build(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
 }
 
 /*
arch/mips/pic32/pic32mzda/early_console.c +1 -1
index 25372e62783b..94d3a5ba5e10 100644
@@ -75,7 +75,7 @@ static char * __init pic32_getcmdline(void)
 	 * arch_mem_init() has not been called yet, so we don't have a real
 	 * command line setup if using CONFIG_CMDLINE_BOOL.
 	 */
-#ifdef CONFIG_CMDLINE_OVERRIDE
+#ifdef CONFIG_CMDLINE_FORCE
 	return CONFIG_CMDLINE;
 #else
 	return fw_getcmdline();
arch/mips/pic32/pic32mzda/init.c +0 -2
index 764f2d022fae..39fdacbbac56 100644
@@ -40,9 +40,7 @@ void __init plat_mem_setup(void)
 	pr_info("Found following command lines\n");
 	pr_info(" boot_command_line: %s\n", boot_command_line);
 	pr_info(" arcs_cmdline     : %s\n", arcs_cmdline);
-#ifdef CONFIG_CMDLINE_BOOL
 	pr_info(" builtin_cmdline  : %s\n", CONFIG_CMDLINE);
-#endif
 	if (dtb != __dtb_start)
 		strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
 
Signature · 1 line
2.25.0
#37 lore raw

PATCH v3 17/17 cmdline: Remove CONFIG_CMDLINE_EXTEND

In reply to Christophe Leroy

All architectures providing CONFIG_CMDLINE_EXTEND
are now converted to GENERIC_CMDLINE.

This configuration item is not used anymore, drop it.

---
 init/Kconfig | 6 ------
 1 file changed, 6 deletions(-)
init/Kconfig +0 -6
index af0d84662cc2..fa002e3765ab 100644
@@ -163,12 +163,6 @@ config CMDLINE_FORCE
 	  arguments provided by the bootloader.
 endchoice
 
-config CMDLINE_EXTEND
-	bool
-	default CMDLINE_APPEND
-	help
-	  To be removed once all architectures are converted to generic CMDLINE
-
 config COMPILE_TEST
 	bool "Compile also drivers which will not load"
 	depends on HAS_IOMEM
Signature · 1 line
2.25.0
maintainer
#38 lore raw
In reply to Christophe Leroy
Quoted 121 lines · Christophe Leroy

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 <[email protected]>

Main changes in V3:
- Also accept destination equal to source in cmdline_build() by setting a tmp buffer in __initdata. Powerpc provides different source and destination and call __cmdline_build() directly.
- Taken comments received from Will and Rob
- Converted all architectures (Only tested on powerpc)

Christophe Leroy (17):
cmdline: Add generic function to build command line.
drivers: of: use cmdline building function
cmdline: Gives architectures opportunity to use generically defined
boot cmdline manipulation
powerpc: Convert to GENERIC_CMDLINE
arm: Convert to GENERIC_CMDLINE
arm64: Convert to GENERIC_CMDLINE
hexagon: Convert to GENERIC_CMDLINE
microblaze: Convert to GENERIC_CMDLINE
nios2: Convert to GENERIC_CMDLINE
openrisc: Convert to GENERIC_CMDLINE
riscv: Convert to GENERIC_CMDLINE
sh: Convert to GENERIC_CMDLINE
sparc: Convert to GENERIC_CMDLINE
xtensa: Convert to GENERIC_CMDLINE
x86: Convert to GENERIC_CMDLINE
mips: Convert to GENERIC_CMDLINE
cmdline: Remove CONFIG_CMDLINE_EXTEND

 arch/arm/Kconfig                            | 38 +-------------
 arch/arm/kernel/atags_parse.c               | 15 ++----
 arch/arm64/Kconfig                          | 33 +-----------
 arch/arm64/kernel/idreg-override.c          |  9 ++--
 arch/hexagon/Kconfig                        | 11 +---
 arch/hexagon/kernel/setup.c                 | 10 +---
 arch/microblaze/Kconfig                     | 24 +--------
 arch/microblaze/configs/mmu_defconfig       |  2 +-
 arch/microblaze/kernel/head.S               |  4 +-
 arch/mips/Kconfig                           |  1 +
 arch/mips/Kconfig.debug                     | 44 ----------------
 arch/mips/configs/ar7_defconfig             |  1 -
 arch/mips/configs/bcm47xx_defconfig         |  1 -
 arch/mips/configs/bcm63xx_defconfig         |  1 -
 arch/mips/configs/bmips_be_defconfig        |  1 -
 arch/mips/configs/bmips_stb_defconfig       |  1 -
 arch/mips/configs/capcella_defconfig        |  1 -
 arch/mips/configs/ci20_defconfig            |  1 -
 arch/mips/configs/cu1000-neo_defconfig      |  1 -
 arch/mips/configs/cu1830-neo_defconfig      |  1 -
 arch/mips/configs/e55_defconfig             |  1 -
 arch/mips/configs/generic_defconfig         |  1 -
 arch/mips/configs/gpr_defconfig             |  1 -
 arch/mips/configs/loongson3_defconfig       |  1 -
 arch/mips/configs/mpc30x_defconfig          |  1 -
 arch/mips/configs/rt305x_defconfig          |  1 -
 arch/mips/configs/tb0219_defconfig          |  1 -
 arch/mips/configs/tb0226_defconfig          |  1 -
 arch/mips/configs/tb0287_defconfig          |  1 -
 arch/mips/configs/workpad_defconfig         |  1 -
 arch/mips/configs/xway_defconfig            |  1 -
 arch/mips/kernel/relocate.c                 |  4 +-
 arch/mips/kernel/setup.c                    | 40 +--------------
 arch/mips/pic32/pic32mzda/early_console.c   |  2 +-
 arch/mips/pic32/pic32mzda/init.c            |  2 -
 arch/nios2/Kconfig                          | 24 +--------
 arch/nios2/kernel/setup.c                   | 13 ++---
 arch/openrisc/Kconfig                       | 10 +---
 arch/powerpc/Kconfig                        | 37 +------------
 arch/powerpc/kernel/prom_init.c             | 17 +++---
 arch/riscv/Kconfig                          | 44 +---------------
 arch/riscv/kernel/setup.c                   |  5 +-
 arch/sh/Kconfig                             | 30 +----------
 arch/sh/configs/ap325rxa_defconfig          |  2 +-
 arch/sh/configs/dreamcast_defconfig         |  2 +-
 arch/sh/configs/ecovec24-romimage_defconfig |  2 +-
 arch/sh/configs/ecovec24_defconfig          |  2 +-
 arch/sh/configs/edosk7760_defconfig         |  2 +-
 arch/sh/configs/espt_defconfig              |  2 +-
 arch/sh/configs/j2_defconfig                |  2 +-
 arch/sh/configs/kfr2r09-romimage_defconfig  |  2 +-
 arch/sh/configs/kfr2r09_defconfig           |  2 +-
 arch/sh/configs/lboxre2_defconfig           |  2 +-
 arch/sh/configs/microdev_defconfig          |  2 +-
 arch/sh/configs/migor_defconfig             |  2 +-
 arch/sh/configs/polaris_defconfig           |  2 +-
 arch/sh/configs/r7780mp_defconfig           |  2 +-
 arch/sh/configs/r7785rp_defconfig           |  2 +-
 arch/sh/configs/rsk7201_defconfig           |  2 +-
 arch/sh/configs/rsk7203_defconfig           |  2 +-
 arch/sh/configs/rts7751r2d1_defconfig       |  2 +-
 arch/sh/configs/rts7751r2dplus_defconfig    |  2 +-
 arch/sh/configs/sdk7780_defconfig           |  2 +-
 arch/sh/configs/sdk7786_defconfig           |  2 +-
 arch/sh/configs/se7206_defconfig            |  2 +-
 arch/sh/configs/se7343_defconfig            |  2 +-
 arch/sh/configs/se7712_defconfig            |  2 +-
 arch/sh/configs/se7721_defconfig            |  2 +-
 arch/sh/configs/se7724_defconfig            |  2 +-
 arch/sh/configs/se7751_defconfig            |  2 +-
 arch/sh/configs/se7780_defconfig            |  2 +-
 arch/sh/configs/sh03_defconfig              |  2 +-
 arch/sh/configs/sh2007_defconfig            |  2 +-
 arch/sh/configs/sh7757lcr_defconfig         |  2 +-
 arch/sh/configs/sh7763rdp_defconfig         |  2 +-
 arch/sh/configs/shmin_defconfig             |  2 +-
 arch/sh/configs/shx3_defconfig              |  2 +-
 arch/sh/configs/titan_defconfig             |  2 +-
 arch/sh/configs/ul2_defconfig               |  2 +-
 arch/sh/kernel/setup.c                      | 11 +---
 arch/sparc/Kconfig                          | 18 +------
 arch/sparc/prom/bootstr_64.c                |  2 +-
 arch/x86/Kconfig                            | 45 +---------------
 arch/x86/kernel/setup.c                     | 17 +-----
 arch/xtensa/Kconfig                         | 15 +-----
 arch/xtensa/configs/audio_kc705_defconfig   |  1 -
 arch/xtensa/configs/common_defconfig        |  1 -
Quoted 8 lines
 arch/xtensa/configs/generic_kc705_defconfig |  1 -
 arch/xtensa/configs/iss_defconfig           |  1 -
 arch/xtensa/configs/nommu_kc705_defconfig   |  1 -
 arch/xtensa/configs/smp_lx200_defconfig     |  1 -
 arch/xtensa/configs/virt_defconfig          |  1 -
 arch/xtensa/configs/xip_kc705_defconfig     |  1 -
 arch/xtensa/kernel/setup.c                  | 10 +---
 drivers/firmware/efi/libstub/x86-stub.c     | 26 +++++-----

You missed efi-stub.c which has CMDLINE_EXTEND.

Quoted 9 lines
 drivers/of/fdt.c                            | 23 ++-------
 include/linux/cmdline.h                     | 57 +++++++++++++++++++++
 init/Kconfig                                | 46 +++++++++++++++++
 98 files changed, 209 insertions(+), 580 deletions(-)
 create mode 100644 include/linux/cmdline.h

--
2.25.0

#39 lore raw

Le 26/03/2021 à 16:04, Rob Herring a écrit :

Quoted 132 lines
Quoted 121 lines · Christophe Leroy

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 <[email protected]>

Main changes in V3:
- Also accept destination equal to source in cmdline_build() by setting a tmp buffer in __initdata. Powerpc provides different source and destination and call __cmdline_build() directly.
- Taken comments received from Will and Rob
- Converted all architectures (Only tested on powerpc)

Christophe Leroy (17):
cmdline: Add generic function to build command line.
drivers: of: use cmdline building function
cmdline: Gives architectures opportunity to use generically defined
boot cmdline manipulation
powerpc: Convert to GENERIC_CMDLINE
arm: Convert to GENERIC_CMDLINE
arm64: Convert to GENERIC_CMDLINE
hexagon: Convert to GENERIC_CMDLINE
microblaze: Convert to GENERIC_CMDLINE
nios2: Convert to GENERIC_CMDLINE
openrisc: Convert to GENERIC_CMDLINE
riscv: Convert to GENERIC_CMDLINE
sh: Convert to GENERIC_CMDLINE
sparc: Convert to GENERIC_CMDLINE
xtensa: Convert to GENERIC_CMDLINE
x86: Convert to GENERIC_CMDLINE
mips: Convert to GENERIC_CMDLINE
cmdline: Remove CONFIG_CMDLINE_EXTEND

  arch/arm/Kconfig                            | 38 +-------------
  arch/arm/kernel/atags_parse.c               | 15 ++----
  arch/arm64/Kconfig                          | 33 +-----------
  arch/arm64/kernel/idreg-override.c          |  9 ++--
  arch/hexagon/Kconfig                        | 11 +---
  arch/hexagon/kernel/setup.c                 | 10 +---
  arch/microblaze/Kconfig                     | 24 +--------
  arch/microblaze/configs/mmu_defconfig       |  2 +-
  arch/microblaze/kernel/head.S               |  4 +-
  arch/mips/Kconfig                           |  1 +
  arch/mips/Kconfig.debug                     | 44 ----------------
  arch/mips/configs/ar7_defconfig             |  1 -
  arch/mips/configs/bcm47xx_defconfig         |  1 -
  arch/mips/configs/bcm63xx_defconfig         |  1 -
  arch/mips/configs/bmips_be_defconfig        |  1 -
  arch/mips/configs/bmips_stb_defconfig       |  1 -
  arch/mips/configs/capcella_defconfig        |  1 -
  arch/mips/configs/ci20_defconfig            |  1 -
  arch/mips/configs/cu1000-neo_defconfig      |  1 -
  arch/mips/configs/cu1830-neo_defconfig      |  1 -
  arch/mips/configs/e55_defconfig             |  1 -
  arch/mips/configs/generic_defconfig         |  1 -
  arch/mips/configs/gpr_defconfig             |  1 -
  arch/mips/configs/loongson3_defconfig       |  1 -
  arch/mips/configs/mpc30x_defconfig          |  1 -
  arch/mips/configs/rt305x_defconfig          |  1 -
  arch/mips/configs/tb0219_defconfig          |  1 -
  arch/mips/configs/tb0226_defconfig          |  1 -
  arch/mips/configs/tb0287_defconfig          |  1 -
  arch/mips/configs/workpad_defconfig         |  1 -
  arch/mips/configs/xway_defconfig            |  1 -
  arch/mips/kernel/relocate.c                 |  4 +-
  arch/mips/kernel/setup.c                    | 40 +--------------
  arch/mips/pic32/pic32mzda/early_console.c   |  2 +-
  arch/mips/pic32/pic32mzda/init.c            |  2 -
  arch/nios2/Kconfig                          | 24 +--------
  arch/nios2/kernel/setup.c                   | 13 ++---
  arch/openrisc/Kconfig                       | 10 +---
  arch/powerpc/Kconfig                        | 37 +------------
  arch/powerpc/kernel/prom_init.c             | 17 +++---
  arch/riscv/Kconfig                          | 44 +---------------
  arch/riscv/kernel/setup.c                   |  5 +-
  arch/sh/Kconfig                             | 30 +----------
  arch/sh/configs/ap325rxa_defconfig          |  2 +-
  arch/sh/configs/dreamcast_defconfig         |  2 +-
  arch/sh/configs/ecovec24-romimage_defconfig |  2 +-
  arch/sh/configs/ecovec24_defconfig          |  2 +-
  arch/sh/configs/edosk7760_defconfig         |  2 +-
  arch/sh/configs/espt_defconfig              |  2 +-
  arch/sh/configs/j2_defconfig                |  2 +-
  arch/sh/configs/kfr2r09-romimage_defconfig  |  2 +-
  arch/sh/configs/kfr2r09_defconfig           |  2 +-
  arch/sh/configs/lboxre2_defconfig           |  2 +-
  arch/sh/configs/microdev_defconfig          |  2 +-
  arch/sh/configs/migor_defconfig             |  2 +-
  arch/sh/configs/polaris_defconfig           |  2 +-
  arch/sh/configs/r7780mp_defconfig           |  2 +-
  arch/sh/configs/r7785rp_defconfig           |  2 +-
  arch/sh/configs/rsk7201_defconfig           |  2 +-
  arch/sh/configs/rsk7203_defconfig           |  2 +-
  arch/sh/configs/rts7751r2d1_defconfig       |  2 +-
  arch/sh/configs/rts7751r2dplus_defconfig    |  2 +-
  arch/sh/configs/sdk7780_defconfig           |  2 +-
  arch/sh/configs/sdk7786_defconfig           |  2 +-
  arch/sh/configs/se7206_defconfig            |  2 +-
  arch/sh/configs/se7343_defconfig            |  2 +-
  arch/sh/configs/se7712_defconfig            |  2 +-
  arch/sh/configs/se7721_defconfig            |  2 +-
  arch/sh/configs/se7724_defconfig            |  2 +-
  arch/sh/configs/se7751_defconfig            |  2 +-
  arch/sh/configs/se7780_defconfig            |  2 +-
  arch/sh/configs/sh03_defconfig              |  2 +-
  arch/sh/configs/sh2007_defconfig            |  2 +-
  arch/sh/configs/sh7757lcr_defconfig         |  2 +-
  arch/sh/configs/sh7763rdp_defconfig         |  2 +-
  arch/sh/configs/shmin_defconfig             |  2 +-
  arch/sh/configs/shx3_defconfig              |  2 +-
  arch/sh/configs/titan_defconfig             |  2 +-
  arch/sh/configs/ul2_defconfig               |  2 +-
  arch/sh/kernel/setup.c                      | 11 +---
  arch/sparc/Kconfig                          | 18 +------
  arch/sparc/prom/bootstr_64.c                |  2 +-
  arch/x86/Kconfig                            | 45 +---------------
  arch/x86/kernel/setup.c                     | 17 +-----
  arch/xtensa/Kconfig                         | 15 +-----
  arch/xtensa/configs/audio_kc705_defconfig   |  1 -
  arch/xtensa/configs/common_defconfig        |  1 -
Quoted 8 lines
  arch/xtensa/configs/generic_kc705_defconfig |  1 -
  arch/xtensa/configs/iss_defconfig           |  1 -
  arch/xtensa/configs/nommu_kc705_defconfig   |  1 -
  arch/xtensa/configs/smp_lx200_defconfig     |  1 -
  arch/xtensa/configs/virt_defconfig          |  1 -
  arch/xtensa/configs/xip_kc705_defconfig     |  1 -
  arch/xtensa/kernel/setup.c                  | 10 +---
  drivers/firmware/efi/libstub/x86-stub.c     | 26 +++++-----
Quoted 2 lines

You missed efi-stub.c which has CMDLINE_EXTEND.

I think I completely missed EFI.

Reworked in V4.