linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] generic command line v6
@ 2023-11-10  1:38 Daniel Walker
  2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
                   ` (9 more replies)
  0 siblings, 10 replies; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, H. Peter Anvin, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-arm-kernel, linux-kernel,
	devicetree, linux-kbuild
  Cc: linux-efi

This release is an up-rev of the v5 patches. No additional features have
been added. Some changes were mode to function names and some changes to
Kconfig dependencies. Also updated the config conversion for mips.

There are a number of people who have expressed interest in these
patches either by asking for them to be merge or testing them. If
people are so inclined please continue to request them to be merge
or to ask the status of the next release. It's helpful to motivate me to
release them again and for the maintainers to see the interest
generated.

These patches have been used by Cisco Systems, Inc. on millions of
released products to great effect. Hopefully they can be used by the
entire Linux eco system.

My apologies on the length between releases. I will try to release more
often.


Daniel Walker (8):
  CMDLINE: add generic builtin command line
  scripts: insert-sys-cert: add command line insert capability
  scripts: insert-sys-cert: change name to insert-symbol
  CMDLINE: mips: convert to generic builtin command line
  drivers: firmware: efi: libstub: enable generic commandline
  CMDLINE: x86: convert to generic builtin command line
  of: replace command line handling
  CMDLINE: arm64: convert to generic builtin command line

 arch/arm64/Kconfig                            |  33 +--
 arch/arm64/include/asm/setup.h                |   4 +
 arch/arm64/include/uapi/asm/setup.h           |   2 +
 arch/arm64/kernel/idreg-override.c            |   9 +-
 arch/arm64/kernel/pi/kaslr_early.c            |  14 +-
 arch/mips/Kconfig                             |   4 +-
 arch/mips/Kconfig.debug                       |  44 ----
 arch/mips/configs/ar7_defconfig               |  12 +-
 arch/mips/configs/bcm47xx_defconfig           |  10 +-
 arch/mips/configs/bcm63xx_defconfig           |  21 +-
 arch/mips/configs/bmips_be_defconfig          |  17 +-
 arch/mips/configs/bmips_stb_defconfig         | 139 ++++------
 arch/mips/configs/ci20_defconfig              |   8 +-
 arch/mips/configs/cu1000-neo_defconfig        |  19 +-
 arch/mips/configs/cu1830-neo_defconfig        |  19 +-
 arch/mips/configs/generic_defconfig           |  15 +-
 arch/mips/configs/gpr_defconfig               |  33 +--
 arch/mips/configs/loongson3_defconfig         |  29 +--
 arch/mips/include/asm/setup.h                 |   2 +
 arch/mips/kernel/relocate.c                   |  17 +-
 arch/mips/kernel/setup.c                      |  36 +--
 arch/mips/pic32/pic32mzda/early_console.c     |   2 +-
 arch/mips/pic32/pic32mzda/init.c              |   3 +-
 arch/x86/Kconfig                              |  44 +---
 arch/x86/kernel/setup.c                       |  18 +-
 .../firmware/efi/libstub/efi-stub-helper.c    |  29 +++
 drivers/firmware/efi/libstub/efi-stub.c       |   9 +
 drivers/firmware/efi/libstub/efistub.h        |   1 +
 drivers/firmware/efi/libstub/x86-stub.c       |  14 +-
 drivers/of/fdt.c                              |  22 +-
 include/linux/cmdline.h                       | 137 ++++++++++
 init/Kconfig                                  |  79 ++++++
 lib/Kconfig                                   |   4 +
 lib/Makefile                                  |   3 +
 lib/generic_cmdline.S                         |  53 ++++
 lib/test_cmdline1.c                           | 139 ++++++++++
 scripts/Makefile                              |   2 +-
 .../{insert-sys-cert.c => insert-symbol.c}    | 243 ++++++++++++------
 38 files changed, 807 insertions(+), 482 deletions(-)
 create mode 100644 include/linux/cmdline.h
 create mode 100644 lib/generic_cmdline.S
 create mode 100644 lib/test_cmdline1.c
 rename scripts/{insert-sys-cert.c => insert-symbol.c} (72%)

-- 
2.39.2


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

* [PATCH 1/8] CMDLINE: add generic builtin command line
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-10 16:12   ` kernel test robot
                     ` (2 more replies)
  2023-11-10  1:38 ` [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability Daniel Walker
                   ` (8 subsequent siblings)
  9 siblings, 3 replies; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, Ruslan Bilovol, linux-kernel

This code allows architectures to use a generic builtin command line.
The state of the builtin command line options across architecture is
diverse. MIPS and X86 once has similar systems, then mips added some
options to allow extending the command line. Powerpc did something
simiar in adding the ability to extend. Even with mips and powerpc
enhancement the needs of Cisco are not met on these platforms.

The code in this commit unifies the code into a generic
header file under the CONFIG_GENERIC_CMDLINE option. When this
option is enabled the architecture can call the cmdline_add_builtin()
to add the builtin command line. The generic code provides both
append and/or prepend options and provides a way to redefine these
option after the kernel is compiled.

This code also includes test's which are meant to confirm
functionality.

This unified implementation offers the same functionality needed by
Cisco on all platform which we enable it on.

Cc: xe-linux-external@cisco.com
Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 include/linux/cmdline.h | 106 ++++++++++++++++++++++++++++++
 init/Kconfig            |  79 +++++++++++++++++++++++
 lib/Kconfig             |   4 ++
 lib/Makefile            |   3 +
 lib/generic_cmdline.S   |  53 +++++++++++++++
 lib/test_cmdline1.c     | 139 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 384 insertions(+)
 create mode 100644 include/linux/cmdline.h
 create mode 100644 lib/generic_cmdline.S
 create mode 100644 lib/test_cmdline1.c

diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
new file mode 100644
index 000000000000..a94758a0f257
--- /dev/null
+++ b/include/linux/cmdline.h
@@ -0,0 +1,106 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+/*
+ *
+ * Copyright (C) 2006,2021. Cisco Systems, Inc.
+ *
+ * Generic Append/Prepend cmdline support.
+ */
+
+
+#include <linux/ctype.h>
+#include <linux/cache.h>
+#include <asm/setup.h>
+
+#ifdef CONFIG_CMDLINE_BOOL
+extern char cmdline_prepend[];
+extern char cmdline_append[];
+extern char cmdline_tmp[];
+#define CMDLINE_PREPEND cmdline_prepend
+#define CMDLINE_APPEND cmdline_append
+#define CMDLINE_TMP cmdline_tmp
+#define CMDLINE_STATIC_PREPEND CONFIG_CMDLINE_PREPEND
+#define CMDLINE_STATIC_APPEND CONFIG_CMDLINE_APPEND
+#else
+#define CMDLINE_PREPEND ""
+#define CMDLINE_APPEND ""
+#define CMDLINE_TMP ""
+#define CMDLINE_STATIC_PREPEND ""
+#define CMDLINE_STATIC_APPEND ""
+#endif
+
+#ifndef CMDLINE_STRLCAT
+#define CMDLINE_STRLCAT strlcat
+#endif
+
+#ifndef CMDLINE_STRLEN
+#define CMDLINE_STRLEN strlen
+#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.
+ * @dest: The destination of the final appended/prepended string
+ * @tmp: temporary space used for prepending
+ * @prepend: string to prepend to @dest
+ * @append: string to append to @dest
+ * @length: the maximum length of the strings above.
+ * @cmdline_strlen: point to a compatible strlen
+ * @cmdline_strlcat: point to a compatible strlcat
+ * This function returns true when the builtin command line was copied successfully
+ * and false when there was not enough room to copy all parts of the command line.
+ */
+static inline bool
+__cmdline_add_builtin(
+		char *dest,
+		char *tmp,
+		char *prepend,
+		char *append,
+		unsigned long length,
+		size_t (*cmdline_strlen)(const char *s),
+		size_t (*cmdline_strlcat)(char *dest, const char *src, size_t count))
+{
+	size_t total_length = 0, tmp_length;
+
+	if (!IS_ENABLED(CONFIG_GENERIC_CMDLINE))
+		return true;
+
+	if (!IS_ENABLED(CONFIG_CMDLINE_BOOL))
+		return true;
+
+	if (IS_ENABLED(CONFIG_CMDLINE_OVERRIDE))
+		dest[0] = '\0';
+	else
+		total_length += cmdline_strlen(dest);
+
+	tmp_length = cmdline_strlen(append);
+	if (tmp_length > 0) {
+		cmdline_strlcat(dest, append, length);
+		total_length += tmp_length;
+	}
+
+	tmp_length = cmdline_strlen(prepend);
+	if (tmp_length > 0) {
+		cmdline_strlcat(tmp, prepend, length);
+		cmdline_strlcat(tmp, dest, length);
+		dest[0] = '\0';
+		cmdline_strlcat(dest, tmp, length);
+		total_length += tmp_length;
+	}
+
+	tmp[0] = '\0';
+
+	if (total_length > length)
+		return false;
+
+	return true;
+}
+
+#define cmdline_add_builtin(dest) \
+	__cmdline_add_builtin(dest, CMDLINE_TMP, CMDLINE_PREPEND, CMDLINE_APPEND, COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT)
+
+#define cmdline_get_static_builtin(dest) \
+	(CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND)
+#endif
diff --git a/init/Kconfig b/init/Kconfig
index 6d35728b94b2..703eed88d140 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1922,6 +1922,85 @@ config TRACEPOINTS
 
 source "kernel/Kconfig.kexec"
 
+config GENERIC_CMDLINE
+	bool
+
+if GENERIC_CMDLINE
+
+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
+	  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_APPEND
+	string "Built-in kernel command string append"
+	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, this string is appended to it 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_PREPEND
+	string "Built-in kernel command string prepend"
+	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, this string is prepended to it 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_EXTRA
+	bool "Reserve more space for inserting prepend and append without recompiling"
+	depends on CMDLINE_BOOL
+	select SYSTEM_EXTRA_CERTIFICATE
+	help
+	  If set, space for an append and prepend will be reserved in the kernel
+	  image. This allows updating or changing the append and prepend to a large
+	  string then the kernel was compiled for without recompiling the kernel.
+
+	  The maximum size is the command line size for each prepend and append.
+
+config CMDLINE_OVERRIDE
+	bool "Built-in command line overrides boot loader arguments"
+	depends on CMDLINE_BOOL
+	help
+	  Set this option to 'Y' to have the kernel ignore the boot loader
+	  command line, and use ONLY the built-in command line. In this case
+	  append and prepend strings are concatenated to form the full
+	  command line.
+
+	  This is used to work around broken boot loaders.  This should
+	  be set to 'N' under normal conditions.
+endif
+
 endmenu		# General setup
 
 source "arch/Kconfig"
diff --git a/lib/Kconfig b/lib/Kconfig
index c686f4adc124..d520f1aa7c32 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -729,6 +729,10 @@ config PARMAN
 config OBJAGG
 	tristate "objagg" if COMPILE_TEST
 
+config TEST_CMDLINE
+	depends on CMDLINE_BOOL && !CMDLINE_OVERRIDE
+	tristate "Test generic command line handling"
+
 endmenu
 
 config GENERIC_IOREMAP
diff --git a/lib/Makefile b/lib/Makefile
index 740109b6e2c8..aa7b14a0ced7 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -438,3 +438,6 @@ $(obj)/$(TEST_FORTIFY_LOG): $(addprefix $(obj)/, $(TEST_FORTIFY_LOGS)) FORCE
 ifeq ($(CONFIG_FORTIFY_SOURCE),y)
 $(obj)/string.o: $(obj)/$(TEST_FORTIFY_LOG)
 endif
+
+obj-$(CONFIG_TEST_CMDLINE) += test_cmdline1.o
+obj-$(CONFIG_CMDLINE_BOOL)     += generic_cmdline.o
diff --git a/lib/generic_cmdline.S b/lib/generic_cmdline.S
new file mode 100644
index 000000000000..223763f9eeb6
--- /dev/null
+++ b/lib/generic_cmdline.S
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/export.h>
+#include <linux/init.h>
+
+#include <asm/setup.h>
+
+        __INITDATA
+
+       .align 8
+       .global cmdline_prepend
+cmdline_prepend:
+       .ifnc CONFIG_CMDLINE_PREPEND,""
+       .ascii CONFIG_CMDLINE_PREPEND
+       .string " "
+       .else
+       .byte 0x0
+       .endif
+#ifdef CONFIG_CMDLINE_EXTRA
+       .space COMMAND_LINE_SIZE - (.-cmdline_prepend)
+       .size cmdline_prepend, COMMAND_LINE_SIZE
+#endif /* CONFIG_CMDLINE_EXTRA */
+
+cmdline_prepend_end:
+       .size cmdline_prepend, (cmdline_prepend_end - cmdline_prepend)
+
+       .align 8
+       .global cmdline_tmp
+cmdline_tmp:
+       .ifnc CONFIG_CMDLINE_PREPEND,""
+       .size cmdline_tmp, COMMAND_LINE_SIZE
+       .space COMMAND_LINE_SIZE
+       .else
+       .byte 0x0
+       .endif
+cmdline_tmp_end:
+       .size cmdline_tmp, (cmdline_tmp_end - cmdline_tmp)
+
+       .align 8
+       .global cmdline_append
+       .size cmdline_append, COMMAND_LINE_SIZE
+cmdline_append:
+       .ifnc CONFIG_CMDLINE_APPEND,""
+       .ascii " "
+       .string CONFIG_CMDLINE_APPEND
+       .else
+       .byte 0x0
+       .endif
+#ifdef CONFIG_CMDLINE_EXTRA
+       .space COMMAND_LINE_SIZE - (.-cmdline_append)
+#endif /* CONFIG_CMDLINE_EXTRA */
+cmdline_append_end:
+       .size cmdline_append, (cmdline_append_end - cmdline_append)
+
diff --git a/lib/test_cmdline1.c b/lib/test_cmdline1.c
new file mode 100644
index 000000000000..bcaffcc024e4
--- /dev/null
+++ b/lib/test_cmdline1.c
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/bitmap.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/cmdline.h>
+#include <linux/uaccess.h>
+
+#include "../tools/testing/selftests/kselftest_module.h"
+
+KSTM_MODULE_GLOBALS();
+
+char test1_prepend[] = "prepend ";
+char test1_append[] = " append";
+char test1_bootloader_args[] = "console=ttyS0 log_level=3";
+char test1_result[] = "prepend console=ttyS0 log_level=3 append";
+
+char test2_append[] = " append";
+char test2_bootloader_args[] = "console=ttyS0 log_level=3";
+char test2_result[] = "console=ttyS0 log_level=3 append";
+
+char test3_prepend[] = "prepend ";
+char test3_bootloader_args[] = "console=ttyS0 log_level=3";
+char test3_result[] = "prepend console=ttyS0 log_level=3";
+
+char test4_bootloader_args[] = "console=ttyS0 log_level=3";
+char test4_result[] = "console=ttyS0 log_level=3";
+
+char test5_prepend[] = "prepend ";
+char test5_append[] = " append";
+static char test5_bootloader_args[] =
+"00000000000000 011111111111111 0222222222222222 033333333333333 "
+"10000000000000 111111111111111 1222222222222222 133333333333333 "
+"20000000000000 211111111111111 2222222222222222 233333333333333 "
+"30000000000000 311111111111111 3222222222222222 333333333333333 "
+"40000000000000 411111111111111 4222222222222222 433333333333333 "
+"50000000000000 511111111111111 5222222222222222 533333333333333 "
+"60000000000000 611111111111111 6222222222222222 633333333333333 "
+"70000000000000 711111111111111 7222222222222222 733333333333333";
+static char test5_result[] =
+"prepend 00000000000000 011111111111111 0222222222222222 033333333333333 "
+"10000000000000 111111111111111 1222222222222222 133333333333333 "
+"20000000000000 211111111111111 2222222222222222 233333333333333 "
+"30000000000000 311111111111111 3222222222222222 333333333333333 "
+"40000000000000 411111111111111 4222222222222222 433333333333333 "
+"50000000000000 511111111111111 5222222222222222 533333333333333 "
+"60000000000000 611111111111111 6222222222222222 633333333333333 "
+"70000000000000 711111111111111 7222222222222222 7333333";
+
+char test5_boot_command_line[COMMAND_LINE_SIZE];
+
+char test_tmp[COMMAND_LINE_SIZE];
+
+char test_boot_command_line[COMMAND_LINE_SIZE];
+
+static void __init selftest(void)
+{
+	bool result;
+
+	/* Normal operation */
+	strcpy(test_boot_command_line, test1_bootloader_args);
+	test_tmp[0] = '\0';
+	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, test1_prepend, test1_append, COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
+
+	if (result == true && !strncmp(test_boot_command_line, test1_result, COMMAND_LINE_SIZE)) {
+		pr_info("test1 success.\n");
+	} else {
+		pr_info("test1 failed. OUTPUT BELOW:\n");
+		pr_info("\"%s\"\n", test_boot_command_line);
+		failed_tests++;
+	}
+	total_tests++;
+
+	/* Missing prepend */
+	strcpy(test_boot_command_line, test2_bootloader_args);
+	test_tmp[0] = '\0';
+	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, "", test2_append, COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
+
+	if (result == true && !strncmp(test_boot_command_line, test2_result, COMMAND_LINE_SIZE)) {
+		pr_info("test2 success.\n");
+	} else {
+		pr_info("test2 failed. OUTPUT BELOW:\n");
+		pr_info("\"%s\"\n", test_boot_command_line);
+		failed_tests++;
+	}
+	total_tests++;
+
+	/* Missing append */
+	strcpy(test_boot_command_line, test3_bootloader_args);
+	test_tmp[0] = '\0';
+	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, test3_prepend, "", COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
+
+	if (result == true && !strncmp(test_boot_command_line, test3_result, COMMAND_LINE_SIZE)) {
+		pr_info("test3 success.\n");
+	} else {
+		pr_info("test3 failed. OUTPUT BELOW:\n");
+		pr_info("\"%s\"\n", test_boot_command_line);
+		failed_tests++;
+	}
+	total_tests++;
+
+	/* Missing append and prepend */
+	strcpy(test_boot_command_line, test4_bootloader_args);
+	test_tmp[0] = '\0';
+	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, "", "", COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
+
+	if (result == true && !strncmp(test_boot_command_line, test4_result, COMMAND_LINE_SIZE)) {
+		pr_info("test4 success.\n");
+	} else {
+		pr_info("test4 failed. OUTPUT BELOW:\n");
+		pr_info("\"%s\"\n", test_boot_command_line);
+		failed_tests++;
+	}
+	total_tests++;
+
+	/* Already full boot arguments */
+	strcpy(test5_boot_command_line, test5_bootloader_args);
+	test_tmp[0] = '\0';
+	result = __cmdline_add_builtin(test5_boot_command_line, test_tmp, test5_prepend, test5_append, 512, CMDLINE_STRLEN, CMDLINE_STRLCAT);
+
+	if (result == false && !strncmp(test5_boot_command_line, test5_result, COMMAND_LINE_SIZE)) {
+		pr_info("test5 success.\n");
+	} else {
+		pr_info("test5 failed. OUTPUT BELOW:\n");
+		pr_info("\"%s\"\n", test5_boot_command_line);
+		failed_tests++;
+	}
+	total_tests++;
+}
+
+KSTM_MODULE_LOADERS(cmdline_test);
+MODULE_AUTHOR("Daniel Walker <danielwa@cisco.com>");
+MODULE_LICENSE("GPL");
-- 
2.39.2


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

* [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
  2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-23  6:33   ` Christophe Leroy
  2023-11-10  1:38 ` [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol Daniel Walker
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, linux-kernel

This adds changes to the insert-sys-cert tool to allow updating
the cmdline_prepend and cmdline_append symbols in addition to
adding certificates.

Updating the cmdline symbols was tested on a PVH virtual machine
with a vmlinux, and with a bzImage which was repackaged on x86.

This commit intentionally keeps the tool filename the same to allow
the changes to be seen more easily. The next commit will change
the name of the tool.

Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 scripts/insert-sys-cert.c | 241 +++++++++++++++++++++++++++-----------
 1 file changed, 170 insertions(+), 71 deletions(-)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836c2342..77d3306cfbfb 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -30,6 +30,9 @@
 #define USED_SYM  "system_extra_cert_used"
 #define LSIZE_SYM "system_certificate_list_size"
 
+#define CMDLINE_APPEND "cmdline_append"
+#define CMDLINE_PREPEND "cmdline_prepend"
+
 #define info(format, args...) fprintf(stderr, "INFO:    " format, ## args)
 #define warn(format, args...) fprintf(stdout, "WARNING: " format, ## args)
 #define  err(format, args...) fprintf(stderr, "ERROR:   " format, ## args)
@@ -267,95 +270,46 @@ static void print_sym(Elf_Ehdr *hdr, struct sym *s)
 
 static void print_usage(char *e)
 {
-	printf("Usage %s [-s <System.map>] -b <vmlinux> -c <certfile>\n", e);
+	printf("Usage %s [-s <System.map>] -b <vmlinux> [ -c <certfile> | -p <command line prepend> | -a <command line append> ]-\n", e);
 }
 
-int main(int argc, char **argv)
+static char *cmdline_prepend, *cmdline_append;
+static char *system_map_file;
+static char *cert_file;
+static char *cli_name;
+
+static int insert_certificate(Elf_Ehdr *hdr)
 {
-	char *system_map_file = NULL;
-	char *vmlinux_file = NULL;
-	char *cert_file = NULL;
-	int vmlinux_size;
+	struct sym cert_sym, lsize_sym, used_sym;
+	Elf_Shdr *symtab = NULL;
+	unsigned long *lsize;
+	FILE *system_map;
 	int cert_size;
-	Elf_Ehdr *hdr;
 	char *cert;
-	FILE *system_map;
-	unsigned long *lsize;
 	int *used;
-	int opt;
-	Elf_Shdr *symtab = NULL;
-	struct sym cert_sym, lsize_sym, used_sym;
-
-	while ((opt = getopt(argc, argv, "b:c:s:")) != -1) {
-		switch (opt) {
-		case 's':
-			system_map_file = optarg;
-			break;
-		case 'b':
-			vmlinux_file = optarg;
-			break;
-		case 'c':
-			cert_file = optarg;
-			break;
-		default:
-			break;
-		}
-	}
 
-	if (!vmlinux_file || !cert_file) {
-		print_usage(argv[0]);
-		exit(EXIT_FAILURE);
+	if (!cert_file) {
+		print_usage(cli_name);
+		return EXIT_FAILURE;
 	}
 
 	cert = read_file(cert_file, &cert_size);
 	if (!cert)
-		exit(EXIT_FAILURE);
-
-	hdr = map_file(vmlinux_file, &vmlinux_size);
-	if (!hdr)
-		exit(EXIT_FAILURE);
-
-	if (vmlinux_size < sizeof(*hdr)) {
-		err("Invalid ELF file.\n");
-		exit(EXIT_FAILURE);
-	}
-
-	if ((hdr->e_ident[EI_MAG0] != ELFMAG0) ||
-	    (hdr->e_ident[EI_MAG1] != ELFMAG1) ||
-	    (hdr->e_ident[EI_MAG2] != ELFMAG2) ||
-	    (hdr->e_ident[EI_MAG3] != ELFMAG3)) {
-		err("Invalid ELF magic.\n");
-		exit(EXIT_FAILURE);
-	}
-
-	if (hdr->e_ident[EI_CLASS] != CURRENT_ELFCLASS) {
-		err("ELF class mismatch.\n");
-		exit(EXIT_FAILURE);
-	}
-
-	if (hdr->e_ident[EI_DATA] != endianness()) {
-		err("ELF endian mismatch.\n");
-		exit(EXIT_FAILURE);
-	}
-
-	if (hdr->e_shoff > vmlinux_size) {
-		err("Could not find section header.\n");
-		exit(EXIT_FAILURE);
-	}
+		return EXIT_FAILURE;
 
 	symtab = get_symbol_table(hdr);
 	if (!symtab) {
 		warn("Could not find the symbol table.\n");
 		if (!system_map_file) {
 			err("Please provide a System.map file.\n");
-			print_usage(argv[0]);
-			exit(EXIT_FAILURE);
+			print_usage(cli_name);
+			return EXIT_FAILURE;
 		}
 
 		system_map = fopen(system_map_file, "r");
 		if (!system_map) {
 			perror(system_map_file);
-			exit(EXIT_FAILURE);
+			return EXIT_FAILURE;
 		}
 		get_symbol_from_map(hdr, system_map, CERT_SYM, &cert_sym);
 		get_symbol_from_map(hdr, system_map, USED_SYM, &used_sym);
@@ -371,7 +325,7 @@ int main(int argc, char **argv)
 	}
 
 	if (!cert_sym.offset || !lsize_sym.offset || !used_sym.offset)
-		exit(EXIT_FAILURE);
+		return EXIT_FAILURE;
 
 	print_sym(hdr, &cert_sym);
 	print_sym(hdr, &used_sym);
@@ -382,14 +336,14 @@ int main(int argc, char **argv)
 
 	if (cert_sym.size < cert_size) {
 		err("Certificate is larger than the reserved area!\n");
-		exit(EXIT_FAILURE);
+		return EXIT_FAILURE;
 	}
 
 	/* If the existing cert is the same, don't overwrite */
 	if (cert_size == *used &&
 	    strncmp(cert_sym.content, cert, cert_size) == 0) {
 		warn("Certificate was already inserted.\n");
-		exit(EXIT_SUCCESS);
+		return EXIT_SUCCESS;
 	}
 
 	if (*used > 0)
@@ -406,5 +360,150 @@ int main(int argc, char **argv)
 						cert_sym.address);
 	info("Used %d bytes out of %d bytes reserved.\n", *used,
 						 cert_sym.size);
-	exit(EXIT_SUCCESS);
+	return EXIT_SUCCESS;
+}
+
+static int insert_cmdline(Elf_Ehdr *hdr)
+{
+	struct sym cmdline_prepend_sym, cmdline_append_sym;
+	Elf_Shdr *symtab = NULL;
+	FILE *system_map;
+
+	symtab = get_symbol_table(hdr);
+	if (!symtab) {
+		warn("Could not find the symbol table.\n");
+		if (!system_map_file) {
+			err("Please provide a System.map file.\n");
+			print_usage(cli_name);
+			return EXIT_FAILURE;
+		}
+
+		system_map = fopen(system_map_file, "r");
+		if (!system_map) {
+			perror(system_map_file);
+			return EXIT_FAILURE;
+		}
+		get_symbol_from_map(hdr, system_map, CMDLINE_PREPEND, &cmdline_prepend_sym);
+		get_symbol_from_map(hdr, system_map, CMDLINE_APPEND, &cmdline_append_sym);
+	} else {
+		info("Symbol table found.\n");
+		if (system_map_file)
+			warn("System.map is ignored.\n");
+		get_symbol_from_table(hdr, symtab, CMDLINE_PREPEND, &cmdline_prepend_sym);
+		get_symbol_from_table(hdr, symtab, CMDLINE_APPEND, &cmdline_append_sym);
+	}
+
+	print_sym(hdr, &cmdline_prepend_sym);
+	print_sym(hdr, &cmdline_append_sym);
+
+
+	if (cmdline_prepend) {
+		if ((strlen(cmdline_prepend) + 1) > cmdline_prepend_sym.size) {
+			err("cmdline prepend is larger than the reserved area!\n");
+			return EXIT_FAILURE;
+		}
+
+		memcpy(cmdline_prepend_sym.content, cmdline_prepend, strlen(cmdline_prepend) + 1);
+		if ((strlen(cmdline_prepend) + 1) < cmdline_prepend_sym.size)
+			memset(cmdline_prepend_sym.content + strlen(cmdline_prepend) + 1,
+				0, cmdline_prepend_sym.size - (strlen(cmdline_prepend) + 1));
+
+		info("Inserted cmdline prepend of \"%s\" into vmlinux.\n", cmdline_prepend);
+
+	}
+	if (cmdline_append) {
+		if ((strlen(cmdline_append) + 1) > cmdline_append_sym.size) {
+			err("cmdline append is larger than the reserved area!\n");
+			return EXIT_FAILURE;
+		}
+
+		memcpy(cmdline_append_sym.content, cmdline_append, strlen(cmdline_append) + 1);
+		if ((strlen(cmdline_append) + 1) < cmdline_append_sym.size)
+			memset(cmdline_append_sym.content + strlen(cmdline_append) + 1,
+				0, cmdline_append_sym.size - (strlen(cmdline_append) + 1));
+
+		info("Inserted cmdline append of \"%s\" into vmlinux.\n", cmdline_append);
+
+	}
+	return EXIT_SUCCESS;
+}
+
+int main(int argc, char **argv)
+{
+	char *vmlinux_file = NULL;
+	int vmlinux_size;
+	Elf_Ehdr *hdr;
+	int opt;
+	int ret = EXIT_SUCCESS;
+
+	while ((opt = getopt(argc, argv, "b:c:s:p:a:")) != -1) {
+		switch (opt) {
+		case 's':
+			system_map_file = optarg;
+			break;
+		case 'b':
+			vmlinux_file = optarg;
+			break;
+		case 'c':
+			cert_file = optarg;
+			break;
+		case 'p':
+			cmdline_prepend = optarg;
+			break;
+		case 'a':
+			cmdline_append = optarg;
+			break;
+		default:
+			break;
+		}
+	}
+
+	cli_name = argv[0];
+
+	if (!vmlinux_file) {
+		print_usage(cli_name);
+		exit(EXIT_FAILURE);
+	}
+
+	hdr = map_file(vmlinux_file, &vmlinux_size);
+	if (!hdr)
+		exit(EXIT_FAILURE);
+
+	if (vmlinux_size < sizeof(*hdr)) {
+		err("Invalid ELF file.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if ((hdr->e_ident[EI_MAG0] != ELFMAG0) ||
+	    (hdr->e_ident[EI_MAG1] != ELFMAG1) ||
+	    (hdr->e_ident[EI_MAG2] != ELFMAG2) ||
+	    (hdr->e_ident[EI_MAG3] != ELFMAG3)) {
+		err("Invalid ELF magic.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (hdr->e_ident[EI_CLASS] != CURRENT_ELFCLASS) {
+		err("ELF class mismatch.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (hdr->e_ident[EI_DATA] != endianness()) {
+		err("ELF endian mismatch.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (hdr->e_shoff > vmlinux_size) {
+		err("Could not find section header.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (cert_file) {
+		ret = insert_certificate(hdr);
+		printf("%s\n", cert_file);
+	}
+
+	if (cmdline_append || cmdline_prepend)
+		ret = insert_cmdline(hdr);
+
+	exit(ret);
 }
-- 
2.39.2


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

* [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
  2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
  2023-11-10  1:38 ` [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-23  6:34   ` Christophe Leroy
  2023-11-10  1:38 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier
  Cc: xe-linux-external, linux-kbuild, linux-kernel

Since the tool is used to update the command line and/or
to update the certificates, I think it makes sense to
changes the name of this tool.

Update the name of the tool to better reflect it's new use.

Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 scripts/Makefile                               | 2 +-
 scripts/{insert-sys-cert.c => insert-symbol.c} | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename scripts/{insert-sys-cert.c => insert-symbol.c} (99%)

diff --git a/scripts/Makefile b/scripts/Makefile
index 576cf64be667..2d7618fa5d6b 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -8,10 +8,10 @@ hostprogs-always-$(BUILD_C_RECORDMCOUNT)		+= recordmcount
 hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT)		+= sorttable
 hostprogs-always-$(CONFIG_ASN1)				+= asn1_compiler
 hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT)		+= sign-file
-hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)	+= insert-sys-cert
 hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS)		+= rustdoc_test_builder
 hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS)		+= rustdoc_test_gen
 always-$(CONFIG_RUST)					+= target.json
+hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)	+= insert-symbol
 
 filechk_rust_target = $< < include/config/auto.conf
 
diff --git a/scripts/insert-sys-cert.c b/scripts/insert-symbol.c
similarity index 99%
rename from scripts/insert-sys-cert.c
rename to scripts/insert-symbol.c
index 77d3306cfbfb..6866e3a84974 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-symbol.c
@@ -7,7 +7,7 @@
  * This software may be used and distributed according to the terms
  * of the GNU General Public License, incorporated herein by reference.
  *
- * Usage: insert-sys-cert [-s <System.map> -b <vmlinux> -c <certfile>
+ * Usage: insert-symbol [-s <System.map> -b <vmlinux> -c <certfile>
  */
 
 #define _GNU_SOURCE
-- 
2.39.2


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

* [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (2 preceding siblings ...)
  2023-11-10  1:38 ` [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-23  6:36   ` Christophe Leroy
  2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Thomas Bogendoerfer
  Cc: xe-linux-external, Ruslan Ruslichenko, Ruslan Bilovol, linux-kernel

This updates the mips code to use the CONFIG_GENERIC_CMDLINE
option.

This deletes the option for MIPS_CMDLINE_BUILTIN_EXTEND
and replaces the functionality with generic code.

Of note, the pic32 has some strange handling of the current built
in command line. It was converted to use the static variant which
can't be updated after compilation. It should eventually be updated
to use to append and prepend symbols.

This includes a scripted mass convert of the config files to use
the new generic cmdline. There is a bit of a trim effect here.
It would seems that some of the config haven't been trimmed in
a while.

The script used is as follows,

if [[ -z "$1" || -z "$2" ]]; then
        echo "Two arguments are needed."
        exit 1
fi
mkdir $1
cp $2 $1/.config
sed -i 's/CONFIG_CMDLINE=/CONFIG_CMDLINE_BOOL=y\nCONFIG_CMDLINE_PREPEND=/g' $1/.config
make ARCH=$1 O=$1 olddefconfig
make ARCH=$1 O=$1 savedefconfig
cp $1/defconfig $2
rm -Rf $1

Cc: xe-linux-external@cisco.com
Signed-off-by: Ruslan Ruslichenko <rruslich@cisco.com>
Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 arch/mips/Kconfig                         |   4 +-
 arch/mips/Kconfig.debug                   |  44 -------
 arch/mips/configs/ar7_defconfig           |  12 +-
 arch/mips/configs/bcm47xx_defconfig       |  10 +-
 arch/mips/configs/bcm63xx_defconfig       |  21 ++--
 arch/mips/configs/bmips_be_defconfig      |  17 ++-
 arch/mips/configs/bmips_stb_defconfig     | 139 ++++++++--------------
 arch/mips/configs/ci20_defconfig          |   8 +-
 arch/mips/configs/cu1000-neo_defconfig    |  19 ++-
 arch/mips/configs/cu1830-neo_defconfig    |  19 ++-
 arch/mips/configs/generic_defconfig       |  15 +--
 arch/mips/configs/gpr_defconfig           |  33 ++---
 arch/mips/configs/loongson3_defconfig     |  29 ++---
 arch/mips/include/asm/setup.h             |   2 +
 arch/mips/kernel/relocate.c               |  17 ++-
 arch/mips/kernel/setup.c                  |  36 +-----
 arch/mips/pic32/pic32mzda/early_console.c |   2 +-
 arch/mips/pic32/pic32mzda/init.c          |   3 +-
 18 files changed, 144 insertions(+), 286 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index bc8421859006..65fd3decc6b1 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -31,6 +31,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
@@ -2989,9 +2990,6 @@ choice
 	config MIPS_CMDLINE_FROM_BOOTLOADER
 		bool "Bootloader kernel arguments if available"
 
-	config MIPS_CMDLINE_BUILTIN_EXTEND
-		depends on CMDLINE_BOOL
-		bool "Extend builtin kernel arguments with bootloader arguments"
 endchoice
 
 endmenu
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index f4ae7900fcd3..f9da53d4ebd2 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -26,50 +26,6 @@ config EARLY_PRINTK_8250
 config USE_GENERIC_EARLY_PRINTK_8250
 	bool
 
-config CMDLINE_BOOL
-	bool "Built-in kernel command line"
-	help
-	  For most systems, it is firmware or second stage bootloader that
-	  by default specifies the kernel command line options.  However,
-	  it might be necessary or advantageous to either override the
-	  default kernel command line or add a few extra options to it.
-	  For such cases, this option allows you to hardcode your own
-	  command line options directly into the kernel.  For that, you
-	  should choose 'Y' here, and fill in the extra boot arguments
-	  in CONFIG_CMDLINE.
-
-	  The built-in options will be concatenated to the default command
-	  line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
-	  command line will be ignored and replaced by the built-in string.
-
-	  Most MIPS systems will normally expect 'N' here and rely upon
-	  the command line from the firmware or the second-stage bootloader.
-
-config CMDLINE
-	string "Default kernel command string"
-	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, and for the cases
-	  when you want to add some extra options to the command line or ignore
-	  the default command line, 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.
-
-	  For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
-	  options.
-
-config CMDLINE_OVERRIDE
-	bool "Built-in command line overrides firmware arguments"
-	depends on CMDLINE_BOOL
-	help
-	  By setting this option to 'Y' you will have your kernel ignore
-	  command line arguments from firmware or second stage bootloader.
-	  Instead, the built-in command line will be used exclusively.
-
-	  Normally, you will choose 'N' here.
-
 config SB1XXX_CORELIS
 	bool "Corelis Debugger"
 	depends on SIBYTE_SB1xxx_SOC
diff --git a/arch/mips/configs/ar7_defconfig b/arch/mips/configs/ar7_defconfig
index 329c60aa570a..0dff0795705e 100644
--- a/arch/mips/configs/ar7_defconfig
+++ b/arch/mips/configs/ar7_defconfig
@@ -9,17 +9,18 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 # CONFIG_ELF_CORE is not set
 # CONFIG_KALLSYMS is not set
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_COMPAT_BRK is not set
+CONFIG_KEXEC=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="rootfstype=squashfs,jffs2"
 CONFIG_AR7=y
 CONFIG_HZ_100=y
-CONFIG_KEXEC=y
 # CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
-# CONFIG_BLK_DEV_BSG is not set
 CONFIG_PARTITION_ADVANCED=y
 CONFIG_BSD_DISKLABEL=y
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -39,7 +40,6 @@ CONFIG_TCP_CONG_WESTWOOD=y
 # CONFIG_TCP_CONG_HTCP is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETFILTER=y
-# CONFIG_BRIDGE_NETFILTER is not set
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_MARK=y
 CONFIG_NF_CONNTRACK_FTP=m
@@ -115,5 +115,3 @@ CONFIG_SQUASHFS=y
 # CONFIG_CRYPTO_HW is not set
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_DEBUG_FS=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig
index 6a68a96d13f8..26e2134f83af 100644
--- a/arch/mips/configs/bcm47xx_defconfig
+++ b/arch/mips/configs/bcm47xx_defconfig
@@ -3,8 +3,9 @@ CONFIG_HIGH_RES_TIMERS=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_EXPERT=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
 CONFIG_BCM47XX=y
-CONFIG_PCI=y
 # CONFIG_SUSPEND is not set
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
@@ -31,6 +32,7 @@ CONFIG_NET_SCH_FQ_CODEL=y
 CONFIG_HAMRADIO=y
 CONFIG_CFG80211=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
 CONFIG_MTD=y
 CONFIG_MTD_BCM47XX_PARTS=y
 CONFIG_MTD_BLOCK=y
@@ -67,14 +69,10 @@ CONFIG_BCMA_DRIVER_GMAC_CMN=y
 CONFIG_USB=y
 CONFIG_USB_HCD_BCMA=y
 CONFIG_USB_HCD_SSB=y
-CONFIG_LEDS_TRIGGER_TIMER=y
-CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
 CONFIG_CRC32_SARWATE=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 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"
+CONFIG_DEBUG_FS=y
diff --git a/arch/mips/configs/bcm63xx_defconfig b/arch/mips/configs/bcm63xx_defconfig
index 34d0ca638ef0..0a73fd34063f 100644
--- a/arch/mips/configs/bcm63xx_defconfig
+++ b/arch/mips/configs/bcm63xx_defconfig
@@ -1,5 +1,4 @@
 # CONFIG_LOCALVERSION_AUTO is not set
-# CONFIG_SWAP is not set
 CONFIG_NO_HZ=y
 CONFIG_EXPERT=y
 # CONFIG_FUTEX is not set
@@ -9,18 +8,16 @@ CONFIG_EXPERT=y
 # CONFIG_EVENTFD is not set
 # CONFIG_SHMEM is not set
 # CONFIG_AIO is not set
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
 CONFIG_BCM63XX=y
 CONFIG_BCM63XX_CPU_6338=y
 CONFIG_BCM63XX_CPU_6345=y
 CONFIG_BCM63XX_CPU_6348=y
 CONFIG_BCM63XX_CPU_6358=y
 # CONFIG_SECCOMP is not set
-CONFIG_PCI=y
-CONFIG_PCCARD=y
-CONFIG_PCMCIA_BCM63XX=y
-# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_SWAP is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_NET=y
 CONFIG_UNIX=y
 CONFIG_INET=y
@@ -29,6 +26,10 @@ CONFIG_INET=y
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
+# CONFIG_VGA_ARB is not set
+CONFIG_PCCARD=y
+CONFIG_PCMCIA_BCM63XX=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 CONFIG_MTD=y
@@ -47,11 +48,8 @@ CONFIG_B43=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
-CONFIG_SERIAL_BCM63XX=y
-CONFIG_SERIAL_BCM63XX_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
-# CONFIG_VGA_ARB is not set
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
@@ -62,5 +60,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"
+# CONFIG_SLUB_DEBUG is not set
diff --git a/arch/mips/configs/bmips_be_defconfig b/arch/mips/configs/bmips_be_defconfig
index daef132d000b..0b2b7685330f 100644
--- a/arch/mips/configs/bmips_be_defconfig
+++ b/arch/mips/configs/bmips_be_defconfig
@@ -1,17 +1,17 @@
 # CONFIG_LOCALVERSION_AUTO is not set
-# CONFIG_SWAP is not set
 CONFIG_NO_HZ=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_BMIPS_GENERIC=y
 CONFIG_HIGHMEM=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=4
-# CONFIG_SECCOMP is not set
 CONFIG_MIPS_O32_FP64_SUPPORT=y
-# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_SECCOMP is not set
+# CONFIG_SWAP is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
@@ -34,6 +34,7 @@ CONFIG_MTD_PHYSMAP=y
 # CONFIG_BLK_DEV is not set
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
+# CONFIG_BLK_DEV_BSG is not set
 # CONFIG_SCSI_LOWLEVEL is not set
 CONFIG_NETDEVICES=y
 CONFIG_BCMGENET=y
@@ -41,7 +42,6 @@ CONFIG_USB_USBNET=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-CONFIG_SERIAL_BCM63XX=y
 CONFIG_SERIAL_BCM63XX_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 CONFIG_POWER_RESET=y
@@ -70,7 +70,6 @@ CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
 # CONFIG_CRYPTO_HW is not set
 CONFIG_PRINTK_TIME=y
-CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon"
+CONFIG_DEBUG_FS=y
+# CONFIG_SLUB_DEBUG is not set
diff --git a/arch/mips/configs/bmips_stb_defconfig b/arch/mips/configs/bmips_stb_defconfig
index cd0dc37c3d84..4f96a1da7610 100644
--- a/arch/mips/configs/bmips_stb_defconfig
+++ b/arch/mips/configs/bmips_stb_defconfig
@@ -1,59 +1,44 @@
 # CONFIG_LOCALVERSION_AUTO is not set
-# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
 CONFIG_NO_HZ=y
-CONFIG_HZ=1000
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_CGROUPS=y
 CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
 CONFIG_EXPERT=y
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_BMIPS_GENERIC=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_HIGHMEM=y
-CONFIG_HIGH_RES_TIMERS=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=4
-# CONFIG_SECCOMP is not set
 CONFIG_MIPS_O32_FP64_SUPPORT=y
-# CONFIG_RD_GZIP is not set
-# CONFIG_RD_BZIP2 is not set
-# CONFIG_RD_LZMA is not set
-CONFIG_RD_XZ=y
-# CONFIG_RD_LZO is not set
-# CONFIG_RD_LZ4 is not set
-CONFIG_PCI=y
-CONFIG_PCI_MSI=y
-CONFIG_PCIEASPM_POWERSAVE=y
-CONFIG_PCIEPORTBUS=y
-CONFIG_PCIE_BRCMSTB=y
+CONFIG_MIPS_CMDLINE_DTB_EXTEND=y
+CONFIG_PM_DEBUG=y
 CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_STAT=y
-CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
-CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
 CONFIG_BMIPS_CPUFREQ=y
-# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_SECCOMP is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+# CONFIG_SWAP is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_DIAG is not set
-CONFIG_CFG80211=y
-CONFIG_NL80211_TESTMODE=y
-CONFIG_WIRELESS=y
-CONFIG_MAC80211=y
-CONFIG_DEVTMPFS=y
-CONFIG_DEVTMPFS_MOUNT=y
-# CONFIG_STANDALONE is not set
-# CONFIG_PREVENT_FIRMWARE_BUILD is not set
-CONFIG_BRCMSTB_GISB_ARB=y
-CONFIG_MODULES=y
-CONFIG_MODULE_FORCE_LOAD=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_MODVERSIONS=y
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
@@ -62,25 +47,32 @@ CONFIG_IP_PNP_RARP=y
 CONFIG_IP_MROUTE=y
 CONFIG_IP_PIMSM_V1=y
 CONFIG_IP_PIMSM_V2=y
-CONFIG_INET_UDP_DIAG=y
+# CONFIG_INET_DIAG is not set
 CONFIG_TCP_CONG_ADVANCED=y
 CONFIG_TCP_CONG_BIC=y
 # CONFIG_TCP_CONG_WESTWOOD is not set
 # CONFIG_TCP_CONG_HTCP is not set
 # CONFIG_IPV6 is not set
-CONFIG_IP_NF_IPTABLES=y
-CONFIG_IP_NF_FILTER=y
 CONFIG_NETFILTER=y
-CONFIG_NETFILTER_XTABLES=y
-CONFIG_BRIDGE=y
 CONFIG_BRIDGE_NETFILTER=m
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_FILTER=y
 CONFIG_BRIDGE_NF_EBTABLES=m
 CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE=y
 CONFIG_NET_DSA=y
-CONFIG_NET_SWITCHDEV=y
-CONFIG_DMA_CMA=y
-CONFIG_CMA_ALIGNMENT=12
-CONFIG_SPI=y
+CONFIG_VLAN_8021Q=y
+CONFIG_CFG80211=y
+CONFIG_NL80211_TESTMODE=y
+CONFIG_MAC80211=y
+CONFIG_PCI=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_PCIEASPM_POWERSAVE=y
+CONFIG_PCI_MSI=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
 CONFIG_MTD=y
 CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_BLOCK=y
@@ -91,22 +83,21 @@ CONFIG_MTD_CFI_AMDSTD=y
 CONFIG_MTD_CFI_STAA=y
 CONFIG_MTD_ROM=y
 CONFIG_MTD_ABSENT=y
-CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_NAND_BRCMNAND=y
 CONFIG_MTD_SPI_NOR=y
 # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_GLUEBI=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
 # CONFIG_BLK_DEV is not set
-CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
+# CONFIG_BLK_DEV_BSG is not set
 # CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_ATA=y
+CONFIG_SATA_AHCI_PLATFORM=y
+CONFIG_AHCI_BRCM=y
 CONFIG_NETDEVICES=y
-CONFIG_VLAN_8021Q=y
 CONFIG_MACVLAN=y
 CONFIG_BCMGENET=y
 CONFIG_USB_USBNET=y
@@ -116,15 +107,16 @@ CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_UINPUT=y
 # CONFIG_SERIO is not set
-CONFIG_VT=y
 CONFIG_VT_HW_CONSOLE_BINDING=y
 CONFIG_SERIAL_8250=y
 # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_OF_PLATFORM=y
 # CONFIG_HW_RANDOM is not set
+CONFIG_SPI=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
 CONFIG_POWER_RESET=y
-CONFIG_POWER_RESET_BRCMSTB=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_POWER_SUPPLY=y
 # CONFIG_HWMON is not set
@@ -135,21 +127,18 @@ CONFIG_USB_EHCI_HCD_PLATFORM=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_HCD_PLATFORM=y
 CONFIG_USB_STORAGE=y
-CONFIG_SOC_BRCMSTB=y
 CONFIG_MMC=y
 CONFIG_MMC_BLOCK_MINORS=16
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_SOC_BRCMSTB=y
+CONFIG_PHY_BRCM_SATA=y
 CONFIG_EXT4_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
 CONFIG_EXT4_FS_SECURITY=y
-# CONFIG_DNOTIFY is not set
-CONFIG_PROC_KCORE=y
-CONFIG_CIFS=y
 CONFIG_JBD2_DEBUG=y
+# CONFIG_DNOTIFY is not set
 CONFIG_FUSE_FS=y
-CONFIG_FHANDLE=y
-CONFIG_CGROUPS=y
 CONFIG_CUSE=y
 CONFIG_ISO9660_FS=y
 CONFIG_JOLIET=y
@@ -157,6 +146,7 @@ CONFIG_ZISOFS=y
 CONFIG_UDF_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
+CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_JFFS2_FS=y
 CONFIG_UBIFS_FS=y
@@ -169,42 +159,17 @@ CONFIG_NFS_V4=y
 CONFIG_NFS_V4_1=y
 CONFIG_NFS_V4_2=y
 CONFIG_ROOT_NFS=y
+CONFIG_CIFS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
+# CONFIG_CRYPTO_HW is not set
 CONFIG_PRINTK_TIME=y
 CONFIG_DYNAMIC_DEBUG=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_INFO_REDUCED is not set
-CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_LOCKUP_DETECTOR=y
-CONFIG_DEBUG_USER=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon"
-# CONFIG_MIPS_CMDLINE_FROM_DTB is not set
-CONFIG_MIPS_CMDLINE_DTB_EXTEND=y
-# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
-# CONFIG_CRYPTO_HW is not set
-CONFIG_FW_CFE=y
-CONFIG_ATA=y
-CONFIG_SATA_AHCI_PLATFORM=y
-CONFIG_GENERIC_PHY=y
-CONFIG_GPIOLIB=y
-CONFIG_GPIO_SYSFS=y
-CONFIG_PHY_BRCM_USB=y
-CONFIG_PHY_BRCM_SATA=y
-CONFIG_PM_DEBUG=y
-CONFIG_SYSVIPC=y
-CONFIG_FUNCTION_GRAPH_TRACER=y
-CONFIG_DYNAMIC_FTRACE=y
-CONFIG_FUNCTION_TRACER=y
+# CONFIG_SLUB_DEBUG is not set
 CONFIG_FUNCTION_PROFILER=y
+CONFIG_STACK_TRACER=y
 CONFIG_IRQSOFF_TRACER=y
 CONFIG_SCHED_TRACER=y
-CONFIG_BLK_DEV_IO_TRACE=y
 CONFIG_FTRACE_SYSCALLS=y
-CONFIG_TRACER_SNAPSHOT=y
-CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y
-CONFIG_STACK_TRACER=y
-CONFIG_AHCI_BRCM=y
-CONFIG_MTD_RAW_NAND=y
+CONFIG_BLK_DEV_IO_TRACE=y
diff --git a/arch/mips/configs/ci20_defconfig b/arch/mips/configs/ci20_defconfig
index cdf2a782dee1..87d34b903f04 100644
--- a/arch/mips/configs/ci20_defconfig
+++ b/arch/mips/configs/ci20_defconfig
@@ -17,8 +17,10 @@ CONFIG_CGROUP_CPUACCT=y
 CONFIG_NAMESPACES=y
 CONFIG_USER_NS=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_KALLSYMS_ALL=y
 CONFIG_EXPERT=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon console=ttyS4,115200 clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_JZ4780_CI20=y
 CONFIG_HIGHMEM=y
@@ -126,7 +128,6 @@ CONFIG_DRM_INGENIC=m
 CONFIG_DRM_INGENIC_DW_HDMI=m
 CONFIG_FB=y
 # CONFIG_VGA_CONSOLE is not set
-CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
@@ -225,7 +226,4 @@ CONFIG_DEBUG_FS=y
 CONFIG_PANIC_ON_OOPS=y
 CONFIG_PANIC_TIMEOUT=10
 # CONFIG_SCHED_DEBUG is not set
-CONFIG_STACKTRACE=y
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon console=ttyS4,115200 clk_ignore_unused"
diff --git a/arch/mips/configs/cu1000-neo_defconfig b/arch/mips/configs/cu1000-neo_defconfig
index 19517beaf540..f5be8b992a0c 100644
--- a/arch/mips/configs/cu1000-neo_defconfig
+++ b/arch/mips/configs/cu1000-neo_defconfig
@@ -14,20 +14,22 @@ CONFIG_CGROUP_CPUACCT=y
 CONFIG_NAMESPACES=y
 CONFIG_USER_NS=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_KALLSYMS_ALL=y
 CONFIG_EXPERT=y
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_COMPAT_BRK is not set
+CONFIG_KALLSYMS_ALL=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_X1000_CU1000_NEO=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_COMPACTION is not set
 CONFIG_CMA=y
+# CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -66,7 +68,6 @@ CONFIG_SENSORS_ADS7828=m
 CONFIG_WATCHDOG=y
 CONFIG_JZ4740_WDT=y
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
@@ -86,7 +87,6 @@ CONFIG_DMA_JZ4780=y
 # CONFIG_INGENIC_TIMER is not set
 CONFIG_INGENIC_SYSOST=y
 # CONFIG_IOMMU_SUPPORT is not set
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -97,15 +97,14 @@ CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_NFS_FS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_936=y
 CONFIG_NLS_CODEPAGE_950=y
 CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
 CONFIG_NLS_UTF8=y
-CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_LZO=y
 CONFIG_PRINTK_TIME=y
@@ -119,8 +118,4 @@ CONFIG_DEBUG_FS=y
 CONFIG_PANIC_ON_OOPS=y
 CONFIG_PANIC_TIMEOUT=10
 # CONFIG_SCHED_DEBUG is not set
-# CONFIG_DEBUG_PREEMPT is not set
-CONFIG_STACKTRACE=y
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon clk_ignore_unused"
diff --git a/arch/mips/configs/cu1830-neo_defconfig b/arch/mips/configs/cu1830-neo_defconfig
index b403e67ab105..b02d32f19604 100644
--- a/arch/mips/configs/cu1830-neo_defconfig
+++ b/arch/mips/configs/cu1830-neo_defconfig
@@ -14,20 +14,22 @@ CONFIG_CGROUP_CPUACCT=y
 CONFIG_NAMESPACES=y
 CONFIG_USER_NS=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_KALLSYMS_ALL=y
 CONFIG_EXPERT=y
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_COMPAT_BRK is not set
+CONFIG_KALLSYMS_ALL=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_X1830_CU1830_NEO=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_COMPACTION is not set
 CONFIG_CMA=y
+# CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -69,7 +71,6 @@ CONFIG_SENSORS_ADS7828=m
 CONFIG_WATCHDOG=y
 CONFIG_JZ4740_WDT=y
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
@@ -89,7 +90,6 @@ CONFIG_DMA_JZ4780=y
 # CONFIG_INGENIC_TIMER is not set
 CONFIG_INGENIC_SYSOST=y
 # CONFIG_IOMMU_SUPPORT is not set
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -100,15 +100,14 @@ CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_NFS_FS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_936=y
 CONFIG_NLS_CODEPAGE_950=y
 CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
 CONFIG_NLS_UTF8=y
-CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_LZO=y
 CONFIG_PRINTK_TIME=y
@@ -122,8 +121,4 @@ CONFIG_DEBUG_FS=y
 CONFIG_PANIC_ON_OOPS=y
 CONFIG_PANIC_TIMEOUT=10
 # CONFIG_SCHED_DEBUG is not set
-# CONFIG_DEBUG_PREEMPT is not set
-CONFIG_STACKTRACE=y
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon clk_ignore_unused"
diff --git a/arch/mips/configs/generic_defconfig b/arch/mips/configs/generic_defconfig
index 071e2205c7ed..53eddba32478 100644
--- a/arch/mips/configs/generic_defconfig
+++ b/arch/mips/configs/generic_defconfig
@@ -1,5 +1,6 @@
 CONFIG_SYSVIPC=y
 CONFIG_NO_HZ_IDLE=y
+CONFIG_BPF_SYSCALL=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_MEMCG=y
@@ -15,11 +16,9 @@ CONFIG_NAMESPACES=y
 CONFIG_USER_NS=y
 CONFIG_SCHED_AUTOGROUP=y
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_BPF_SYSCALL=y
-CONFIG_USERFAULTFD=y
 CONFIG_EXPERT=y
-# CONFIG_SLUB_DEBUG is not set
-# CONFIG_COMPAT_BRK is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_CPS=y
 CONFIG_HIGHMEM=y
@@ -29,6 +28,8 @@ CONFIG_JUMP_LABEL=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_TRIM_UNUSED_KSYMS=y
+# CONFIG_COMPAT_BRK is not set
+CONFIG_USERFAULTFD=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -44,14 +45,11 @@ CONFIG_HW_RANDOM=y
 # CONFIG_HWMON is not set
 CONFIG_MFD_SYSCON=y
 CONFIG_HID_A4TECH=y
-CONFIG_HID_APPLE=y
 CONFIG_HID_BELKIN=y
 CONFIG_HID_CHERRY=y
-CONFIG_HID_CHICONY=y
 CONFIG_HID_CYPRESS=y
 CONFIG_HID_EZKEY=y
 CONFIG_HID_KENSINGTON=y
-CONFIG_HID_LOGITECH=y
 CONFIG_HID_MICROSOFT=y
 CONFIG_HID_MONTEREY=y
 # CONFIG_MIPS_PLATFORM_DEVICES is not set
@@ -85,7 +83,6 @@ CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 CONFIG_DEBUG_INFO_REDUCED=y
 CONFIG_DEBUG_FS=y
+# CONFIG_SLUB_DEBUG is not set
 # CONFIG_SCHED_DEBUG is not set
 # CONFIG_FTRACE is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon"
diff --git a/arch/mips/configs/gpr_defconfig b/arch/mips/configs/gpr_defconfig
index 92fc0edbac47..5c070a81a26d 100644
--- a/arch/mips/configs/gpr_defconfig
+++ b/arch/mips/configs/gpr_defconfig
@@ -9,9 +9,10 @@ CONFIG_RELAY=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 CONFIG_PROFILING=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
 CONFIG_MIPS_ALCHEMY=y
 CONFIG_MIPS_GPR=y
-CONFIG_PCI=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_PARTITION_ADVANCED=y
@@ -45,7 +46,6 @@ CONFIG_NETFILTER_XT_MATCH_LIMIT=m
 CONFIG_NETFILTER_XT_MATCH_MAC=m
 CONFIG_NETFILTER_XT_MATCH_MARK=m
 CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
-CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
 CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
 CONFIG_NETFILTER_XT_MATCH_QUOTA=m
 CONFIG_NETFILTER_XT_MATCH_REALM=m
@@ -102,27 +102,21 @@ CONFIG_IPDDP_ENCAP=y
 CONFIG_X25=m
 CONFIG_LAPB=m
 CONFIG_NET_SCHED=y
-CONFIG_NET_SCH_CBQ=m
 CONFIG_NET_SCH_HTB=m
 CONFIG_NET_SCH_HFSC=m
-CONFIG_NET_SCH_ATM=m
 CONFIG_NET_SCH_PRIO=m
 CONFIG_NET_SCH_RED=m
 CONFIG_NET_SCH_SFQ=m
 CONFIG_NET_SCH_TEQL=m
 CONFIG_NET_SCH_TBF=m
 CONFIG_NET_SCH_GRED=m
-CONFIG_NET_SCH_DSMARK=m
 CONFIG_NET_SCH_NETEM=m
 CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_CLS_BASIC=m
-CONFIG_NET_CLS_TCINDEX=m
 CONFIG_NET_CLS_ROUTE4=m
 CONFIG_NET_CLS_FW=m
 CONFIG_NET_CLS_U32=m
 CONFIG_CLS_U32_MARK=y
-CONFIG_NET_CLS_RSVP=m
-CONFIG_NET_CLS_RSVP6=m
 CONFIG_NET_EMATCH=y
 CONFIG_NET_EMATCH_CMP=m
 CONFIG_NET_EMATCH_NBYTE=m
@@ -145,6 +139,8 @@ CONFIG_BAYCOM_SER_HDX=m
 CONFIG_YAM=m
 CONFIG_CFG80211=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
+# CONFIG_VGA_ARB is not set
 CONFIG_MTD=y
 CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
@@ -232,8 +228,6 @@ CONFIG_WATCHDOG=y
 CONFIG_WATCHDOG_NOWAYOUT=y
 CONFIG_SSB=m
 CONFIG_SSB_DRIVER_PCICORE=y
-# CONFIG_VGA_ARB is not set
-# CONFIG_LCD_CLASS_DEVICE is not set
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_USB_HID=m
@@ -250,10 +244,6 @@ CONFIG_USB_STORAGE=m
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_GENERIC=y
 CONFIG_USB_SERIAL_SIERRAWIRELESS=y
-CONFIG_LEDS_GPIO=y
-CONFIG_LEDS_TRIGGER_TIMER=y
-CONFIG_LEDS_TRIGGER_HEARTBEAT=y
-CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
 # CONFIG_DNOTIFY is not set
 # CONFIG_INOTIFY_USER is not set
 CONFIG_ISO9660_FS=m
@@ -275,20 +265,15 @@ CONFIG_NLS_CODEPAGE_850=y
 CONFIG_NLS_ISO8859_1=y
 CONFIG_CRYPTO_AUTHENC=m
 CONFIG_CRYPTO_TEST=m
-CONFIG_CRYPTO_PCBC=m
-CONFIG_CRYPTO_MD4=m
-CONFIG_CRYPTO_MICHAEL_MIC=m
-CONFIG_CRYPTO_SHA512=m
-CONFIG_CRYPTO_WP512=m
-CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
-CONFIG_CRYPTO_KHAZAD=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
index 07839a4b397e..aca4797b5bb6 100644
--- a/arch/mips/configs/loongson3_defconfig
+++ b/arch/mips/configs/loongson3_defconfig
@@ -5,6 +5,8 @@ CONFIG_POSIX_MQUEUE=y
 CONFIG_AUDIT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BPF_SYSCALL=y
+CONFIG_BPF_JIT=y
 CONFIG_PREEMPT=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
@@ -22,18 +24,18 @@ CONFIG_CGROUP_CPUACCT=y
 CONFIG_NAMESPACES=y
 CONFIG_USER_NS=y
 CONFIG_SCHED_AUTOGROUP=y
-CONFIG_SYSFS_DEPRECATED=y
 CONFIG_RELAY=y
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_BPF_SYSCALL=y
 CONFIG_EXPERT=y
 CONFIG_PERF_EVENTS=y
+CONFIG_KEXEC=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="ieee754=relaxed"
 CONFIG_MACH_LOONGSON64=y
 CONFIG_CPU_HAS_MSA=y
 CONFIG_NUMA=y
 CONFIG_NR_CPUS=16
 CONFIG_HZ_256=y
-CONFIG_KEXEC=y
 CONFIG_MIPS32_O32=y
 CONFIG_MIPS32_N32=y
 CONFIG_VIRTUALIZATION=y
@@ -47,15 +49,12 @@ CONFIG_MODVERSIONS=y
 CONFIG_PARTITION_ADVANCED=y
 CONFIG_MQ_IOSCHED_DEADLINE=m
 CONFIG_IOSCHED_BFQ=y
-CONFIG_BFQ_GROUP_IOSCHED=y
 CONFIG_BINFMT_MISC=m
 CONFIG_KSM=y
 CONFIG_NET=y
 CONFIG_PACKET=y
-CONFIG_UNIX=y
 CONFIG_XFRM_USER=y
 CONFIG_NET_KEY=y
-CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MULTIPLE_TABLES=y
@@ -128,7 +127,6 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_VSOCKETS=m
 CONFIG_VIRTIO_VSOCKETS=m
-CONFIG_BPF_JIT=y
 CONFIG_CFG80211=m
 CONFIG_CFG80211_WEXT=y
 CONFIG_MAC80211=m
@@ -196,7 +194,6 @@ CONFIG_VIRTIO_NET=m
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CHELSIO is not set
 # CONFIG_NET_VENDOR_CIRRUS is not set
 # CONFIG_NET_VENDOR_CISCO is not set
@@ -216,6 +213,7 @@ CONFIG_IXGBE=y
 # CONFIG_NET_VENDOR_NVIDIA is not set
 # CONFIG_NET_VENDOR_OKI is not set
 # CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_RDC is not set
 CONFIG_8139CP=m
 CONFIG_8139TOO=m
@@ -276,15 +274,14 @@ CONFIG_MEDIA_SUPPORT=m
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_DRM=y
+CONFIG_DRM_RADEON=m
 CONFIG_DRM_AMDGPU=m
 CONFIG_DRM_AMDGPU_SI=y
 CONFIG_DRM_AMDGPU_CIK=y
 CONFIG_DRM_AMDGPU_USERPTR=y
 CONFIG_DRM_AMD_ACP=y
-CONFIG_DRM_AMD_DC=y
 CONFIG_DRM_AMD_DC_SI=y
 CONFIG_DRM_AST=m
-CONFIG_DRM_RADEON=m
 CONFIG_DRM_QXL=y
 CONFIG_DRM_VIRTIO_GPU=y
 CONFIG_FB=y
@@ -292,7 +289,6 @@ CONFIG_FB_RADEON=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_PLATFORM=m
 # CONFIG_VGA_CONSOLE is not set
-CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
 CONFIG_LOGO=y
 CONFIG_SOUND=y
@@ -350,7 +346,6 @@ CONFIG_EXT3_FS_SECURITY=y
 CONFIG_XFS_FS=y
 CONFIG_XFS_POSIX_ACL=y
 CONFIG_QUOTA=y
-# CONFIG_PRINT_QUOTA_WARNING is not set
 CONFIG_QFMT_V1=m
 CONFIG_QFMT_V2=m
 CONFIG_AUTOFS_FS=y
@@ -390,24 +385,20 @@ CONFIG_SECURITY_NETWORK=y
 CONFIG_SECURITY_PATH=y
 CONFIG_SECURITY_SELINUX=y
 CONFIG_SECURITY_SELINUX_BOOTPARAM=y
-CONFIG_SECURITY_SELINUX_DISABLE=y
 CONFIG_DEFAULT_SECURITY_DAC=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_MD5=y
-CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
 CONFIG_CRYPTO_SERPENT=m
 CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_PRINTK_TIME=y
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_FS=y
 # CONFIG_SCHED_DEBUG is not set
-# CONFIG_DEBUG_PREEMPT is not set
 CONFIG_FUNCTION_TRACER=y
 CONFIG_FTRACE_SYSCALLS=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ieee754=relaxed"
diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h
index 8c56b862fd9c..798bc3c68080 100644
--- a/arch/mips/include/asm/setup.h
+++ b/arch/mips/include/asm/setup.h
@@ -5,6 +5,7 @@
 #include <linux/types.h>
 #include <uapi/asm/setup.h>
 
+#ifndef __ASSEMBLY__
 extern void prom_putchar(char);
 extern void setup_early_printk(void);
 
@@ -27,5 +28,6 @@ extern unsigned long ebase;
 extern unsigned int hwrena;
 extern void per_cpu_trap_init(bool);
 extern void cpu_cache_init(void);
+#endif
 
 #endif /* __SETUP_H */
diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
index 58fc8d089402..089d67c476ae 100644
--- a/arch/mips/kernel/relocate.c
+++ b/arch/mips/kernel/relocate.c
@@ -23,6 +23,7 @@
 #include <linux/start_kernel.h>
 #include <linux/string.h>
 #include <linux/printk.h>
+#include <linux/cmdline.h>
 
 #define RELOCATED(x) ((void *)((long)x + offset))
 
@@ -247,16 +248,26 @@ static inline __init bool kaslr_disabled(void)
 	char *str;
 
 #if defined(CONFIG_CMDLINE_BOOL)
-	const char *builtin_cmdline = CONFIG_CMDLINE;
+	char *builtin_cmdline = CMDLINE_PREPEND;
 
 	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) == ' '))
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		str = strstr(arcs_cmdline, "nokaslr");
+		if (str == arcs_cmdline || (str > arcs_cmdline && *(str - 1) == ' '))
+			return true;
+	}
+
+#if defined(CONFIG_CMDLINE_BOOL)
+	builtin_cmdline = CMDLINE_APPEND;
+	str = strstr(builtin_cmdline, "nokaslr");
+	if (str == builtin_cmdline ||
+	    (str > builtin_cmdline && *(str - 1) == ' '))
 		return true;
+#endif
 
 	return false;
 }
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index cb871eb784a7..38e0e19b9c0d 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -25,6 +25,7 @@
 #include <linux/debugfs.h>
 #include <linux/kexec.h>
 #include <linux/sizes.h>
+#include <linux/cmdline.h>
 #include <linux/device.h>
 #include <linux/dma-map-ops.h>
 #include <linux/decompress/generic.h>
@@ -70,12 +71,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.
@@ -561,27 +556,7 @@ 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)) {
-		strscpy(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))
-		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-	else
-		boot_command_line[0] = 0;
+	boot_command_line[0] = 0;
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 	/*
@@ -604,12 +579,9 @@ static void __init bootcmdline_init(void)
 		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.
+	 * Use the generic system for builtin prepend and append.
 	 */
-	if (IS_ENABLED(CONFIG_CMDLINE_BOOL) &&
-	    !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
-		bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE);
+	cmdline_add_builtin(boot_command_line);
 }
 
 /*
diff --git a/arch/mips/pic32/pic32mzda/early_console.c b/arch/mips/pic32/pic32mzda/early_console.c
index 3cd1b408fa1c..f14bc1846706 100644
--- a/arch/mips/pic32/pic32mzda/early_console.c
+++ b/arch/mips/pic32/pic32mzda/early_console.c
@@ -76,7 +76,7 @@ static char * __init pic32_getcmdline(void)
 	 * command line setup if using CONFIG_CMDLINE_BOOL.
 	 */
 #ifdef CONFIG_CMDLINE_OVERRIDE
-	return CONFIG_CMDLINE;
+	return CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND;
 #else
 	return fw_getcmdline();
 #endif
diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c
index 53b227a9074c..ba2524255857 100644
--- a/arch/mips/pic32/pic32mzda/init.c
+++ b/arch/mips/pic32/pic32mzda/init.c
@@ -9,6 +9,7 @@
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
 #include <linux/platform_data/sdhci-pic32.h>
+#include <linux/cmdline.h>
 
 #include <asm/fw/fw.h>
 #include <asm/mips-boards/generic.h>
@@ -41,7 +42,7 @@ void __init plat_mem_setup(void)
 	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);
+	pr_info(" builtin_cmdline  : %s\n", CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND);
 #endif
 	if (dtb != __dtb_start)
 		strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-- 
2.39.2


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

* [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (3 preceding siblings ...)
  2023-11-10  1:38 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-10  4:23   ` kernel test robot
                     ` (2 more replies)
  2023-11-10  1:38 ` [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line Daniel Walker
                   ` (4 subsequent siblings)
  9 siblings, 3 replies; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, Ard Biesheuvel, linux-efi, linux-kernel

This adds code to handle the generic command line changes.
The efi code appears that it doesn't benefit as much from this design
as it could.

For example, if you had a prepend command line with "nokaslr" then
you might be helpful to re-enable it in the boot loader or dts,
but there appears to be no way to re-enable kaslr or some of the
other options.

The efi command line handling is incorrect. x86 and arm have an append
system however the efi code prepends the command line.

For example, you could have a non-upgradable bios which sends

efi=disable_early_pci_dma

This hypothetically could have been set because early pci dma caused
issues on early versions of the product.

Then later the early pci dma was made to work and the company desired
to start using it. To override the bios you could set the CONFIG_CMDLINE
to,

efi=no_disable_early_pci_dma

then parsing would normally start with the bios command line, then move
to the CONFIG_CMDLINE and you would end up with early pci dma turned on.

however, current efi code keeps early pci dma off because the bios
arguments always override the built in.

Per my reading this is different from the main body of x86, arm, and
arm64.

The generic command line provides both append and prepend, so it
alleviates this issue if it's used. However not all architectures use
it.

It would be desirable to allow the efi stub to have it's builtin command
line to be modified after compile, but I don't see a feasible way to do
that currently.

Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 .../firmware/efi/libstub/efi-stub-helper.c    | 29 +++++++++++++++++++
 drivers/firmware/efi/libstub/efi-stub.c       |  9 ++++++
 drivers/firmware/efi/libstub/efistub.h        |  1 +
 drivers/firmware/efi/libstub/x86-stub.c       | 14 +++++++--
 4 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index bfa30625f5d0..952fa2cdff51 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -11,6 +11,7 @@
 
 #include <linux/efi.h>
 #include <linux/kernel.h>
+#include <linux/cmdline.h>
 #include <asm/efi.h>
 #include <asm/setup.h>
 
@@ -29,6 +30,34 @@ bool __pure __efi_soft_reserve_enabled(void)
 	return !efi_nosoftreserve;
 }
 
+/**
+ * efi_handle_cmdline() - handle adding in built-in parts of the command line
+ * @cmdline:	kernel command line
+ *
+ * Add in the generic parts of the commandline and start the parsing of the
+ * command line.
+ *
+ * Return:	status code
+ */
+efi_status_t efi_handle_builtin_cmdline(char const *cmdline)
+{
+	efi_status_t status = EFI_SUCCESS;
+
+	if (sizeof(CMDLINE_STATIC_PREPEND) > 1)
+		status |= efi_parse_options(CMDLINE_STATIC_PREPEND);
+
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE))
+		status |= efi_parse_options(cmdline);
+
+	if (sizeof(CMDLINE_STATIC_APPEND) > 1)
+		status |= efi_parse_options(CMDLINE_STATIC_APPEND);
+
+	if (status != EFI_SUCCESS)
+		efi_err("Failed to parse options\n");
+
+	return status;
+}
+
 /**
  * efi_parse_options() - Parse EFI command line options
  * @cmdline:	kernel command line
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index f9c1e8a2bd1d..770abe95c0ee 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -127,6 +127,14 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
 		return EFI_OUT_OF_RESOURCES;
 	}
 
+#ifdef CONFIG_GENERIC_CMDLINE
+	status = efi_handle_builtin_cmdline(cmdline);
+	if (status != EFI_SUCCESS) {
+		goto fail_free_cmdline;
+	}
+#endif
+
+#ifdef CONFIG_CMDLINE
 	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
 	    IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
 	    cmdline_size == 0) {
@@ -144,6 +152,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
 			goto fail_free_cmdline;
 		}
 	}
+#endif
 
 	*cmdline_ptr = cmdline;
 	return EFI_SUCCESS;
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 212687c30d79..1ac6631905c5 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -996,6 +996,7 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr,
 				 unsigned long alignment,
 				 unsigned long min_addr);
 
+efi_status_t efi_handle_builtin_cmdline(char const *cmdline);
 efi_status_t efi_parse_options(char const *cmdline);
 
 void efi_parse_option_graphics(char *option);
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 9d5df683f882..273a8a9c8bbb 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -847,6 +847,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
 	struct setup_header *hdr = &boot_params->hdr;
 	const struct linux_efi_initrd *initrd = NULL;
 	unsigned long kernel_entry;
+	unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
+				       ((u64)boot_params->ext_cmd_line_ptr << 32));
 	efi_status_t status;
 
 	boot_params_pointer = boot_params;
@@ -877,6 +879,14 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
 		goto fail;
 	}
 
+#ifdef CONFIG_GENERIC_CMDLINE
+	status = efi_handle_builtin_cmdline((char *)cmdline_paddr);
+	if (status != EFI_SUCCESS) {
+		efi_err("Failed to parse options\n");
+		goto fail;
+	}
+#else /* CONFIG_GENERIC_CMDLINE */
+
 #ifdef CONFIG_CMDLINE_BOOL
 	status = efi_parse_options(CONFIG_CMDLINE);
 	if (status != EFI_SUCCESS) {
@@ -885,8 +895,6 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
 	}
 #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");
@@ -894,6 +902,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
 		}
 	}
 
+#endif
+
 	status = efi_decompress_kernel(&kernel_entry);
 	if (status != EFI_SUCCESS) {
 		efi_err("Failed to decompress kernel\n");
-- 
2.39.2


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

* [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (4 preceding siblings ...)
  2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-10  7:17   ` kernel test robot
  2023-11-10  1:38 ` [PATCH 7/8] of: replace command line handling Daniel Walker
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, H. Peter Anvin
  Cc: xe-linux-external, Ruslan Ruslichenko, Ruslan Bilovol, linux-kernel

This updates the x86 code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: xe-linux-external@cisco.com
Signed-off-by: Ruslan Ruslichenko <rruslich@cisco.com>
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 arch/x86/Kconfig        | 44 +----------------------------------------
 arch/x86/kernel/setup.c | 18 ++---------------
 2 files changed, 3 insertions(+), 59 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 66bfabae8814..390ffaa743df 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -145,6 +145,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
@@ -2309,49 +2310,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
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index b098b1fa2470..bd025c003f32 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -55,6 +55,7 @@
 #include <asm/unwind.h>
 #include <asm/vsyscall.h>
 #include <linux/vmalloc.h>
+#include <linux/cmdline.h>
 
 /*
  * max_low_pfn_mapped: highest directly mapped pfn < 4 GB
@@ -162,9 +163,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;
@@ -959,19 +957,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
-	strscpy(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);
-		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-	}
-#endif
-#endif
-
+	cmdline_add_builtin(boot_command_line);
 	strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
-- 
2.39.2


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

* [PATCH 7/8] of: replace command line handling
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (5 preceding siblings ...)
  2023-11-10  1:38 ` [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-16 16:09   ` Rob Herring
  2023-11-23  6:39   ` Christophe Leroy
  2023-11-10  1:38 ` [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line Daniel Walker
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Rob Herring, Frank Rowand
  Cc: xe-linux-external, devicetree, linux-kernel

Rob Herring has complained about this section of code. I removed the
command line handling code to the cmdline.h header. This hopefully makes
it easier for Rob to maintain it (at least he doesn't have to look at it
directly anymore). I would like to add a Kconfig option called
OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code.
This would allow a platform to use the cmdline.h and the added function
directly and remove the Kconfig option. This change would be in a subsequent
patch.

This code was boot tested on powerpc 32bit, powerpc 64bit without
any generic command line conversion.

Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 drivers/of/fdt.c        | 22 +++-------------------
 include/linux/cmdline.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bf502ba8da95..1fc1b17d04dc 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -26,6 +26,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>
@@ -1183,27 +1184,10 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 
 	/* Retrieve command line */
 	p = of_get_flat_dt_prop(node, "bootargs", &l);
-	if (p != NULL && l > 0)
-		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
 
 handle_cmdline:
-	/*
-	 * 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(cmdline, " ", COMMAND_LINE_SIZE);
-	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#elif defined(CONFIG_CMDLINE_FORCE)
-	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#else
-	/* No arguments from boot loader, use kernel's  cmdl*/
-	if (!((char *)cmdline)[0])
-		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif
-#endif /* CONFIG_CMDLINE */
+
+	of_deprecated_cmdline_update(cmdline, p, l);
 
 	pr_debug("Command line is: %s\n", (char *)cmdline);
 
diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
index a94758a0f257..c772afb7340f 100644
--- a/include/linux/cmdline.h
+++ b/include/linux/cmdline.h
@@ -103,4 +103,35 @@ __cmdline_add_builtin(
 
 #define cmdline_get_static_builtin(dest) \
 	(CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND)
+
+#ifndef CONFIG_GENERIC_CMDLINE
+static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length)
+{
+	if (dt_bootargs != NULL && length > 0)
+		strlcpy(cmdline, dt_bootargs, min(length, COMMAND_LINE_SIZE));
+	/*
+	 * 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(cmdline, " ", COMMAND_LINE_SIZE);
+	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#elif defined(CONFIG_CMDLINE_FORCE)
+	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#else
+	/* No arguments from boot loader, use kernel's  cmdl*/
+	if (!((char *)cmdline)[0])
+		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 #endif
+#endif /* CONFIG_CMDLINE */
+	return true;
+}
+#else
+static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length) { return false; }
+#endif /* CONFIG_GENERIC_CMDLINE */
+
+
+#endif /* _LINUX_CMDLINE_H */
-- 
2.39.2


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

* [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (6 preceding siblings ...)
  2023-11-10  1:38 ` [PATCH 7/8] of: replace command line handling Daniel Walker
@ 2023-11-10  1:38 ` Daniel Walker
  2023-11-23  6:39   ` Christophe Leroy
  2023-11-10  1:51 ` [PATCH 0/8] generic command line v6 Andrew Morton
  2023-11-23  6:23 ` Christophe Leroy
  9 siblings, 1 reply; 30+ messages in thread
From: Daniel Walker @ 2023-11-10  1:38 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Catalin Marinas
  Cc: xe-linux-external, linux-arm-kernel, linux-kernel

This removes arm64 from the device tree handling of the
command line arguments.

The boot_command_line variable is populated inside the earliest
user of the command line, which is in idreg-override.c.

The device tree should not be needed to do any further handling
of the boot command line options.

Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 arch/arm64/Kconfig                  | 33 +----------------------------
 arch/arm64/include/asm/setup.h      |  4 ++++
 arch/arm64/include/uapi/asm/setup.h |  2 ++
 arch/arm64/kernel/idreg-override.c  |  9 ++++----
 arch/arm64/kernel/pi/kaslr_early.c  | 14 ++++++------
 5 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 78f20e632712..d3b7fd1080d0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -131,6 +131,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
@@ -2217,38 +2218,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
 
diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
index f4af547ef54c..5a8037262cbb 100644
--- a/arch/arm64/include/asm/setup.h
+++ b/arch/arm64/include/asm/setup.h
@@ -3,10 +3,13 @@
 #ifndef __ARM64_ASM_SETUP_H
 #define __ARM64_ASM_SETUP_H
 
+#ifndef __ASSEMBLY__
 #include <linux/string.h>
+#endif
 
 #include <uapi/asm/setup.h>
 
+#ifndef __ASSEMBLY__
 void *get_early_fdt_ptr(void);
 void early_fdt_map(u64 dt_phys);
 
@@ -30,5 +33,6 @@ static inline bool arch_parse_debug_rodata(char *arg)
 	return false;
 }
 #define arch_parse_debug_rodata arch_parse_debug_rodata
+#endif /* __ASSEMBLY__ */
 
 #endif
diff --git a/arch/arm64/include/uapi/asm/setup.h b/arch/arm64/include/uapi/asm/setup.h
index 5d703888f351..f5fc5b806369 100644
--- a/arch/arm64/include/uapi/asm/setup.h
+++ b/arch/arm64/include/uapi/asm/setup.h
@@ -20,7 +20,9 @@
 #ifndef __ASM_SETUP_H
 #define __ASM_SETUP_H
 
+#ifndef __ASSEMBLY__
 #include <linux/types.h>
+#endif
 
 #define COMMAND_LINE_SIZE	2048
 
diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
index 3addc09f8746..6334a9228909 100644
--- a/arch/arm64/kernel/idreg-override.c
+++ b/arch/arm64/kernel/idreg-override.c
@@ -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>
@@ -304,11 +305,11 @@ static __init void parse_cmdline(void)
 {
 	const u8 *prop = get_bootargs_cmdline();
 
-	if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop)
-		__parse_cmdline(CONFIG_CMDLINE, true);
+	strscpy(boot_command_line, prop, COMMAND_LINE_SIZE);
+	cmdline_add_builtin(boot_command_line);
+
+	__parse_cmdline(boot_command_line, true);
 
-	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && prop)
-		__parse_cmdline(prop, true);
 }
 
 /* Keep checkers quiet */
diff --git a/arch/arm64/kernel/pi/kaslr_early.c b/arch/arm64/kernel/pi/kaslr_early.c
index 17bff6e399e4..1e00bc01fa7a 100644
--- a/arch/arm64/kernel/pi/kaslr_early.c
+++ b/arch/arm64/kernel/pi/kaslr_early.c
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/sizes.h>
 #include <linux/string.h>
+#include <linux/cmdline.h>
 
 #include <asm/archrandom.h>
 #include <asm/memory.h>
@@ -42,7 +43,7 @@ static bool cmdline_contains_nokaslr(const u8 *cmdline)
 
 static bool is_kaslr_disabled_cmdline(void *fdt)
 {
-	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
 		int node;
 		const u8 *prop;
 
@@ -54,16 +55,15 @@ static bool is_kaslr_disabled_cmdline(void *fdt)
 		if (!prop)
 			goto out;
 
+		if (cmdline_contains_nokaslr(CMDLINE_STATIC_APPEND))
+			return true;
 		if (cmdline_contains_nokaslr(prop))
 			return true;
-
-		if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
-			goto out;
-
-		return false;
+		if (cmdline_contains_nokaslr(CMDLINE_STATIC_PREPEND))
+			return true;
 	}
 out:
-	return cmdline_contains_nokaslr(CONFIG_CMDLINE);
+	return cmdline_contains_nokaslr(cmdline_get_static_builtin());
 }
 
 static u64 get_kaslr_seed(void *fdt)
-- 
2.39.2


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

* Re: [PATCH 0/8] generic command line v6
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (7 preceding siblings ...)
  2023-11-10  1:38 ` [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line Daniel Walker
@ 2023-11-10  1:51 ` Andrew Morton
  2023-11-10  2:22   ` Daniel Walker (danielwa)
  2023-11-23  6:23 ` Christophe Leroy
  9 siblings, 1 reply; 30+ messages in thread
From: Andrew Morton @ 2023-11-10  1:51 UTC (permalink / raw)
  To: Daniel Walker
  Cc: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Pratyush Brahma, Tomas Mudrunka, Sean Anderson, x86, linux-mips,
	linuxppc-dev, H. Peter Anvin, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-arm-kernel, linux-kernel,
	devicetree, linux-kbuild, linux-efi

On Thu,  9 Nov 2023 17:38:04 -0800 Daniel Walker <danielwa@cisco.com> wrote:

> This release is an up-rev of the v5 patches. No additional features have
> been added. Some changes were mode to function names and some changes to
> Kconfig dependencies. Also updated the config conversion for mips.
> 
> There are a number of people who have expressed interest in these
> patches either by asking for them to be merge or testing them. If
> people are so inclined please continue to request them to be merge
> or to ask the status of the next release. It's helpful to motivate me to
> release them again and for the maintainers to see the interest
> generated.
> 
> These patches have been used by Cisco Systems, Inc. on millions of
> released products to great effect. Hopefully they can be used by the
> entire Linux eco system.
> 

fyi, none of the above is suitable for a [0/N] changelog - it's all
transitory stuff which tells readers nothing much about what the
patchset does.

And that info is sorely missed.  I can see that it's a code cleanup,
but I'm sure Cisco wouldn't expend resources to maintain such a thing. 
There's something else here.

In [1/8] I see "Even with mips and powerpc enhancement the needs of
Cisco are not met on these platforms" and "This unified implementation
offers the same functionality needed by Cisco on all platform which we
enable it on".

Well OK, what are these needs?   What functionality changes does this
patchset offer which Cisco finds useful?  IOW, what were the
requirements?  What's wrong with the old code and how does this
patchset fix/enhance that?


I see the patchset updates nothing under Documentation/.  Should it do
so?  Could it do so?


I don't know what is the expected merge patch for this work.  I can
grab them if no other maintainer is in the firing line.

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

* Re: [PATCH 0/8] generic command line v6
  2023-11-10  1:51 ` [PATCH 0/8] generic command line v6 Andrew Morton
@ 2023-11-10  2:22   ` Daniel Walker (danielwa)
  2023-11-10  2:40     ` Andrew Morton
  0 siblings, 1 reply; 30+ messages in thread
From: Daniel Walker (danielwa) @ 2023-11-10  2:22 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Pratyush Brahma, Tomas Mudrunka, Sean Anderson, x86, linux-mips,
	linuxppc-dev, H. Peter Anvin, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-arm-kernel, linux-kernel,
	devicetree, linux-kbuild, linux-efi

On Thu, Nov 09, 2023 at 05:51:42PM -0800, Andrew Morton wrote:
> On Thu,  9 Nov 2023 17:38:04 -0800 Daniel Walker <danielwa@cisco.com> wrote:
> 
> > This release is an up-rev of the v5 patches. No additional features have
> > been added. Some changes were mode to function names and some changes to
> > Kconfig dependencies. Also updated the config conversion for mips.
> > 
> > There are a number of people who have expressed interest in these
> > patches either by asking for them to be merge or testing them. If
> > people are so inclined please continue to request them to be merge
> > or to ask the status of the next release. It's helpful to motivate me to
> > release them again and for the maintainers to see the interest
> > generated.
> > 
> > These patches have been used by Cisco Systems, Inc. on millions of
> > released products to great effect. Hopefully they can be used by the
> > entire Linux eco system.
> > 
> 
> fyi, none of the above is suitable for a [0/N] changelog - it's all
> transitory stuff which tells readers nothing much about what the
> patchset does.
 
I did not think about it this way. It's because I've submitted this so many
times. I guess I assume everyone knows what it is.

> And that info is sorely missed.  I can see that it's a code cleanup,
> but I'm sure Cisco wouldn't expend resources to maintain such a thing. 
> There's something else here.

I think the prior submissions there was no cover letter, maybe I should just
achoo that entirely.

> In [1/8] I see "Even with mips and powerpc enhancement the needs of
> Cisco are not met on these platforms" and "This unified implementation
> offers the same functionality needed by Cisco on all platform which we
> enable it on".
> 
> Well OK, what are these needs?   What functionality changes does this
> patchset offer which Cisco finds useful?  IOW, what were the
> requirements?  What's wrong with the old code and how does this
> patchset fix/enhance that?

The limitation is that you can't append and prepend to the command line at the
same time in any of the architectures. Having access to both allows OEMs to deal
with broken bootloaders which can't easily be upgraded. Others have responded
that they also use these patches for this same reason.

In 2/8 and 3/8 I modify the insert-sys-cert tool to allow modification of the
command line append and prepend after the build. This allow for an SDK
provided with a binary kernel and for the command line append/prepend to still
be modified identically to how that's done with certificates.

Making all this generic means each platform has a unified set of command line
services. Cisco uses x86/arm32/arm64/mips/powerpc , and it's nice to have all
the same features across platforms.

> 
> I see the patchset updates nothing under Documentation/.  Should it do
> so?  Could it do so?

The only documentation is Kconfig descriptions and commit messages. I suppose it
could have something under Documentation/. The only part which could use more
documentation are the changes in 2/8 and 3/8. That feature is maybe confusing
and has limitations which are maybe not clear. Although the same limitation exist for
inserting certificates.

> 
> I don't know what is the expected merge patch for this work.  I can
> grab them if no other maintainer is in the firing line.

merge patch ? Do you mean merge description ? I think your the maintainer in the
firing line for this one.

Daniel

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

* Re: [PATCH 0/8] generic command line v6
  2023-11-10  2:22   ` Daniel Walker (danielwa)
@ 2023-11-10  2:40     ` Andrew Morton
  0 siblings, 0 replies; 30+ messages in thread
From: Andrew Morton @ 2023-11-10  2:40 UTC (permalink / raw)
  To: Daniel Walker (danielwa)
  Cc: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Pratyush Brahma, Tomas Mudrunka, Sean Anderson, x86, linux-mips,
	linuxppc-dev, H. Peter Anvin, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-arm-kernel, linux-kernel,
	devicetree, linux-kbuild, linux-efi

On Fri, 10 Nov 2023 02:22:27 +0000 "Daniel Walker (danielwa)" <danielwa@cisco.com> wrote:

> On Thu, Nov 09, 2023 at 05:51:42PM -0800, Andrew Morton wrote:
> > On Thu,  9 Nov 2023 17:38:04 -0800 Daniel Walker <danielwa@cisco.com> wrote:
> > 
> > > This release is an up-rev of the v5 patches. No additional features have
> > > been added. Some changes were mode to function names and some changes to
> > > Kconfig dependencies. Also updated the config conversion for mips.
> > > 
> > > There are a number of people who have expressed interest in these
> > > patches either by asking for them to be merge or testing them. If
> > > people are so inclined please continue to request them to be merge
> > > or to ask the status of the next release. It's helpful to motivate me to
> > > release them again and for the maintainers to see the interest
> > > generated.
> > > 
> > > These patches have been used by Cisco Systems, Inc. on millions of
> > > released products to great effect. Hopefully they can be used by the
> > > entire Linux eco system.
> > > 
> > 
> > fyi, none of the above is suitable for a [0/N] changelog - it's all
> > transitory stuff which tells readers nothing much about what the
> > patchset does.
>  
> I did not think about it this way. It's because I've submitted this so many
> times. I guess I assume everyone knows what it is.

This is all on the path to the mainline git history.  Think about how
we want it presented to future readers.  10 years from now nobody will
remember the v5 series email spray.

> 
> > In [1/8] I see "Even with mips and powerpc enhancement the needs of
> > Cisco are not met on these platforms" and "This unified implementation
> > offers the same functionality needed by Cisco on all platform which we
> > enable it on".
> > 
> > Well OK, what are these needs?   What functionality changes does this
> > patchset offer which Cisco finds useful?  IOW, what were the
> > requirements?  What's wrong with the old code and how does this
> > patchset fix/enhance that?
> 
> The limitation is that you can't append and prepend to the command line at the
> same time in any of the architectures. Having access to both allows OEMs to deal
> with broken bootloaders which can't easily be upgraded.

I would never ever have guessed that from the emails I received!

> Others have responded
> that they also use these patches for this same reason.

Citing this info in the [0/N] would be useful.

> In 2/8 and 3/8 I modify the insert-sys-cert tool to allow modification of the
> command line append and prepend after the build. This allow for an SDK
> provided with a binary kernel and for the command line append/prepend to still
> be modified identically to how that's done with certificates.

And this.

> Making all this generic means each platform has a unified set of command line
> services. Cisco uses x86/arm32/arm64/mips/powerpc , and it's nice to have all
> the same features across platforms.

Sounds good.

> > 
> > I see the patchset updates nothing under Documentation/.  Should it do
> > so?  Could it do so?
> 
> The only documentation is Kconfig descriptions and commit messages. I suppose it
> could have something under Documentation/. The only part which could use more
> documentation are the changes in 2/8 and 3/8. That feature is maybe confusing
> and has limitations which are maybe not clear. Although the same limitation exist for
> inserting certificates.

Perhaps the new functionality could be described in
Documentation/admin-guide/kernel-parameters.rst

> > 
> > I don't know what is the expected merge patch for this work.  I can
> > grab them if no other maintainer is in the firing line.
> 
> merge patch ?

"path", sorry.

> Do you mean merge description ? I think your the maintainer in the
> firing line for this one.

OK.  

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

* Re: [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline
  2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
@ 2023-11-10  4:23   ` kernel test robot
  2023-11-23  6:37   ` Christophe Leroy
  2023-12-12  9:55   ` Ard Biesheuvel
  2 siblings, 0 replies; 30+ messages in thread
From: kernel test robot @ 2023-11-10  4:23 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Christophe Leroy, Rob Herring,
	Daniel Gimpelevich, Andrew Morton, Pratyush Brahma,
	Tomas Mudrunka, Sean Anderson, x86, linux-mips, linuxppc-dev
  Cc: oe-kbuild-all, Linux Memory Management List, xe-linux-external,
	Ard Biesheuvel, linux-efi, linux-kernel

Hi Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on v6.6]
[cannot apply to arm64/for-next/core efi/next tip/x86/core robh/for-next linus/master next-20231110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Walker/CMDLINE-add-generic-builtin-command-line/20231110-094423
base:   v6.6
patch link:    https://lore.kernel.org/r/20231110013817.2378507-6-danielwa%40cisco.com
patch subject: [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline
config: loongarch-randconfig-002-20231110 (https://download.01.org/0day-ci/archive/20231110/202311101224.evyh4zgY-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231110/202311101224.evyh4zgY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311101224.evyh4zgY-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/firmware/efi/libstub/efi-stub-helper.c:43: warning: expecting prototype for efi_handle_cmdline(). Prototype was for efi_handle_builtin_cmdline() instead
   drivers/firmware/efi/libstub/efi-stub-helper.c:592: warning: Function parameter or member 'out' not described in 'efi_load_initrd'


vim +43 drivers/firmware/efi/libstub/efi-stub-helper.c

    32	
    33	/**
    34	 * efi_handle_cmdline() - handle adding in built-in parts of the command line
    35	 * @cmdline:	kernel command line
    36	 *
    37	 * Add in the generic parts of the commandline and start the parsing of the
    38	 * command line.
    39	 *
    40	 * Return:	status code
    41	 */
    42	efi_status_t efi_handle_builtin_cmdline(char const *cmdline)
  > 43	{
    44		efi_status_t status = EFI_SUCCESS;
    45	
    46		if (sizeof(CMDLINE_STATIC_PREPEND) > 1)
    47			status |= efi_parse_options(CMDLINE_STATIC_PREPEND);
    48	
    49		if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE))
    50			status |= efi_parse_options(cmdline);
    51	
    52		if (sizeof(CMDLINE_STATIC_APPEND) > 1)
    53			status |= efi_parse_options(CMDLINE_STATIC_APPEND);
    54	
    55		if (status != EFI_SUCCESS)
    56			efi_err("Failed to parse options\n");
    57	
    58		return status;
    59	}
    60	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line
  2023-11-10  1:38 ` [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line Daniel Walker
@ 2023-11-10  7:17   ` kernel test robot
  0 siblings, 0 replies; 30+ messages in thread
From: kernel test robot @ 2023-11-10  7:17 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Christophe Leroy, Rob Herring,
	Daniel Gimpelevich, Andrew Morton, Pratyush Brahma,
	Tomas Mudrunka, Sean Anderson, x86, linux-mips, linuxppc-dev,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin
  Cc: Paul Gazzillo, Necip Fazil Yildiran, oe-kbuild-all,
	Linux Memory Management List, xe-linux-external,
	Ruslan Ruslichenko, Ruslan Bilovol, linux-kernel

Hi Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on v6.6]
[cannot apply to arm64/for-next/core efi/next tip/x86/core robh/for-next linus/master next-20231110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Walker/CMDLINE-add-generic-builtin-command-line/20231110-094423
base:   v6.6
patch link:    https://lore.kernel.org/r/20231110013817.2378507-7-danielwa%40cisco.com
patch subject: [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line
config: x86_64-kismet-CONFIG_SYSTEM_EXTRA_CERTIFICATE-CONFIG_CMDLINE_EXTRA-0-0 (https://download.01.org/0day-ci/archive/20231110/202311101507.q12gPUvS-lkp@intel.com/config)
reproduce: (https://download.01.org/0day-ci/archive/20231110/202311101507.q12gPUvS-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311101507.q12gPUvS-lkp@intel.com/

kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for SYSTEM_EXTRA_CERTIFICATE when selected by CMDLINE_EXTRA
   
   WARNING: unmet direct dependencies detected for SYSTEM_EXTRA_CERTIFICATE
     Depends on [n]: CRYPTO [=y] && SYSTEM_TRUSTED_KEYRING [=n]
     Selected by [y]:
     - CMDLINE_EXTRA [=y] && GENERIC_CMDLINE [=y] && CMDLINE_BOOL [=y]

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 1/8] CMDLINE: add generic builtin command line
  2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
@ 2023-11-10 16:12   ` kernel test robot
  2023-11-23  6:32   ` Christophe Leroy
  2023-12-04 11:11   ` Jaskaran Singh
  2 siblings, 0 replies; 30+ messages in thread
From: kernel test robot @ 2023-11-10 16:12 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Christophe Leroy, Rob Herring,
	Daniel Gimpelevich, Andrew Morton, Pratyush Brahma,
	Tomas Mudrunka, Sean Anderson, x86, linux-mips, linuxppc-dev
  Cc: oe-kbuild-all, Linux Memory Management List, xe-linux-external,
	Ruslan Bilovol, linux-kernel

Hi Daniel,

kernel test robot noticed the following build errors:

[auto build test ERROR on v6.6]
[cannot apply to arm64/for-next/core efi/next tip/x86/core robh/for-next linus/master next-20231110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Walker/CMDLINE-add-generic-builtin-command-line/20231110-094423
base:   v6.6
patch link:    https://lore.kernel.org/r/20231110013817.2378507-2-danielwa%40cisco.com
patch subject: [PATCH 1/8] CMDLINE: add generic builtin command line
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20231110/202311102331.GllFaI9t-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231110/202311102331.GllFaI9t-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311102331.GllFaI9t-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:15,
                    from include/linux/interrupt.h:6,
                    from arch/sparc/include/asm/setup.h:8,
                    from lib/generic_cmdline.S:5:
>> include/linux/align.h:8: warning: "ALIGN" redefined
       8 | #define ALIGN(x, a)             __ALIGN_KERNEL((x), (a))
         | 
   In file included from include/linux/export.h:6,
                    from lib/generic_cmdline.S:2:
   include/linux/linkage.h:103: note: this is the location of the previous definition
     103 | #define ALIGN __ALIGN
         | 
   In file included from include/linux/kcsan-checks.h:13,
                    from include/linux/instrumented.h:12,
                    from include/linux/atomic/atomic-instrumented.h:17,
                    from include/linux/atomic.h:82,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/sparc/include/asm/bitops_64.h:52,
                    from arch/sparc/include/asm/bitops.h:5,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22:
>> include/linux/compiler_attributes.h:55: warning: "__always_inline" redefined
      55 | #define __always_inline                 inline __attribute__((__always_inline__))
         | 
   In file included from include/linux/stddef.h:5,
                    from include/linux/kernel.h:18:
   include/uapi/linux/stddef.h:8: note: this is the location of the previous definition
       8 | #define __always_inline inline
         | 
>> include/linux/compiler_attributes.h:91:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
      91 | #if __has_attribute(__copy__)
         |     ^~~~~~~~~~~~~~~
>> include/linux/compiler_attributes.h:91:20: error: missing binary operator before token "("
      91 | #if __has_attribute(__copy__)
         |                    ^
   include/linux/compiler_attributes.h:104:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     104 | #if __has_attribute(__counted_by__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:104:20: error: missing binary operator before token "("
     104 | #if __has_attribute(__counted_by__)
         |                    ^
>> include/linux/compiler_attributes.h:107: warning: "__counted_by" redefined
     107 | # define __counted_by(member)
         | 
   include/uapi/linux/stddef.h:55: note: this is the location of the previous definition
      55 | #define __counted_by(m)
         | 
   include/linux/compiler_attributes.h:116:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     116 | #if __has_attribute(__diagnose_as_builtin__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:116:20: error: missing binary operator before token "("
     116 | #if __has_attribute(__diagnose_as_builtin__)
         |                    ^
   include/linux/compiler_attributes.h:139:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     139 | #if __has_attribute(__designated_init__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:139:20: error: missing binary operator before token "("
     139 | #if __has_attribute(__designated_init__)
         |                    ^
   include/linux/compiler_attributes.h:150:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     150 | #if __has_attribute(__error__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:150:20: error: missing binary operator before token "("
     150 | #if __has_attribute(__error__)
         |                    ^
   include/linux/compiler_attributes.h:161:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     161 | #if __has_attribute(__externally_visible__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:161:20: error: missing binary operator before token "("
     161 | #if __has_attribute(__externally_visible__)
         |                    ^
   include/linux/compiler_attributes.h:198:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     198 | #if __has_attribute(__no_caller_saved_registers__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:198:20: error: missing binary operator before token "("
     198 | #if __has_attribute(__no_caller_saved_registers__)
         |                    ^
   include/linux/compiler_attributes.h:209:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     209 | #if __has_attribute(__noclone__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:209:20: error: missing binary operator before token "("
     209 | #if __has_attribute(__noclone__)
         |                    ^
   include/linux/compiler_attributes.h:226:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     226 | #if __has_attribute(__fallthrough__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:226:20: error: missing binary operator before token "("
     226 | #if __has_attribute(__fallthrough__)
         |                    ^
   include/linux/compiler_attributes.h:252:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     252 | #if __has_attribute(__nonstring__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:252:20: error: missing binary operator before token "("
     252 | #if __has_attribute(__nonstring__)
         |                    ^
   include/linux/compiler_attributes.h:264:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     264 | #if __has_attribute(__no_profile_instrument_function__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:264:20: error: missing binary operator before token "("
     264 | #if __has_attribute(__no_profile_instrument_function__)
         |                    ^
   include/linux/compiler_attributes.h:283:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     283 | #if __has_attribute(__no_stack_protector__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:283:20: error: missing binary operator before token "("
     283 | #if __has_attribute(__no_stack_protector__)
         |                    ^
   include/linux/compiler_attributes.h:294:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     294 | #if __has_attribute(__overloadable__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:294:20: error: missing binary operator before token "("
     294 | #if __has_attribute(__overloadable__)
         |                    ^
   include/linux/compiler_attributes.h:313:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     313 | #if __has_attribute(__pass_dynamic_object_size__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:313:20: error: missing binary operator before token "("
     313 | #if __has_attribute(__pass_dynamic_object_size__)
         |                    ^
   include/linux/compiler_attributes.h:318:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     318 | #if __has_attribute(__pass_object_size__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:318:20: error: missing binary operator before token "("
     318 | #if __has_attribute(__pass_object_size__)
         |                    ^
   include/linux/compiler_attributes.h:363:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     363 | #if __has_attribute(__warning__)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:363:20: error: missing binary operator before token "("
     363 | #if __has_attribute(__warning__)
         |                    ^
   include/linux/compiler_attributes.h:380:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
     380 | #if __has_attribute(disable_sanitizer_instrumentation)
         |     ^~~~~~~~~~~~~~~
   include/linux/compiler_attributes.h:380:20: error: missing binary operator before token "("
     380 | #if __has_attribute(disable_sanitizer_instrumentation)
         |                    ^


vim +91 include/linux/compiler_attributes.h

86cffecdeaa278 Kees Cook      2021-11-05   45  
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   46  /*
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   47   * Note: users of __always_inline currently do not write "inline" themselves,
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   48   * which seems to be required by gcc to apply the attribute according
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   49   * to its docs (and also "warning: always_inline function might not be
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   50   * inlinable [-Wattributes]" is emitted).
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   51   *
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   52   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   53   * clang: mentioned
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   54   */
a3f8a30f3f0079 Miguel Ojeda   2018-08-30  @55  #define __always_inline                 inline __attribute__((__always_inline__))
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   56  
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   57  /*
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   58   * The second argument is optional (default 0), so we use a variadic macro
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   59   * to make the shorthand.
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   60   *
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   61   * Beware: Do not apply this to functions which may return
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   62   * ERR_PTRs. Also, it is probably unwise to apply it to functions
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   63   * returning extra information in the low bits (but in that case the
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   64   * compiler should see some alignment anyway, when the return value is
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   65   * massaged by 'flags = ptr & 3; ptr &= ~3;').
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   66   *
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   67   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-assume_005faligned-function-attribute
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   68   * clang: https://clang.llvm.org/docs/AttributeReference.html#assume-aligned
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   69   */
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   70  #define __assume_aligned(a, ...)        __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   71  
54da6a0924311c Peter Zijlstra 2023-05-26   72  /*
54da6a0924311c Peter Zijlstra 2023-05-26   73   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-cleanup-variable-attribute
54da6a0924311c Peter Zijlstra 2023-05-26   74   * clang: https://clang.llvm.org/docs/AttributeReference.html#cleanup
54da6a0924311c Peter Zijlstra 2023-05-26   75   */
54da6a0924311c Peter Zijlstra 2023-05-26   76  #define __cleanup(func)			__attribute__((__cleanup__(func)))
54da6a0924311c Peter Zijlstra 2023-05-26   77  
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   78  /*
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   79   * Note the long name.
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   80   *
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   81   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   82   */
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   83  #define __attribute_const__             __attribute__((__const__))
a3f8a30f3f0079 Miguel Ojeda   2018-08-30   84  
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   85  /*
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   86   * Optional: only supported since gcc >= 9
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   87   * Optional: not supported by clang
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   88   *
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   89   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-copy-function-attribute
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   90   */
c0d9782f5b6d71 Miguel Ojeda   2019-02-08  @91  #if __has_attribute(__copy__)
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   92  # define __copy(symbol)                 __attribute__((__copy__(symbol)))
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   93  #else
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   94  # define __copy(symbol)
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   95  #endif
c0d9782f5b6d71 Miguel Ojeda   2019-02-08   96  
c8248faf3ca276 Kees Cook      2023-08-17   97  /*
c8248faf3ca276 Kees Cook      2023-08-17   98   * Optional: only supported since gcc >= 14
c8248faf3ca276 Kees Cook      2023-08-17   99   * Optional: only supported since clang >= 18
c8248faf3ca276 Kees Cook      2023-08-17  100   *
c8248faf3ca276 Kees Cook      2023-08-17  101   *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
c8248faf3ca276 Kees Cook      2023-08-17  102   * clang: https://reviews.llvm.org/D148381
c8248faf3ca276 Kees Cook      2023-08-17  103   */
c8248faf3ca276 Kees Cook      2023-08-17  104  #if __has_attribute(__counted_by__)
c8248faf3ca276 Kees Cook      2023-08-17  105  # define __counted_by(member)		__attribute__((__counted_by__(member)))
c8248faf3ca276 Kees Cook      2023-08-17  106  #else
c8248faf3ca276 Kees Cook      2023-08-17 @107  # define __counted_by(member)
c8248faf3ca276 Kees Cook      2023-08-17  108  #endif
c8248faf3ca276 Kees Cook      2023-08-17  109  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 7/8] of: replace command line handling
  2023-11-10  1:38 ` [PATCH 7/8] of: replace command line handling Daniel Walker
@ 2023-11-16 16:09   ` Rob Herring
  2023-11-16 16:33     ` Daniel Walker (danielwa)
  2023-11-23  6:39   ` Christophe Leroy
  1 sibling, 1 reply; 30+ messages in thread
From: Rob Herring @ 2023-11-16 16:09 UTC (permalink / raw)
  To: Daniel Walker
  Cc: Will Deacon, Christophe Leroy, Daniel Gimpelevich, Andrew Morton,
	Pratyush Brahma, Tomas Mudrunka, Sean Anderson, x86, linux-mips,
	linuxppc-dev, Frank Rowand, xe-linux-external, devicetree,
	linux-kernel

On Thu, Nov 09, 2023 at 05:38:11PM -0800, Daniel Walker wrote:
> Rob Herring has complained about this section of code. I removed the
> command line handling code to the cmdline.h header. This hopefully makes
> it easier for Rob to maintain it (at least he doesn't have to look at it
> directly anymore).

Well, my goal is to eliminate drivers/of/, but no.

> I would like to add a Kconfig option called
> OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code.

Which architecture needs this code? Do we wait and see who complains 
their platform broke and then go set this option? In the meantime, new 
platforms started depending on the new behavior and setting the option 
may break them. So we can't have a kconfig option.

> This would allow a platform to use the cmdline.h and the added function
> directly and remove the Kconfig option. This change would be in a subsequent
> patch.

Per platform code handling the cmdline is completely the wrong 
direction. Per arch behavior is bad enough.

Rob

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

* Re: [PATCH 7/8] of: replace command line handling
  2023-11-16 16:09   ` Rob Herring
@ 2023-11-16 16:33     ` Daniel Walker (danielwa)
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Walker (danielwa) @ 2023-11-16 16:33 UTC (permalink / raw)
  To: Rob Herring
  Cc: Will Deacon, Christophe Leroy, Daniel Gimpelevich, Andrew Morton,
	Pratyush Brahma, Tomas Mudrunka, Sean Anderson, x86, linux-mips,
	linuxppc-dev, Frank Rowand, xe-linux-external(mailer list),
	devicetree, linux-kernel

On Thu, Nov 16, 2023 at 10:09:36AM -0600, Rob Herring wrote:
> On Thu, Nov 09, 2023 at 05:38:11PM -0800, Daniel Walker wrote:
> > Rob Herring has complained about this section of code. I removed the
> > command line handling code to the cmdline.h header. This hopefully makes
> > it easier for Rob to maintain it (at least he doesn't have to look at it
> > directly anymore).
> 
> Well, my goal is to eliminate drivers/of/, but no.
> 
> > I would like to add a Kconfig option called
> > OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code.
> 
> Which architecture needs this code? Do we wait and see who complains 
> their platform broke and then go set this option? In the meantime, new 
> platforms started depending on the new behavior and setting the option 
> may break them. So we can't have a kconfig option.
 
 I think you misunderstood the comments. The objective is,

 1) Remove the code in drivers/of/
 2) Remove platform specific command line handling

> > This would allow a platform to use the cmdline.h and the added function
> > directly and remove the Kconfig option. This change would be in a subsequent
> > patch.
> 
> Per platform code handling the cmdline is completely the wrong 
> direction. Per arch behavior is bad enough.

This code unifies the handling into generic code outside drivers/of/ .

Daniel

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

* Re: [PATCH 0/8] generic command line v6
  2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
                   ` (8 preceding siblings ...)
  2023-11-10  1:51 ` [PATCH 0/8] generic command line v6 Andrew Morton
@ 2023-11-23  6:23 ` Christophe Leroy
  9 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:23 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, H. Peter Anvin, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-arm-kernel, linux-kernel,
	devicetree, linux-kbuild
  Cc: linux-efi



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> This release is an up-rev of the v5 patches. No additional features have
> been added. Some changes were mode to function names and some changes to
> Kconfig dependencies. Also updated the config conversion for mips.
> 
> There are a number of people who have expressed interest in these
> patches either by asking for them to be merge or testing them. If
> people are so inclined please continue to request them to be merge
> or to ask the status of the next release. It's helpful to motivate me to
> release them again and for the maintainers to see the interest
> generated.

Good, then lets work all together and get the best of it.

Your series has good features like the update of the command line addons 
without rebuild, including updating of the signature when applicable. 
However your series still has weaknesses it had in previous versions. I 
was hopping we could work all together to improve it, but you have been 
repeatedly telling that my proposal doesn't fit your needs without 
explaining why. Can we work in a more win-win spirit this time ?

By the way, for the record, here is a link to a series I sent out as an 
exemple of what it could look like. The intention at that time was not 
to have a concurrent series, but just to show what I meant in my 
comments, because exemples are often more explicit than words. That 
series was considered more mature and closer to a mergeable state than 
yours at that time. Link to the said series: 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?state=*&series=237158

Your series only converts a few architectures, and I can't see any 
demonstration that it will be possible to convert other architectures as 
a follow-up without too much pain.

> 
> These patches have been used by Cisco Systems, Inc. on millions of
> released products to great effect. Hopefully they can be used by the
> entire Linux eco system.

This is not an argument. Billions of computers are running Micr*s*ft 
Windows, does it make Windows better ? Do IBM or Google claim about the 
million equipment they are sending out with special Linux features ? 
Showing objectively what's the benefit of your features without 
referring to Cisco would be better.

> 
> My apologies on the length between releases. I will try to release more
> often.

Christophe

> 
> 
> Daniel Walker (8):
>    CMDLINE: add generic builtin command line
>    scripts: insert-sys-cert: add command line insert capability
>    scripts: insert-sys-cert: change name to insert-symbol
>    CMDLINE: mips: convert to generic builtin command line
>    drivers: firmware: efi: libstub: enable generic commandline
>    CMDLINE: x86: convert to generic builtin command line
>    of: replace command line handling
>    CMDLINE: arm64: convert to generic builtin command line
> 
>   arch/arm64/Kconfig                            |  33 +--
>   arch/arm64/include/asm/setup.h                |   4 +
>   arch/arm64/include/uapi/asm/setup.h           |   2 +
>   arch/arm64/kernel/idreg-override.c            |   9 +-
>   arch/arm64/kernel/pi/kaslr_early.c            |  14 +-
>   arch/mips/Kconfig                             |   4 +-
>   arch/mips/Kconfig.debug                       |  44 ----
>   arch/mips/configs/ar7_defconfig               |  12 +-
>   arch/mips/configs/bcm47xx_defconfig           |  10 +-
>   arch/mips/configs/bcm63xx_defconfig           |  21 +-
>   arch/mips/configs/bmips_be_defconfig          |  17 +-
>   arch/mips/configs/bmips_stb_defconfig         | 139 ++++------
>   arch/mips/configs/ci20_defconfig              |   8 +-
>   arch/mips/configs/cu1000-neo_defconfig        |  19 +-
>   arch/mips/configs/cu1830-neo_defconfig        |  19 +-
>   arch/mips/configs/generic_defconfig           |  15 +-
>   arch/mips/configs/gpr_defconfig               |  33 +--
>   arch/mips/configs/loongson3_defconfig         |  29 +--
>   arch/mips/include/asm/setup.h                 |   2 +
>   arch/mips/kernel/relocate.c                   |  17 +-
>   arch/mips/kernel/setup.c                      |  36 +--
>   arch/mips/pic32/pic32mzda/early_console.c     |   2 +-
>   arch/mips/pic32/pic32mzda/init.c              |   3 +-
>   arch/x86/Kconfig                              |  44 +---
>   arch/x86/kernel/setup.c                       |  18 +-
>   .../firmware/efi/libstub/efi-stub-helper.c    |  29 +++
>   drivers/firmware/efi/libstub/efi-stub.c       |   9 +
>   drivers/firmware/efi/libstub/efistub.h        |   1 +
>   drivers/firmware/efi/libstub/x86-stub.c       |  14 +-
>   drivers/of/fdt.c                              |  22 +-
>   include/linux/cmdline.h                       | 137 ++++++++++
>   init/Kconfig                                  |  79 ++++++
>   lib/Kconfig                                   |   4 +
>   lib/Makefile                                  |   3 +
>   lib/generic_cmdline.S                         |  53 ++++
>   lib/test_cmdline1.c                           | 139 ++++++++++
>   scripts/Makefile                              |   2 +-
>   .../{insert-sys-cert.c => insert-symbol.c}    | 243 ++++++++++++------
>   38 files changed, 807 insertions(+), 482 deletions(-)
>   create mode 100644 include/linux/cmdline.h
>   create mode 100644 lib/generic_cmdline.S
>   create mode 100644 lib/test_cmdline1.c
>   rename scripts/{insert-sys-cert.c => insert-symbol.c} (72%)
> 

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

* Re: [PATCH 1/8] CMDLINE: add generic builtin command line
  2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
  2023-11-10 16:12   ` kernel test robot
@ 2023-11-23  6:32   ` Christophe Leroy
  2023-12-04 11:11   ` Jaskaran Singh
  2 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:32 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, Ruslan Bilovol, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> This code allows architectures to use a generic builtin command line.
> The state of the builtin command line options across architecture is
> diverse. MIPS and X86 once has similar systems, then mips added some
> options to allow extending the command line. Powerpc did something
> simiar in adding the ability to extend. Even with mips and powerpc
> enhancement the needs of Cisco are not met on these platforms.

What are those needs, can you list them in the cover letter, and 
probably also in here ?
Are those needs specific to Cisco or can they interest the entire Linux 
community ?

> 
> The code in this commit unifies the code into a generic
> header file under the CONFIG_GENERIC_CMDLINE option. When this
> option is enabled the architecture can call the cmdline_add_builtin()
> to add the builtin command line. The generic code provides both
> append and/or prepend options and provides a way to redefine these
> option after the kernel is compiled.

Explain how.

> 
> This code also includes test's which are meant to confirm
> functionality.

Would be better to have test part as a separate patch if possible.

> 
> This unified implementation offers the same functionality needed by
> Cisco on all platform which we enable it on.

Cisco ... cisco ... cisco ...

> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   include/linux/cmdline.h | 106 ++++++++++++++++++++++++++++++
>   init/Kconfig            |  79 +++++++++++++++++++++++
>   lib/Kconfig             |   4 ++
>   lib/Makefile            |   3 +
>   lib/generic_cmdline.S   |  53 +++++++++++++++
>   lib/test_cmdline1.c     | 139 ++++++++++++++++++++++++++++++++++++++++
>   6 files changed, 384 insertions(+)
>   create mode 100644 include/linux/cmdline.h
>   create mode 100644 lib/generic_cmdline.S
>   create mode 100644 lib/test_cmdline1.c
> 
> diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
> new file mode 100644
> index 000000000000..a94758a0f257
> --- /dev/null
> +++ b/include/linux/cmdline.h
> @@ -0,0 +1,106 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _LINUX_CMDLINE_H
> +#define _LINUX_CMDLINE_H
> +/*
> + *
> + * Copyright (C) 2006,2021. Cisco Systems, Inc.
> + *
> + * Generic Append/Prepend cmdline support.
> + */
> +
> +
> +#include <linux/ctype.h>
> +#include <linux/cache.h>
> +#include <asm/setup.h>
> +
> +#ifdef CONFIG_CMDLINE_BOOL
> +extern char cmdline_prepend[];
> +extern char cmdline_append[];
> +extern char cmdline_tmp[];
> +#define CMDLINE_PREPEND cmdline_prepend
> +#define CMDLINE_APPEND cmdline_append
> +#define CMDLINE_TMP cmdline_tmp
> +#define CMDLINE_STATIC_PREPEND CONFIG_CMDLINE_PREPEND
> +#define CMDLINE_STATIC_APPEND CONFIG_CMDLINE_APPEND

Too many macros reduces the readability of code, avoid them when possible.

> +#else

Explain why this else leg is needed. It should be possible to set 
default values directly in Kconfig.

> +#define CMDLINE_PREPEND ""
> +#define CMDLINE_APPEND ""
> +#define CMDLINE_TMP ""
> +#define CMDLINE_STATIC_PREPEND ""
> +#define CMDLINE_STATIC_APPEND ""
> +#endif
> +
> +#ifndef CMDLINE_STRLCAT
> +#define CMDLINE_STRLCAT strlcat
> +#endif
> +
> +#ifndef CMDLINE_STRLEN
> +#define CMDLINE_STRLEN strlen
> +#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.
> + * @dest: The destination of the final appended/prepended string
> + * @tmp: temporary space used for prepending
> + * @prepend: string to prepend to @dest
> + * @append: string to append to @dest
> + * @length: the maximum length of the strings above.
> + * @cmdline_strlen: point to a compatible strlen

Remove that function pointer argument and use macros.

> + * @cmdline_strlcat: point to a compatible strlcat

Same

> + * This function returns true when the builtin command line was copied successfully
> + * and false when there was not enough room to copy all parts of the command line.

What happens when it returns false, is it partially copied or nothing is 
done ?

> + */
> +static inline bool
> +__cmdline_add_builtin(
> +		char *dest,
> +		char *tmp,
> +		char *prepend,
> +		char *append,
> +		unsigned long length,
> +		size_t (*cmdline_strlen)(const char *s),
> +		size_t (*cmdline_strlcat)(char *dest, const char *src, size_t count))

This cmdline feature is used in early deep parts of architectures, so in 
a way more or less comparable to linux-mm. Approach with linux-mm has 
always been to define macros that can be overriden by architectures. 
Please do the same and define cmdline_strlen() and cmdline_strlcat() as 
macros that can be overriden by architectures instead of passing 
function pointers. And keep macro names as lower case for this type of 
macros.

> +{
> +	size_t total_length = 0, tmp_length;

Try to use shorter names for local variables, see kernel codying style.

> +
> +	if (!IS_ENABLED(CONFIG_GENERIC_CMDLINE))
> +		return true;
> +
> +	if (!IS_ENABLED(CONFIG_CMDLINE_BOOL))
> +		return true;
> +
> +	if (IS_ENABLED(CONFIG_CMDLINE_OVERRIDE))
> +		dest[0] = '\0';
> +	else
> +		total_length += cmdline_strlen(dest);

All those Kconfig options should be explained in the commit message, 
that would help understanding the patch.

Impact on existing defconfigs should also be taken care of and minimised.

> +
> +	tmp_length = cmdline_strlen(append);
> +	if (tmp_length > 0) {
> +		cmdline_strlcat(dest, append, length);
> +		total_length += tmp_length;
> +	}
> +
> +	tmp_length = cmdline_strlen(prepend);
> +	if (tmp_length > 0) {
> +		cmdline_strlcat(tmp, prepend, length);
> +		cmdline_strlcat(tmp, dest, length);
> +		dest[0] = '\0';
> +		cmdline_strlcat(dest, tmp, length);
> +		total_length += tmp_length;
> +	}
> +
> +	tmp[0] = '\0';

What's the purpose of setting tmp[0] to 0 ?

> +
> +	if (total_length > length)
> +		return false;
> +
> +	return true;

Can be writen as:

	return total_length <= length;

> +}
> +
> +#define cmdline_add_builtin(dest) \
> +	__cmdline_add_builtin(dest, CMDLINE_TMP, CMDLINE_PREPEND, CMDLINE_APPEND, COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT)
> +
> +#define cmdline_get_static_builtin(dest) \
> +	(CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND)
> +#endif
> diff --git a/init/Kconfig b/init/Kconfig
> index 6d35728b94b2..703eed88d140 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1922,6 +1922,85 @@ config TRACEPOINTS
>   
>   source "kernel/Kconfig.kexec"
>   
> +config GENERIC_CMDLINE
> +	bool
> +
> +if GENERIC_CMDLINE
> +
> +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
> +	  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_APPEND
> +	string "Built-in kernel command string append"
> +	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, this string is appended to it 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_PREPEND
> +	string "Built-in kernel command string prepend"
> +	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, this string is prepended to it 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_EXTRA
> +	bool "Reserve more space for inserting prepend and append without recompiling"
> +	depends on CMDLINE_BOOL
> +	select SYSTEM_EXTRA_CERTIFICATE
> +	help
> +	  If set, space for an append and prepend will be reserved in the kernel
> +	  image. This allows updating or changing the append and prepend to a large
> +	  string then the kernel was compiled for without recompiling the kernel.

s/large/larger
s/then/than

> +
> +	  The maximum size is the command line size for each prepend and append.
> +
> +config CMDLINE_OVERRIDE
> +	bool "Built-in command line overrides boot loader arguments"
> +	depends on CMDLINE_BOOL
> +	help
> +	  Set this option to 'Y' to have the kernel ignore the boot loader
> +	  command line, and use ONLY the built-in command line. In this case
> +	  append and prepend strings are concatenated to form the full
> +	  command line.
> +
> +	  This is used to work around broken boot loaders.  This should
> +	  be set to 'N' under normal conditions.
> +endif

An analysis of what exists on each existing architecture should 
demonstrate that you have defined all needed options.

> +
>   endmenu		# General setup
>   
>   source "arch/Kconfig"
> diff --git a/lib/Kconfig b/lib/Kconfig
> index c686f4adc124..d520f1aa7c32 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -729,6 +729,10 @@ config PARMAN
>   config OBJAGG
>   	tristate "objagg" if COMPILE_TEST
>   
> +config TEST_CMDLINE
> +	depends on CMDLINE_BOOL && !CMDLINE_OVERRIDE
> +	tristate "Test generic command line handling"
> +

Put the test part in a second patch.

>   endmenu
>   
>   config GENERIC_IOREMAP
> diff --git a/lib/Makefile b/lib/Makefile
> index 740109b6e2c8..aa7b14a0ced7 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -438,3 +438,6 @@ $(obj)/$(TEST_FORTIFY_LOG): $(addprefix $(obj)/, $(TEST_FORTIFY_LOGS)) FORCE
>   ifeq ($(CONFIG_FORTIFY_SOURCE),y)
>   $(obj)/string.o: $(obj)/$(TEST_FORTIFY_LOG)
>   endif
> +
> +obj-$(CONFIG_TEST_CMDLINE) += test_cmdline1.o
> +obj-$(CONFIG_CMDLINE_BOOL)     += generic_cmdline.o
> diff --git a/lib/generic_cmdline.S b/lib/generic_cmdline.S
> new file mode 100644
> index 000000000000..223763f9eeb6
> --- /dev/null
> +++ b/lib/generic_cmdline.S
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#include <linux/export.h>
> +#include <linux/init.h>
> +
> +#include <asm/setup.h>
> +
> +        __INITDATA
> +
> +       .align 8
> +       .global cmdline_prepend
> +cmdline_prepend:
> +       .ifnc CONFIG_CMDLINE_PREPEND,""
> +       .ascii CONFIG_CMDLINE_PREPEND
> +       .string " "
> +       .else
> +       .byte 0x0
> +       .endif
> +#ifdef CONFIG_CMDLINE_EXTRA
> +       .space COMMAND_LINE_SIZE - (.-cmdline_prepend)
> +       .size cmdline_prepend, COMMAND_LINE_SIZE
> +#endif /* CONFIG_CMDLINE_EXTRA */
> +
> +cmdline_prepend_end:
> +       .size cmdline_prepend, (cmdline_prepend_end - cmdline_prepend)
> +
> +       .align 8
> +       .global cmdline_tmp
> +cmdline_tmp:
> +       .ifnc CONFIG_CMDLINE_PREPEND,""
> +       .size cmdline_tmp, COMMAND_LINE_SIZE
> +       .space COMMAND_LINE_SIZE
> +       .else
> +       .byte 0x0
> +       .endif
> +cmdline_tmp_end:
> +       .size cmdline_tmp, (cmdline_tmp_end - cmdline_tmp)
> +
> +       .align 8
> +       .global cmdline_append
> +       .size cmdline_append, COMMAND_LINE_SIZE
> +cmdline_append:
> +       .ifnc CONFIG_CMDLINE_APPEND,""
> +       .ascii " "
> +       .string CONFIG_CMDLINE_APPEND
> +       .else
> +       .byte 0x0
> +       .endif
> +#ifdef CONFIG_CMDLINE_EXTRA
> +       .space COMMAND_LINE_SIZE - (.-cmdline_append)
> +#endif /* CONFIG_CMDLINE_EXTRA */
> +cmdline_append_end:
> +       .size cmdline_append, (cmdline_append_end - cmdline_append)
> +

Can all this be done in a C file, possibly with inline assembly if 
required, instead of an assembly file ?

> diff --git a/lib/test_cmdline1.c b/lib/test_cmdline1.c
> new file mode 100644
> index 000000000000..bcaffcc024e4
> --- /dev/null
> +++ b/lib/test_cmdline1.c
> @@ -0,0 +1,139 @@
> +// SPDX-License-Identifier: GPL-2.0-only

Why 2.0-only ? Not sure it is the preferred licence for new files unless 
they are tied to something already existing.

> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/bitmap.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/printk.h>
> +#include <linux/slab.h>
> +#include <linux/string.h>
> +#include <linux/cmdline.h>
> +#include <linux/uaccess.h>
> +
> +#include "../tools/testing/selftests/kselftest_module.h"

Is it common practice to include tools/testing/ stuff into kernel ?

> +
> +KSTM_MODULE_GLOBALS();
> +
> +char test1_prepend[] = "prepend ";
> +char test1_append[] = " append";
> +char test1_bootloader_args[] = "console=ttyS0 log_level=3";
> +char test1_result[] = "prepend console=ttyS0 log_level=3 append";
> +
> +char test2_append[] = " append";
> +char test2_bootloader_args[] = "console=ttyS0 log_level=3";
> +char test2_result[] = "console=ttyS0 log_level=3 append";
> +
> +char test3_prepend[] = "prepend ";
> +char test3_bootloader_args[] = "console=ttyS0 log_level=3";
> +char test3_result[] = "prepend console=ttyS0 log_level=3";
> +
> +char test4_bootloader_args[] = "console=ttyS0 log_level=3";
> +char test4_result[] = "console=ttyS0 log_level=3";
> +
> +char test5_prepend[] = "prepend ";
> +char test5_append[] = " append";
> +static char test5_bootloader_args[] =
> +"00000000000000 011111111111111 0222222222222222 033333333333333 "
> +"10000000000000 111111111111111 1222222222222222 133333333333333 "
> +"20000000000000 211111111111111 2222222222222222 233333333333333 "
> +"30000000000000 311111111111111 3222222222222222 333333333333333 "
> +"40000000000000 411111111111111 4222222222222222 433333333333333 "
> +"50000000000000 511111111111111 5222222222222222 533333333333333 "
> +"60000000000000 611111111111111 6222222222222222 633333333333333 "
> +"70000000000000 711111111111111 7222222222222222 733333333333333";
> +static char test5_result[] =
> +"prepend 00000000000000 011111111111111 0222222222222222 033333333333333 "
> +"10000000000000 111111111111111 1222222222222222 133333333333333 "
> +"20000000000000 211111111111111 2222222222222222 233333333333333 "
> +"30000000000000 311111111111111 3222222222222222 333333333333333 "
> +"40000000000000 411111111111111 4222222222222222 433333333333333 "
> +"50000000000000 511111111111111 5222222222222222 533333333333333 "
> +"60000000000000 611111111111111 6222222222222222 633333333333333 "
> +"70000000000000 711111111111111 7222222222222222 7333333";
> +
> +char test5_boot_command_line[COMMAND_LINE_SIZE];
> +
> +char test_tmp[COMMAND_LINE_SIZE];
> +
> +char test_boot_command_line[COMMAND_LINE_SIZE];
> +
> +static void __init selftest(void)
> +{
> +	bool result;
> +
> +	/* Normal operation */
> +	strcpy(test_boot_command_line, test1_bootloader_args);
> +	test_tmp[0] = '\0';
> +	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, test1_prepend, test1_append, COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
> +
> +	if (result == true && !strncmp(test_boot_command_line, test1_result, COMMAND_LINE_SIZE)) {
> +		pr_info("test1 success.\n");
> +	} else {
> +		pr_info("test1 failed. OUTPUT BELOW:\n");
> +		pr_info("\"%s\"\n", test_boot_command_line);
> +		failed_tests++;
> +	}
> +	total_tests++;
> +
> +	/* Missing prepend */
> +	strcpy(test_boot_command_line, test2_bootloader_args);
> +	test_tmp[0] = '\0';
> +	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, "", test2_append, COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
> +
> +	if (result == true && !strncmp(test_boot_command_line, test2_result, COMMAND_LINE_SIZE)) {
> +		pr_info("test2 success.\n");
> +	} else {
> +		pr_info("test2 failed. OUTPUT BELOW:\n");
> +		pr_info("\"%s\"\n", test_boot_command_line);
> +		failed_tests++;
> +	}

Can you refactor and avoid repeating those 7 lines five times ?

> +	total_tests++;
> +
> +	/* Missing append */
> +	strcpy(test_boot_command_line, test3_bootloader_args);
> +	test_tmp[0] = '\0';
> +	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, test3_prepend, "", COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
> +
> +	if (result == true && !strncmp(test_boot_command_line, test3_result, COMMAND_LINE_SIZE)) {
> +		pr_info("test3 success.\n");
> +	} else {
> +		pr_info("test3 failed. OUTPUT BELOW:\n");
> +		pr_info("\"%s\"\n", test_boot_command_line);
> +		failed_tests++;
> +	}
> +	total_tests++;
> +
> +	/* Missing append and prepend */
> +	strcpy(test_boot_command_line, test4_bootloader_args);
> +	test_tmp[0] = '\0';
> +	result = __cmdline_add_builtin(test_boot_command_line, test_tmp, "", "", COMMAND_LINE_SIZE, CMDLINE_STRLEN, CMDLINE_STRLCAT);
> +
> +	if (result == true && !strncmp(test_boot_command_line, test4_result, COMMAND_LINE_SIZE)) {
> +		pr_info("test4 success.\n");
> +	} else {
> +		pr_info("test4 failed. OUTPUT BELOW:\n");
> +		pr_info("\"%s\"\n", test_boot_command_line);
> +		failed_tests++;
> +	}
> +	total_tests++;
> +
> +	/* Already full boot arguments */
> +	strcpy(test5_boot_command_line, test5_bootloader_args);
> +	test_tmp[0] = '\0';
> +	result = __cmdline_add_builtin(test5_boot_command_line, test_tmp, test5_prepend, test5_append, 512, CMDLINE_STRLEN, CMDLINE_STRLCAT);
> +
> +	if (result == false && !strncmp(test5_boot_command_line, test5_result, COMMAND_LINE_SIZE)) {
> +		pr_info("test5 success.\n");
> +	} else {
> +		pr_info("test5 failed. OUTPUT BELOW:\n");
> +		pr_info("\"%s\"\n", test5_boot_command_line);
> +		failed_tests++;
> +	}
> +	total_tests++;
> +}
> +
> +KSTM_MODULE_LOADERS(cmdline_test);
> +MODULE_AUTHOR("Daniel Walker <danielwa@cisco.com>");
> +MODULE_LICENSE("GPL");

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

* Re: [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability
  2023-11-10  1:38 ` [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability Daniel Walker
@ 2023-11-23  6:33   ` Christophe Leroy
  0 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:33 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> This adds changes to the insert-sys-cert tool to allow updating
> the cmdline_prepend and cmdline_append symbols in addition to
> adding certificates.

Nice feature.

> 
> Updating the cmdline symbols was tested on a PVH virtual machine
> with a vmlinux, and with a bzImage which was repackaged on x86.

Can it also work with Uimages from uboot/ppc ?

> 
> This commit intentionally keeps the tool filename the same to allow
> the changes to be seen more easily. The next commit will change
> the name of the tool.

Not sure what you mean.
If I understand correctly, git format-patch -M should do what you want.

> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   scripts/insert-sys-cert.c | 241 +++++++++++++++++++++++++++-----------
>   1 file changed, 170 insertions(+), 71 deletions(-)
> 
> diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
> index 8902836c2342..77d3306cfbfb 100644
> --- a/scripts/insert-sys-cert.c
> +++ b/scripts/insert-sys-cert.c
> @@ -30,6 +30,9 @@
>   #define USED_SYM  "system_extra_cert_used"
>   #define LSIZE_SYM "system_certificate_list_size"
>   
> +#define CMDLINE_APPEND "cmdline_append"
> +#define CMDLINE_PREPEND "cmdline_prepend"
> +
>   #define info(format, args...) fprintf(stderr, "INFO:    " format, ## args)
>   #define warn(format, args...) fprintf(stdout, "WARNING: " format, ## args)
>   #define  err(format, args...) fprintf(stderr, "ERROR:   " format, ## args)
> @@ -267,95 +270,46 @@ static void print_sym(Elf_Ehdr *hdr, struct sym *s)
>   
>   static void print_usage(char *e)
>   {
> -	printf("Usage %s [-s <System.map>] -b <vmlinux> -c <certfile>\n", e);
> +	printf("Usage %s [-s <System.map>] -b <vmlinux> [ -c <certfile> | -p <command line prepend> | -a <command line append> ]-\n", e);
>   }
>   
> -int main(int argc, char **argv)
> +static char *cmdline_prepend, *cmdline_append;
> +static char *system_map_file;
> +static char *cert_file;
> +static char *cli_name;
> +
> +static int insert_certificate(Elf_Ehdr *hdr)
>   {
> -	char *system_map_file = NULL;
> -	char *vmlinux_file = NULL;
> -	char *cert_file = NULL;
> -	int vmlinux_size;
> +	struct sym cert_sym, lsize_sym, used_sym;
> +	Elf_Shdr *symtab = NULL;
> +	unsigned long *lsize;
> +	FILE *system_map;
>   	int cert_size;
> -	Elf_Ehdr *hdr;
>   	char *cert;
> -	FILE *system_map;
> -	unsigned long *lsize;
>   	int *used;
> -	int opt;
> -	Elf_Shdr *symtab = NULL;
> -	struct sym cert_sym, lsize_sym, used_sym;
> -
> -	while ((opt = getopt(argc, argv, "b:c:s:")) != -1) {
> -		switch (opt) {
> -		case 's':
> -			system_map_file = optarg;
> -			break;
> -		case 'b':
> -			vmlinux_file = optarg;
> -			break;
> -		case 'c':
> -			cert_file = optarg;
> -			break;
> -		default:
> -			break;
> -		}
> -	}
>   
> -	if (!vmlinux_file || !cert_file) {
> -		print_usage(argv[0]);
> -		exit(EXIT_FAILURE);
> +	if (!cert_file) {
> +		print_usage(cli_name);
> +		return EXIT_FAILURE;
>   	}
>   
>   	cert = read_file(cert_file, &cert_size);
>   	if (!cert)
> -		exit(EXIT_FAILURE);
> -
> -	hdr = map_file(vmlinux_file, &vmlinux_size);
> -	if (!hdr)
> -		exit(EXIT_FAILURE);
> -
> -	if (vmlinux_size < sizeof(*hdr)) {
> -		err("Invalid ELF file.\n");
> -		exit(EXIT_FAILURE);
> -	}
> -
> -	if ((hdr->e_ident[EI_MAG0] != ELFMAG0) ||
> -	    (hdr->e_ident[EI_MAG1] != ELFMAG1) ||
> -	    (hdr->e_ident[EI_MAG2] != ELFMAG2) ||
> -	    (hdr->e_ident[EI_MAG3] != ELFMAG3)) {
> -		err("Invalid ELF magic.\n");
> -		exit(EXIT_FAILURE);
> -	}
> -
> -	if (hdr->e_ident[EI_CLASS] != CURRENT_ELFCLASS) {
> -		err("ELF class mismatch.\n");
> -		exit(EXIT_FAILURE);
> -	}
> -
> -	if (hdr->e_ident[EI_DATA] != endianness()) {
> -		err("ELF endian mismatch.\n");
> -		exit(EXIT_FAILURE);
> -	}
> -
> -	if (hdr->e_shoff > vmlinux_size) {
> -		err("Could not find section header.\n");
> -		exit(EXIT_FAILURE);
> -	}
> +		return EXIT_FAILURE;
>   
>   	symtab = get_symbol_table(hdr);
>   	if (!symtab) {
>   		warn("Could not find the symbol table.\n");
>   		if (!system_map_file) {
>   			err("Please provide a System.map file.\n");
> -			print_usage(argv[0]);
> -			exit(EXIT_FAILURE);
> +			print_usage(cli_name);
> +			return EXIT_FAILURE;
>   		}
>   
>   		system_map = fopen(system_map_file, "r");
>   		if (!system_map) {
>   			perror(system_map_file);
> -			exit(EXIT_FAILURE);
> +			return EXIT_FAILURE;
>   		}
>   		get_symbol_from_map(hdr, system_map, CERT_SYM, &cert_sym);
>   		get_symbol_from_map(hdr, system_map, USED_SYM, &used_sym);
> @@ -371,7 +325,7 @@ int main(int argc, char **argv)
>   	}
>   
>   	if (!cert_sym.offset || !lsize_sym.offset || !used_sym.offset)
> -		exit(EXIT_FAILURE);
> +		return EXIT_FAILURE;
>   
>   	print_sym(hdr, &cert_sym);
>   	print_sym(hdr, &used_sym);
> @@ -382,14 +336,14 @@ int main(int argc, char **argv)
>   
>   	if (cert_sym.size < cert_size) {
>   		err("Certificate is larger than the reserved area!\n");
> -		exit(EXIT_FAILURE);
> +		return EXIT_FAILURE;
>   	}
>   
>   	/* If the existing cert is the same, don't overwrite */
>   	if (cert_size == *used &&
>   	    strncmp(cert_sym.content, cert, cert_size) == 0) {
>   		warn("Certificate was already inserted.\n");
> -		exit(EXIT_SUCCESS);
> +		return EXIT_SUCCESS;
>   	}
>   
>   	if (*used > 0)
> @@ -406,5 +360,150 @@ int main(int argc, char **argv)
>   						cert_sym.address);
>   	info("Used %d bytes out of %d bytes reserved.\n", *used,
>   						 cert_sym.size);
> -	exit(EXIT_SUCCESS);
> +	return EXIT_SUCCESS;
> +}
> +
> +static int insert_cmdline(Elf_Ehdr *hdr)
> +{
> +	struct sym cmdline_prepend_sym, cmdline_append_sym;
> +	Elf_Shdr *symtab = NULL;
> +	FILE *system_map;
> +
> +	symtab = get_symbol_table(hdr);
> +	if (!symtab) {
> +		warn("Could not find the symbol table.\n");
> +		if (!system_map_file) {
> +			err("Please provide a System.map file.\n");
> +			print_usage(cli_name);
> +			return EXIT_FAILURE;
> +		}
> +
> +		system_map = fopen(system_map_file, "r");
> +		if (!system_map) {
> +			perror(system_map_file);
> +			return EXIT_FAILURE;
> +		}
> +		get_symbol_from_map(hdr, system_map, CMDLINE_PREPEND, &cmdline_prepend_sym);
> +		get_symbol_from_map(hdr, system_map, CMDLINE_APPEND, &cmdline_append_sym);
> +	} else {
> +		info("Symbol table found.\n");
> +		if (system_map_file)
> +			warn("System.map is ignored.\n");
> +		get_symbol_from_table(hdr, symtab, CMDLINE_PREPEND, &cmdline_prepend_sym);
> +		get_symbol_from_table(hdr, symtab, CMDLINE_APPEND, &cmdline_append_sym);
> +	}
> +
> +	print_sym(hdr, &cmdline_prepend_sym);
> +	print_sym(hdr, &cmdline_append_sym);
> +
> +
> +	if (cmdline_prepend) {
> +		if ((strlen(cmdline_prepend) + 1) > cmdline_prepend_sym.size) {
> +			err("cmdline prepend is larger than the reserved area!\n");
> +			return EXIT_FAILURE;
> +		}
> +
> +		memcpy(cmdline_prepend_sym.content, cmdline_prepend, strlen(cmdline_prepend) + 1);
> +		if ((strlen(cmdline_prepend) + 1) < cmdline_prepend_sym.size)
> +			memset(cmdline_prepend_sym.content + strlen(cmdline_prepend) + 1,
> +				0, cmdline_prepend_sym.size - (strlen(cmdline_prepend) + 1));
> +
> +		info("Inserted cmdline prepend of \"%s\" into vmlinux.\n", cmdline_prepend);
> +
> +	}
> +	if (cmdline_append) {
> +		if ((strlen(cmdline_append) + 1) > cmdline_append_sym.size) {
> +			err("cmdline append is larger than the reserved area!\n");
> +			return EXIT_FAILURE;
> +		}
> +
> +		memcpy(cmdline_append_sym.content, cmdline_append, strlen(cmdline_append) + 1);
> +		if ((strlen(cmdline_append) + 1) < cmdline_append_sym.size)
> +			memset(cmdline_append_sym.content + strlen(cmdline_append) + 1,
> +				0, cmdline_append_sym.size - (strlen(cmdline_append) + 1));
> +
> +		info("Inserted cmdline append of \"%s\" into vmlinux.\n", cmdline_append);
> +
> +	}
> +	return EXIT_SUCCESS;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	char *vmlinux_file = NULL;
> +	int vmlinux_size;
> +	Elf_Ehdr *hdr;
> +	int opt;
> +	int ret = EXIT_SUCCESS;
> +
> +	while ((opt = getopt(argc, argv, "b:c:s:p:a:")) != -1) {
> +		switch (opt) {
> +		case 's':
> +			system_map_file = optarg;
> +			break;
> +		case 'b':
> +			vmlinux_file = optarg;
> +			break;
> +		case 'c':
> +			cert_file = optarg;
> +			break;
> +		case 'p':
> +			cmdline_prepend = optarg;
> +			break;
> +		case 'a':
> +			cmdline_append = optarg;
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +
> +	cli_name = argv[0];
> +
> +	if (!vmlinux_file) {
> +		print_usage(cli_name);
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	hdr = map_file(vmlinux_file, &vmlinux_size);
> +	if (!hdr)
> +		exit(EXIT_FAILURE);
> +
> +	if (vmlinux_size < sizeof(*hdr)) {
> +		err("Invalid ELF file.\n");
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	if ((hdr->e_ident[EI_MAG0] != ELFMAG0) ||
> +	    (hdr->e_ident[EI_MAG1] != ELFMAG1) ||
> +	    (hdr->e_ident[EI_MAG2] != ELFMAG2) ||
> +	    (hdr->e_ident[EI_MAG3] != ELFMAG3)) {
> +		err("Invalid ELF magic.\n");
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	if (hdr->e_ident[EI_CLASS] != CURRENT_ELFCLASS) {
> +		err("ELF class mismatch.\n");
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	if (hdr->e_ident[EI_DATA] != endianness()) {
> +		err("ELF endian mismatch.\n");
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	if (hdr->e_shoff > vmlinux_size) {
> +		err("Could not find section header.\n");
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	if (cert_file) {
> +		ret = insert_certificate(hdr);
> +		printf("%s\n", cert_file);
> +	}
> +
> +	if (cmdline_append || cmdline_prepend)
> +		ret = insert_cmdline(hdr);
> +
> +	exit(ret);
>   }

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

* Re: [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol
  2023-11-10  1:38 ` [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol Daniel Walker
@ 2023-11-23  6:34   ` Christophe Leroy
  0 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:34 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier
  Cc: xe-linux-external, linux-kbuild, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> Since the tool is used to update the command line and/or
> to update the certificates, I think it makes sense to
> changes the name of this tool.
> 
> Update the name of the tool to better reflect it's new use.

Should be squashed into previous patch.

> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   scripts/Makefile                               | 2 +-
>   scripts/{insert-sys-cert.c => insert-symbol.c} | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>   rename scripts/{insert-sys-cert.c => insert-symbol.c} (99%)
> 
> diff --git a/scripts/Makefile b/scripts/Makefile
> index 576cf64be667..2d7618fa5d6b 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -8,10 +8,10 @@ hostprogs-always-$(BUILD_C_RECORDMCOUNT)		+= recordmcount
>   hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT)		+= sorttable
>   hostprogs-always-$(CONFIG_ASN1)				+= asn1_compiler
>   hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT)		+= sign-file
> -hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)	+= insert-sys-cert
>   hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS)		+= rustdoc_test_builder
>   hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS)		+= rustdoc_test_gen
>   always-$(CONFIG_RUST)					+= target.json
> +hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)	+= insert-symbol
>   
>   filechk_rust_target = $< < include/config/auto.conf
>   
> diff --git a/scripts/insert-sys-cert.c b/scripts/insert-symbol.c
> similarity index 99%
> rename from scripts/insert-sys-cert.c
> rename to scripts/insert-symbol.c
> index 77d3306cfbfb..6866e3a84974 100644
> --- a/scripts/insert-sys-cert.c
> +++ b/scripts/insert-symbol.c
> @@ -7,7 +7,7 @@
>    * This software may be used and distributed according to the terms
>    * of the GNU General Public License, incorporated herein by reference.
>    *
> - * Usage: insert-sys-cert [-s <System.map> -b <vmlinux> -c <certfile>
> + * Usage: insert-symbol [-s <System.map> -b <vmlinux> -c <certfile>
>    */
>   
>   #define _GNU_SOURCE

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

* Re: [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line
  2023-11-10  1:38 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker
@ 2023-11-23  6:36   ` Christophe Leroy
  0 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:36 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Thomas Bogendoerfer
  Cc: xe-linux-external, Ruslan Ruslichenko, Ruslan Bilovol, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> This updates the mips code to use the CONFIG_GENERIC_CMDLINE
> option.
> 
> This deletes the option for MIPS_CMDLINE_BUILTIN_EXTEND
> and replaces the functionality with generic code.
> 
> Of note, the pic32 has some strange handling of the current built
> in command line. It was converted to use the static variant which
> can't be updated after compilation. It should eventually be updated
> to use to append and prepend symbols.
> 
> This includes a scripted mass convert of the config files to use
> the new generic cmdline. There is a bit of a trim effect here.
> It would seems that some of the config haven't been trimmed in
> a while.

trim effect should go in a separate preparatory patch in order to 
clearly see what are the changes implied by this patch.

> 
> The script used is as follows,
> 
> if [[ -z "$1" || -z "$2" ]]; then
>          echo "Two arguments are needed."
>          exit 1
> fi
> mkdir $1
> cp $2 $1/.config
> sed -i 's/CONFIG_CMDLINE=/CONFIG_CMDLINE_BOOL=y\nCONFIG_CMDLINE_PREPEND=/g' $1/.config
> make ARCH=$1 O=$1 olddefconfig
> make ARCH=$1 O=$1 savedefconfig
> cp $1/defconfig $2
> rm -Rf $1
> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Ruslan Ruslichenko <rruslich@cisco.com>
> Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   arch/mips/Kconfig                         |   4 +-
>   arch/mips/Kconfig.debug                   |  44 -------
>   arch/mips/configs/ar7_defconfig           |  12 +-
>   arch/mips/configs/bcm47xx_defconfig       |  10 +-
>   arch/mips/configs/bcm63xx_defconfig       |  21 ++--
>   arch/mips/configs/bmips_be_defconfig      |  17 ++-
>   arch/mips/configs/bmips_stb_defconfig     | 139 ++++++++--------------
>   arch/mips/configs/ci20_defconfig          |   8 +-
>   arch/mips/configs/cu1000-neo_defconfig    |  19 ++-
>   arch/mips/configs/cu1830-neo_defconfig    |  19 ++-
>   arch/mips/configs/generic_defconfig       |  15 +--
>   arch/mips/configs/gpr_defconfig           |  33 ++---
>   arch/mips/configs/loongson3_defconfig     |  29 ++---
>   arch/mips/include/asm/setup.h             |   2 +
>   arch/mips/kernel/relocate.c               |  17 ++-
>   arch/mips/kernel/setup.c                  |  36 +-----
>   arch/mips/pic32/pic32mzda/early_console.c |   2 +-
>   arch/mips/pic32/pic32mzda/init.c          |   3 +-
>   18 files changed, 144 insertions(+), 286 deletions(-)
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index bc8421859006..65fd3decc6b1 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -31,6 +31,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
> @@ -2989,9 +2990,6 @@ choice
>   	config MIPS_CMDLINE_FROM_BOOTLOADER
>   		bool "Bootloader kernel arguments if available"
>   
> -	config MIPS_CMDLINE_BUILTIN_EXTEND
> -		depends on CMDLINE_BOOL
> -		bool "Extend builtin kernel arguments with bootloader arguments"
>   endchoice
>   
>   endmenu
> diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
> index f4ae7900fcd3..f9da53d4ebd2 100644
> --- a/arch/mips/Kconfig.debug
> +++ b/arch/mips/Kconfig.debug
> @@ -26,50 +26,6 @@ config EARLY_PRINTK_8250
>   config USE_GENERIC_EARLY_PRINTK_8250
>   	bool
>   
> -config CMDLINE_BOOL
> -	bool "Built-in kernel command line"
> -	help
> -	  For most systems, it is firmware or second stage bootloader that
> -	  by default specifies the kernel command line options.  However,
> -	  it might be necessary or advantageous to either override the
> -	  default kernel command line or add a few extra options to it.
> -	  For such cases, this option allows you to hardcode your own
> -	  command line options directly into the kernel.  For that, you
> -	  should choose 'Y' here, and fill in the extra boot arguments
> -	  in CONFIG_CMDLINE.
> -
> -	  The built-in options will be concatenated to the default command
> -	  line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
> -	  command line will be ignored and replaced by the built-in string.
> -
> -	  Most MIPS systems will normally expect 'N' here and rely upon
> -	  the command line from the firmware or the second-stage bootloader.
> -
> -config CMDLINE
> -	string "Default kernel command string"
> -	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, and for the cases
> -	  when you want to add some extra options to the command line or ignore
> -	  the default command line, 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.
> -
> -	  For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
> -	  options.
> -
> -config CMDLINE_OVERRIDE
> -	bool "Built-in command line overrides firmware arguments"
> -	depends on CMDLINE_BOOL
> -	help
> -	  By setting this option to 'Y' you will have your kernel ignore
> -	  command line arguments from firmware or second stage bootloader.
> -	  Instead, the built-in command line will be used exclusively.
> -
> -	  Normally, you will choose 'N' here.
> -
>   config SB1XXX_CORELIS
>   	bool "Corelis Debugger"
>   	depends on SIBYTE_SB1xxx_SOC
> diff --git a/arch/mips/configs/ar7_defconfig b/arch/mips/configs/ar7_defconfig
> index 329c60aa570a..0dff0795705e 100644
> --- a/arch/mips/configs/ar7_defconfig
> +++ b/arch/mips/configs/ar7_defconfig
> @@ -9,17 +9,18 @@ CONFIG_BLK_DEV_INITRD=y
>   CONFIG_EXPERT=y
>   # CONFIG_ELF_CORE is not set
>   # CONFIG_KALLSYMS is not set
> -# CONFIG_VM_EVENT_COUNTERS is not set
> -# CONFIG_COMPAT_BRK is not set
> +CONFIG_KEXEC=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="rootfstype=squashfs,jffs2"
>   CONFIG_AR7=y
>   CONFIG_HZ_100=y
> -CONFIG_KEXEC=y
>   # CONFIG_SECCOMP is not set
>   CONFIG_MODULES=y
>   CONFIG_MODULE_UNLOAD=y
> -# CONFIG_BLK_DEV_BSG is not set
>   CONFIG_PARTITION_ADVANCED=y
>   CONFIG_BSD_DISKLABEL=y
> +# CONFIG_COMPAT_BRK is not set
> +# CONFIG_VM_EVENT_COUNTERS is not set
>   CONFIG_NET=y
>   CONFIG_PACKET=y
>   CONFIG_UNIX=y
> @@ -39,7 +40,6 @@ CONFIG_TCP_CONG_WESTWOOD=y
>   # CONFIG_TCP_CONG_HTCP is not set
>   # CONFIG_IPV6 is not set
>   CONFIG_NETFILTER=y
> -# CONFIG_BRIDGE_NETFILTER is not set
>   CONFIG_NF_CONNTRACK=m
>   CONFIG_NF_CONNTRACK_MARK=y
>   CONFIG_NF_CONNTRACK_FTP=m
> @@ -115,5 +115,3 @@ CONFIG_SQUASHFS=y
>   # CONFIG_CRYPTO_HW is not set
>   CONFIG_STRIP_ASM_SYMS=y
>   CONFIG_DEBUG_FS=y
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
> diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig
> index 6a68a96d13f8..26e2134f83af 100644
> --- a/arch/mips/configs/bcm47xx_defconfig
> +++ b/arch/mips/configs/bcm47xx_defconfig
> @@ -3,8 +3,9 @@ CONFIG_HIGH_RES_TIMERS=y
>   CONFIG_BLK_DEV_INITRD=y
>   CONFIG_CC_OPTIMIZE_FOR_SIZE=y
>   CONFIG_EXPERT=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
>   CONFIG_BCM47XX=y
> -CONFIG_PCI=y
>   # CONFIG_SUSPEND is not set
>   CONFIG_MODULES=y
>   CONFIG_MODULE_UNLOAD=y
> @@ -31,6 +32,7 @@ CONFIG_NET_SCH_FQ_CODEL=y
>   CONFIG_HAMRADIO=y
>   CONFIG_CFG80211=y
>   CONFIG_MAC80211=y
> +CONFIG_PCI=y
>   CONFIG_MTD=y
>   CONFIG_MTD_BCM47XX_PARTS=y
>   CONFIG_MTD_BLOCK=y
> @@ -67,14 +69,10 @@ CONFIG_BCMA_DRIVER_GMAC_CMN=y
>   CONFIG_USB=y
>   CONFIG_USB_HCD_BCMA=y
>   CONFIG_USB_HCD_SSB=y
> -CONFIG_LEDS_TRIGGER_TIMER=y
> -CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
>   CONFIG_CRC32_SARWATE=y
>   CONFIG_PRINTK_TIME=y
>   CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
>   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"
> +CONFIG_DEBUG_FS=y
> diff --git a/arch/mips/configs/bcm63xx_defconfig b/arch/mips/configs/bcm63xx_defconfig
> index 34d0ca638ef0..0a73fd34063f 100644
> --- a/arch/mips/configs/bcm63xx_defconfig
> +++ b/arch/mips/configs/bcm63xx_defconfig
> @@ -1,5 +1,4 @@
>   # CONFIG_LOCALVERSION_AUTO is not set
> -# CONFIG_SWAP is not set
>   CONFIG_NO_HZ=y
>   CONFIG_EXPERT=y
>   # CONFIG_FUTEX is not set
> @@ -9,18 +8,16 @@ CONFIG_EXPERT=y
>   # CONFIG_EVENTFD is not set
>   # CONFIG_SHMEM is not set
>   # CONFIG_AIO is not set
> -# CONFIG_VM_EVENT_COUNTERS is not set
> -# CONFIG_SLUB_DEBUG is not set
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
>   CONFIG_BCM63XX=y
>   CONFIG_BCM63XX_CPU_6338=y
>   CONFIG_BCM63XX_CPU_6345=y
>   CONFIG_BCM63XX_CPU_6348=y
>   CONFIG_BCM63XX_CPU_6358=y
>   # CONFIG_SECCOMP is not set
> -CONFIG_PCI=y
> -CONFIG_PCCARD=y
> -CONFIG_PCMCIA_BCM63XX=y
> -# CONFIG_BLK_DEV_BSG is not set
> +# CONFIG_SWAP is not set
> +# CONFIG_VM_EVENT_COUNTERS is not set
>   CONFIG_NET=y
>   CONFIG_UNIX=y
>   CONFIG_INET=y
> @@ -29,6 +26,10 @@ CONFIG_INET=y
>   CONFIG_CFG80211=y
>   CONFIG_NL80211_TESTMODE=y
>   CONFIG_MAC80211=y
> +CONFIG_PCI=y
> +# CONFIG_VGA_ARB is not set
> +CONFIG_PCCARD=y
> +CONFIG_PCMCIA_BCM63XX=y
>   # CONFIG_STANDALONE is not set
>   # CONFIG_PREVENT_FIRMWARE_BUILD is not set
>   CONFIG_MTD=y
> @@ -47,11 +48,8 @@ CONFIG_B43=y
>   # CONFIG_SERIO is not set
>   # CONFIG_VT is not set
>   # CONFIG_UNIX98_PTYS is not set
> -CONFIG_SERIAL_BCM63XX=y
> -CONFIG_SERIAL_BCM63XX_CONSOLE=y
>   # CONFIG_HW_RANDOM is not set
>   # CONFIG_HWMON is not set
> -# CONFIG_VGA_ARB is not set
>   CONFIG_USB=y
>   CONFIG_USB_EHCI_HCD=y
>   # CONFIG_USB_EHCI_TT_NEWSCHED is not set
> @@ -62,5 +60,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"
> +# CONFIG_SLUB_DEBUG is not set
> diff --git a/arch/mips/configs/bmips_be_defconfig b/arch/mips/configs/bmips_be_defconfig
> index daef132d000b..0b2b7685330f 100644
> --- a/arch/mips/configs/bmips_be_defconfig
> +++ b/arch/mips/configs/bmips_be_defconfig
> @@ -1,17 +1,17 @@
>   # CONFIG_LOCALVERSION_AUTO is not set
> -# CONFIG_SWAP is not set
>   CONFIG_NO_HZ=y
>   CONFIG_BLK_DEV_INITRD=y
>   CONFIG_EXPERT=y
> -# CONFIG_VM_EVENT_COUNTERS is not set
> -# CONFIG_SLUB_DEBUG is not set
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="earlycon"
>   CONFIG_BMIPS_GENERIC=y
>   CONFIG_HIGHMEM=y
>   CONFIG_SMP=y
>   CONFIG_NR_CPUS=4
> -# CONFIG_SECCOMP is not set
>   CONFIG_MIPS_O32_FP64_SUPPORT=y
> -# CONFIG_BLK_DEV_BSG is not set
> +# CONFIG_SECCOMP is not set
> +# CONFIG_SWAP is not set
> +# CONFIG_VM_EVENT_COUNTERS is not set
>   CONFIG_NET=y
>   CONFIG_PACKET=y
>   CONFIG_PACKET_DIAG=y
> @@ -34,6 +34,7 @@ CONFIG_MTD_PHYSMAP=y
>   # CONFIG_BLK_DEV is not set
>   CONFIG_SCSI=y
>   CONFIG_BLK_DEV_SD=y
> +# CONFIG_BLK_DEV_BSG is not set
>   # CONFIG_SCSI_LOWLEVEL is not set
>   CONFIG_NETDEVICES=y
>   CONFIG_BCMGENET=y
> @@ -41,7 +42,6 @@ CONFIG_USB_USBNET=y
>   # CONFIG_INPUT is not set
>   # CONFIG_SERIO is not set
>   # CONFIG_VT is not set
> -CONFIG_SERIAL_BCM63XX=y
>   CONFIG_SERIAL_BCM63XX_CONSOLE=y
>   # CONFIG_HW_RANDOM is not set
>   CONFIG_POWER_RESET=y
> @@ -70,7 +70,6 @@ CONFIG_NLS_ASCII=y
>   CONFIG_NLS_ISO8859_1=y
>   # CONFIG_CRYPTO_HW is not set
>   CONFIG_PRINTK_TIME=y
> -CONFIG_DEBUG_FS=y
>   CONFIG_MAGIC_SYSRQ=y
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="earlycon"
> +CONFIG_DEBUG_FS=y
> +# CONFIG_SLUB_DEBUG is not set
> diff --git a/arch/mips/configs/bmips_stb_defconfig b/arch/mips/configs/bmips_stb_defconfig
> index cd0dc37c3d84..4f96a1da7610 100644
> --- a/arch/mips/configs/bmips_stb_defconfig
> +++ b/arch/mips/configs/bmips_stb_defconfig
> @@ -1,59 +1,44 @@
>   # CONFIG_LOCALVERSION_AUTO is not set
> -# CONFIG_SWAP is not set
> +CONFIG_SYSVIPC=y
>   CONFIG_NO_HZ=y
> -CONFIG_HZ=1000
> +CONFIG_HIGH_RES_TIMERS=y
> +CONFIG_CGROUPS=y
>   CONFIG_BLK_DEV_INITRD=y
> +# CONFIG_RD_GZIP is not set
> +# CONFIG_RD_BZIP2 is not set
> +# CONFIG_RD_LZMA is not set
> +# CONFIG_RD_LZO is not set
> +# CONFIG_RD_LZ4 is not set
>   CONFIG_EXPERT=y
> -# CONFIG_VM_EVENT_COUNTERS is not set
> -# CONFIG_SLUB_DEBUG is not set
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="earlycon"
>   CONFIG_BMIPS_GENERIC=y
>   CONFIG_CPU_LITTLE_ENDIAN=y
>   CONFIG_HIGHMEM=y
> -CONFIG_HIGH_RES_TIMERS=y
>   CONFIG_SMP=y
>   CONFIG_NR_CPUS=4
> -# CONFIG_SECCOMP is not set
>   CONFIG_MIPS_O32_FP64_SUPPORT=y
> -# CONFIG_RD_GZIP is not set
> -# CONFIG_RD_BZIP2 is not set
> -# CONFIG_RD_LZMA is not set
> -CONFIG_RD_XZ=y
> -# CONFIG_RD_LZO is not set
> -# CONFIG_RD_LZ4 is not set
> -CONFIG_PCI=y
> -CONFIG_PCI_MSI=y
> -CONFIG_PCIEASPM_POWERSAVE=y
> -CONFIG_PCIEPORTBUS=y
> -CONFIG_PCIE_BRCMSTB=y
> +CONFIG_MIPS_CMDLINE_DTB_EXTEND=y
> +CONFIG_PM_DEBUG=y
>   CONFIG_CPU_FREQ=y
>   CONFIG_CPU_FREQ_STAT=y
> -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
> -CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
>   CONFIG_CPU_FREQ_GOV_POWERSAVE=y
>   CONFIG_CPU_FREQ_GOV_USERSPACE=y
>   CONFIG_CPU_FREQ_GOV_ONDEMAND=y
>   CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
>   CONFIG_BMIPS_CPUFREQ=y
> -# CONFIG_BLK_DEV_BSG is not set
> +# CONFIG_SECCOMP is not set
> +CONFIG_MODULES=y
> +CONFIG_MODULE_FORCE_LOAD=y
> +CONFIG_MODULE_UNLOAD=y
> +CONFIG_MODVERSIONS=y
> +# CONFIG_SWAP is not set
> +# CONFIG_VM_EVENT_COUNTERS is not set
>   CONFIG_NET=y
>   CONFIG_PACKET=y
>   CONFIG_PACKET_DIAG=y
>   CONFIG_UNIX=y
>   CONFIG_INET=y
> -# CONFIG_INET_DIAG is not set
> -CONFIG_CFG80211=y
> -CONFIG_NL80211_TESTMODE=y
> -CONFIG_WIRELESS=y
> -CONFIG_MAC80211=y
> -CONFIG_DEVTMPFS=y
> -CONFIG_DEVTMPFS_MOUNT=y
> -# CONFIG_STANDALONE is not set
> -# CONFIG_PREVENT_FIRMWARE_BUILD is not set
> -CONFIG_BRCMSTB_GISB_ARB=y
> -CONFIG_MODULES=y
> -CONFIG_MODULE_FORCE_LOAD=y
> -CONFIG_MODULE_UNLOAD=y
> -CONFIG_MODVERSIONS=y
>   CONFIG_IP_MULTICAST=y
>   CONFIG_IP_PNP=y
>   CONFIG_IP_PNP_DHCP=y
> @@ -62,25 +47,32 @@ CONFIG_IP_PNP_RARP=y
>   CONFIG_IP_MROUTE=y
>   CONFIG_IP_PIMSM_V1=y
>   CONFIG_IP_PIMSM_V2=y
> -CONFIG_INET_UDP_DIAG=y
> +# CONFIG_INET_DIAG is not set
>   CONFIG_TCP_CONG_ADVANCED=y
>   CONFIG_TCP_CONG_BIC=y
>   # CONFIG_TCP_CONG_WESTWOOD is not set
>   # CONFIG_TCP_CONG_HTCP is not set
>   # CONFIG_IPV6 is not set
> -CONFIG_IP_NF_IPTABLES=y
> -CONFIG_IP_NF_FILTER=y
>   CONFIG_NETFILTER=y
> -CONFIG_NETFILTER_XTABLES=y
> -CONFIG_BRIDGE=y
>   CONFIG_BRIDGE_NETFILTER=m
> +CONFIG_IP_NF_IPTABLES=y
> +CONFIG_IP_NF_FILTER=y
>   CONFIG_BRIDGE_NF_EBTABLES=m
>   CONFIG_BRIDGE_EBT_BROUTE=m
> +CONFIG_BRIDGE=y
>   CONFIG_NET_DSA=y
> -CONFIG_NET_SWITCHDEV=y
> -CONFIG_DMA_CMA=y
> -CONFIG_CMA_ALIGNMENT=12
> -CONFIG_SPI=y
> +CONFIG_VLAN_8021Q=y
> +CONFIG_CFG80211=y
> +CONFIG_NL80211_TESTMODE=y
> +CONFIG_MAC80211=y
> +CONFIG_PCI=y
> +CONFIG_PCIEPORTBUS=y
> +CONFIG_PCIEASPM_POWERSAVE=y
> +CONFIG_PCI_MSI=y
> +CONFIG_DEVTMPFS=y
> +CONFIG_DEVTMPFS_MOUNT=y
> +# CONFIG_STANDALONE is not set
> +# CONFIG_PREVENT_FIRMWARE_BUILD is not set
>   CONFIG_MTD=y
>   CONFIG_MTD_CMDLINE_PARTS=y
>   CONFIG_MTD_BLOCK=y
> @@ -91,22 +83,21 @@ CONFIG_MTD_CFI_AMDSTD=y
>   CONFIG_MTD_CFI_STAA=y
>   CONFIG_MTD_ROM=y
>   CONFIG_MTD_ABSENT=y
> -CONFIG_MTD_PHYSMAP_OF=y
> +CONFIG_MTD_RAW_NAND=y
>   CONFIG_MTD_NAND_BRCMNAND=y
>   CONFIG_MTD_SPI_NOR=y
>   # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
>   CONFIG_MTD_UBI=y
>   CONFIG_MTD_UBI_GLUEBI=y
> -CONFIG_BLK_DEV_LOOP=y
> -CONFIG_BLK_DEV_RAM=y
> -CONFIG_BLK_DEV_RAM_SIZE=8192
>   # CONFIG_BLK_DEV is not set
> -CONFIG_SCSI=y
>   CONFIG_BLK_DEV_SD=y
>   CONFIG_CHR_DEV_SG=y
> +# CONFIG_BLK_DEV_BSG is not set
>   # CONFIG_SCSI_LOWLEVEL is not set
> +CONFIG_ATA=y
> +CONFIG_SATA_AHCI_PLATFORM=y
> +CONFIG_AHCI_BRCM=y
>   CONFIG_NETDEVICES=y
> -CONFIG_VLAN_8021Q=y
>   CONFIG_MACVLAN=y
>   CONFIG_BCMGENET=y
>   CONFIG_USB_USBNET=y
> @@ -116,15 +107,16 @@ CONFIG_INPUT_EVDEV=y
>   CONFIG_INPUT_MISC=y
>   CONFIG_INPUT_UINPUT=y
>   # CONFIG_SERIO is not set
> -CONFIG_VT=y
>   CONFIG_VT_HW_CONSOLE_BINDING=y
>   CONFIG_SERIAL_8250=y
>   # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
>   CONFIG_SERIAL_8250_CONSOLE=y
>   CONFIG_SERIAL_OF_PLATFORM=y
>   # CONFIG_HW_RANDOM is not set
> +CONFIG_SPI=y
> +CONFIG_GPIOLIB=y
> +CONFIG_GPIO_SYSFS=y
>   CONFIG_POWER_RESET=y
> -CONFIG_POWER_RESET_BRCMSTB=y
>   CONFIG_POWER_RESET_SYSCON=y
>   CONFIG_POWER_SUPPLY=y
>   # CONFIG_HWMON is not set
> @@ -135,21 +127,18 @@ CONFIG_USB_EHCI_HCD_PLATFORM=y
>   CONFIG_USB_OHCI_HCD=y
>   CONFIG_USB_OHCI_HCD_PLATFORM=y
>   CONFIG_USB_STORAGE=y
> -CONFIG_SOC_BRCMSTB=y
>   CONFIG_MMC=y
>   CONFIG_MMC_BLOCK_MINORS=16
>   CONFIG_MMC_SDHCI=y
>   CONFIG_MMC_SDHCI_PLTFM=y
> +CONFIG_SOC_BRCMSTB=y
> +CONFIG_PHY_BRCM_SATA=y
>   CONFIG_EXT4_FS=y
>   CONFIG_EXT4_FS_POSIX_ACL=y
>   CONFIG_EXT4_FS_SECURITY=y
> -# CONFIG_DNOTIFY is not set
> -CONFIG_PROC_KCORE=y
> -CONFIG_CIFS=y
>   CONFIG_JBD2_DEBUG=y
> +# CONFIG_DNOTIFY is not set
>   CONFIG_FUSE_FS=y
> -CONFIG_FHANDLE=y
> -CONFIG_CGROUPS=y
>   CONFIG_CUSE=y
>   CONFIG_ISO9660_FS=y
>   CONFIG_JOLIET=y
> @@ -157,6 +146,7 @@ CONFIG_ZISOFS=y
>   CONFIG_UDF_FS=y
>   CONFIG_MSDOS_FS=y
>   CONFIG_VFAT_FS=y
> +CONFIG_PROC_KCORE=y
>   CONFIG_TMPFS=y
>   CONFIG_JFFS2_FS=y
>   CONFIG_UBIFS_FS=y
> @@ -169,42 +159,17 @@ CONFIG_NFS_V4=y
>   CONFIG_NFS_V4_1=y
>   CONFIG_NFS_V4_2=y
>   CONFIG_ROOT_NFS=y
> +CONFIG_CIFS=y
>   CONFIG_NLS_CODEPAGE_437=y
>   CONFIG_NLS_ISO8859_1=y
> +# CONFIG_CRYPTO_HW is not set
>   CONFIG_PRINTK_TIME=y
>   CONFIG_DYNAMIC_DEBUG=y
> -# CONFIG_DEBUG_INFO is not set
> -# CONFIG_DEBUG_INFO_REDUCED is not set
> -CONFIG_DEBUG_FS=y
>   CONFIG_MAGIC_SYSRQ=y
> -CONFIG_LOCKUP_DETECTOR=y
> -CONFIG_DEBUG_USER=y
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="earlycon"
> -# CONFIG_MIPS_CMDLINE_FROM_DTB is not set
> -CONFIG_MIPS_CMDLINE_DTB_EXTEND=y
> -# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
> -# CONFIG_CRYPTO_HW is not set
> -CONFIG_FW_CFE=y
> -CONFIG_ATA=y
> -CONFIG_SATA_AHCI_PLATFORM=y
> -CONFIG_GENERIC_PHY=y
> -CONFIG_GPIOLIB=y
> -CONFIG_GPIO_SYSFS=y
> -CONFIG_PHY_BRCM_USB=y
> -CONFIG_PHY_BRCM_SATA=y
> -CONFIG_PM_DEBUG=y
> -CONFIG_SYSVIPC=y
> -CONFIG_FUNCTION_GRAPH_TRACER=y
> -CONFIG_DYNAMIC_FTRACE=y
> -CONFIG_FUNCTION_TRACER=y
> +# CONFIG_SLUB_DEBUG is not set
>   CONFIG_FUNCTION_PROFILER=y
> +CONFIG_STACK_TRACER=y
>   CONFIG_IRQSOFF_TRACER=y
>   CONFIG_SCHED_TRACER=y
> -CONFIG_BLK_DEV_IO_TRACE=y
>   CONFIG_FTRACE_SYSCALLS=y
> -CONFIG_TRACER_SNAPSHOT=y
> -CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y
> -CONFIG_STACK_TRACER=y
> -CONFIG_AHCI_BRCM=y
> -CONFIG_MTD_RAW_NAND=y
> +CONFIG_BLK_DEV_IO_TRACE=y
> diff --git a/arch/mips/configs/ci20_defconfig b/arch/mips/configs/ci20_defconfig
> index cdf2a782dee1..87d34b903f04 100644
> --- a/arch/mips/configs/ci20_defconfig
> +++ b/arch/mips/configs/ci20_defconfig
> @@ -17,8 +17,10 @@ CONFIG_CGROUP_CPUACCT=y
>   CONFIG_NAMESPACES=y
>   CONFIG_USER_NS=y
>   CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> -CONFIG_KALLSYMS_ALL=y
>   CONFIG_EXPERT=y
> +CONFIG_KALLSYMS_ALL=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="earlycon console=ttyS4,115200 clk_ignore_unused"
>   CONFIG_MACH_INGENIC_SOC=y
>   CONFIG_JZ4780_CI20=y
>   CONFIG_HIGHMEM=y
> @@ -126,7 +128,6 @@ CONFIG_DRM_INGENIC=m
>   CONFIG_DRM_INGENIC_DW_HDMI=m
>   CONFIG_FB=y
>   # CONFIG_VGA_CONSOLE is not set
> -CONFIG_FRAMEBUFFER_CONSOLE=y
>   CONFIG_USB=y
>   CONFIG_USB_STORAGE=y
>   CONFIG_USB_DWC2=y
> @@ -225,7 +226,4 @@ CONFIG_DEBUG_FS=y
>   CONFIG_PANIC_ON_OOPS=y
>   CONFIG_PANIC_TIMEOUT=10
>   # CONFIG_SCHED_DEBUG is not set
> -CONFIG_STACKTRACE=y
>   # CONFIG_FTRACE is not set
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="earlycon console=ttyS4,115200 clk_ignore_unused"
> diff --git a/arch/mips/configs/cu1000-neo_defconfig b/arch/mips/configs/cu1000-neo_defconfig
> index 19517beaf540..f5be8b992a0c 100644
> --- a/arch/mips/configs/cu1000-neo_defconfig
> +++ b/arch/mips/configs/cu1000-neo_defconfig
> @@ -14,20 +14,22 @@ CONFIG_CGROUP_CPUACCT=y
>   CONFIG_NAMESPACES=y
>   CONFIG_USER_NS=y
>   CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> -CONFIG_KALLSYMS_ALL=y
>   CONFIG_EXPERT=y
> -# CONFIG_VM_EVENT_COUNTERS is not set
> -# CONFIG_COMPAT_BRK is not set
> +CONFIG_KALLSYMS_ALL=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
>   CONFIG_MACH_INGENIC_SOC=y
>   CONFIG_X1000_CU1000_NEO=y
>   CONFIG_HIGHMEM=y
>   CONFIG_HZ_100=y
> -# CONFIG_SECCOMP is not set
>   # CONFIG_SUSPEND is not set
> +# CONFIG_SECCOMP is not set
>   CONFIG_MODULES=y
>   # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
> +# CONFIG_COMPAT_BRK is not set
>   # CONFIG_COMPACTION is not set
>   CONFIG_CMA=y
> +# CONFIG_VM_EVENT_COUNTERS is not set
>   CONFIG_NET=y
>   CONFIG_PACKET=y
>   CONFIG_UNIX=y
> @@ -66,7 +68,6 @@ CONFIG_SENSORS_ADS7828=m
>   CONFIG_WATCHDOG=y
>   CONFIG_JZ4740_WDT=y
>   # CONFIG_VGA_CONSOLE is not set
> -# CONFIG_HID is not set
>   CONFIG_USB=y
>   CONFIG_USB_STORAGE=y
>   CONFIG_USB_DWC2=y
> @@ -86,7 +87,6 @@ CONFIG_DMA_JZ4780=y
>   # CONFIG_INGENIC_TIMER is not set
>   CONFIG_INGENIC_SYSOST=y
>   # CONFIG_IOMMU_SUPPORT is not set
> -CONFIG_JZ4770_PHY=y
>   CONFIG_EXT4_FS=y
>   # CONFIG_DNOTIFY is not set
>   CONFIG_AUTOFS_FS=y
> @@ -97,15 +97,14 @@ CONFIG_PROC_KCORE=y
>   CONFIG_TMPFS=y
>   CONFIG_CONFIGFS_FS=y
>   CONFIG_NFS_FS=y
> -CONFIG_NLS=y
>   CONFIG_NLS_CODEPAGE_437=y
>   CONFIG_NLS_CODEPAGE_936=y
>   CONFIG_NLS_CODEPAGE_950=y
>   CONFIG_NLS_ASCII=y
>   CONFIG_NLS_ISO8859_1=y
>   CONFIG_NLS_UTF8=y
> -CONFIG_CRYPTO_ECHAINIV=y
>   CONFIG_CRYPTO_AES=y
> +CONFIG_CRYPTO_ECHAINIV=y
>   CONFIG_CRYPTO_DEFLATE=y
>   CONFIG_CRYPTO_LZO=y
>   CONFIG_PRINTK_TIME=y
> @@ -119,8 +118,4 @@ CONFIG_DEBUG_FS=y
>   CONFIG_PANIC_ON_OOPS=y
>   CONFIG_PANIC_TIMEOUT=10
>   # CONFIG_SCHED_DEBUG is not set
> -# CONFIG_DEBUG_PREEMPT is not set
> -CONFIG_STACKTRACE=y
>   # CONFIG_FTRACE is not set
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="earlycon clk_ignore_unused"
> diff --git a/arch/mips/configs/cu1830-neo_defconfig b/arch/mips/configs/cu1830-neo_defconfig
> index b403e67ab105..b02d32f19604 100644
> --- a/arch/mips/configs/cu1830-neo_defconfig
> +++ b/arch/mips/configs/cu1830-neo_defconfig
> @@ -14,20 +14,22 @@ CONFIG_CGROUP_CPUACCT=y
>   CONFIG_NAMESPACES=y
>   CONFIG_USER_NS=y
>   CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> -CONFIG_KALLSYMS_ALL=y
>   CONFIG_EXPERT=y
> -# CONFIG_VM_EVENT_COUNTERS is not set
> -# CONFIG_COMPAT_BRK is not set
> +CONFIG_KALLSYMS_ALL=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
>   CONFIG_MACH_INGENIC_SOC=y
>   CONFIG_X1830_CU1830_NEO=y
>   CONFIG_HIGHMEM=y
>   CONFIG_HZ_100=y
> -# CONFIG_SECCOMP is not set
>   # CONFIG_SUSPEND is not set
> +# CONFIG_SECCOMP is not set
>   CONFIG_MODULES=y
>   # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
> +# CONFIG_COMPAT_BRK is not set
>   # CONFIG_COMPACTION is not set
>   CONFIG_CMA=y
> +# CONFIG_VM_EVENT_COUNTERS is not set
>   CONFIG_NET=y
>   CONFIG_PACKET=y
>   CONFIG_UNIX=y
> @@ -69,7 +71,6 @@ CONFIG_SENSORS_ADS7828=m
>   CONFIG_WATCHDOG=y
>   CONFIG_JZ4740_WDT=y
>   # CONFIG_VGA_CONSOLE is not set
> -# CONFIG_HID is not set
>   CONFIG_USB=y
>   CONFIG_USB_STORAGE=y
>   CONFIG_USB_DWC2=y
> @@ -89,7 +90,6 @@ CONFIG_DMA_JZ4780=y
>   # CONFIG_INGENIC_TIMER is not set
>   CONFIG_INGENIC_SYSOST=y
>   # CONFIG_IOMMU_SUPPORT is not set
> -CONFIG_JZ4770_PHY=y
>   CONFIG_EXT4_FS=y
>   # CONFIG_DNOTIFY is not set
>   CONFIG_AUTOFS_FS=y
> @@ -100,15 +100,14 @@ CONFIG_PROC_KCORE=y
>   CONFIG_TMPFS=y
>   CONFIG_CONFIGFS_FS=y
>   CONFIG_NFS_FS=y
> -CONFIG_NLS=y
>   CONFIG_NLS_CODEPAGE_437=y
>   CONFIG_NLS_CODEPAGE_936=y
>   CONFIG_NLS_CODEPAGE_950=y
>   CONFIG_NLS_ASCII=y
>   CONFIG_NLS_ISO8859_1=y
>   CONFIG_NLS_UTF8=y
> -CONFIG_CRYPTO_ECHAINIV=y
>   CONFIG_CRYPTO_AES=y
> +CONFIG_CRYPTO_ECHAINIV=y
>   CONFIG_CRYPTO_DEFLATE=y
>   CONFIG_CRYPTO_LZO=y
>   CONFIG_PRINTK_TIME=y
> @@ -122,8 +121,4 @@ CONFIG_DEBUG_FS=y
>   CONFIG_PANIC_ON_OOPS=y
>   CONFIG_PANIC_TIMEOUT=10
>   # CONFIG_SCHED_DEBUG is not set
> -# CONFIG_DEBUG_PREEMPT is not set
> -CONFIG_STACKTRACE=y
>   # CONFIG_FTRACE is not set
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="earlycon clk_ignore_unused"
> diff --git a/arch/mips/configs/generic_defconfig b/arch/mips/configs/generic_defconfig
> index 071e2205c7ed..53eddba32478 100644
> --- a/arch/mips/configs/generic_defconfig
> +++ b/arch/mips/configs/generic_defconfig
> @@ -1,5 +1,6 @@
>   CONFIG_SYSVIPC=y
>   CONFIG_NO_HZ_IDLE=y
> +CONFIG_BPF_SYSCALL=y
>   CONFIG_IKCONFIG=y
>   CONFIG_IKCONFIG_PROC=y
>   CONFIG_MEMCG=y
> @@ -15,11 +16,9 @@ CONFIG_NAMESPACES=y
>   CONFIG_USER_NS=y
>   CONFIG_SCHED_AUTOGROUP=y
>   CONFIG_BLK_DEV_INITRD=y
> -CONFIG_BPF_SYSCALL=y
> -CONFIG_USERFAULTFD=y
>   CONFIG_EXPERT=y
> -# CONFIG_SLUB_DEBUG is not set
> -# CONFIG_COMPAT_BRK is not set
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="earlycon"
>   CONFIG_CPU_LITTLE_ENDIAN=y
>   CONFIG_MIPS_CPS=y
>   CONFIG_HIGHMEM=y
> @@ -29,6 +28,8 @@ CONFIG_JUMP_LABEL=y
>   CONFIG_MODULES=y
>   CONFIG_MODULE_UNLOAD=y
>   CONFIG_TRIM_UNUSED_KSYMS=y
> +# CONFIG_COMPAT_BRK is not set
> +CONFIG_USERFAULTFD=y
>   CONFIG_NET=y
>   CONFIG_PACKET=y
>   CONFIG_UNIX=y
> @@ -44,14 +45,11 @@ CONFIG_HW_RANDOM=y
>   # CONFIG_HWMON is not set
>   CONFIG_MFD_SYSCON=y
>   CONFIG_HID_A4TECH=y
> -CONFIG_HID_APPLE=y
>   CONFIG_HID_BELKIN=y
>   CONFIG_HID_CHERRY=y
> -CONFIG_HID_CHICONY=y
>   CONFIG_HID_CYPRESS=y
>   CONFIG_HID_EZKEY=y
>   CONFIG_HID_KENSINGTON=y
> -CONFIG_HID_LOGITECH=y
>   CONFIG_HID_MICROSOFT=y
>   CONFIG_HID_MONTEREY=y
>   # CONFIG_MIPS_PLATFORM_DEVICES is not set
> @@ -85,7 +83,6 @@ CONFIG_PRINTK_TIME=y
>   CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
>   CONFIG_DEBUG_INFO_REDUCED=y
>   CONFIG_DEBUG_FS=y
> +# CONFIG_SLUB_DEBUG is not set
>   # CONFIG_SCHED_DEBUG is not set
>   # CONFIG_FTRACE is not set
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="earlycon"
> diff --git a/arch/mips/configs/gpr_defconfig b/arch/mips/configs/gpr_defconfig
> index 92fc0edbac47..5c070a81a26d 100644
> --- a/arch/mips/configs/gpr_defconfig
> +++ b/arch/mips/configs/gpr_defconfig
> @@ -9,9 +9,10 @@ CONFIG_RELAY=y
>   CONFIG_BLK_DEV_INITRD=y
>   CONFIG_EXPERT=y
>   CONFIG_PROFILING=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
>   CONFIG_MIPS_ALCHEMY=y
>   CONFIG_MIPS_GPR=y
> -CONFIG_PCI=y
>   CONFIG_MODULES=y
>   CONFIG_MODULE_UNLOAD=y
>   CONFIG_PARTITION_ADVANCED=y
> @@ -45,7 +46,6 @@ CONFIG_NETFILTER_XT_MATCH_LIMIT=m
>   CONFIG_NETFILTER_XT_MATCH_MAC=m
>   CONFIG_NETFILTER_XT_MATCH_MARK=m
>   CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
> -CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
>   CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
>   CONFIG_NETFILTER_XT_MATCH_QUOTA=m
>   CONFIG_NETFILTER_XT_MATCH_REALM=m
> @@ -102,27 +102,21 @@ CONFIG_IPDDP_ENCAP=y
>   CONFIG_X25=m
>   CONFIG_LAPB=m
>   CONFIG_NET_SCHED=y
> -CONFIG_NET_SCH_CBQ=m
>   CONFIG_NET_SCH_HTB=m
>   CONFIG_NET_SCH_HFSC=m
> -CONFIG_NET_SCH_ATM=m
>   CONFIG_NET_SCH_PRIO=m
>   CONFIG_NET_SCH_RED=m
>   CONFIG_NET_SCH_SFQ=m
>   CONFIG_NET_SCH_TEQL=m
>   CONFIG_NET_SCH_TBF=m
>   CONFIG_NET_SCH_GRED=m
> -CONFIG_NET_SCH_DSMARK=m
>   CONFIG_NET_SCH_NETEM=m
>   CONFIG_NET_SCH_INGRESS=m
>   CONFIG_NET_CLS_BASIC=m
> -CONFIG_NET_CLS_TCINDEX=m
>   CONFIG_NET_CLS_ROUTE4=m
>   CONFIG_NET_CLS_FW=m
>   CONFIG_NET_CLS_U32=m
>   CONFIG_CLS_U32_MARK=y
> -CONFIG_NET_CLS_RSVP=m
> -CONFIG_NET_CLS_RSVP6=m
>   CONFIG_NET_EMATCH=y
>   CONFIG_NET_EMATCH_CMP=m
>   CONFIG_NET_EMATCH_NBYTE=m
> @@ -145,6 +139,8 @@ CONFIG_BAYCOM_SER_HDX=m
>   CONFIG_YAM=m
>   CONFIG_CFG80211=y
>   CONFIG_MAC80211=y
> +CONFIG_PCI=y
> +# CONFIG_VGA_ARB is not set
>   CONFIG_MTD=y
>   CONFIG_MTD_BLOCK=y
>   CONFIG_MTD_CFI=y
> @@ -232,8 +228,6 @@ CONFIG_WATCHDOG=y
>   CONFIG_WATCHDOG_NOWAYOUT=y
>   CONFIG_SSB=m
>   CONFIG_SSB_DRIVER_PCICORE=y
> -# CONFIG_VGA_ARB is not set
> -# CONFIG_LCD_CLASS_DEVICE is not set
>   CONFIG_BACKLIGHT_CLASS_DEVICE=y
>   # CONFIG_VGA_CONSOLE is not set
>   CONFIG_USB_HID=m
> @@ -250,10 +244,6 @@ CONFIG_USB_STORAGE=m
>   CONFIG_USB_SERIAL=y
>   CONFIG_USB_SERIAL_GENERIC=y
>   CONFIG_USB_SERIAL_SIERRAWIRELESS=y
> -CONFIG_LEDS_GPIO=y
> -CONFIG_LEDS_TRIGGER_TIMER=y
> -CONFIG_LEDS_TRIGGER_HEARTBEAT=y
> -CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
>   # CONFIG_DNOTIFY is not set
>   # CONFIG_INOTIFY_USER is not set
>   CONFIG_ISO9660_FS=m
> @@ -275,20 +265,15 @@ CONFIG_NLS_CODEPAGE_850=y
>   CONFIG_NLS_ISO8859_1=y
>   CONFIG_CRYPTO_AUTHENC=m
>   CONFIG_CRYPTO_TEST=m
> -CONFIG_CRYPTO_PCBC=m
> -CONFIG_CRYPTO_MD4=m
> -CONFIG_CRYPTO_MICHAEL_MIC=m
> -CONFIG_CRYPTO_SHA512=m
> -CONFIG_CRYPTO_WP512=m
> -CONFIG_CRYPTO_ANUBIS=m
>   CONFIG_CRYPTO_BLOWFISH=m
>   CONFIG_CRYPTO_CAST5=m
>   CONFIG_CRYPTO_CAST6=m
> -CONFIG_CRYPTO_KHAZAD=m
>   CONFIG_CRYPTO_SERPENT=m
> -CONFIG_CRYPTO_TEA=m
>   CONFIG_CRYPTO_TWOFISH=m
> +CONFIG_CRYPTO_PCBC=m
> +CONFIG_CRYPTO_MD4=m
> +CONFIG_CRYPTO_MICHAEL_MIC=m
> +CONFIG_CRYPTO_SHA512=m
> +CONFIG_CRYPTO_WP512=m
>   CONFIG_CRYPTO_DEFLATE=m
>   CONFIG_MAGIC_SYSRQ=y
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
> diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
> index 07839a4b397e..aca4797b5bb6 100644
> --- a/arch/mips/configs/loongson3_defconfig
> +++ b/arch/mips/configs/loongson3_defconfig
> @@ -5,6 +5,8 @@ CONFIG_POSIX_MQUEUE=y
>   CONFIG_AUDIT=y
>   CONFIG_NO_HZ=y
>   CONFIG_HIGH_RES_TIMERS=y
> +CONFIG_BPF_SYSCALL=y
> +CONFIG_BPF_JIT=y
>   CONFIG_PREEMPT=y
>   CONFIG_BSD_PROCESS_ACCT=y
>   CONFIG_BSD_PROCESS_ACCT_V3=y
> @@ -22,18 +24,18 @@ CONFIG_CGROUP_CPUACCT=y
>   CONFIG_NAMESPACES=y
>   CONFIG_USER_NS=y
>   CONFIG_SCHED_AUTOGROUP=y
> -CONFIG_SYSFS_DEPRECATED=y
>   CONFIG_RELAY=y
>   CONFIG_BLK_DEV_INITRD=y
> -CONFIG_BPF_SYSCALL=y
>   CONFIG_EXPERT=y
>   CONFIG_PERF_EVENTS=y
> +CONFIG_KEXEC=y
> +CONFIG_CMDLINE_BOOL=y
> +CONFIG_CMDLINE_PREPEND="ieee754=relaxed"
>   CONFIG_MACH_LOONGSON64=y
>   CONFIG_CPU_HAS_MSA=y
>   CONFIG_NUMA=y
>   CONFIG_NR_CPUS=16
>   CONFIG_HZ_256=y
> -CONFIG_KEXEC=y
>   CONFIG_MIPS32_O32=y
>   CONFIG_MIPS32_N32=y
>   CONFIG_VIRTUALIZATION=y
> @@ -47,15 +49,12 @@ CONFIG_MODVERSIONS=y
>   CONFIG_PARTITION_ADVANCED=y
>   CONFIG_MQ_IOSCHED_DEADLINE=m
>   CONFIG_IOSCHED_BFQ=y
> -CONFIG_BFQ_GROUP_IOSCHED=y
>   CONFIG_BINFMT_MISC=m
>   CONFIG_KSM=y
>   CONFIG_NET=y
>   CONFIG_PACKET=y
> -CONFIG_UNIX=y
>   CONFIG_XFRM_USER=y
>   CONFIG_NET_KEY=y
> -CONFIG_INET=y
>   CONFIG_IP_MULTICAST=y
>   CONFIG_IP_ADVANCED_ROUTER=y
>   CONFIG_IP_MULTIPLE_TABLES=y
> @@ -128,7 +127,6 @@ CONFIG_L2TP=m
>   CONFIG_BRIDGE=m
>   CONFIG_VSOCKETS=m
>   CONFIG_VIRTIO_VSOCKETS=m
> -CONFIG_BPF_JIT=y
>   CONFIG_CFG80211=m
>   CONFIG_CFG80211_WEXT=y
>   CONFIG_MAC80211=m
> @@ -196,7 +194,6 @@ CONFIG_VIRTIO_NET=m
>   # CONFIG_NET_VENDOR_ARC is not set
>   # CONFIG_NET_VENDOR_ATHEROS is not set
>   # CONFIG_NET_VENDOR_BROADCOM is not set
> -# CONFIG_NET_VENDOR_BROCADE is not set
>   # CONFIG_NET_VENDOR_CHELSIO is not set
>   # CONFIG_NET_VENDOR_CIRRUS is not set
>   # CONFIG_NET_VENDOR_CISCO is not set
> @@ -216,6 +213,7 @@ CONFIG_IXGBE=y
>   # CONFIG_NET_VENDOR_NVIDIA is not set
>   # CONFIG_NET_VENDOR_OKI is not set
>   # CONFIG_NET_VENDOR_QLOGIC is not set
> +# CONFIG_NET_VENDOR_BROCADE is not set
>   # CONFIG_NET_VENDOR_RDC is not set
>   CONFIG_8139CP=m
>   CONFIG_8139TOO=m
> @@ -276,15 +274,14 @@ CONFIG_MEDIA_SUPPORT=m
>   CONFIG_MEDIA_USB_SUPPORT=y
>   CONFIG_USB_VIDEO_CLASS=m
>   CONFIG_DRM=y
> +CONFIG_DRM_RADEON=m
>   CONFIG_DRM_AMDGPU=m
>   CONFIG_DRM_AMDGPU_SI=y
>   CONFIG_DRM_AMDGPU_CIK=y
>   CONFIG_DRM_AMDGPU_USERPTR=y
>   CONFIG_DRM_AMD_ACP=y
> -CONFIG_DRM_AMD_DC=y
>   CONFIG_DRM_AMD_DC_SI=y
>   CONFIG_DRM_AST=m
> -CONFIG_DRM_RADEON=m
>   CONFIG_DRM_QXL=y
>   CONFIG_DRM_VIRTIO_GPU=y
>   CONFIG_FB=y
> @@ -292,7 +289,6 @@ CONFIG_FB_RADEON=y
>   CONFIG_LCD_CLASS_DEVICE=y
>   CONFIG_LCD_PLATFORM=m
>   # CONFIG_VGA_CONSOLE is not set
> -CONFIG_FRAMEBUFFER_CONSOLE=y
>   CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
>   CONFIG_LOGO=y
>   CONFIG_SOUND=y
> @@ -350,7 +346,6 @@ CONFIG_EXT3_FS_SECURITY=y
>   CONFIG_XFS_FS=y
>   CONFIG_XFS_POSIX_ACL=y
>   CONFIG_QUOTA=y
> -# CONFIG_PRINT_QUOTA_WARNING is not set
>   CONFIG_QFMT_V1=m
>   CONFIG_QFMT_V2=m
>   CONFIG_AUTOFS_FS=y
> @@ -390,24 +385,20 @@ CONFIG_SECURITY_NETWORK=y
>   CONFIG_SECURITY_PATH=y
>   CONFIG_SECURITY_SELINUX=y
>   CONFIG_SECURITY_SELINUX_BOOTPARAM=y
> -CONFIG_SECURITY_SELINUX_DISABLE=y
>   CONFIG_DEFAULT_SECURITY_DAC=y
> -CONFIG_CRYPTO_HMAC=y
> -CONFIG_CRYPTO_MD5=y
> -CONFIG_CRYPTO_WP512=m
>   CONFIG_CRYPTO_BLOWFISH=m
>   CONFIG_CRYPTO_CAST5=m
>   CONFIG_CRYPTO_CAST6=m
>   CONFIG_CRYPTO_SERPENT=m
>   CONFIG_CRYPTO_TWOFISH=m
> +CONFIG_CRYPTO_HMAC=y
> +CONFIG_CRYPTO_MD5=y
> +CONFIG_CRYPTO_WP512=m
>   CONFIG_CRYPTO_DEFLATE=m
>   CONFIG_PRINTK_TIME=y
>   CONFIG_STRIP_ASM_SYMS=y
>   CONFIG_MAGIC_SYSRQ=y
>   CONFIG_DEBUG_FS=y
>   # CONFIG_SCHED_DEBUG is not set
> -# CONFIG_DEBUG_PREEMPT is not set
>   CONFIG_FUNCTION_TRACER=y
>   CONFIG_FTRACE_SYSCALLS=y
> -CONFIG_CMDLINE_BOOL=y
> -CONFIG_CMDLINE="ieee754=relaxed"
> diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h
> index 8c56b862fd9c..798bc3c68080 100644
> --- a/arch/mips/include/asm/setup.h
> +++ b/arch/mips/include/asm/setup.h
> @@ -5,6 +5,7 @@
>   #include <linux/types.h>
>   #include <uapi/asm/setup.h>
>   
> +#ifndef __ASSEMBLY__
>   extern void prom_putchar(char);
>   extern void setup_early_printk(void);
>   
> @@ -27,5 +28,6 @@ extern unsigned long ebase;
>   extern unsigned int hwrena;
>   extern void per_cpu_trap_init(bool);
>   extern void cpu_cache_init(void);
> +#endif
>   
>   #endif /* __SETUP_H */
> diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
> index 58fc8d089402..089d67c476ae 100644
> --- a/arch/mips/kernel/relocate.c
> +++ b/arch/mips/kernel/relocate.c
> @@ -23,6 +23,7 @@
>   #include <linux/start_kernel.h>
>   #include <linux/string.h>
>   #include <linux/printk.h>
> +#include <linux/cmdline.h>
>   
>   #define RELOCATED(x) ((void *)((long)x + offset))
>   
> @@ -247,16 +248,26 @@ static inline __init bool kaslr_disabled(void)
>   	char *str;
>   
>   #if defined(CONFIG_CMDLINE_BOOL)
> -	const char *builtin_cmdline = CONFIG_CMDLINE;
> +	char *builtin_cmdline = CMDLINE_PREPEND;
>   
>   	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) == ' '))
> +	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
> +		str = strstr(arcs_cmdline, "nokaslr");
> +		if (str == arcs_cmdline || (str > arcs_cmdline && *(str - 1) == ' '))
> +			return true;
> +	}
> +
> +#if defined(CONFIG_CMDLINE_BOOL)
> +	builtin_cmdline = CMDLINE_APPEND;
> +	str = strstr(builtin_cmdline, "nokaslr");
> +	if (str == builtin_cmdline ||
> +	    (str > builtin_cmdline && *(str - 1) == ' '))
>   		return true;
> +#endif
>   
>   	return false;
>   }
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index cb871eb784a7..38e0e19b9c0d 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -25,6 +25,7 @@
>   #include <linux/debugfs.h>
>   #include <linux/kexec.h>
>   #include <linux/sizes.h>
> +#include <linux/cmdline.h>
>   #include <linux/device.h>
>   #include <linux/dma-map-ops.h>
>   #include <linux/decompress/generic.h>
> @@ -70,12 +71,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.
> @@ -561,27 +556,7 @@ 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)) {
> -		strscpy(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))
> -		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
> -	else
> -		boot_command_line[0] = 0;
> +	boot_command_line[0] = 0;
>   
>   #ifdef CONFIG_OF_EARLY_FLATTREE
>   	/*
> @@ -604,12 +579,9 @@ static void __init bootcmdline_init(void)
>   		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.
> +	 * Use the generic system for builtin prepend and append.
>   	 */
> -	if (IS_ENABLED(CONFIG_CMDLINE_BOOL) &&
> -	    !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
> -		bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE);
> +	cmdline_add_builtin(boot_command_line);
>   }
>   
>   /*
> diff --git a/arch/mips/pic32/pic32mzda/early_console.c b/arch/mips/pic32/pic32mzda/early_console.c
> index 3cd1b408fa1c..f14bc1846706 100644
> --- a/arch/mips/pic32/pic32mzda/early_console.c
> +++ b/arch/mips/pic32/pic32mzda/early_console.c
> @@ -76,7 +76,7 @@ static char * __init pic32_getcmdline(void)
>   	 * command line setup if using CONFIG_CMDLINE_BOOL.
>   	 */
>   #ifdef CONFIG_CMDLINE_OVERRIDE
> -	return CONFIG_CMDLINE;
> +	return CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND;
>   #else
>   	return fw_getcmdline();
>   #endif
> diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c
> index 53b227a9074c..ba2524255857 100644
> --- a/arch/mips/pic32/pic32mzda/init.c
> +++ b/arch/mips/pic32/pic32mzda/init.c
> @@ -9,6 +9,7 @@
>   #include <linux/of_fdt.h>
>   #include <linux/of_platform.h>
>   #include <linux/platform_data/sdhci-pic32.h>
> +#include <linux/cmdline.h>
>   
>   #include <asm/fw/fw.h>
>   #include <asm/mips-boards/generic.h>
> @@ -41,7 +42,7 @@ void __init plat_mem_setup(void)
>   	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);
> +	pr_info(" builtin_cmdline  : %s\n", CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND);
>   #endif
>   	if (dtb != __dtb_start)
>   		strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);

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

