Skip to contentSkip to conversation

arm64: Make CONFIG_CMDLINE behavior configurable

PATCH In review Matija Glavinic Pecotic 3 participants 6 messages Sep 29, 2020 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: Make CONFIG_CMDLINE behavior configurable

arm64 has no means to define behavior if CONFIG_CMDLINE is set as e.g. arm32 has. Parts of the kernel will ignore CMDLINE if behavior on how to treat is not specified, e.g.:

drivers/of/fdt.c:early_init_dt_scan_chosen:
#ifdef CONFIG_CMDLINE

  #if defined(CONFIG_CMDLINE_EXTEND)
        strlcat(data, " ", COMMAND_LINE_SIZE);
        strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #elif defined(CONFIG_CMDLINE_FORCE)
        strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #else
        /* No arguments from boot loader, use kernel's  cmdl*/
        if (!((char *)data)[0])
                strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);

#endif
#endif /* CONFIG_CMDLINE */

Sync behavior of arm64 with arm32 (and other platforms).

---
 arch/arm64/Kconfig | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +19 -1
index 6d232837cbee..0a03db76aa5a 100644
@@ -1824,14 +1824,32 @@ config CMDLINE
 	  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
+	depends on ATAGS
+
+config CMDLINE_FROM_BOOTLOADER
+	bool "Use bootloader kernel arguments if available"
+	help
+	  Uses the command-line options passed by the boot loader. If
+	  the boot loader doesn't provide any, the default kernel command
+	  string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+	bool "Extend bootloader kernel arguments"
+	help
+	  The command-line arguments provided by the boot loader will be
+	  appended to the default kernel command string.
+
 config CMDLINE_FORCE
 	bool "Always use the default kernel command string"
-	depends on CMDLINE != ""
 	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
Signature · 6 lines
2.28.0

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 50 lines · Matija Glavinic Pecotic

arm64 has no means to define behavior if CONFIG_CMDLINE is set as e.g. arm32 has. Parts of the kernel will ignore CMDLINE if behavior on how to treat is not specified, e.g.:

drivers/of/fdt.c:early_init_dt_scan_chosen:
#ifdef CONFIG_CMDLINE

  #if defined(CONFIG_CMDLINE_EXTEND)
        strlcat(data, " ", COMMAND_LINE_SIZE);
        strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #elif defined(CONFIG_CMDLINE_FORCE)
        strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #else
        /* No arguments from boot loader, use kernel's  cmdl*/
        if (!((char *)data)[0])
                strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);

#endif
#endif /* CONFIG_CMDLINE */

Sync behavior of arm64 with arm32 (and other platforms).

---
 arch/arm64/Kconfig | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +17 -0
index 6d232837cbee..0a03db76aa5a 100644
@@ -1824,14 +1824,32 @@ config CMDLINE
 	  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
+	depends on ATAGS
+
+config CMDLINE_FROM_BOOTLOADER
+	bool "Use bootloader kernel arguments if available"
+	help
+	  Uses the command-line options passed by the boot loader. If
+	  the boot loader doesn't provide any, the default kernel command
+	  string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+	bool "Extend bootloader kernel arguments"
+	help
+	  The command-line arguments provided by the boot loader will be
+	  appended to the default kernel command string.

arch/arm64/Kconfig config CMDLINE · line 1852

Quoted 10 lines
arch/arm64/Kconfig +2 -1
+
 config CMDLINE_FORCE
 	bool "Always use the default kernel command string"
-	depends on CMDLINE != ""
 	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

If multiple arches do the same thing, can we factor this out into a common Kconfig file somehow?

Cheers
---Dave

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

#2 lore raw
Quoted 2 lines · Dave Martin

If multiple arches do the same thing, can we factor this out into a common Kconfig file somehow?

Here is current situation across different archs:

aplha - no CMDLINE
arc - no CMDLINE
csky - no CMDLINE
h8300 - no CMDLINE
ia64 - no CMDLINE
m68k - no CMDLINE
nds32 - no CMDLINE
parisc - no CMDLINE
s390 - no CMDLINE
um - no CMDLINE

c6x - no EXTEND option, similar to current arm64 microblaze - no EXTEND option, similar to current arm64 (same as c6x)

hexagon - has non-configurable CMDLINE
openrisc - has non-configurable CMDLINE
sparc - has non-configurable CMDLINE
xtensa - has non-configurable CMDLINE

mips - similar feature set to arm32, different naming, arch specific nios2 - similar feature set to arm32, different naming, arch specific x86 - similar feature set to arm32, different naming, arch specific

powerpc - same as arm32
riscv - same as arm32 (with difference in FALLBACK == FROM_BOOTLOADER) sh - same as arm32

having above, I do not see feasible to factor out and apply to all of them, but to sync arm64 with arm, bringing this useful feature there.

Regards,

Matija

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

maintainer
#3 lore raw
In reply to Matija Glavinic Pecotic
Quoted 15 lines · Matija Glavinic Pecotic

arm64 has no means to define behavior if CONFIG_CMDLINE is set as e.g. arm32 has. Parts of the kernel will ignore CMDLINE if behavior on how to treat is not specified, e.g.:

drivers/of/fdt.c:early_init_dt_scan_chosen:
#ifdef CONFIG_CMDLINE

  #if defined(CONFIG_CMDLINE_EXTEND)
        strlcat(data, " ", COMMAND_LINE_SIZE);
        strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #elif defined(CONFIG_CMDLINE_FORCE)
        strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #else
        /* No arguments from boot loader, use kernel's  cmdl*/
        if (!((char *)data)[0])
                strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
Quoted 4 lines

#endif
#endif /* CONFIG_CMDLINE */

Sync behavior of arm64 with arm32 (and other platforms).

I think this came up in the past and was rejected. What is the use-case for all these combinations? Can you not fix the boot-loader? Sync'ing the arm64 and arm32 behaviour is not a goal, we try to get away from some old habits.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
Quoted 4 lines · Catalin Marinas

I think this came up in the past and was rejected. What is the use-case for all these combinations? Can you not fix the boot-loader? Sync'ing the arm64 and arm32 behaviour is not a goal, we try to get away from some old habits.

Having CMDLINE which only overrides bootloader's makes its application limited. In my experience, you often need to add something, rather to change everything. arm32 (along with mips, nios2, x86, ppc, riscv, sh) does correct action here. You can define CMDLINE, and further, you may choose best applicable way to use it. That would make CMDLINE fully serving its purpose as a config option.

One is not always able to fix or install bootloader or device tree as both may be e.g. in flash and not possible to change easily as kernel image. But I wouldn't go in that direction for justification here. We have kernel option which needs extension to be fully usable as other archs are doing so already. I don't see it as bad habit revival, but making this option more useful.

Regards,

Matija

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

#5 lore raw
In reply to Matija Glavinic Pecotic

arch/arm64/Kconfig config CMDLINE · line 1830

Quoted 12 lines · Matija Glavinic Pecotic
arch/arm64/Kconfig +4 -0
index 6d232837cbee..0a03db76aa5a 100644
@@ -1824,14 +1824,32 @@ config CMDLINE
 	  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
+	depends on ATAGS

I just noticed, ATAGS is surplus, needs to be removed.

Regards,

Matija

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