add generic builtin command line
PATCH 1/4 add generic builtin command line
This code allows architectures to use a generic builtin command line. The state of the builtin command line options across architecture is diverse. On x86 and mips they have pretty much the same code and the code prepends the builtin command line onto the boot loader provided one. On powerpc there is only a builtin override and nothing else.
The code in this commit unifies the mips and x86 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.
--- include/linux/cmdline.h | 69 +++++++++++++++++++++++++++++++++++++++++ init/Kconfig | 69 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 include/linux/cmdline.h
include/linux/cmdline.h new file +69 -0
@@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CMDLINE_H +#define _LINUX_CMDLINE_H + +/* +* +* Copyright (C) 2015. Cisco Systems, Inc. +* +* Generic Append/Prepend cmdline support. +*/ + +#if defined(CONFIG_GENERIC_CMDLINE ) && defined(CONFIG_CMDLINE_BOOL ) + +#ifndef CONFIG_CMDLINE_OVERRIDE +/* +* 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 +* @src: The starting string or NULL if there isn't one. +* @tmp: temporary space used for prepending +* @length: the maximum length of the strings above. +*/ +static inline void +_cmdline_add_builtin (char *dest,char *src,char *tmp,unsigned long length) +{ +if (src != dest && src !=NULL ) { +strlcpy (dest," " , length); +strlcat (dest, src, length); + } + +if (sizeof (CONFIG_CMDLINE_APPEND ) >1 ) +strlcat (dest," " CONFIG_CMDLINE_APPEND , length); + +if (sizeof (CONFIG_CMDLINE_PREPEND ) >1 ) { +strlcpy (tmp,CONFIG_CMDLINE_PREPEND " " , length); +strlcat (tmp, dest, length); +strlcpy (dest, tmp, length); + } +} + +#define cmdline_add_builtin_section (dest, src, length, section) \ +{ \ + if (sizeof(CONFIG_CMDLINE_PREPEND) > 1) { \ + static char cmdline_tmp_space[length] section; \ + _cmdline_add_builtin(dest, src, cmdline_tmp_space, length); \ + } else { \ + _cmdline_add_builtin(dest, src, NULL, length); \ + } \ +} +#else +#define cmdline_add_builtin_section (dest, src, length, section) \ +{ \ + strlcpy(dest, CONFIG_CMDLINE_PREPEND " " CONFIG_CMDLINE_APPEND, \ + length); \ +} +#endif /* !CONFIG_CMDLINE_OVERRIDE */ + +#else +#define cmdline_add_builtin_section (dest, src, length, section) { \ + if (src != NULL) \ + strlcpy(dest, src, length); \ +} +#endif /* CONFIG_GENERIC_CMDLINE */ + +#define cmdline_add_builtin (dest, src, length) \ + cmdline_add_builtin_section(dest, src, length, __initdata) + +#endif /* _LINUX_CMDLINE_H */
init/Kconfig +69 -0
75 lines not on this page · raw message
Signature · 1 line
2.19.1
Quoted 1 line · On Tue, 19 Mar 2019 16:24:45 -0700 Daniel Walker <[email protected]> wrote:
This code allows architectures to use a generic builtin command line.
I wasn't cc'ed on [2/4]. No mailing lists were cc'ed on [0/4] but it didn't say anything useful anyway ;)
I'll queue them up for testing and shall await feedback from the powerpc developers.
Quoted 10 lines · Andrew Morton
Quoted 1 line · On Tue, 19 Mar 2019 16:24:45 -0700 Daniel Walker <[email protected]> wrote:
This code allows architectures to use a generic builtin command line.
I wasn't cc'ed on [2/4]. No mailing lists were cc'ed on [0/4] but it didn't say anything useful anyway ;)
I'll queue them up for testing and shall await feedback from the powerpc developers.
You weren't CC'd , but it was To: you,
35 From: Daniel Walker <[email protected]> 36 To: Andrew Morton <[email protected]>,
37 Christophe Leroy <[email protected]>, 38 Michael Ellerman <[email protected]>, 39 Rob Herring <[email protected]>, [email protected], 40 [email protected], Frank Rowand <[email protected]>
41 Cc: [email protected], [email protected] 42 Subject: [PATCH 2/4] drivers: of: generic command line support
and the first one [0/4] should have went to the linuxppc-dev , and xe-linux-external. Maybe our git-send-email isn't working with our mail servers.
Thanks for picking it up.
Daniel
Quoted 14 lines · On Wed, 20 Mar 2019 16:23:28 -0700 Daniel Walker <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 1 line · On Tue, 19 Mar 2019 16:24:45 -0700 Daniel Walker <[email protected]> wrote:
This code allows architectures to use a generic builtin command line.
I wasn't cc'ed on [2/4]. No mailing lists were cc'ed on [0/4] but it didn't say anything useful anyway ;)
I'll queue them up for testing and shall await feedback from the powerpc developers.
You weren't CC'd , but it was To: you,
Quoted 8 lines
35 From: Daniel Walker <[email protected]> 36 To: Andrew Morton <[email protected]>,
37 Christophe Leroy <[email protected]>, 38 Michael Ellerman <[email protected]>, 39 Rob Herring <[email protected]>, [email protected], 40 [email protected], Frank Rowand <[email protected]>41 Cc: [email protected], [email protected] 42 Subject: [PATCH 2/4] drivers: of: generic command line support
hm.
Quoted 1 line
Thanks for picking it up.
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Quoted 25 lines · Andrew Morton
Quoted 14 lines · On Wed, 20 Mar 2019 16:23:28 -0700 Daniel Walker <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 1 line · On Tue, 19 Mar 2019 16:24:45 -0700 Daniel Walker <[email protected]> wrote:
This code allows architectures to use a generic builtin command line.
I wasn't cc'ed on [2/4]. No mailing lists were cc'ed on [0/4] but it didn't say anything useful anyway ;)
I'll queue them up for testing and shall await feedback from the powerpc developers.
You weren't CC'd , but it was To: you,
Quoted 8 lines
35 From: Daniel Walker <[email protected]> 36 To: Andrew Morton <[email protected]>,
37 Christophe Leroy <[email protected]>, 38 Michael Ellerman <[email protected]>, 39 Rob Herring <[email protected]>, [email protected], 40 [email protected], Frank Rowand <[email protected]>41 Cc: [email protected], [email protected] 42 Subject: [PATCH 2/4] drivers: of: generic command line support
Quoted 6 lines
hm.
Quoted 1 line
Thanks for picking it up.
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Those are from my tree, but I remove them when you picked up the series. The next linux-next should not have them.
Daniel
Quoted 5 lines · On Thu, 21 Mar 2019 08:13:08 -0700 Daniel Walker <[email protected]> wrote:
Quoted 2 lines
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Those are from my tree, but I remove them when you picked up the series. The next linux-next should not have them.
Yup, thanks, all looks good now.
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 21 Mar 2019 08:13:08 -0700 Daniel Walker <[email protected]> wrote:
Quoted 2 lines · Andrew Morton
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Those are from my tree, but I remove them when you picked up the series. The next linux-next should not have them.
Yup, thanks, all looks good now.
This patchset is currently neither in mainline nor in -next. May I ask what happened to it? Thanks.
Daniel Gimpelevich <[email protected]> a écrit :
Quoted 6 lines · Andrew Morton
Quoted 5 lines · On Thu, 21 Mar 2019 08:13:08 -0700 Daniel Walker <[email protected]> wrote:
Quoted 4 lines · Andrew Morton
Quoted 2 lines
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Those are from my tree, but I remove them when you picked up the
series. The
Quoted 1 line
next linux-next should not have them.
Yup, thanks, all looks good now.
This patchset is currently neither in mainline nor in -next. May I ask what happened to it? Thanks.
As far as I remember, there has been a lot of discussion around this series.
As of today, it doesn't apply cleanly anymore and would require rebasing.
I'd suggest also to find the good arguments to convince us that this series has a real added value, not just "cisco use it in its kernels so it is good".
I proposed an alternative at https://patchwork.ozlabs.org/project/linuxppc-dev/cover/[email protected]/ but never got any feedback so I gave up.
If you submit a new series, don't forget to copy ppclinux-dev and linux-arch lists.
Christophe
Quoted 3 lines · Christophe Leroy
I'd suggest also to find the good arguments to convince us that this series has a real added value, not just "cisco use it in its kernels so it is good".
Well, IIRC, this series was endorsed by the device tree maintainers as the preferred alternative to this:
The now-defunct patchwork.linux-mips.org link in that thread pointed to:
https://lore.kernel.org/linux-mips/1510796793.16864.25.camel@chimera/T/#u
When running modern kernels from ancient vendor bootloaders, it is sometimes necessary to pick and choose bits and pieces of the info they pass without taking it verbatim.
Quoted 6 lines · Daniel Gimpelevich
Quoted 5 lines · Andrew Morton
Quoted 4 lines · On Thu, 21 Mar 2019 08:13:08 -0700 Daniel Walker <[email protected]> wrote:
Quoted 2 lines · Andrew Morton
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Those are from my tree, but I remove them when you picked up the series. The next linux-next should not have them.
Yup, thanks, all looks good now.
This patchset is currently neither in mainline nor in -next. May I ask what happened to it? Thanks.
It was dropped silently by Andrew at some point. I wasn't watching -next closely to know when. I have no idea why he dropped it.
We still use this series extensively in Cisco, and have extended it beyond this current series.
We can re-submit.
Daniel
Quoted 6 lines · On Mon, 15 Feb 2021 11:32:01 -0800 Daniel Gimpelevich…
Quoted 5 lines · Andrew Morton
Quoted 4 lines · On Thu, 21 Mar 2019 08:13:08 -0700 Daniel Walker <[email protected]> wrote:
Quoted 2 lines · Andrew Morton
The patches (or some version of them) are already in linux-next, which messes me up. I'll disable them for now.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Those are from my tree, but I remove them when you picked up the series. The next linux-next should not have them.
Yup, thanks, all looks good now.
This patchset is currently neither in mainline nor in -next. May I ask what happened to it? Thanks.
Seems that I didn't bring them back after the confict with the powerpc tree resolved itself.
Please resend everything for -rc1 and let's await the reviewer feedback,
This seems quite useful. Can you please merge it?
Quoted 1 line · Tomas Mudrunka
This seems quite useful. Can you please merge it?
I need to re-send it before it can be merge. I'll try to update it soon.
Daniel
Hi Daniel
We have a usecase which requires this patch necessarily. For android usecases, we have two different build variants differentiated by defconfigs - production and debug. However, we only have a single dts for both these variants.
We want to enable certain features like page owner and slub debug which require cmdline params in addition to their respective configs to be enabled. Enabling page_owner and slub_debug options in dts file enables it for both production and debug variants. These features have significant memory overhead which are undesirable for our production environment. However, these are necessary for debug environment to enable internal testing and debug. Currently, android uses out-of-tree configs like CONFIG_CMDLINE_EXTEND to do so in gki_defconfig [1]. One option is to use CMDLINE_FORCE option which would enable these cmdline params but this disables the bootloader to add any additional cmdline params which may be necessary.
For such a usecase, the CONFIG_CMDLINE_PREPEND seems to be quite useful as it would help to stitch bootloader and the desired build variant's configs together. Can you please help to merge this patch?
Quoted 4 lines · Pratyush Brahma
For such a usecase, the
CONFIG_CMDLINE_PREPENDseems to be quite useful as it would help to stitch bootloader
and the desired build variant's configs together. Can you please help to merge this patch?
Yes, your at least the second person that's asked for it, and it's been on my list for some time to release again. I'll try to release it as soon as possible.
Daniel
Quoted 9 lines · Daniel Walker (danielwa)
Quoted 4 lines · Pratyush Brahma
For such a usecase, the
CONFIG_CMDLINE_PREPENDseems to be quite useful as it would help to stitch bootloader
and the desired build variant's configs together. Can you please help to merge this patch?Yes, your at least the second person that's asked for it, and it's been on my list for some time to release again. I'll try to release it as soon as possible.
Daniel
Thanks Daniel.
Please have this config support for arm64 as well. Previously arm64 used to support CONFIG_CMDLINE_EXTEND which was useful for our usecase. However it was dropped from commit cae118b6acc309539b33339e846cbb19187c164c referring to your patch series as an alternative. Hence the need.
Pratyush
Hi Pratyush,
Le 17/10/2023 à 12:40, Pratyush Brahma a écrit :
Quoted 23 lines
Hi Daniel
We have a usecase which requires this patch necessarily. For android usecases, we have two different build variants differentiated by defconfigs - production and debug. However, we only have a single dts for both these variants.
We want to enable certain features like page owner and slub debug which require cmdline params in addition to
their respective configs to be enabled. Enablingpage_ownerandslub_debugoptions in dts file enables it for both production and debug variants. These features have significant memory overhead which are undesirable for
our production environment. However, these are necessary for debug environment to enable internal testing and debug.
Currently, android uses out-of-tree configs likeCONFIG_CMDLINE_EXTENDto do so ingki_defconfig[1].
One option is to useCMDLINE_FORCEoption which would enable these cmdline params but this disables the bootloader to add
any additional cmdline params which may be necessary.
Quoted 4 lines
For such a usecase, the
CONFIG_CMDLINE_PREPENDseems to be quite useful as it would help to stitch bootloader
and the desired build variant's configs together. Can you please help to merge this patch?
As far as I remember, Daniel's proposal had some weaknesses that were never addressed. At that time I proposed an alternative series that was addressing most weaknesses, and my series was considered more mature that Daniel's one by several maintainers. But I never got enough feedback on it in order to finalise and merge it.
Could you have a look at it and tell if it fits your need ? See
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?state=*&series=237158
If it does, I can then rebase it on latest kernel and restart discussions in order to get it merged.
Thanks
Christophe
Quoted 5 lines · Christophe Leroy
As far as I remember, Daniel's proposal had some weaknesses that were never addressed. At that time I proposed an alternative series that was addressing most weaknesses, and my series was considered more mature that Daniel's one by several maintainers. But I never got enough feedback on it in order to finalise and merge it.
It does something entirely different and doesn't solve the problems .. Certain doesn't solve my problems.
Daniel