* Re: [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline
  2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
  2023-11-10  4:23   ` kernel test robot
@ 2023-11-23  6:37   ` Christophe Leroy
  2023-12-12  9:55   ` Ard Biesheuvel
  2 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:37 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, Ard Biesheuvel, linux-efi, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> This adds code to handle the generic command line changes.
> The efi code appears that it doesn't benefit as much from this design
> as it could.

So what can we do to improve that ?


> 
> For example, if you had a prepend command line with "nokaslr" then
> you might be helpful to re-enable it in the boot loader or dts,

s/you/it

> but there appears to be no way to re-enable kaslr or some of the
> other options.
> 
> The efi command line handling is incorrect. x86 and arm have an append
> system however the efi code prepends the command line.
> 
> For example, you could have a non-upgradable bios which sends
> 
> efi=disable_early_pci_dma
> 
> This hypothetically could have been set because early pci dma caused
> issues on early versions of the product.
> 
> Then later the early pci dma was made to work and the company desired
> to start using it. To override the bios you could set the CONFIG_CMDLINE
> to,
> 
> efi=no_disable_early_pci_dma
> 
> then parsing would normally start with the bios command line, then move
> to the CONFIG_CMDLINE and you would end up with early pci dma turned on.
> 
> however, current efi code keeps early pci dma off because the bios
> arguments always override the built in.
> 
> Per my reading this is different from the main body of x86, arm, and
> arm64.
> 
> The generic command line provides both append and prepend, so it
> alleviates this issue if it's used. However not all architectures use
> it.
> 
> It would be desirable to allow the efi stub to have it's builtin command
> line to be modified after compile, but I don't see a feasible way to do
> that currently.

Would be desirable or is desirable ? Your explanations are unclear.


> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   .../firmware/efi/libstub/efi-stub-helper.c    | 29 +++++++++++++++++++
>   drivers/firmware/efi/libstub/efi-stub.c       |  9 ++++++
>   drivers/firmware/efi/libstub/efistub.h        |  1 +
>   drivers/firmware/efi/libstub/x86-stub.c       | 14 +++++++--
>   4 files changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index bfa30625f5d0..952fa2cdff51 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -11,6 +11,7 @@
>   
>   #include <linux/efi.h>
>   #include <linux/kernel.h>
> +#include <linux/cmdline.h>
>   #include <asm/efi.h>
>   #include <asm/setup.h>
>   
> @@ -29,6 +30,34 @@ bool __pure __efi_soft_reserve_enabled(void)
>   	return !efi_nosoftreserve;
>   }
>   
> +/**
> + * efi_handle_cmdline() - handle adding in built-in parts of the command line
> + * @cmdline:	kernel command line
> + *
> + * Add in the generic parts of the commandline and start the parsing of the
> + * command line.
> + *
> + * Return:	status code
> + */
> +efi_status_t efi_handle_builtin_cmdline(char const *cmdline)
> +{
> +	efi_status_t status = EFI_SUCCESS;
> +
> +	if (sizeof(CMDLINE_STATIC_PREPEND) > 1)
> +		status |= efi_parse_options(CMDLINE_STATIC_PREPEND);
> +
> +	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE))
> +		status |= efi_parse_options(cmdline);
> +
> +	if (sizeof(CMDLINE_STATIC_APPEND) > 1)
> +		status |= efi_parse_options(CMDLINE_STATIC_APPEND);
> +
> +	if (status != EFI_SUCCESS)
> +		efi_err("Failed to parse options\n");
> +
> +	return status;
> +}
> +
>   /**
>    * efi_parse_options() - Parse EFI command line options
>    * @cmdline:	kernel command line
> diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
> index f9c1e8a2bd1d..770abe95c0ee 100644
> --- a/drivers/firmware/efi/libstub/efi-stub.c
> +++ b/drivers/firmware/efi/libstub/efi-stub.c
> @@ -127,6 +127,14 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
>   		return EFI_OUT_OF_RESOURCES;
>   	}
>   
> +#ifdef CONFIG_GENERIC_CMDLINE
> +	status = efi_handle_builtin_cmdline(cmdline);
> +	if (status != EFI_SUCCESS) {
> +		goto fail_free_cmdline;
> +	}
> +#endif
> +
> +#ifdef CONFIG_CMDLINE
>   	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
>   	    IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
>   	    cmdline_size == 0) {
> @@ -144,6 +152,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
>   			goto fail_free_cmdline;
>   		}
>   	}
> +#endif
>   
>   	*cmdline_ptr = cmdline;
>   	return EFI_SUCCESS;
> diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
> index 212687c30d79..1ac6631905c5 100644
> --- a/drivers/firmware/efi/libstub/efistub.h
> +++ b/drivers/firmware/efi/libstub/efistub.h
> @@ -996,6 +996,7 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr,
>   				 unsigned long alignment,
>   				 unsigned long min_addr);
>   
> +efi_status_t efi_handle_builtin_cmdline(char const *cmdline);
>   efi_status_t efi_parse_options(char const *cmdline);
>   
>   void efi_parse_option_graphics(char *option);
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index 9d5df683f882..273a8a9c8bbb 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -847,6 +847,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>   	struct setup_header *hdr = &boot_params->hdr;
>   	const struct linux_efi_initrd *initrd = NULL;
>   	unsigned long kernel_entry;
> +	unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
> +				       ((u64)boot_params->ext_cmd_line_ptr << 32));
>   	efi_status_t status;
>   
>   	boot_params_pointer = boot_params;
> @@ -877,6 +879,14 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>   		goto fail;
>   	}
>   
> +#ifdef CONFIG_GENERIC_CMDLINE
> +	status = efi_handle_builtin_cmdline((char *)cmdline_paddr);
> +	if (status != EFI_SUCCESS) {
> +		efi_err("Failed to parse options\n");
> +		goto fail;
> +	}
> +#else /* CONFIG_GENERIC_CMDLINE */
> +
>   #ifdef CONFIG_CMDLINE_BOOL
>   	status = efi_parse_options(CONFIG_CMDLINE);
>   	if (status != EFI_SUCCESS) {
> @@ -885,8 +895,6 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>   	}
>   #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");
> @@ -894,6 +902,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>   		}
>   	}
>   
> +#endif
> +
>   	status = efi_decompress_kernel(&kernel_entry);
>   	if (status != EFI_SUCCESS) {
>   		efi_err("Failed to decompress kernel\n");

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

* Re: [PATCH 7/8] of: replace command line handling
  2023-11-10  1:38 ` [PATCH 7/8] of: replace command line handling Daniel Walker
  2023-11-16 16:09   ` Rob Herring
@ 2023-11-23  6:39   ` Christophe Leroy
  1 sibling, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:39 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Rob Herring, Frank Rowand
  Cc: xe-linux-external, devicetree, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> Rob Herring has complained about this section of code. I removed the

This kind of considerations shouldn't appear in the commit message, it 
may appear after the --- so that it gets dropped when applying.

> command line handling code to the cmdline.h header. This hopefully makes
> it easier for Rob to maintain it (at least he doesn't have to look at it
> directly anymore). I would like to add a Kconfig option called
> OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code.

Not sure to understand what you want to do and why that is needed. Why 
can't that work for everyone ? Avoid unnecessary options.

> This would allow a platform to use the cmdline.h and the added function
> directly and remove the Kconfig option. This change would be in a subsequent
> patch.

would or will ? Not sure it is worth mentioning if it won't.

> 
> This code was boot tested on powerpc 32bit, powerpc 64bit without
> any generic command line conversion.
> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   drivers/of/fdt.c        | 22 +++-------------------
>   include/linux/cmdline.h | 31 +++++++++++++++++++++++++++++++
>   2 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index bf502ba8da95..1fc1b17d04dc 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -26,6 +26,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>
> @@ -1183,27 +1184,10 @@ int __init early_init_dt_scan_chosen(char *cmdline)
>   
>   	/* Retrieve command line */
>   	p = of_get_flat_dt_prop(node, "bootargs", &l);
> -	if (p != NULL && l > 0)
> -		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
>   
>   handle_cmdline:
> -	/*
> -	 * 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(cmdline, " ", COMMAND_LINE_SIZE);
> -	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#elif defined(CONFIG_CMDLINE_FORCE)
> -	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#else
> -	/* No arguments from boot loader, use kernel's  cmdl*/
> -	if (!((char *)cmdline)[0])
> -		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#endif
> -#endif /* CONFIG_CMDLINE */
> +
> +	of_deprecated_cmdline_update(cmdline, p, l);
>   
>   	pr_debug("Command line is: %s\n", (char *)cmdline);
>   
> diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
> index a94758a0f257..c772afb7340f 100644
> --- a/include/linux/cmdline.h
> +++ b/include/linux/cmdline.h
> @@ -103,4 +103,35 @@ __cmdline_add_builtin(
>   
>   #define cmdline_get_static_builtin(dest) \
>   	(CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND)
> +
> +#ifndef CONFIG_GENERIC_CMDLINE
> +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length)

Add a comment explaining why it is deprecated.

> +{
> +	if (dt_bootargs != NULL && length > 0)
> +		strlcpy(cmdline, dt_bootargs, min(length, COMMAND_LINE_SIZE));
> +	/*
> +	 * 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(cmdline, " ", COMMAND_LINE_SIZE);
> +	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#elif defined(CONFIG_CMDLINE_FORCE)
> +	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#else
> +	/* No arguments from boot loader, use kernel's  cmdl*/
> +	if (!((char *)cmdline)[0])
> +		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
>   #endif
> +#endif /* CONFIG_CMDLINE */
> +	return true;
> +}
> +#else
> +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length) { return false; }
> +#endif /* CONFIG_GENERIC_CMDLINE */
> +
> +
> +#endif /* _LINUX_CMDLINE_H */

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

