diff mbox series

arm64: Make CONFIG_CMDLINE behavior configurable

Message ID 55be67bb-338c-afa1-d863-7a82f9ba803f@nokia.com (mailing list archive)
State New, archived
Headers show
Series arm64: Make CONFIG_CMDLINE behavior configurable | expand

Commit Message

Matija Glavinic Pecotic Sept. 29, 2020, 8:46 a.m. UTC
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).

Signed-off-by: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
---
 arch/arm64/Kconfig | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Dave Martin Sept. 29, 2020, 10:41 a.m. UTC | #1
On Tue, Sep 29, 2020 at 10:46:09AM +0200, Matija Glavinic Pecotic wrote:
> 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).
> 
> Signed-off-by: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
> ---
>  arch/arm64/Kconfig | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 6d232837cbee..0a03db76aa5a 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -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

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

Cheers
---Dave
Matija Glavinic Pecotic Sept. 29, 2020, 12:34 p.m. UTC | #2
On 09/29/2020 12:41 PM, Dave Martin wrote:
> 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
Catalin Marinas Sept. 29, 2020, 5:43 p.m. UTC | #3
On Tue, Sep 29, 2020 at 10:46:09AM +0200, Matija Glavinic Pecotic wrote:
> 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).

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.
Matija Glavinic Pecotic Sept. 29, 2020, 7:09 p.m. UTC | #4
On 09/29/2020 10:46 AM, Matija Glavinic Pecotic wrote:
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 6d232837cbee..0a03db76aa5a 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -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
Matija Glavinic Pecotic Sept. 29, 2020, 7:12 p.m. UTC | #5
On 09/29/2020 07:43 PM, Catalin Marinas wrote:
> 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
diff mbox series

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 6d232837cbee..0a03db76aa5a 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -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