CMDLINE: powerpc: convert to generic builtin command line
PATCH 3/5 CMDLINE: powerpc: convert to generic builtin command line
This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE option.
--- arch/powerpc/Kconfig | 37 +-------------------------------- arch/powerpc/kernel/prom.c | 1 + arch/powerpc/kernel/prom_init.c | 31 +++++++++++++++------------ 3 files changed, 20 insertions(+), 49 deletions(-)
arch/powerpc/Kconfig +1 -36
@@ -167,6 +167,7 @@ config PPC select EDAC_SUPPORT select GENERIC_ATOMIC64 if PPC32 select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CMDLINE select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC
@@ -906,42 +907,6 @@ config PPC_DENORMALISATION Add support for handling denormalisation of single precision values. Useful for bare metal only. If unsure say Y here. -config CMDLINE - string "Initial kernel command string" - default "" - help - On some platforms, there is currently no way for the boot loader to - pass arguments to the kernel. For these platforms, you can supply - some command-line options at build time by entering them here. In - most cases you will need to specify the root device here. - -choice - prompt "Kernel command line type" if CMDLINE != "" - default CMDLINE_FROM_BOOTLOADER - -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" - 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 EXTRA_TARGETS string "Additional default image types" help
arch/powerpc/kernel/prom.c +1 -0
@@ -27,6 +27,7 @@#include <linux/irq.h> #include <linux/memblock.h> #include <linux/of.h> +#include <linux/cmdline.h> #include <linux/of_fdt.h> #include <linux/libfdt.h> #include <linux/cpu.h>
arch/powerpc/kernel/prom_init.c +18 -13
@@ -27,6 +27,7 @@#include <linux/initrd.h> #include <linux/bitops.h> #include <linux/pgtable.h> +#include <linux/cmdline.h> #include <asm/prom.h> #include <asm/rtas.h> #include <asm/page.h>
@@ -242,15 +243,6 @@ static int __init prom_strcmp(const char *cs, const char *ct)return 0 ; } -static char __init *prom_strcpy (char *dest,const char *src) -{ -char *tmp = dest; - -while ((*dest++ = *src++) !='\0' ) -/* nothing */ ; -return tmp; -} -static int __init prom_strncmp (const char *cs,const char *ct,size_t count) {unsigned char c1, c2;
@@ -276,6 +268,19 @@ static size_t __init prom_strlen(const char *s)return sc - s; } +static size_t __init prom_strlcpy (char *dest,const char *src,size_t size) +{ +size_t ret =prom_strlen (src); + +if (size) { +size_t len = (ret >= size) ? size -1 : ret; +memcpy (dest, src, len); + dest[len] ='\0' ; + } +return ret; +} + +static int __init prom_memcmp (const void *cs,const void *ct,size_t count) {const unsigned char *su1, *su2;
@@ -778,9 +783,9 @@ static void __init early_cmdline_parse(void)if (!IS_ENABLED (CONFIG_CMDLINE_FORCE ) && (long )prom.chosen >0 ) l =prom_getprop (prom.chosen,"bootargs" , p,COMMAND_LINE_SIZE -1 ); -if (IS_ENABLED (CONFIG_CMDLINE_EXTEND ) || l <=0 || p[0 ] =='\0' ) -prom_strlcat (prom_cmd_line," " CONFIG_CMDLINE , -sizeof (prom_cmd_line)); +if (l <=0 || p[0 ] =='\0' )/* dbl check */ +cmdline_add_builtin_custom (prom_cmd_line,NULL ,sizeof (prom_cmd_line), + __prombss, &prom_strlcpy, &prom_strlcat);prom_printf ("command line: %s\n" , prom_cmd_line);
@@ -2706,7 +2711,7 @@ static void __init flatten_device_tree(void)/* Add "phandle" in there, we'll need it */ namep =make_room (&mem_start, &mem_end,16 ,1 ); -prom_strcpy (namep,"phandle" ); +prom_strlcpy (namep,"phandle" ,8 ); mem_start = (unsigned long )namep +prom_strlen (namep) +1 ;/* Build string array */
Signature · 1 line
2.25.1
Le 04/03/2021 à 05:48, Daniel Walker a écrit :
Quoted 2 lines
This updates the powerpc code to use the
CONFIG_GENERIC_CMDLINEoption.
Should be split in two patches. The change of strcpy to strlcpy should go in a first patch.
Quoted 127 lines
Signed-off-by Ruslan Ruslichenko <[email protected]>Signed-off-by Ruslan Bilovol <[email protected]>Signed-off-by Daniel Walker <[email protected]>--- arch/powerpc/Kconfig | 37 +-------------------------------- arch/powerpc/kernel/prom.c | 1 + arch/powerpc/kernel/prom_init.c | 31 +++++++++++++++------------ 3 files changed, 20 insertions(+), 49 deletions(-)arch/powerpc/Kconfig +1
-36@@ -167,6 +167,7 @@ config PPC select EDAC_SUPPORT select GENERIC_ATOMIC64 if PPC32 select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CMDLINE select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC@@ -906,42 +907,6 @@ config PPC_DENORMALISATION Add support for handling denormalisation of single precision values. Useful for bare metal only. If unsure say Y here. -config CMDLINE - string "Initial kernel command string" - default "" - help - On some platforms, there is currently no way for the boot loader to - pass arguments to the kernel. For these platforms, you can supply - some command-line options at build time by entering them here. In - most cases you will need to specify the root device here. - -choice - prompt "Kernel command line type" if CMDLINE != "" - default CMDLINE_FROM_BOOTLOADER - -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" - 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 EXTRA_TARGETS string "Additional default image types" helparch/powerpc/kernel/prom.c +1
-0@@ -27,6 +27,7 @@#include <linux/irq.h> #include <linux/memblock.h> #include <linux/of.h> +#include <linux/cmdline.h> #include <linux/of_fdt.h> #include <linux/libfdt.h> #include <linux/cpu.h> arch/powerpc/kernel/prom_init.c +14
-9@@ -27,6 +27,7 @@#include <linux/initrd.h> #include <linux/bitops.h> #include <linux/pgtable.h> +#include <linux/cmdline.h> #include <asm/prom.h> #include <asm/rtas.h> #include <asm/page.h> @@ -242,15 +243,6 @@ static int __init prom_strcmp(const char *cs, const char *ct)return 0 ; } -static char __init *prom_strcpy (char *dest,const char *src) -{ -char *tmp = dest; - -while ((*dest++ = *src++) !='\0' ) -/* nothing */ ; -return tmp; -} -static int __init prom_strncmp (const char *cs,const char *ct,size_t count) {unsigned char c1, c2;@@ -276,6 +268,19 @@ static size_t __init prom_strlen(const char *s)return sc - s; } +static size_t __init prom_strlcpy (char *dest,const char *src,size_t size) +{ +size_t ret =prom_strlen (src); + +if (size) { +size_t len = (ret >= size) ? size -1 : ret; +memcpy (dest, src, len); + dest[len] ='\0' ; + } +return ret; +} + +static int __init prom_memcmp (const void *cs,const void *ct,size_t count) {const unsigned char *su1, *su2;
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 783
Quoted 1 line
arch/powerpc/kernel/prom_init.c +0
-0@@ -778,9 +783,9 @@ static void __init early_cmdline_parse(void)if (!IS_ENABLED (CONFIG_CMDLINE_FORCE ) && (long )prom.chosen >0 )
You have removed CONFIG_CMDLINE_FORCE and the generic cmdline doesn't provide it.
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 786
Quoted 6 lines
arch/powerpc/kernel/prom_init.c +1
-3l =prom_getprop (prom.chosen,"bootargs" , p,COMMAND_LINE_SIZE -1 ); -if (IS_ENABLED (CONFIG_CMDLINE_EXTEND ) || l <=0 || p[0 ] =='\0' ) -prom_strlcat (prom_cmd_line," " CONFIG_CMDLINE , -sizeof (prom_cmd_line)); +if (l <=0 || p[0 ] =='\0' )/* dbl check */
So it means cmdline_add_builtin_custom() is only called when bootloader does not provide bootargs ?
Quoted 15 lines
arch/powerpc/kernel/prom_init.c +3
-1+cmdline_add_builtin_custom (prom_cmd_line,NULL ,sizeof (prom_cmd_line), + __prombss, &prom_strlcpy, &prom_strlcat);prom_printf ("command line: %s\n" , prom_cmd_line);@@ -2706,7 +2711,7 @@ static void __init flatten_device_tree(void)/* Add "phandle" in there, we'll need it */ namep =make_room (&mem_start, &mem_end,16 ,1 ); -prom_strcpy (namep,"phandle" ); +prom_strlcpy (namep,"phandle" ,8 ); mem_start = (unsigned long )namep +prom_strlen (namep) +1 ;/* Build string array */
Le 04/03/2021 à 05:48, Daniel Walker a écrit :
Quoted 2 lines
This updates the powerpc code to use the
CONFIG_GENERIC_CMDLINEoption.
In file included from arch/powerpc/kernel/prom_init.c:30:arch/powerpc/kernel/prom_init.c: In function 'early_cmdline_parse':arch/powerpc/kernel/prom_init.c:788:17: error: lvalue required as unary '&' operand
788 | __prombss, &prom_strlcpy, &prom_strlcat);
| ^./include/linux/cmdline.h:66:3: note: in definition of macro 'cmdline_add_builtin_custom'
66 | strlcpy(dest, src, length); \
| ^~~~~~~
At top level:
arch/powerpc/kernel/prom_init.c:312:22: error: 'prom_strlcat' defined but not used [-Werror=unused-function]
312 | static size_t __init prom_strlcat(char *dest, const char *src, size_t count)
| ^~~~~~~~~~~~cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:279: arch/powerpc/kernel/prom_init.o] Error 1 make[1]: *** [scripts/Makefile.build:496: arch/powerpc/kernel] Error 2 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1805: arch/powerpc] Error 2
make: *** Waiting for unfinished jobs....
Quoted 149 lines
Signed-off-by Ruslan Ruslichenko <[email protected]>Signed-off-by Ruslan Bilovol <[email protected]>Signed-off-by Daniel Walker <[email protected]>--- arch/powerpc/Kconfig | 37 +-------------------------------- arch/powerpc/kernel/prom.c | 1 + arch/powerpc/kernel/prom_init.c | 31 +++++++++++++++------------ 3 files changed, 20 insertions(+), 49 deletions(-)arch/powerpc/Kconfig +1
-36@@ -167,6 +167,7 @@ config PPC select EDAC_SUPPORT select GENERIC_ATOMIC64 if PPC32 select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CMDLINE select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC@@ -906,42 +907,6 @@ config PPC_DENORMALISATION Add support for handling denormalisation of single precision values. Useful for bare metal only. If unsure say Y here. -config CMDLINE - string "Initial kernel command string" - default "" - help - On some platforms, there is currently no way for the boot loader to - pass arguments to the kernel. For these platforms, you can supply - some command-line options at build time by entering them here. In - most cases you will need to specify the root device here. - -choice - prompt "Kernel command line type" if CMDLINE != "" - default CMDLINE_FROM_BOOTLOADER - -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" - 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 EXTRA_TARGETS string "Additional default image types" helparch/powerpc/kernel/prom.c +1
-0@@ -27,6 +27,7 @@#include <linux/irq.h> #include <linux/memblock.h> #include <linux/of.h> +#include <linux/cmdline.h> #include <linux/of_fdt.h> #include <linux/libfdt.h> #include <linux/cpu.h> arch/powerpc/kernel/prom_init.c +18
-13@@ -27,6 +27,7 @@#include <linux/initrd.h> #include <linux/bitops.h> #include <linux/pgtable.h> +#include <linux/cmdline.h> #include <asm/prom.h> #include <asm/rtas.h> #include <asm/page.h> @@ -242,15 +243,6 @@ static int __init prom_strcmp(const char *cs, const char *ct)return 0 ; } -static char __init *prom_strcpy (char *dest,const char *src) -{ -char *tmp = dest; - -while ((*dest++ = *src++) !='\0' ) -/* nothing */ ; -return tmp; -} -static int __init prom_strncmp (const char *cs,const char *ct,size_t count) {unsigned char c1, c2;@@ -276,6 +268,19 @@ static size_t __init prom_strlen(const char *s)return sc - s; } +static size_t __init prom_strlcpy (char *dest,const char *src,size_t size) +{ +size_t ret =prom_strlen (src); + +if (size) { +size_t len = (ret >= size) ? size -1 : ret; +memcpy (dest, src, len); + dest[len] ='\0' ; + } +return ret; +} + +static int __init prom_memcmp (const void *cs,const void *ct,size_t count) {const unsigned char *su1, *su2;@@ -778,9 +783,9 @@ static void __init early_cmdline_parse(void)if (!IS_ENABLED (CONFIG_CMDLINE_FORCE ) && (long )prom.chosen >0 ) l =prom_getprop (prom.chosen,"bootargs" , p,COMMAND_LINE_SIZE -1 ); -if (IS_ENABLED (CONFIG_CMDLINE_EXTEND ) || l <=0 || p[0 ] =='\0' ) -prom_strlcat (prom_cmd_line," " CONFIG_CMDLINE , -sizeof (prom_cmd_line)); +if (l <=0 || p[0 ] =='\0' )/* dbl check */ +cmdline_add_builtin_custom (prom_cmd_line,NULL ,sizeof (prom_cmd_line), + __prombss, &prom_strlcpy, &prom_strlcat);prom_printf ("command line: %s\n" , prom_cmd_line);@@ -2706,7 +2711,7 @@ static void __init flatten_device_tree(void)/* Add "phandle" in there, we'll need it */ namep =make_room (&mem_start, &mem_end,16 ,1 ); -prom_strcpy (namep,"phandle" ); +prom_strlcpy (namep,"phandle" ,8 ); mem_start = (unsigned long )namep +prom_strlen (namep) +1 ;/* Build string array */
Le 04/03/2021 à 05:48, Daniel Walker a écrit :
Quoted 2 lines
This updates the powerpc code to use the
CONFIG_GENERIC_CMDLINEoption.
CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #143: FILE: arch/powerpc/kernel/prom_init.c:788:
+ cmdline_add_builtin_custom(prom_cmd_line, NULL, sizeof(prom_cmd_line),
+ __prombss, &prom_strlcpy, &prom_strlcat);
total: 0 errors, 0 warnings, 1 checks, 117 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
the.patch has style problems, please review.
NOTE: Ignored message types: ARCH_INCLUDE_LINUX BIT_MACRO COMPARISON_TO_NULL DT_SPLIT_BINDING_PATCH EMAIL_SUBJECT FILE_PATH_CHANGES GLOBAL_INITIALISERS LINE_SPACING MULTIPLE_ASSIGNMENTS
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
Quoted 149 lines
Signed-off-by Ruslan Ruslichenko <[email protected]>Signed-off-by Ruslan Bilovol <[email protected]>Signed-off-by Daniel Walker <[email protected]>--- arch/powerpc/Kconfig | 37 +-------------------------------- arch/powerpc/kernel/prom.c | 1 + arch/powerpc/kernel/prom_init.c | 31 +++++++++++++++------------ 3 files changed, 20 insertions(+), 49 deletions(-)arch/powerpc/Kconfig +1
-36@@ -167,6 +167,7 @@ config PPC select EDAC_SUPPORT select GENERIC_ATOMIC64 if PPC32 select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CMDLINE select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC@@ -906,42 +907,6 @@ config PPC_DENORMALISATION Add support for handling denormalisation of single precision values. Useful for bare metal only. If unsure say Y here. -config CMDLINE - string "Initial kernel command string" - default "" - help - On some platforms, there is currently no way for the boot loader to - pass arguments to the kernel. For these platforms, you can supply - some command-line options at build time by entering them here. In - most cases you will need to specify the root device here. - -choice - prompt "Kernel command line type" if CMDLINE != "" - default CMDLINE_FROM_BOOTLOADER - -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" - 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 EXTRA_TARGETS string "Additional default image types" helparch/powerpc/kernel/prom.c +1
-0@@ -27,6 +27,7 @@#include <linux/irq.h> #include <linux/memblock.h> #include <linux/of.h> +#include <linux/cmdline.h> #include <linux/of_fdt.h> #include <linux/libfdt.h> #include <linux/cpu.h> arch/powerpc/kernel/prom_init.c +18
-13@@ -27,6 +27,7 @@#include <linux/initrd.h> #include <linux/bitops.h> #include <linux/pgtable.h> +#include <linux/cmdline.h> #include <asm/prom.h> #include <asm/rtas.h> #include <asm/page.h> @@ -242,15 +243,6 @@ static int __init prom_strcmp(const char *cs, const char *ct)return 0 ; } -static char __init *prom_strcpy (char *dest,const char *src) -{ -char *tmp = dest; - -while ((*dest++ = *src++) !='\0' ) -/* nothing */ ; -return tmp; -} -static int __init prom_strncmp (const char *cs,const char *ct,size_t count) {unsigned char c1, c2;@@ -276,6 +268,19 @@ static size_t __init prom_strlen(const char *s)return sc - s; } +static size_t __init prom_strlcpy (char *dest,const char *src,size_t size) +{ +size_t ret =prom_strlen (src); + +if (size) { +size_t len = (ret >= size) ? size -1 : ret; +memcpy (dest, src, len); + dest[len] ='\0' ; + } +return ret; +} + +static int __init prom_memcmp (const void *cs,const void *ct,size_t count) {const unsigned char *su1, *su2;@@ -778,9 +783,9 @@ static void __init early_cmdline_parse(void)if (!IS_ENABLED (CONFIG_CMDLINE_FORCE ) && (long )prom.chosen >0 ) l =prom_getprop (prom.chosen,"bootargs" , p,COMMAND_LINE_SIZE -1 ); -if (IS_ENABLED (CONFIG_CMDLINE_EXTEND ) || l <=0 || p[0 ] =='\0' ) -prom_strlcat (prom_cmd_line," " CONFIG_CMDLINE , -sizeof (prom_cmd_line)); +if (l <=0 || p[0 ] =='\0' )/* dbl check */ +cmdline_add_builtin_custom (prom_cmd_line,NULL ,sizeof (prom_cmd_line), + __prombss, &prom_strlcpy, &prom_strlcat);prom_printf ("command line: %s\n" , prom_cmd_line);@@ -2706,7 +2711,7 @@ static void __init flatten_device_tree(void)/* Add "phandle" in there, we'll need it */ namep =make_room (&mem_start, &mem_end,16 ,1 ); -prom_strcpy (namep,"phandle" ); +prom_strlcpy (namep,"phandle" ,8 ); mem_start = (unsigned long )namep +prom_strlen (namep) +1 ;/* Build string array */