* Re: [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line
  2023-11-10  1:38 ` [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line Daniel Walker
@ 2023-11-23  6:39   ` Christophe Leroy
  0 siblings, 0 replies; 30+ messages in thread
From: Christophe Leroy @ 2023-11-23  6:39 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, Catalin Marinas
  Cc: xe-linux-external, linux-arm-kernel, linux-kernel



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> This removes arm64 from the device tree handling of the
> command line arguments.

You should provide more details on how each existing Kconfig option is 
converted, for instance when CONFIG_CMDLINE_FORCE becomes 
CONFIG_CMDLINE_OVERRIDE.

> 
> The boot_command_line variable is populated inside the earliest
> user of the command line, which is in idreg-override.c.
> 
> The device tree should not be needed to do any further handling
> of the boot command line options.

should not be ? But what's the result at the end, is it needed or not ?

> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   arch/arm64/Kconfig                  | 33 +----------------------------
>   arch/arm64/include/asm/setup.h      |  4 ++++
>   arch/arm64/include/uapi/asm/setup.h |  2 ++
>   arch/arm64/kernel/idreg-override.c  |  9 ++++----
>   arch/arm64/kernel/pi/kaslr_early.c  | 14 ++++++------
>   5 files changed, 19 insertions(+), 43 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 78f20e632712..d3b7fd1080d0 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -131,6 +131,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
> @@ -2217,38 +2218,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
>   
> diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
> index f4af547ef54c..5a8037262cbb 100644
> --- a/arch/arm64/include/asm/setup.h
> +++ b/arch/arm64/include/asm/setup.h
> @@ -3,10 +3,13 @@
>   #ifndef __ARM64_ASM_SETUP_H
>   #define __ARM64_ASM_SETUP_H
>   
> +#ifndef __ASSEMBLY__
>   #include <linux/string.h>
> +#endif
>   
>   #include <uapi/asm/setup.h>
>   
> +#ifndef __ASSEMBLY__
>   void *get_early_fdt_ptr(void);
>   void early_fdt_map(u64 dt_phys);
>   
> @@ -30,5 +33,6 @@ static inline bool arch_parse_debug_rodata(char *arg)
>   	return false;
>   }
>   #define arch_parse_debug_rodata arch_parse_debug_rodata
> +#endif /* __ASSEMBLY__ */
>   
>   #endif
> diff --git a/arch/arm64/include/uapi/asm/setup.h b/arch/arm64/include/uapi/asm/setup.h
> index 5d703888f351..f5fc5b806369 100644
> --- a/arch/arm64/include/uapi/asm/setup.h
> +++ b/arch/arm64/include/uapi/asm/setup.h
> @@ -20,7 +20,9 @@
>   #ifndef __ASM_SETUP_H
>   #define __ASM_SETUP_H
>   
> +#ifndef __ASSEMBLY__
>   #include <linux/types.h>
> +#endif
>   
>   #define COMMAND_LINE_SIZE	2048
>   
> diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
> index 3addc09f8746..6334a9228909 100644
> --- a/arch/arm64/kernel/idreg-override.c
> +++ b/arch/arm64/kernel/idreg-override.c
> @@ -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>
> @@ -304,11 +305,11 @@ static __init void parse_cmdline(void)
>   {
>   	const u8 *prop = get_bootargs_cmdline();
>   
> -	if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop)
> -		__parse_cmdline(CONFIG_CMDLINE, true);
> +	strscpy(boot_command_line, prop, COMMAND_LINE_SIZE);
> +	cmdline_add_builtin(boot_command_line);
> +
> +	__parse_cmdline(boot_command_line, true);
>   
> -	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && prop)
> -		__parse_cmdline(prop, true);
>   }
>   
>   /* Keep checkers quiet */
> diff --git a/arch/arm64/kernel/pi/kaslr_early.c b/arch/arm64/kernel/pi/kaslr_early.c
> index 17bff6e399e4..1e00bc01fa7a 100644
> --- a/arch/arm64/kernel/pi/kaslr_early.c
> +++ b/arch/arm64/kernel/pi/kaslr_early.c
> @@ -11,6 +11,7 @@
>   #include <linux/types.h>
>   #include <linux/sizes.h>
>   #include <linux/string.h>
> +#include <linux/cmdline.h>
>   
>   #include <asm/archrandom.h>
>   #include <asm/memory.h>
> @@ -42,7 +43,7 @@ static bool cmdline_contains_nokaslr(const u8 *cmdline)
>   
>   static bool is_kaslr_disabled_cmdline(void *fdt)
>   {
> -	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
> +	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
>   		int node;
>   		const u8 *prop;
>   
> @@ -54,16 +55,15 @@ static bool is_kaslr_disabled_cmdline(void *fdt)
>   		if (!prop)
>   			goto out;
>   
> +		if (cmdline_contains_nokaslr(CMDLINE_STATIC_APPEND))
> +			return true;
>   		if (cmdline_contains_nokaslr(prop))
>   			return true;
> -
> -		if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
> -			goto out;
> -
> -		return false;
> +		if (cmdline_contains_nokaslr(CMDLINE_STATIC_PREPEND))
> +			return true;
>   	}
>   out:
> -	return cmdline_contains_nokaslr(CONFIG_CMDLINE);
> +	return cmdline_contains_nokaslr(cmdline_get_static_builtin());
>   }
>   
>   static u64 get_kaslr_seed(void *fdt)

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

