[PATCH] ARM: Fix support for CMDLINE_EXTEND

Yeking
2025-03-28T10:29:07Z

From: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>

It should be the default command line appended to the bootloader command
line, not the bootloader command line appended to the default command
line.

This will be consistent with the behavior of FDT, EFI, and other
platforms.

Fixes: 4394c1244249 ("ARM: 6893/1: Allow for kernel command line concatenation")
Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>
---
arch/arm/Kconfig | 4 ++--
arch/arm/kernel/atags_parse.c | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 25ed6f1a7c7a..635e4da33fff 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1534,8 +1534,8 @@ config CMDLINE_FROM_BOOTLOADER
config CMDLINE_EXTEND
bool "Extend bootloader kernel arguments"
help
- The command-line arguments provided by the boot loader will be
- appended to the default kernel command string.
+ The default kernel command string will be appended to the
+ command-line arguments provided by the boot loader.

config CMDLINE_FORCE
bool "Always use the default kernel command string"
diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c
index 4ec591bde3df..bd163f00602e 100644
--- a/arch/arm/kernel/atags_parse.c
+++ b/arch/arm/kernel/atags_parse.c
@@ -120,15 +120,15 @@ __tagtable(ATAG_REVISION, parse_tag_revision);

static int __init parse_tag_cmdline(const struct tag *tag)
{
-#if defined(CONFIG_CMDLINE_EXTEND)
- strlcat(default_command_line, " ", COMMAND_LINE_SIZE);
- strlcat(default_command_line, tag->u.cmdline.cmdline,
- COMMAND_LINE_SIZE);
-#elif defined(CONFIG_CMDLINE_FORCE)
+#if defined(CONFIG_CMDLINE_FORCE)
pr_warn("Ignoring tag cmdline (using the default kernel command line)\n");
#else
strscpy(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
+#if defined(CONFIG_CMDLINE_EXTEND)
+ strlcat(default_command_line, " ", COMMAND_LINE_SIZE);
+ strlcat(default_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif
#endif
return 0;
}
--
2.43.0