* Re: [PATCH 1/8] CMDLINE: add generic builtin command line
  2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
  2023-11-10 16:12   ` kernel test robot
  2023-11-23  6:32   ` Christophe Leroy
@ 2023-12-04 11:11   ` Jaskaran Singh
  2 siblings, 0 replies; 30+ messages in thread
From: Jaskaran Singh @ 2023-12-04 11:11 UTC (permalink / raw)
  To: Daniel Walker, Will Deacon, Christophe Leroy, Rob Herring,
	Daniel Gimpelevich, Andrew Morton, Pratyush Brahma,
	Tomas Mudrunka, Sean Anderson, x86, linux-mips, linuxppc-dev
  Cc: xe-linux-external, Ruslan Bilovol, linux-kernel



On 11/10/2023 7:08 AM, Daniel Walker wrote:
> diff --git a/lib/generic_cmdline.S b/lib/generic_cmdline.S
> new file mode 100644
> index 000000000000..223763f9eeb6
> --- /dev/null
> +++ b/lib/generic_cmdline.S
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#include <linux/export.h>
> +#include <linux/init.h>
> +
> +#include <asm/setup.h>
> +
> +        __INITDATA
> +
> +       .align 8
> +       .global cmdline_prepend
> +cmdline_prepend:
> +       .ifnc CONFIG_CMDLINE_PREPEND,""
> +       .ascii CONFIG_CMDLINE_PREPEND
> +       .string " "
> +       .else
> +       .byte 0x0
> +       .endif
> +#ifdef CONFIG_CMDLINE_EXTRA
> +       .space COMMAND_LINE_SIZE - (.-cmdline_prepend)
> +       .size cmdline_prepend, COMMAND_LINE_SIZE
> +#endif /* CONFIG_CMDLINE_EXTRA */
> +
> +cmdline_prepend_end:
> +       .size cmdline_prepend, (cmdline_prepend_end - cmdline_prepend)
> +
> +       .align 8
> +       .global cmdline_tmp
> +cmdline_tmp:
> +       .ifnc CONFIG_CMDLINE_PREPEND,""
> +       .size cmdline_tmp, COMMAND_LINE_SIZE
> +       .space COMMAND_LINE_SIZE
> +       .else
> +       .byte 0x0
> +       .endif
> +cmdline_tmp_end:
> +       .size cmdline_tmp, (cmdline_tmp_end - cmdline_tmp)
> +
> +       .align 8
> +       .global cmdline_append
> +       .size cmdline_append, COMMAND_LINE_SIZE
> +cmdline_append:
> +       .ifnc CONFIG_CMDLINE_APPEND,""
> +       .ascii " "
> +       .string CONFIG_CMDLINE_APPEND
> +       .else
> +       .byte 0x0
> +       .endif
> +#ifdef CONFIG_CMDLINE_EXTRA
> +       .space COMMAND_LINE_SIZE - (.-cmdline_append)
> +#endif /* CONFIG_CMDLINE_EXTRA */
> +cmdline_append_end:
> +       .size cmdline_append, (cmdline_append_end - cmdline_append)
> +

Hi Daniel,

I picked these patches to test a usecase of ours. generic_cmdline.S does
not escape semicolons in the CMDLINE_APPEND and CMDLINE_PREPEND strings.
Take this config snippet for example:

CONFIG_CMDLINE_APPEND="slub_debug=FZP,zs_handle,zspage;FZPU page_owner=on"
CONFIG_CMDLINE_BOOL=y
# CONFIG_CMDLINE_EXTRA is not set
# CONFIG_CMDLINE_OVERRIDE is not set
# CONFIG_CMDLINE_PREPEND is not set
# CONFIG_TEST_CMDLINE is not set

While compiling, the word FZPU is considered as a mnemonic because of
the semicolon preceding it causing parsing to fail:

kernel/lib/generic_cmdline.S: Assembler messages:
kernel/lib/generic_cmdline.S:42: Warning: missing closing `"'
kernel/lib/generic_cmdline.S:42: Error: unknown mnemonic `fzpu' -- `fzpu
page_owner=on",""'

Maybe Christophe's suggestion of moving this code to a C file and using
inline assembly helps mitigate similar problems?

Thanks,
Jaskaran.

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

* Re: [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline
  2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
  2023-11-10  4:23   ` kernel test robot
  2023-11-23  6:37   ` Christophe Leroy
@ 2023-12-12  9:55   ` Ard Biesheuvel
  2023-12-12 17:25     ` Daniel Walker (danielwa)
  2 siblings, 1 reply; 30+ messages in thread
From: Ard Biesheuvel @ 2023-12-12  9:55 UTC (permalink / raw)
  To: Daniel Walker
  Cc: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, xe-linux-external, linux-efi,
	linux-kernel

On Fri, 10 Nov 2023 at 02:39, Daniel Walker <danielwa@cisco.com> wrote:
>
> This adds code to handle the generic command line changes.
> The efi code appears that it doesn't benefit as much from this design
> as it could.
>
> For example, if you had a prepend command line with "nokaslr" then
> you might be helpful to re-enable it in the boot loader or dts,
> but there appears to be no way to re-enable kaslr or some of the
> other options.
>
> The efi command line handling is incorrect. x86 and arm have an append
> system however the efi code prepends the command line.
>
> For example, you could have a non-upgradable bios which sends
>
> efi=disable_early_pci_dma
>
> This hypothetically could have been set because early pci dma caused
> issues on early versions of the product.
>
> Then later the early pci dma was made to work and the company desired
> to start using it. To override the bios you could set the CONFIG_CMDLINE
> to,
>
> efi=no_disable_early_pci_dma
>
> then parsing would normally start with the bios command line, then move
> to the CONFIG_CMDLINE and you would end up with early pci dma turned on.
>
> however, current efi code keeps early pci dma off because the bios
> arguments always override the built in.
>
> Per my reading this is different from the main body of x86, arm, and
> arm64.
>
> The generic command line provides both append and prepend, so it
> alleviates this issue if it's used. However not all architectures use
> it.
>
> It would be desirable to allow the efi stub to have it's builtin command
> line to be modified after compile, but I don't see a feasible way to do
> that currently.
>
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>

There are quite some 'might be's and 'hypothetical's in this commit log.

Is there an actual use case that you are addressing here? Without
that, this looks like unnecessary churn to me, tbh.

Note that this code executes in the context of platform firmware,
which may be old and buggy so we should be cautious about making
unnecessary changes here.


> ---
>  .../firmware/efi/libstub/efi-stub-helper.c    | 29 +++++++++++++++++++
>  drivers/firmware/efi/libstub/efi-stub.c       |  9 ++++++
>  drivers/firmware/efi/libstub/efistub.h        |  1 +
>  drivers/firmware/efi/libstub/x86-stub.c       | 14 +++++++--
>  4 files changed, 51 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index bfa30625f5d0..952fa2cdff51 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -11,6 +11,7 @@
>
>  #include <linux/efi.h>
>  #include <linux/kernel.h>
> +#include <linux/cmdline.h>
>  #include <asm/efi.h>
>  #include <asm/setup.h>
>
> @@ -29,6 +30,34 @@ bool __pure __efi_soft_reserve_enabled(void)
>         return !efi_nosoftreserve;
>  }
>
> +/**
> + * efi_handle_cmdline() - handle adding in built-in parts of the command line
> + * @cmdline:   kernel command line
> + *
> + * Add in the generic parts of the commandline and start the parsing of the
> + * command line.
> + *
> + * Return:     status code
> + */
> +efi_status_t efi_handle_builtin_cmdline(char const *cmdline)
> +{
> +       efi_status_t status = EFI_SUCCESS;
> +
> +       if (sizeof(CMDLINE_STATIC_PREPEND) > 1)
> +               status |= efi_parse_options(CMDLINE_STATIC_PREPEND);
> +
> +       if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE))
> +               status |= efi_parse_options(cmdline);
> +
> +       if (sizeof(CMDLINE_STATIC_APPEND) > 1)
> +               status |= efi_parse_options(CMDLINE_STATIC_APPEND);
> +
> +       if (status != EFI_SUCCESS)
> +               efi_err("Failed to parse options\n");
> +
> +       return status;
> +}
> +
>  /**
>   * efi_parse_options() - Parse EFI command line options
>   * @cmdline:   kernel command line
> diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
> index f9c1e8a2bd1d..770abe95c0ee 100644
> --- a/drivers/firmware/efi/libstub/efi-stub.c
> +++ b/drivers/firmware/efi/libstub/efi-stub.c
> @@ -127,6 +127,14 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
>                 return EFI_OUT_OF_RESOURCES;
>         }
>
> +#ifdef CONFIG_GENERIC_CMDLINE
> +       status = efi_handle_builtin_cmdline(cmdline);
> +       if (status != EFI_SUCCESS) {
> +               goto fail_free_cmdline;
> +       }
> +#endif
> +
> +#ifdef CONFIG_CMDLINE
>         if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
>             IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
>             cmdline_size == 0) {
> @@ -144,6 +152,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
>                         goto fail_free_cmdline;
>                 }
>         }
> +#endif
>
>         *cmdline_ptr = cmdline;
>         return EFI_SUCCESS;
> diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
> index 212687c30d79..1ac6631905c5 100644
> --- a/drivers/firmware/efi/libstub/efistub.h
> +++ b/drivers/firmware/efi/libstub/efistub.h
> @@ -996,6 +996,7 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr,
>                                  unsigned long alignment,
>                                  unsigned long min_addr);
>
> +efi_status_t efi_handle_builtin_cmdline(char const *cmdline);
>  efi_status_t efi_parse_options(char const *cmdline);
>
>  void efi_parse_option_graphics(char *option);
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index 9d5df683f882..273a8a9c8bbb 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -847,6 +847,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>         struct setup_header *hdr = &boot_params->hdr;
>         const struct linux_efi_initrd *initrd = NULL;
>         unsigned long kernel_entry;
> +       unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
> +                                      ((u64)boot_params->ext_cmd_line_ptr << 32));
>         efi_status_t status;
>
>         boot_params_pointer = boot_params;
> @@ -877,6 +879,14 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>                 goto fail;
>         }
>
> +#ifdef CONFIG_GENERIC_CMDLINE
> +       status = efi_handle_builtin_cmdline((char *)cmdline_paddr);
> +       if (status != EFI_SUCCESS) {
> +               efi_err("Failed to parse options\n");
> +               goto fail;
> +       }
> +#else /* CONFIG_GENERIC_CMDLINE */
> +
>  #ifdef CONFIG_CMDLINE_BOOL
>         status = efi_parse_options(CONFIG_CMDLINE);
>         if (status != EFI_SUCCESS) {
> @@ -885,8 +895,6 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>         }
>  #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");
> @@ -894,6 +902,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
>                 }
>         }
>
> +#endif
> +
>         status = efi_decompress_kernel(&kernel_entry);
>         if (status != EFI_SUCCESS) {
>                 efi_err("Failed to decompress kernel\n");
> --
> 2.39.2
>
>

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

* Re: [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline
  2023-12-12  9:55   ` Ard Biesheuvel
@ 2023-12-12 17:25     ` Daniel Walker (danielwa)
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Walker (danielwa) @ 2023-12-12 17:25 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Pratyush Brahma, Tomas Mudrunka, Sean Anderson,
	x86, linux-mips, linuxppc-dev, xe-linux-external(mailer list),
	linux-efi, linux-kernel

On Tue, Dec 12, 2023 at 10:55:33AM +0100, Ard Biesheuvel wrote:
> On Fri, 10 Nov 2023 at 02:39, Daniel Walker <danielwa@cisco.com> wrote:
> >
> > This adds code to handle the generic command line changes.
> > The efi code appears that it doesn't benefit as much from this design
> > as it could.
> >
> > For example, if you had a prepend command line with "nokaslr" then
> > you might be helpful to re-enable it in the boot loader or dts,
> > but there appears to be no way to re-enable kaslr or some of the
> > other options.
> >
> > The efi command line handling is incorrect. x86 and arm have an append
> > system however the efi code prepends the command line.
> >
> > For example, you could have a non-upgradable bios which sends
> >
> > efi=disable_early_pci_dma
> >
> > This hypothetically could have been set because early pci dma caused
> > issues on early versions of the product.
> >
> > Then later the early pci dma was made to work and the company desired
> > to start using it. To override the bios you could set the CONFIG_CMDLINE
> > to,
> >
> > efi=no_disable_early_pci_dma
> >
> > then parsing would normally start with the bios command line, then move
> > to the CONFIG_CMDLINE and you would end up with early pci dma turned on.
> >
> > however, current efi code keeps early pci dma off because the bios
> > arguments always override the built in.
> >
> > Per my reading this is different from the main body of x86, arm, and
> > arm64.
> >
> > The generic command line provides both append and prepend, so it
> > alleviates this issue if it's used. However not all architectures use
> > it.
> >
> > It would be desirable to allow the efi stub to have it's builtin command
> > line to be modified after compile, but I don't see a feasible way to do
> > that currently.
> >
> > Cc: xe-linux-external@cisco.com
> > Signed-off-by: Daniel Walker <danielwa@cisco.com>
> 
> There are quite some 'might be's and 'hypothetical's in this commit log.
> 
> Is there an actual use case that you are addressing here? Without
> that, this looks like unnecessary churn to me, tbh.
> 
> Note that this code executes in the context of platform firmware,
> which may be old and buggy so we should be cautious about making
> unnecessary changes here.

It's been a while since I wrote this patch description, but there is an example I
provided in the description. If you intend to enable early pci dma the command
line parsing may still disable it because of how the parsing works inside the
efi stub. There is an implementation difference between the efi stub and the
architectures which results in this problem. This was not an issue I observed in
the wild, it was the results of code review of the efi stub.

Maybe the greater issue is that the efi stub seems to have connected itself to
the kernels command line system. If the kernel changes then EFI stub must also
change.

Daniel

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

* [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line
  2022-09-29  2:32 [PATCH 0/8] generic command line v5 Daniel Walker
@ 2022-09-29  2:32 ` Daniel Walker
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Walker @ 2022-09-29  2:32 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, Sean Anderson, Thomas Bogendoerfer
  Cc: xe-linux-external, Ruslan Ruslichenko, Ruslan Bilovol,
	linux-mips, linux-kernel

This updates the mips code to use the CONFIG_GENERIC_CMDLINE
option.

This deletes the option for MIPS_CMDLINE_BUILTIN_EXTEND
and replaces the functionality with generic code.

Of note, the pic32 has some strange handling of the current built
in command line. It was converted to use the static variant which
can't be updated after compilation. It should eventually be updated
to use to append and prepend symbols.

This includes a scripted mass convert of the config files to use
the new generic cmdline. There is a bit of a trim effect here.
It would seems that some of the config haven't been trimmed in
a while.

The script used is as follows,

if [[ -z "$1" || -z "$2" ]]; then
        echo "Two arguments are needed."
        exit 1
fi
mkdir $1
cp $2 $1/.config
sed -i 's/CONFIG_CMDLINE=/CONFIG_CMDLINE_BOOL=y\nCONFIG_CMDLINE_PREPEND=/g' $1/.config
make ARCH=$1 O=$1 olddefconfig
make ARCH=$1 O=$1 savedefconfig
cp $1/defconfig $2
rm -Rf $1

Cc: xe-linux-external@cisco.com
Signed-off-by: Ruslan Ruslichenko <rruslich@cisco.com>
Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 arch/mips/Kconfig                         |  4 +--
 arch/mips/Kconfig.debug                   | 44 -----------------------
 arch/mips/configs/ar7_defconfig           |  9 ++---
 arch/mips/configs/bcm47xx_defconfig       |  8 ++---
 arch/mips/configs/bcm63xx_defconfig       | 15 +++-----
 arch/mips/configs/bmips_be_defconfig      | 11 +++---
 arch/mips/configs/bmips_stb_defconfig     |  6 ++--
 arch/mips/configs/ci20_defconfig          |  9 +++--
 arch/mips/configs/cu1000-neo_defconfig    | 10 +++---
 arch/mips/configs/cu1830-neo_defconfig    | 10 +++---
 arch/mips/configs/generic_defconfig       |  6 ++--
 arch/mips/configs/gpr_defconfig           | 18 ++--------
 arch/mips/configs/loongson3_defconfig     | 12 +++----
 arch/mips/include/asm/setup.h             |  2 ++
 arch/mips/kernel/relocate.c               | 17 +++++++--
 arch/mips/kernel/setup.c                  | 36 +++----------------
 arch/mips/pic32/pic32mzda/early_console.c |  2 +-
 arch/mips/pic32/pic32mzda/init.c          |  3 +-
 18 files changed, 64 insertions(+), 158 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 25dd4c5a8ef5..732526b0d53e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -31,6 +31,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
@@ -3084,9 +3085,6 @@ choice
 	config MIPS_CMDLINE_FROM_BOOTLOADER
 		bool "Bootloader kernel arguments if available"
 
-	config MIPS_CMDLINE_BUILTIN_EXTEND
-		depends on CMDLINE_BOOL
-		bool "Extend builtin kernel arguments with bootloader arguments"
 endchoice
 
 endmenu
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index f4ae7900fcd3..f9da53d4ebd2 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -26,50 +26,6 @@ config EARLY_PRINTK_8250
 config USE_GENERIC_EARLY_PRINTK_8250
 	bool
 
-config CMDLINE_BOOL
-	bool "Built-in kernel command line"
-	help
-	  For most systems, it is firmware or second stage bootloader that
-	  by default specifies the kernel command line options.  However,
-	  it might be necessary or advantageous to either override the
-	  default kernel command line or add a few extra options to it.
-	  For such cases, this option allows you to hardcode your own
-	  command line options directly into the kernel.  For that, you
-	  should choose 'Y' here, and fill in the extra boot arguments
-	  in CONFIG_CMDLINE.
-
-	  The built-in options will be concatenated to the default command
-	  line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
-	  command line will be ignored and replaced by the built-in string.
-
-	  Most MIPS systems will normally expect 'N' here and rely upon
-	  the command line from the firmware or the second-stage bootloader.
-
-config CMDLINE
-	string "Default kernel command string"
-	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, and for the cases
-	  when you want to add some extra options to the command line or ignore
-	  the default command line, 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.
-
-	  For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
-	  options.
-
-config CMDLINE_OVERRIDE
-	bool "Built-in command line overrides firmware arguments"
-	depends on CMDLINE_BOOL
-	help
-	  By setting this option to 'Y' you will have your kernel ignore
-	  command line arguments from firmware or second stage bootloader.
-	  Instead, the built-in command line will be used exclusively.
-
-	  Normally, you will choose 'N' here.
-
 config SB1XXX_CORELIS
 	bool "Corelis Debugger"
 	depends on SIBYTE_SB1xxx_SOC
diff --git a/arch/mips/configs/ar7_defconfig b/arch/mips/configs/ar7_defconfig
index cf9c6329b807..c09470aa672f 100644
--- a/arch/mips/configs/ar7_defconfig
+++ b/arch/mips/configs/ar7_defconfig
@@ -12,6 +12,8 @@ CONFIG_EXPERT=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="rootfstype=squashfs,jffs2"
 CONFIG_AR7=y
 CONFIG_HZ_100=y
 CONFIG_KEXEC=y
@@ -32,9 +34,6 @@ CONFIG_IP_ROUTE_MULTIPATH=y
 CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_MROUTE=y
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 CONFIG_TCP_CONG_ADVANCED=y
 # CONFIG_TCP_CONG_BIC is not set
@@ -43,7 +42,6 @@ CONFIG_TCP_CONG_WESTWOOD=y
 # CONFIG_TCP_CONG_HTCP is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETFILTER=y
-# CONFIG_BRIDGE_NETFILTER is not set
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_MARK=y
 CONFIG_NF_CONNTRACK_FTP=m
@@ -117,8 +115,5 @@ CONFIG_JFFS2_SUMMARY=y
 CONFIG_JFFS2_COMPRESSION_OPTIONS=y
 CONFIG_SQUASHFS=y
 # CONFIG_CRYPTO_HW is not set
-# 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"
diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig
index 91ce75edbfb4..69a965bb2dd9 100644
--- a/arch/mips/configs/bcm47xx_defconfig
+++ b/arch/mips/configs/bcm47xx_defconfig
@@ -4,8 +4,9 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_EMBEDDED=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
 CONFIG_BCM47XX=y
-CONFIG_PCI=y
 # CONFIG_SUSPEND is not set
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
@@ -32,6 +33,7 @@ CONFIG_NET_SCH_FQ_CODEL=y
 CONFIG_HAMRADIO=y
 CONFIG_CFG80211=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
 CONFIG_MTD=y
 CONFIG_MTD_BCM47XX_PARTS=y
 CONFIG_MTD_BLOCK=y
@@ -75,7 +77,5 @@ CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO=y
 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"
+CONFIG_DEBUG_FS=y
diff --git a/arch/mips/configs/bcm63xx_defconfig b/arch/mips/configs/bcm63xx_defconfig
index 861f680184b9..6791e48b2d7d 100644
--- a/arch/mips/configs/bcm63xx_defconfig
+++ b/arch/mips/configs/bcm63xx_defconfig
@@ -11,27 +11,26 @@ CONFIG_EXPERT=y
 # CONFIG_AIO is not set
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
 CONFIG_BCM63XX=y
 CONFIG_BCM63XX_CPU_6338=y
 CONFIG_BCM63XX_CPU_6345=y
 CONFIG_BCM63XX_CPU_6348=y
 CONFIG_BCM63XX_CPU_6358=y
 # CONFIG_SECCOMP is not set
-CONFIG_PCI=y
-CONFIG_PCCARD=y
-CONFIG_PCMCIA_BCM63XX=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_NET=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
+CONFIG_PCCARD=y
+CONFIG_PCMCIA_BCM63XX=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 CONFIG_MTD=y
@@ -50,8 +49,6 @@ CONFIG_B43=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
-CONFIG_SERIAL_BCM63XX=y
-CONFIG_SERIAL_BCM63XX_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
 # CONFIG_VGA_ARB is not set
@@ -65,5 +62,3 @@ 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"
diff --git a/arch/mips/configs/bmips_be_defconfig b/arch/mips/configs/bmips_be_defconfig
index 032bb51defe8..ae1c4adf8d98 100644
--- a/arch/mips/configs/bmips_be_defconfig
+++ b/arch/mips/configs/bmips_be_defconfig
@@ -5,21 +5,20 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_BMIPS_GENERIC=y
 CONFIG_HIGHMEM=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=4
-# CONFIG_SECCOMP is not set
 CONFIG_MIPS_O32_FP64_SUPPORT=y
+# CONFIG_SECCOMP is not set
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
@@ -73,7 +72,5 @@ CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
 # CONFIG_CRYPTO_HW is not set
 CONFIG_PRINTK_TIME=y
-CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon"
+CONFIG_DEBUG_FS=y
diff --git a/arch/mips/configs/bmips_stb_defconfig b/arch/mips/configs/bmips_stb_defconfig
index 5956fb95c19f..19d9ef899d42 100644
--- a/arch/mips/configs/bmips_stb_defconfig
+++ b/arch/mips/configs/bmips_stb_defconfig
@@ -6,6 +6,8 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_BMIPS_GENERIC=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_HIGHMEM=y
@@ -38,15 +40,13 @@ CONFIG_CPU_FREQ_GOV_USERSPACE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
 CONFIG_BMIPS_CPUFREQ=y
+# CONFIG_SECCOMP is not set
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
diff --git a/arch/mips/configs/ci20_defconfig b/arch/mips/configs/ci20_defconfig
index cc69b215854e..20c3e4c33356 100644
--- a/arch/mips/configs/ci20_defconfig
+++ b/arch/mips/configs/ci20_defconfig
@@ -22,12 +22,14 @@ CONFIG_EMBEDDED=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon console=ttyS4,115200 clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_JZ4780_CI20=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
@@ -111,6 +113,7 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_CH341=y
+CONFIG_JZ4770_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_JZ4740=y
@@ -144,7 +147,6 @@ CONFIG_JZ4780_NEMC=y
 CONFIG_PWM=y
 CONFIG_PWM_JZ4740=m
 CONFIG_JZ4780_EFUSE=y
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -157,7 +159,6 @@ CONFIG_CONFIGFS_FS=y
 CONFIG_UBIFS_FS=y
 CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_737=y
 CONFIG_NLS_CODEPAGE_775=y
@@ -209,5 +210,3 @@ 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"
diff --git a/arch/mips/configs/cu1000-neo_defconfig b/arch/mips/configs/cu1000-neo_defconfig
index 5bd55eb32fe5..a554439529cd 100644
--- a/arch/mips/configs/cu1000-neo_defconfig
+++ b/arch/mips/configs/cu1000-neo_defconfig
@@ -19,12 +19,14 @@ CONFIG_EMBEDDED=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_X1000_CU1000_NEO=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
@@ -67,12 +69,12 @@ CONFIG_SENSORS_ADS7828=m
 CONFIG_WATCHDOG=y
 CONFIG_JZ4740_WDT=y
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_CH341=y
+CONFIG_JZ4770_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_JZ4740=y
@@ -87,7 +89,6 @@ CONFIG_DMA_JZ4780=y
 # CONFIG_INGENIC_TIMER is not set
 CONFIG_INGENIC_SYSOST=y
 # CONFIG_IOMMU_SUPPORT is not set
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -98,7 +99,6 @@ CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_NFS_FS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_936=y
 CONFIG_NLS_CODEPAGE_950=y
@@ -123,5 +123,3 @@ 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"
diff --git a/arch/mips/configs/cu1830-neo_defconfig b/arch/mips/configs/cu1830-neo_defconfig
index cc69688962e8..6d7d03197f17 100644
--- a/arch/mips/configs/cu1830-neo_defconfig
+++ b/arch/mips/configs/cu1830-neo_defconfig
@@ -19,12 +19,14 @@ CONFIG_EMBEDDED=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_X1830_CU1830_NEO=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
@@ -70,12 +72,12 @@ CONFIG_SENSORS_ADS7828=m
 CONFIG_WATCHDOG=y
 CONFIG_JZ4740_WDT=y
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_CH341=y
+CONFIG_JZ4770_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_JZ4740=y
@@ -90,7 +92,6 @@ CONFIG_DMA_JZ4780=y
 # CONFIG_INGENIC_TIMER is not set
 CONFIG_INGENIC_SYSOST=y
 # CONFIG_IOMMU_SUPPORT is not set
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -101,7 +102,6 @@ CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_NFS_FS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_936=y
 CONFIG_NLS_CODEPAGE_950=y
@@ -126,5 +126,3 @@ 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"
diff --git a/arch/mips/configs/generic_defconfig b/arch/mips/configs/generic_defconfig
index 714169e411cf..665ae8d63ef3 100644
--- a/arch/mips/configs/generic_defconfig
+++ b/arch/mips/configs/generic_defconfig
@@ -3,7 +3,6 @@ CONFIG_NO_HZ_IDLE=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_MEMCG=y
-CONFIG_MEMCG_SWAP=y
 CONFIG_BLK_CGROUP=y
 CONFIG_CFS_BANDWIDTH=y
 CONFIG_RT_GROUP_SCHED=y
@@ -21,6 +20,8 @@ CONFIG_USERFAULTFD=y
 CONFIG_EMBEDDED=y
 # CONFIG_SLUB_DEBUG is not set
 # CONFIG_COMPAT_BRK is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_CPS=y
 CONFIG_HIGHMEM=y
@@ -52,7 +53,6 @@ CONFIG_HID_CHICONY=y
 CONFIG_HID_CYPRESS=y
 CONFIG_HID_EZKEY=y
 CONFIG_HID_KENSINGTON=y
-CONFIG_HID_LOGITECH=y
 CONFIG_HID_MICROSOFT=y
 CONFIG_HID_MONTEREY=y
 # CONFIG_MIPS_PLATFORM_DEVICES is not set
@@ -88,5 +88,3 @@ 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"
diff --git a/arch/mips/configs/gpr_defconfig b/arch/mips/configs/gpr_defconfig
index d82f4ebf687f..21c9109c2f63 100644
--- a/arch/mips/configs/gpr_defconfig
+++ b/arch/mips/configs/gpr_defconfig
@@ -10,9 +10,10 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
 CONFIG_PROFILING=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
 CONFIG_MIPS_ALCHEMY=y
 CONFIG_MIPS_GPR=y
-CONFIG_PCI=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_PARTITION_ADVANCED=y
@@ -29,9 +30,6 @@ CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
 CONFIG_NETFILTER=y
@@ -49,7 +47,6 @@ CONFIG_NETFILTER_XT_MATCH_LIMIT=m
 CONFIG_NETFILTER_XT_MATCH_MAC=m
 CONFIG_NETFILTER_XT_MATCH_MARK=m
 CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
-CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
 CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
 CONFIG_NETFILTER_XT_MATCH_QUOTA=m
 CONFIG_NETFILTER_XT_MATCH_REALM=m
@@ -151,6 +148,7 @@ CONFIG_BAYCOM_SER_HDX=m
 CONFIG_YAM=m
 CONFIG_CFG80211=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
 CONFIG_MTD=y
 CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
@@ -220,9 +218,6 @@ CONFIG_HDLC_X25=m
 CONFIG_PCI200SYN=m
 CONFIG_WANXL=m
 CONFIG_FARSYNC=m
-CONFIG_DSCC4=m
-CONFIG_DSCC4_PCISYNC=y
-CONFIG_DSCC4_PCI_RST=y
 CONFIG_LAPBETHER=m
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
@@ -242,7 +237,6 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 CONFIG_SSB=m
 CONFIG_SSB_DRIVER_PCICORE=y
 # CONFIG_VGA_ARB is not set
-# CONFIG_LCD_CLASS_DEVICE is not set
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_USB_HID=m
@@ -290,16 +284,10 @@ CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_SHA512=m
 CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
-CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
-CONFIG_CRYPTO_KHAZAD=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_TEA=m
 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"
diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
index 25ecd15bc952..4c53ed33d03f 100644
--- a/arch/mips/configs/loongson3_defconfig
+++ b/arch/mips/configs/loongson3_defconfig
@@ -5,6 +5,8 @@ CONFIG_POSIX_MQUEUE=y
 CONFIG_AUDIT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BPF_SYSCALL=y
+CONFIG_BPF_JIT=y
 CONFIG_PREEMPT=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
@@ -25,9 +27,10 @@ CONFIG_SCHED_AUTOGROUP=y
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_RELAY=y
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_BPF_SYSCALL=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="ieee754=relaxed"
 CONFIG_MACH_LOONGSON64=y
 CONFIG_CPU_HAS_MSA=y
 CONFIG_NUMA=y
@@ -128,7 +131,6 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_VSOCKETS=m
 CONFIG_VIRTIO_VSOCKETS=m
-CONFIG_BPF_JIT=y
 CONFIG_CFG80211=m
 CONFIG_CFG80211_WEXT=y
 CONFIG_MAC80211=m
@@ -143,7 +145,6 @@ CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_MTD=m
 CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_CRYPTOLOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_VIRTIO_BLK=y
@@ -197,7 +198,6 @@ CONFIG_VIRTIO_NET=m
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CHELSIO is not set
 # CONFIG_NET_VENDOR_CIRRUS is not set
 # CONFIG_NET_VENDOR_CISCO is not set
@@ -218,6 +218,7 @@ CONFIG_IXGBE=y
 # CONFIG_NET_VENDOR_NVIDIA is not set
 # CONFIG_NET_VENDOR_OKI is not set
 # CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_RDC is not set
 CONFIG_8139CP=m
 CONFIG_8139TOO=m
@@ -268,7 +269,6 @@ CONFIG_SERIAL_OF_PLATFORM=y
 CONFIG_SERIAL_NONSTANDARD=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_HW_RANDOM=y
-CONFIG_RAW_DRIVER=m
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_PIIX4=y
 CONFIG_GPIO_LOONGSON=y
@@ -404,5 +404,3 @@ CONFIG_DEBUG_FS=y
 # CONFIG_DEBUG_PREEMPT is not set
 CONFIG_FUNCTION_TRACER=y
 CONFIG_FTRACE_SYSCALLS=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ieee754=relaxed"
diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h
index 8c56b862fd9c..798bc3c68080 100644
--- a/arch/mips/include/asm/setup.h
+++ b/arch/mips/include/asm/setup.h
@@ -5,6 +5,7 @@
 #include <linux/types.h>
 #include <uapi/asm/setup.h>
 
+#ifndef __ASSEMBLY__
 extern void prom_putchar(char);
 extern void setup_early_printk(void);
 
@@ -27,5 +28,6 @@ extern unsigned long ebase;
 extern unsigned int hwrena;
 extern void per_cpu_trap_init(bool);
 extern void cpu_cache_init(void);
+#endif
 
 #endif /* __SETUP_H */
diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
index 56b51de2dc51..e73bff474a08 100644
--- a/arch/mips/kernel/relocate.c
+++ b/arch/mips/kernel/relocate.c
@@ -23,6 +23,7 @@
 #include <linux/start_kernel.h>
 #include <linux/string.h>
 #include <linux/printk.h>
+#include <linux/cmdline.h>
 
 #define RELOCATED(x) ((void *)((long)x + offset))
 
@@ -247,16 +248,26 @@ static inline __init bool kaslr_disabled(void)
 	char *str;
 
 #if defined(CONFIG_CMDLINE_BOOL)
-	const char *builtin_cmdline = CONFIG_CMDLINE;
+	char *builtin_cmdline = CMDLINE_PREPEND;
 
 	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) == ' '))
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		str = strstr(arcs_cmdline, "nokaslr");
+		if (str == arcs_cmdline || (str > arcs_cmdline && *(str - 1) == ' '))
+			return true;
+	}
+
+#if defined(CONFIG_CMDLINE_BOOL)
+	builtin_cmdline = CMDLINE_APPEND;
+	str = strstr(builtin_cmdline, "nokaslr");
+	if (str == builtin_cmdline ||
+	    (str > builtin_cmdline && *(str - 1) == ' '))
 		return true;
+#endif
 
 	return false;
 }
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 2ca156a5b231..f43c599068be 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -23,6 +23,7 @@
 #include <linux/debugfs.h>
 #include <linux/kexec.h>
 #include <linux/sizes.h>
+#include <linux/cmdline.h>
 #include <linux/device.h>
 #include <linux/dma-map-ops.h>
 #include <linux/decompress/generic.h>
@@ -67,12 +68,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.
@@ -557,27 +552,7 @@ 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)) {
-		strscpy(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))
-		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-	else
-		boot_command_line[0] = 0;
+	boot_command_line[0] = 0;
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 	/*
@@ -600,12 +575,9 @@ static void __init bootcmdline_init(void)
 		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.
+	 * Use the generic system for builtin prepend and append.
 	 */
-	if (IS_ENABLED(CONFIG_CMDLINE_BOOL) &&
-	    !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
-		bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE);
+	cmdline_add_builtin(boot_command_line);
 }
 
 /*
diff --git a/arch/mips/pic32/pic32mzda/early_console.c b/arch/mips/pic32/pic32mzda/early_console.c
index 25372e62783b..213e318d7ad4 100644
--- a/arch/mips/pic32/pic32mzda/early_console.c
+++ b/arch/mips/pic32/pic32mzda/early_console.c
@@ -76,7 +76,7 @@ static char * __init pic32_getcmdline(void)
 	 * command line setup if using CONFIG_CMDLINE_BOOL.
 	 */
 #ifdef CONFIG_CMDLINE_OVERRIDE
-	return CONFIG_CMDLINE;
+	return CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND;
 #else
 	return fw_getcmdline();
 #endif
diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c
index d9c8c4e46aff..e4eac5e1f95f 100644
--- a/arch/mips/pic32/pic32mzda/init.c
+++ b/arch/mips/pic32/pic32mzda/init.c
@@ -9,6 +9,7 @@
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
 #include <linux/platform_data/sdhci-pic32.h>
+#include <linux/cmdline.h>
 
 #include <asm/fw/fw.h>
 #include <asm/mips-boards/generic.h>
@@ -41,7 +42,7 @@ void __init plat_mem_setup(void)
 	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);
+	pr_info(" builtin_cmdline  : %s\n", CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND);
 #endif
 	if (dtb != __dtb_start)
 		strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-- 
2.25.1


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

* [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line
  2021-04-16  4:09 [PATCH 0/8] generic command line v4 Daniel Walker
@ 2021-04-16  4:09 ` Daniel Walker
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Walker @ 2021-04-16  4:09 UTC (permalink / raw)
  To: Will Deacon, Christophe Leroy, Rob Herring, Daniel Gimpelevich,
	Andrew Morton, x86, linux-mips, linuxppc-dev,
	Thomas Bogendoerfer, Florian Fainelli, bcm-kernel-feedback-list
  Cc: xe-linux-external, Ruslan Ruslichenko, Ruslan Bilovol,
	linux-kernel, linux-arm-kernel

This updates the mips code to use the CONFIG_GENERIC_CMDLINE
option.

This deletes the option for MIPS_CMDLINE_BUILTIN_EXTEND
and replaces the functionality with generic code.

Of note, the pic32 has some strange handling of the current built
in command line. It was converted to use the static variant which
can't be updated after compilation. It should eventually be updated
to use to append and prepend symbols.

This includes a scripted mass convert of the config files to use
the new generic cmdline. There is a bit of a trim effect here.
It would seems that some of the config haven't been trimmed in
a while.

The script used is as follows,

if [[ -z "$1" || -z "$2" ]]; then
        echo "Two arguments are needed."
        exit 1
fi
mkdir $1
cp $2 $1/.config
sed -i 's/CONFIG_CMDLINE=/CONFIG_CMDLINE_BOOL=y\nCONFIG_CMDLINE_PREPEND=/g' $1/.config
make ARCH=$1 O=$1 olddefconfig
make ARCH=$1 O=$1 savedefconfig
cp $1/defconfig $2
rm -Rf $1

Cc: xe-linux-external@cisco.com
Signed-off-by: Ruslan Ruslichenko <rruslich@cisco.com>
Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
Signed-off-by: Daniel Walker <danielwa@cisco.com>
---
 arch/mips/Kconfig                         |  4 +--
 arch/mips/Kconfig.debug                   | 44 -----------------------
 arch/mips/configs/ar7_defconfig           |  9 ++---
 arch/mips/configs/bcm47xx_defconfig       |  8 ++---
 arch/mips/configs/bcm63xx_defconfig       | 15 +++-----
 arch/mips/configs/bmips_be_defconfig      | 11 +++---
 arch/mips/configs/bmips_stb_defconfig     | 11 +++---
 arch/mips/configs/capcella_defconfig      | 11 ++----
 arch/mips/configs/ci20_defconfig          | 10 +++---
 arch/mips/configs/cu1000-neo_defconfig    | 10 +++---
 arch/mips/configs/cu1830-neo_defconfig    | 10 +++---
 arch/mips/configs/e55_defconfig           |  4 +--
 arch/mips/configs/generic_defconfig       |  6 ++--
 arch/mips/configs/gpr_defconfig           | 18 ++--------
 arch/mips/configs/loongson3_defconfig     | 13 ++-----
 arch/mips/configs/mpc30x_defconfig        |  7 ++--
 arch/mips/configs/tb0219_defconfig        |  7 ++--
 arch/mips/configs/tb0226_defconfig        |  7 ++--
 arch/mips/configs/tb0287_defconfig        |  7 ++--
 arch/mips/configs/workpad_defconfig       | 11 +++---
 arch/mips/include/asm/setup.h             |  2 ++
 arch/mips/kernel/relocate.c               | 17 +++++++--
 arch/mips/kernel/setup.c                  | 36 +++----------------
 arch/mips/pic32/pic32mzda/early_console.c |  2 +-
 arch/mips/pic32/pic32mzda/init.c          |  3 +-
 25 files changed, 78 insertions(+), 205 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index d89efba3d8a4..0e753894d28d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -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
@@ -3212,9 +3213,6 @@ choice
 	config MIPS_CMDLINE_FROM_BOOTLOADER
 		bool "Bootloader kernel arguments if available"
 
-	config MIPS_CMDLINE_BUILTIN_EXTEND
-		depends on CMDLINE_BOOL
-		bool "Extend builtin kernel arguments with bootloader arguments"
 endchoice
 
 endmenu
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 7a8d94cdd493..b5a099c74eb6 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -30,50 +30,6 @@ config EARLY_PRINTK_8250
 config USE_GENERIC_EARLY_PRINTK_8250
 	bool
 
-config CMDLINE_BOOL
-	bool "Built-in kernel command line"
-	help
-	  For most systems, it is firmware or second stage bootloader that
-	  by default specifies the kernel command line options.  However,
-	  it might be necessary or advantageous to either override the
-	  default kernel command line or add a few extra options to it.
-	  For such cases, this option allows you to hardcode your own
-	  command line options directly into the kernel.  For that, you
-	  should choose 'Y' here, and fill in the extra boot arguments
-	  in CONFIG_CMDLINE.
-
-	  The built-in options will be concatenated to the default command
-	  line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
-	  command line will be ignored and replaced by the built-in string.
-
-	  Most MIPS systems will normally expect 'N' here and rely upon
-	  the command line from the firmware or the second-stage bootloader.
-
-config CMDLINE
-	string "Default kernel command string"
-	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, and for the cases
-	  when you want to add some extra options to the command line or ignore
-	  the default command line, 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.
-
-	  For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
-	  options.
-
-config CMDLINE_OVERRIDE
-	bool "Built-in command line overrides firmware arguments"
-	depends on CMDLINE_BOOL
-	help
-	  By setting this option to 'Y' you will have your kernel ignore
-	  command line arguments from firmware or second stage bootloader.
-	  Instead, the built-in command line will be used exclusively.
-
-	  Normally, you will choose 'N' here.
-
 config SB1XXX_CORELIS
 	bool "Corelis Debugger"
 	depends on SIBYTE_SB1xxx_SOC
diff --git a/arch/mips/configs/ar7_defconfig b/arch/mips/configs/ar7_defconfig
index cf9c6329b807..c09470aa672f 100644
--- a/arch/mips/configs/ar7_defconfig
+++ b/arch/mips/configs/ar7_defconfig
@@ -12,6 +12,8 @@ CONFIG_EXPERT=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="rootfstype=squashfs,jffs2"
 CONFIG_AR7=y
 CONFIG_HZ_100=y
 CONFIG_KEXEC=y
@@ -32,9 +34,6 @@ CONFIG_IP_ROUTE_MULTIPATH=y
 CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_MROUTE=y
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 CONFIG_TCP_CONG_ADVANCED=y
 # CONFIG_TCP_CONG_BIC is not set
@@ -43,7 +42,6 @@ CONFIG_TCP_CONG_WESTWOOD=y
 # CONFIG_TCP_CONG_HTCP is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETFILTER=y
-# CONFIG_BRIDGE_NETFILTER is not set
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_MARK=y
 CONFIG_NF_CONNTRACK_FTP=m
@@ -117,8 +115,5 @@ CONFIG_JFFS2_SUMMARY=y
 CONFIG_JFFS2_COMPRESSION_OPTIONS=y
 CONFIG_SQUASHFS=y
 # CONFIG_CRYPTO_HW is not set
-# 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"
diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig
index 91ce75edbfb4..69a965bb2dd9 100644
--- a/arch/mips/configs/bcm47xx_defconfig
+++ b/arch/mips/configs/bcm47xx_defconfig
@@ -4,8 +4,9 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_EMBEDDED=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
 CONFIG_BCM47XX=y
-CONFIG_PCI=y
 # CONFIG_SUSPEND is not set
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
@@ -32,6 +33,7 @@ CONFIG_NET_SCH_FQ_CODEL=y
 CONFIG_HAMRADIO=y
 CONFIG_CFG80211=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
 CONFIG_MTD=y
 CONFIG_MTD_BCM47XX_PARTS=y
 CONFIG_MTD_BLOCK=y
@@ -75,7 +77,5 @@ CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO=y
 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"
+CONFIG_DEBUG_FS=y
diff --git a/arch/mips/configs/bcm63xx_defconfig b/arch/mips/configs/bcm63xx_defconfig
index 861f680184b9..6791e48b2d7d 100644
--- a/arch/mips/configs/bcm63xx_defconfig
+++ b/arch/mips/configs/bcm63xx_defconfig
@@ -11,27 +11,26 @@ CONFIG_EXPERT=y
 # CONFIG_AIO is not set
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200"
 CONFIG_BCM63XX=y
 CONFIG_BCM63XX_CPU_6338=y
 CONFIG_BCM63XX_CPU_6345=y
 CONFIG_BCM63XX_CPU_6348=y
 CONFIG_BCM63XX_CPU_6358=y
 # CONFIG_SECCOMP is not set
-CONFIG_PCI=y
-CONFIG_PCCARD=y
-CONFIG_PCMCIA_BCM63XX=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_NET=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
+CONFIG_PCCARD=y
+CONFIG_PCMCIA_BCM63XX=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 CONFIG_MTD=y
@@ -50,8 +49,6 @@ CONFIG_B43=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
-CONFIG_SERIAL_BCM63XX=y
-CONFIG_SERIAL_BCM63XX_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
 # CONFIG_VGA_ARB is not set
@@ -65,5 +62,3 @@ 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"
diff --git a/arch/mips/configs/bmips_be_defconfig b/arch/mips/configs/bmips_be_defconfig
index 032bb51defe8..ae1c4adf8d98 100644
--- a/arch/mips/configs/bmips_be_defconfig
+++ b/arch/mips/configs/bmips_be_defconfig
@@ -5,21 +5,20 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_BMIPS_GENERIC=y
 CONFIG_HIGHMEM=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=4
-# CONFIG_SECCOMP is not set
 CONFIG_MIPS_O32_FP64_SUPPORT=y
+# CONFIG_SECCOMP is not set
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
@@ -73,7 +72,5 @@ CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
 # CONFIG_CRYPTO_HW is not set
 CONFIG_PRINTK_TIME=y
-CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon"
+CONFIG_DEBUG_FS=y
diff --git a/arch/mips/configs/bmips_stb_defconfig b/arch/mips/configs/bmips_stb_defconfig
index 625bd2d7e685..cb3b114b10d0 100644
--- a/arch/mips/configs/bmips_stb_defconfig
+++ b/arch/mips/configs/bmips_stb_defconfig
@@ -5,12 +5,13 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_BMIPS_GENERIC=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_HIGHMEM=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=4
-# CONFIG_SECCOMP is not set
 CONFIG_MIPS_O32_FP64_SUPPORT=y
 CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_STAT=y
@@ -20,15 +21,13 @@ CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
 CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
 CONFIG_BMIPS_CPUFREQ=y
+# CONFIG_SECCOMP is not set
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_DIAG is not set
 CONFIG_CFG80211=y
 CONFIG_NL80211_TESTMODE=y
@@ -84,7 +83,5 @@ CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
 # CONFIG_CRYPTO_HW is not set
 CONFIG_PRINTK_TIME=y
-CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="earlycon"
+CONFIG_DEBUG_FS=y
diff --git a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
index 7bf8971af53b..a8b87cccfade 100644
--- a/arch/mips/configs/capcella_defconfig
+++ b/arch/mips/configs/capcella_defconfig
@@ -2,6 +2,8 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="mem=32M console=ttyVR0,38400"
 CONFIG_MACH_VR41XX=y
 CONFIG_ZAO_CAPCELLA=y
 CONFIG_MODULES=y
@@ -20,9 +22,6 @@ CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_BOOTP=y
-CONFIG_INET_XFRM_MODE_TRANSPORT=m
-CONFIG_INET_XFRM_MODE_TUNNEL=m
-CONFIG_INET_XFRM_MODE_BEET=m
 CONFIG_TCP_MD5SIG=y
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
@@ -73,19 +72,13 @@ CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_SHA512=m
 CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
-CONFIG_CRYPTO_ANUBIS=m
-CONFIG_CRYPTO_ARC4=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAMELLIA=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
 CONFIG_CRYPTO_DES=m
 CONFIG_CRYPTO_FCRYPT=m
-CONFIG_CRYPTO_KHAZAD=m
 CONFIG_CRYPTO_SERPENT=m
-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"
diff --git a/arch/mips/configs/ci20_defconfig b/arch/mips/configs/ci20_defconfig
index ab7ebb066834..28e72ae87ca9 100644
--- a/arch/mips/configs/ci20_defconfig
+++ b/arch/mips/configs/ci20_defconfig
@@ -22,12 +22,14 @@ CONFIG_EMBEDDED=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon console=ttyS4,115200 clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_JZ4780_CI20=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
@@ -99,12 +101,12 @@ CONFIG_IR_GPIO_CIR=m
 CONFIG_IR_GPIO_TX=m
 CONFIG_MEDIA_SUPPORT=m
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_CH341=y
+CONFIG_JZ4770_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_JZ4740=y
@@ -138,7 +140,6 @@ CONFIG_JZ4780_NEMC=y
 CONFIG_PWM=y
 CONFIG_PWM_JZ4740=m
 CONFIG_JZ4780_EFUSE=y
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -151,7 +152,6 @@ CONFIG_CONFIGFS_FS=y
 CONFIG_UBIFS_FS=y
 CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_737=y
 CONFIG_NLS_CODEPAGE_775=y
@@ -203,5 +203,3 @@ 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"
diff --git a/arch/mips/configs/cu1000-neo_defconfig b/arch/mips/configs/cu1000-neo_defconfig
index 9d75f5b77d5d..e54e708783d9 100644
--- a/arch/mips/configs/cu1000-neo_defconfig
+++ b/arch/mips/configs/cu1000-neo_defconfig
@@ -19,12 +19,14 @@ CONFIG_EMBEDDED=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_X1000_CU1000_NEO=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
@@ -67,12 +69,12 @@ CONFIG_SENSORS_ADS7828=m
 CONFIG_WATCHDOG=y
 CONFIG_JZ4740_WDT=y
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_CH341=y
+CONFIG_JZ4770_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_JZ4740=y
@@ -87,7 +89,6 @@ CONFIG_DMA_JZ4780=y
 # CONFIG_INGENIC_TIMER is not set
 CONFIG_INGENIC_SYSOST=y
 # CONFIG_IOMMU_SUPPORT is not set
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -98,7 +99,6 @@ CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_NFS_FS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_936=y
 CONFIG_NLS_CODEPAGE_950=y
@@ -123,5 +123,3 @@ 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"
diff --git a/arch/mips/configs/cu1830-neo_defconfig b/arch/mips/configs/cu1830-neo_defconfig
index 29decd0003c6..06267749acc9 100644
--- a/arch/mips/configs/cu1830-neo_defconfig
+++ b/arch/mips/configs/cu1830-neo_defconfig
@@ -19,12 +19,14 @@ CONFIG_EMBEDDED=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon clk_ignore_unused"
 CONFIG_MACH_INGENIC_SOC=y
 CONFIG_X1830_CU1830_NEO=y
 CONFIG_HIGHMEM=y
 CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
 # CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
 CONFIG_MODULES=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
@@ -70,12 +72,12 @@ CONFIG_SENSORS_ADS7828=m
 CONFIG_WATCHDOG=y
 CONFIG_JZ4740_WDT=y
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_HID is not set
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_CH341=y
+CONFIG_JZ4770_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_JZ4740=y
@@ -90,7 +92,6 @@ CONFIG_DMA_JZ4780=y
 # CONFIG_INGENIC_TIMER is not set
 CONFIG_INGENIC_SYSOST=y
 # CONFIG_IOMMU_SUPPORT is not set
-CONFIG_JZ4770_PHY=y
 CONFIG_EXT4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_AUTOFS_FS=y
@@ -101,7 +102,6 @@ CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_NFS_FS=y
-CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_CODEPAGE_936=y
 CONFIG_NLS_CODEPAGE_950=y
@@ -126,5 +126,3 @@ 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"
diff --git a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
index fd82b858a8f0..19769d645fcb 100644
--- a/arch/mips/configs/e55_defconfig
+++ b/arch/mips/configs/e55_defconfig
@@ -2,6 +2,8 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyVR0,19200 ide0=0x1f0,0x3f6,40 mem=8M"
 CONFIG_MACH_VR41XX=y
 CONFIG_CASIO_E55=y
 CONFIG_MODULES=y
@@ -33,5 +35,3 @@ 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"
diff --git a/arch/mips/configs/generic_defconfig b/arch/mips/configs/generic_defconfig
index 714169e411cf..665ae8d63ef3 100644
--- a/arch/mips/configs/generic_defconfig
+++ b/arch/mips/configs/generic_defconfig
@@ -3,7 +3,6 @@ CONFIG_NO_HZ_IDLE=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_MEMCG=y
-CONFIG_MEMCG_SWAP=y
 CONFIG_BLK_CGROUP=y
 CONFIG_CFS_BANDWIDTH=y
 CONFIG_RT_GROUP_SCHED=y
@@ -21,6 +20,8 @@ CONFIG_USERFAULTFD=y
 CONFIG_EMBEDDED=y
 # CONFIG_SLUB_DEBUG is not set
 # CONFIG_COMPAT_BRK is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="earlycon"
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_CPS=y
 CONFIG_HIGHMEM=y
@@ -52,7 +53,6 @@ CONFIG_HID_CHICONY=y
 CONFIG_HID_CYPRESS=y
 CONFIG_HID_EZKEY=y
 CONFIG_HID_KENSINGTON=y
-CONFIG_HID_LOGITECH=y
 CONFIG_HID_MICROSOFT=y
 CONFIG_HID_MONTEREY=y
 # CONFIG_MIPS_PLATFORM_DEVICES is not set
@@ -88,5 +88,3 @@ 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"
diff --git a/arch/mips/configs/gpr_defconfig b/arch/mips/configs/gpr_defconfig
index 5cb91509bb7c..cb642d14dd93 100644
--- a/arch/mips/configs/gpr_defconfig
+++ b/arch/mips/configs/gpr_defconfig
@@ -10,9 +10,10 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
 CONFIG_PROFILING=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyS0,115200 root=/dev/nfs rw ip=auto"
 CONFIG_MIPS_ALCHEMY=y
 CONFIG_MIPS_GPR=y
-CONFIG_PCI=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_PARTITION_ADVANCED=y
@@ -29,9 +30,6 @@ CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
 CONFIG_NETFILTER=y
@@ -49,7 +47,6 @@ CONFIG_NETFILTER_XT_MATCH_LIMIT=m
 CONFIG_NETFILTER_XT_MATCH_MAC=m
 CONFIG_NETFILTER_XT_MATCH_MARK=m
 CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
-CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
 CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
 CONFIG_NETFILTER_XT_MATCH_QUOTA=m
 CONFIG_NETFILTER_XT_MATCH_REALM=m
@@ -151,6 +148,7 @@ CONFIG_BAYCOM_SER_HDX=m
 CONFIG_YAM=m
 CONFIG_CFG80211=y
 CONFIG_MAC80211=y
+CONFIG_PCI=y
 CONFIG_MTD=y
 CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
@@ -225,9 +223,6 @@ CONFIG_HDLC_X25=m
 CONFIG_PCI200SYN=m
 CONFIG_WANXL=m
 CONFIG_FARSYNC=m
-CONFIG_DSCC4=m
-CONFIG_DSCC4_PCISYNC=y
-CONFIG_DSCC4_PCI_RST=y
 CONFIG_LAPBETHER=m
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
@@ -247,7 +242,6 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 CONFIG_SSB=m
 CONFIG_SSB_DRIVER_PCICORE=y
 # CONFIG_VGA_ARB is not set
-# CONFIG_LCD_CLASS_DEVICE is not set
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_USB_HID=m
@@ -295,16 +289,10 @@ CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_SHA512=m
 CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
-CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
-CONFIG_CRYPTO_KHAZAD=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_TEA=m
 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"
diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
index 0e79f81217bc..f3b8c64ea379 100644
--- a/arch/mips/configs/loongson3_defconfig
+++ b/arch/mips/configs/loongson3_defconfig
@@ -13,7 +13,6 @@ CONFIG_TASK_DELAY_ACCT=y
 CONFIG_TASK_XACCT=y
 CONFIG_TASK_IO_ACCOUNTING=y
 CONFIG_MEMCG=y
-CONFIG_MEMCG_SWAP=y
 CONFIG_BLK_CGROUP=y
 CONFIG_CGROUP_PIDS=y
 CONFIG_CGROUP_FREEZER=y
@@ -28,6 +27,8 @@ CONFIG_RELAY=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="ieee754=relaxed"
 CONFIG_MACH_LOONGSON64=y
 CONFIG_CPU_HAS_MSA=y
 CONFIG_NR_CPUS=16
@@ -39,7 +40,6 @@ CONFIG_MIPS32_O32=y
 CONFIG_MIPS32_N32=y
 CONFIG_VIRTUALIZATION=y
 CONFIG_KVM=m
-CONFIG_KVM_MIPS_VZ=y
 CONFIG_MODULES=y
 CONFIG_MODULE_FORCE_LOAD=y
 CONFIG_MODULE_UNLOAD=y
@@ -204,7 +204,6 @@ CONFIG_VIRTIO_NET=m
 # CONFIG_NET_VENDOR_DEC is not set
 # CONFIG_NET_VENDOR_DLINK is not set
 # CONFIG_NET_VENDOR_EMULEX is not set
-# CONFIG_NET_VENDOR_HP is not set
 # CONFIG_NET_VENDOR_I825XX is not set
 CONFIG_E1000=y
 CONFIG_E1000E=y
@@ -246,7 +245,6 @@ CONFIG_PPP_ASYNC=m
 CONFIG_PPP_SYNC_TTY=m
 CONFIG_ATH9K=m
 CONFIG_HOSTAP=m
-CONFIG_INPUT_POLLDEV=m
 CONFIG_INPUT_SPARSEKMAP=y
 CONFIG_INPUT_MOUSEDEV=y
 CONFIG_INPUT_MOUSEDEV_PSAUX=y
@@ -278,7 +276,6 @@ CONFIG_SENSORS_LM75=m
 CONFIG_SENSORS_LM93=m
 CONFIG_SENSORS_W83627HF=m
 CONFIG_MEDIA_SUPPORT=m
-CONFIG_MEDIA_CAMERA_SUPPORT=y
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_DRM=y
@@ -388,18 +385,14 @@ CONFIG_SECURITY_SELINUX=y
 CONFIG_SECURITY_SELINUX_BOOTPARAM=y
 CONFIG_SECURITY_SELINUX_DISABLE=y
 CONFIG_DEFAULT_SECURITY_DAC=y
-CONFIG_CRYPTO_AUTHENC=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_MD5=y
 CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
-CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
-CONFIG_CRYPTO_KHAZAD=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_PRINTK_TIME=y
@@ -408,5 +401,3 @@ 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"
diff --git a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
index d4e038802510..925e71b9a9a7 100644
--- a/arch/mips/configs/mpc30x_defconfig
+++ b/arch/mips/configs/mpc30x_defconfig
@@ -3,6 +3,8 @@ CONFIG_LOG_BUF_SHIFT=14
 CONFIG_RELAY=y
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="mem=32M console=ttyVR0,19200 ide0=0x170,0x376,73"
 CONFIG_MACH_VR41XX=y
 CONFIG_VICTOR_MPC30X=y
 CONFIG_MODULES=y
@@ -18,9 +20,6 @@ CONFIG_NET_KEY=y
 CONFIG_NET_KEY_MIGRATE=y
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
-CONFIG_INET_XFRM_MODE_TRANSPORT=m
-CONFIG_INET_XFRM_MODE_TUNNEL=m
-CONFIG_INET_XFRM_MODE_BEET=m
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
 CONFIG_CONNECTOR=m
@@ -49,5 +48,3 @@ 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"
diff --git a/arch/mips/configs/tb0219_defconfig b/arch/mips/configs/tb0219_defconfig
index 6547f84750b5..1d1bacd3eb2b 100644
--- a/arch/mips/configs/tb0219_defconfig
+++ b/arch/mips/configs/tb0219_defconfig
@@ -2,6 +2,8 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="cca=3 mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
 CONFIG_MACH_VR41XX=y
 CONFIG_TANBAC_TB0219=y
 CONFIG_MODULES=y
@@ -23,9 +25,6 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_NET_IPIP=m
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
 CONFIG_BLK_DEV_LOOP=m
@@ -73,5 +72,3 @@ 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"
diff --git a/arch/mips/configs/tb0226_defconfig b/arch/mips/configs/tb0226_defconfig
index 7e099f7c2286..072ac9fa92a7 100644
--- a/arch/mips/configs/tb0226_defconfig
+++ b/arch/mips/configs/tb0226_defconfig
@@ -2,6 +2,8 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="cca=3 mem=32M console=ttyVR0,115200"
 CONFIG_MACH_VR41XX=y
 CONFIG_TANBAC_TB0226=y
 CONFIG_MODULES=y
@@ -21,9 +23,6 @@ CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
 CONFIG_BLK_DEV_LOOP=m
@@ -68,5 +67,3 @@ 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"
diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig
index 0d881dd862c0..30b1b84fe46b 100644
--- a/arch/mips/configs/tb0287_defconfig
+++ b/arch/mips/configs/tb0287_defconfig
@@ -2,6 +2,8 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="cca=3 mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
 CONFIG_MACH_VR41XX=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
@@ -22,9 +24,6 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_NET_IPIP=m
 CONFIG_SYN_COOKIES=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 CONFIG_TCP_CONG_ADVANCED=y
 CONFIG_TCP_CONG_BIC=y
 CONFIG_TCP_CONG_CUBIC=m
@@ -81,5 +80,3 @@ 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"
diff --git a/arch/mips/configs/workpad_defconfig b/arch/mips/configs/workpad_defconfig
index 891a5f77305d..81bf360060a2 100644
--- a/arch/mips/configs/workpad_defconfig
+++ b/arch/mips/configs/workpad_defconfig
@@ -2,10 +2,10 @@ CONFIG_SYSVIPC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_EXPERT=y
 CONFIG_SLAB=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="console=ttyVR0,19200 ide0=0x170,0x376,49 mem=16M"
 CONFIG_MACH_VR41XX=y
 CONFIG_IBM_WORKPAD=y
-CONFIG_PCCARD=y
-CONFIG_PCMCIA_VRC4171=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
@@ -20,11 +20,10 @@ CONFIG_NET_KEY=y
 CONFIG_NET_KEY_MIGRATE=y
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
 CONFIG_NETWORK_SECMARK=y
+CONFIG_PCCARD=y
+CONFIG_PCMCIA_VRC4171=y
 CONFIG_BLK_DEV_RAM=m
 CONFIG_IDE=y
 CONFIG_BLK_DEV_IDECS=m
@@ -61,5 +60,3 @@ 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"
diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h
index bb36a400203d..085f0b503f07 100644
--- a/arch/mips/include/asm/setup.h
+++ b/arch/mips/include/asm/setup.h
@@ -5,6 +5,7 @@
 #include <linux/types.h>
 #include <uapi/asm/setup.h>
 
+#ifndef __ASSEMBLY__
 extern void prom_putchar(char);
 extern void setup_early_printk(void);
 
@@ -27,5 +28,6 @@ extern unsigned long ebase;
 extern unsigned int hwrena;
 extern void per_cpu_trap_init(bool);
 extern void cpu_cache_init(void);
+#endif
 
 #endif /* __SETUP_H */
diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
index 499a5357c09f..67ad1c481417 100644
--- a/arch/mips/kernel/relocate.c
+++ b/arch/mips/kernel/relocate.c
@@ -22,6 +22,7 @@
 #include <linux/start_kernel.h>
 #include <linux/string.h>
 #include <linux/printk.h>
+#include <linux/cmdline.h>
 
 #define RELOCATED(x) ((void *)((long)x + offset))
 
@@ -246,16 +247,26 @@ static inline __init bool kaslr_disabled(void)
 	char *str;
 
 #if defined(CONFIG_CMDLINE_BOOL)
-	const char *builtin_cmdline = CONFIG_CMDLINE;
+	char *builtin_cmdline = CMDLINE_PREPEND;
 
 	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) == ' '))
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		str = strstr(arcs_cmdline, "nokaslr");
+		if (str == arcs_cmdline || (str > arcs_cmdline && *(str - 1) == ' '))
+			return true;
+	}
+
+#if defined(CONFIG_CMDLINE_BOOL)
+	builtin_cmdline = CMDLINE_APPEND;
+	str = strstr(builtin_cmdline, "nokaslr");
+	if (str == builtin_cmdline ||
+	    (str > builtin_cmdline && *(str - 1) == ' '))
 		return true;
+#endif
 
 	return false;
 }
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 23a140327a0b..bbe1b34339ab 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -23,6 +23,7 @@
 #include <linux/debugfs.h>
 #include <linux/kexec.h>
 #include <linux/sizes.h>
+#include <linux/cmdline.h>
 #include <linux/device.h>
 #include <linux/dma-map-ops.h>
 #include <linux/decompress/generic.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,27 +541,7 @@ 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;
+	boot_command_line[0] = 0;
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 	/*
@@ -589,12 +564,9 @@ static void __init bootcmdline_init(void)
 		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.
+	 * Use the generic system for builtin prepend and append.
 	 */
-	if (IS_ENABLED(CONFIG_CMDLINE_BOOL) &&
-	    !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
-		bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE);
+	cmdline_add_builtin(boot_command_line);
 }
 
 /*
diff --git a/arch/mips/pic32/pic32mzda/early_console.c b/arch/mips/pic32/pic32mzda/early_console.c
index 25372e62783b..213e318d7ad4 100644
--- a/arch/mips/pic32/pic32mzda/early_console.c
+++ b/arch/mips/pic32/pic32mzda/early_console.c
@@ -76,7 +76,7 @@ static char * __init pic32_getcmdline(void)
 	 * command line setup if using CONFIG_CMDLINE_BOOL.
 	 */
 #ifdef CONFIG_CMDLINE_OVERRIDE
-	return CONFIG_CMDLINE;
+	return CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND;
 #else
 	return fw_getcmdline();
 #endif
diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c
index 764f2d022fae..9a3328ba8ea1 100644
--- a/arch/mips/pic32/pic32mzda/init.c
+++ b/arch/mips/pic32/pic32mzda/init.c
@@ -9,6 +9,7 @@
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
 #include <linux/platform_data/sdhci-pic32.h>
+#include <linux/cmdline.h>
 
 #include <asm/fw/fw.h>
 #include <asm/mips-boards/generic.h>
@@ -41,7 +42,7 @@ void __init plat_mem_setup(void)
 	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);
+	pr_info(" builtin_cmdline  : %s\n", CMDLINE_STATIC_PREPEND " " CMDLINE_STATIC_APPEND);
 #endif
 	if (dtb != __dtb_start)
 		strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-- 
2.25.1


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

end of thread, other threads:[~2023-12-12 17:26 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
2023-11-10 16:12   ` kernel test robot
2023-11-23  6:32   ` Christophe Leroy
2023-12-04 11:11   ` Jaskaran Singh
2023-11-10  1:38 ` [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability Daniel Walker
2023-11-23  6:33   ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol Daniel Walker
2023-11-23  6:34   ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker
2023-11-23  6:36   ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
2023-11-10  4:23   ` kernel test robot
2023-11-23  6:37   ` Christophe Leroy
2023-12-12  9:55   ` Ard Biesheuvel
2023-12-12 17:25     ` Daniel Walker (danielwa)
2023-11-10  1:38 ` [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line Daniel Walker
2023-11-10  7:17   ` kernel test robot
2023-11-10  1:38 ` [PATCH 7/8] of: replace command line handling Daniel Walker
2023-11-16 16:09   ` Rob Herring
2023-11-16 16:33     ` Daniel Walker (danielwa)
2023-11-23  6:39   ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line Daniel Walker
2023-11-23  6:39   ` Christophe Leroy
2023-11-10  1:51 ` [PATCH 0/8] generic command line v6 Andrew Morton
2023-11-10  2:22   ` Daniel Walker (danielwa)
2023-11-10  2:40     ` Andrew Morton
2023-11-23  6:23 ` Christophe Leroy
  -- strict thread matches above, loose matches on Subject: below --
2022-09-29  2:32 [PATCH 0/8] generic command line v5 Daniel Walker
2022-09-29  2:32 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker
2021-04-16  4:09 [PATCH 0/8] generic command line v4 Daniel Walker
2021-04-16  4:09 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker

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