[PATCH v2 2/2] mips: sort list of configs for Malta

2018-11-12 Thread Maksym Kokhan
Sort configs in menu "Machine selection" under MIPS_MALTA.

Signed-off-by: Maksym Kokhan 
Signed-off-by: Andrii Bordunov 
---
 arch/mips/Kconfig | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index fe4c28275271..2ac32dac90b7 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -494,22 +494,23 @@ config MIPS_MALTA
select BOOT_RAW
select BUILTIN_DTB
select CEVT_R4K
-   select CSRC_R4K
select CLKSRC_MIPS_GIC
select COMMON_CLK
+   select CSRC_R4K
select DMA_MAYBE_COHERENT
select GENERIC_ISA_DMA
select HAVE_PCSPKR_PLATFORM
-   select IRQ_MIPS_CPU
-   select MIPS_GIC
select HW_HAS_PCI
select I8253
select I8259
+   select IRQ_MIPS_CPU
+   select LIBFDT
select MIPS_BONITO64
select MIPS_CPU_SCACHE
+   select MIPS_GIC
select MIPS_L1_CACHE_SHIFT_6
-   select PCI_GT64XXX_PCI0
select MIPS_MSC
+   select PCI_GT64XXX_PCI0
select SMP_UP if SMP
select SWAP_IO_SPACE
select SYS_HAS_CPU_MIPS32_R1
@@ -528,16 +529,15 @@ config MIPS_MALTA
select SYS_SUPPORTS_HIGHMEM
select SYS_SUPPORTS_LITTLE_ENDIAN
select SYS_SUPPORTS_MICROMIPS
+   select SYS_SUPPORTS_MIPS16
select SYS_SUPPORTS_MIPS_CMP
select SYS_SUPPORTS_MIPS_CPS
-   select SYS_SUPPORTS_MIPS16
select SYS_SUPPORTS_MULTITHREADING
+   select SYS_SUPPORTS_RELOCATABLE
select SYS_SUPPORTS_SMARTMIPS
select SYS_SUPPORTS_VPE_LOADER
select SYS_SUPPORTS_ZBOOT
-   select SYS_SUPPORTS_RELOCATABLE
select USE_OF
-   select LIBFDT
select ZONE_DMA32 if 64BIT
help
  This enables support for the MIPS Technologies Malta evaluation
-- 
2.19.1



[PATCH v2 2/2] mips: sort list of configs for Malta

2018-11-12 Thread Maksym Kokhan
Sort configs in menu "Machine selection" under MIPS_MALTA.

Signed-off-by: Maksym Kokhan 
Signed-off-by: Andrii Bordunov 
---
 arch/mips/Kconfig | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index fe4c28275271..2ac32dac90b7 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -494,22 +494,23 @@ config MIPS_MALTA
select BOOT_RAW
select BUILTIN_DTB
select CEVT_R4K
-   select CSRC_R4K
select CLKSRC_MIPS_GIC
select COMMON_CLK
+   select CSRC_R4K
select DMA_MAYBE_COHERENT
select GENERIC_ISA_DMA
select HAVE_PCSPKR_PLATFORM
-   select IRQ_MIPS_CPU
-   select MIPS_GIC
select HW_HAS_PCI
select I8253
select I8259
+   select IRQ_MIPS_CPU
+   select LIBFDT
select MIPS_BONITO64
select MIPS_CPU_SCACHE
+   select MIPS_GIC
select MIPS_L1_CACHE_SHIFT_6
-   select PCI_GT64XXX_PCI0
select MIPS_MSC
+   select PCI_GT64XXX_PCI0
select SMP_UP if SMP
select SWAP_IO_SPACE
select SYS_HAS_CPU_MIPS32_R1
@@ -528,16 +529,15 @@ config MIPS_MALTA
select SYS_SUPPORTS_HIGHMEM
select SYS_SUPPORTS_LITTLE_ENDIAN
select SYS_SUPPORTS_MICROMIPS
+   select SYS_SUPPORTS_MIPS16
select SYS_SUPPORTS_MIPS_CMP
select SYS_SUPPORTS_MIPS_CPS
-   select SYS_SUPPORTS_MIPS16
select SYS_SUPPORTS_MULTITHREADING
+   select SYS_SUPPORTS_RELOCATABLE
select SYS_SUPPORTS_SMARTMIPS
select SYS_SUPPORTS_VPE_LOADER
select SYS_SUPPORTS_ZBOOT
-   select SYS_SUPPORTS_RELOCATABLE
select USE_OF
-   select LIBFDT
select ZONE_DMA32 if 64BIT
help
  This enables support for the MIPS Technologies Malta evaluation
-- 
2.19.1



[PATCH v2 1/2] mips: delete duplicated BUILTIN_DTB and LIBFDT configs

2018-11-12 Thread Maksym Kokhan
CONFIG_BUILTIN_DTB and CONFIG_LIBFDT selection is duplicated
in menu "Machine selection" under MIPS_MALTA.

Signed-off-by: Maksym Kokhan 
Signed-off-by: Andrii Bordunov 
---
 arch/mips/Kconfig | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 8272ea4c7264..fe4c28275271 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -539,8 +539,6 @@ config MIPS_MALTA
select USE_OF
select LIBFDT
select ZONE_DMA32 if 64BIT
-   select BUILTIN_DTB
-   select LIBFDT
help
  This enables support for the MIPS Technologies Malta evaluation
  board.
-- 
2.19.1



[PATCH v2 1/2] mips: delete duplicated BUILTIN_DTB and LIBFDT configs

2018-11-12 Thread Maksym Kokhan
CONFIG_BUILTIN_DTB and CONFIG_LIBFDT selection is duplicated
in menu "Machine selection" under MIPS_MALTA.

Signed-off-by: Maksym Kokhan 
Signed-off-by: Andrii Bordunov 
---
 arch/mips/Kconfig | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 8272ea4c7264..fe4c28275271 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -539,8 +539,6 @@ config MIPS_MALTA
select USE_OF
select LIBFDT
select ZONE_DMA32 if 64BIT
-   select BUILTIN_DTB
-   select LIBFDT
help
  This enables support for the MIPS Technologies Malta evaluation
  board.
-- 
2.19.1



Re: [PATCH] mips: delete duplication of BUILTIN_DTB selection

2018-11-06 Thread Maksym Kokhan
On Thu, Oct 4, 2018 at 3:06 PM Maksym Kokhan
 wrote:
>
> On Thu, Oct 4, 2018 at 12:14 PM Geert Uytterhoeven  
> wrote:
> >
> > On Thu, Oct 4, 2018 at 10:38 AM Sergei Shtylyov
> >  wrote:
> > > On 10/3/2018 8:23 PM, Maksym Kokhan wrote:
> > > > CONFIG_BUILTIN_DTB selection is duplicated in menu
> > > > "Machine selection" under MIPS_MALTA.
> > > >
> > > > Fixes: e81a8c7dabac ("MIPS: Malta: Setup RAM regions via DT")
> > > > Signed-off-by: Maksym Kokhan 
> > > > Signed-off-by: Andrii Bordunov 
> > > > ---
> > > >   arch/mips/Kconfig | 1 -
> > > >   1 file changed, 1 deletion(-)
> > > >
> > > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > > > index 3551199..71d6549 100644
> > > > --- a/arch/mips/Kconfig
> > > > +++ b/arch/mips/Kconfig
> > > > @@ -539,7 +539,6 @@ config MIPS_MALTA
> > > >   select USE_OF
> > > >   select LIBFDT
> > > >   select ZONE_DMA32 if 64BIT
> > > > - select BUILTIN_DTB
> > > >   select LIBFDT
> > >
> > > LIBFDT seems duplicated too.
> >
> > Using random sort order doesn't help. Keep them sorted, please?
>
> We are going to deal with it in the separate patch.

Is it OK to leave this patch as it is and make another patch/patches
for other changes or it would be better to modify it to remove
duplication of LIBFDT too and sort this list of configs?

--
Regards,
Maksym Kokhan


Re: [PATCH] mips: delete duplication of BUILTIN_DTB selection

2018-11-06 Thread Maksym Kokhan
On Thu, Oct 4, 2018 at 3:06 PM Maksym Kokhan
 wrote:
>
> On Thu, Oct 4, 2018 at 12:14 PM Geert Uytterhoeven  
> wrote:
> >
> > On Thu, Oct 4, 2018 at 10:38 AM Sergei Shtylyov
> >  wrote:
> > > On 10/3/2018 8:23 PM, Maksym Kokhan wrote:
> > > > CONFIG_BUILTIN_DTB selection is duplicated in menu
> > > > "Machine selection" under MIPS_MALTA.
> > > >
> > > > Fixes: e81a8c7dabac ("MIPS: Malta: Setup RAM regions via DT")
> > > > Signed-off-by: Maksym Kokhan 
> > > > Signed-off-by: Andrii Bordunov 
> > > > ---
> > > >   arch/mips/Kconfig | 1 -
> > > >   1 file changed, 1 deletion(-)
> > > >
> > > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > > > index 3551199..71d6549 100644
> > > > --- a/arch/mips/Kconfig
> > > > +++ b/arch/mips/Kconfig
> > > > @@ -539,7 +539,6 @@ config MIPS_MALTA
> > > >   select USE_OF
> > > >   select LIBFDT
> > > >   select ZONE_DMA32 if 64BIT
> > > > - select BUILTIN_DTB
> > > >   select LIBFDT
> > >
> > > LIBFDT seems duplicated too.
> >
> > Using random sort order doesn't help. Keep them sorted, please?
>
> We are going to deal with it in the separate patch.

Is it OK to leave this patch as it is and make another patch/patches
for other changes or it would be better to modify it to remove
duplication of LIBFDT too and sort this list of configs?

--
Regards,
Maksym Kokhan


Re: [PATCH 2/8] drivers: of: ifdef out cmdline section

2018-10-08 Thread Maksym Kokhan
Hi, Rob

On Fri, Sep 28, 2018 at 12:07 AM Rob Herring  wrote:
>
> On Thu, Sep 27, 2018 at 11:55 AM Maksym Kokhan
>  wrote:
> >
> > From: Daniel Walker 
> >
> > It looks like there's some seepage of cmdline stuff into
> > the generic device tree code. This conflicts with the
> > generic cmdline implementation so I remove it in the case
> > when that's enabled.
>
> What's preventing removing this or simplifying the DT code to just be
> "give me the cmdline data from DT" and the common code deals with all
> the combinations of config options.

This code (handling built-in cmdline in old, non-generic way) is used by
some other architectures besides those, modified in our patches, so for
now we can't remove it.

Thanks,
Maksym


Re: [PATCH 2/8] drivers: of: ifdef out cmdline section

2018-10-08 Thread Maksym Kokhan
Hi, Rob

On Fri, Sep 28, 2018 at 12:07 AM Rob Herring  wrote:
>
> On Thu, Sep 27, 2018 at 11:55 AM Maksym Kokhan
>  wrote:
> >
> > From: Daniel Walker 
> >
> > It looks like there's some seepage of cmdline stuff into
> > the generic device tree code. This conflicts with the
> > generic cmdline implementation so I remove it in the case
> > when that's enabled.
>
> What's preventing removing this or simplifying the DT code to just be
> "give me the cmdline data from DT" and the common code deals with all
> the combinations of config options.

This code (handling built-in cmdline in old, non-generic way) is used by
some other architectures besides those, modified in our patches, so for
now we can't remove it.

Thanks,
Maksym


Re: [PATCH 7/8] mips: convert to generic builtin command line

2018-10-08 Thread Maksym Kokhan
Hi, Paul,

On Thu, Sep 27, 2018 at 9:56 PM Paul Burton  wrote:
>
> Hi Maksym,
>
> On Thu, Sep 27, 2018 at 07:56:57PM +0300, Maksym Kokhan wrote:
> > -choice
> > - prompt "Kernel command line type" if !CMDLINE_OVERRIDE
> > - default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && 
> > \
> > -  !MIPS_MALTA && \
> > -  !CAVIUM_OCTEON_SOC
> > - default MIPS_CMDLINE_FROM_BOOTLOADER
> > -
> > - config MIPS_CMDLINE_FROM_DTB
> > - depends on USE_OF
> > - bool "Dtb kernel arguments if available"
> > -
> > - config MIPS_CMDLINE_DTB_EXTEND
> > - depends on USE_OF
> > - bool "Extend dtb kernel arguments with bootloader arguments"
> > -
> > - config MIPS_CMDLINE_FROM_BOOTLOADER
> > - bool "Bootloader kernel arguments if available"
> > -
> > - config MIPS_CMDLINE_BUILTIN_EXTEND
> > - depends on CMDLINE_BOOL
> > - bool "Extend builtin kernel arguments with bootloader 
> > arguments"
> > -endchoice
> >%
> > -#define USE_PROM_CMDLINE 
> > IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER)
> > -#define USE_DTB_CMDLINE  
> > IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB)
> > -#define EXTEND_WITH_PROM IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND)
> > -#define BUILTIN_EXTEND_WITH_PROM \
> > - IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND)
> > -
> >  static void __init arch_mem_init(char **cmdline_p)
> >  {
> >   struct memblock_region *reg;
> >   extern void plat_mem_setup(void);
> >
> > -#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE)
> > - strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
> > -#else
> > - if ((USE_PROM_CMDLINE && arcs_cmdline[0]) ||
> > - (USE_DTB_CMDLINE && !boot_command_line[0]))
> > - strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
> > -
> > - if (EXTEND_WITH_PROM && arcs_cmdline[0]) {
> > - if (boot_command_line[0])
> > - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> > - strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
> > - }
> > -
> > -#if defined(CONFIG_CMDLINE_BOOL)
> > - if (builtin_cmdline[0]) {
> > - if (boot_command_line[0])
> > - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> > - strlcat(boot_command_line, builtin_cmdline, 
> > COMMAND_LINE_SIZE);
> > - }
> > -
> > - if (BUILTIN_EXTEND_WITH_PROM && arcs_cmdline[0]) {
> > - if (boot_command_line[0])
> > - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> > - strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
> > - }
> > -#endif
> > -#endif
> > -
> >   /* call board setup routine */
> >   plat_mem_setup();
> >
> > @@ -893,6 +856,8 @@ static void __init arch_mem_init(char **cmdline_p)
> >   pr_info("Determined physical RAM map:\n");
> >   print_memory_map();
> >
> > + cmdline_add_builtin(boot_command_line, arcs_cmdline, 
> > COMMAND_LINE_SIZE);
> > +
> >   strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
> >
> >   *cmdline_p = command_line;
>
> I love the idea of simplifying this & sharing code with other
> architectures, but unfortunately I believe the above will be problematic
> for systems using arguments from device tree.
>
> At the point you call cmdline_add_builtin we should expect that:
>
>   - boot_command_line contains arguments from the DT, if any, and
> otherwise may contain CONFIG_CMDLINE copied there by
> early_init_dt_scan_chosen().
>
>   - arcs_cmdline contains arguments from the bootloader, if any.
>
> If I understand correctly you overwrite boot_command_line with the
> concatenation of CONFIG_CMDLINE_PREPEND, arcs_cmdline &
> CONFIG_CMDLINE_APPEND. This will clobber/lose the DT arguments.
>
> I'd expect this to be reproducible under QEMU using its boston emulation
> (ie. -M boston) and a kernel built for the generic platform that
> includes boston support (eg. 64r6el_defconfig).

You are right, there is a mistake in our implementation, thank you for
your observation. This bug can be easil

Re: [PATCH 7/8] mips: convert to generic builtin command line

2018-10-08 Thread Maksym Kokhan
Hi, Paul,

On Thu, Sep 27, 2018 at 9:56 PM Paul Burton  wrote:
>
> Hi Maksym,
>
> On Thu, Sep 27, 2018 at 07:56:57PM +0300, Maksym Kokhan wrote:
> > -choice
> > - prompt "Kernel command line type" if !CMDLINE_OVERRIDE
> > - default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && 
> > \
> > -  !MIPS_MALTA && \
> > -  !CAVIUM_OCTEON_SOC
> > - default MIPS_CMDLINE_FROM_BOOTLOADER
> > -
> > - config MIPS_CMDLINE_FROM_DTB
> > - depends on USE_OF
> > - bool "Dtb kernel arguments if available"
> > -
> > - config MIPS_CMDLINE_DTB_EXTEND
> > - depends on USE_OF
> > - bool "Extend dtb kernel arguments with bootloader arguments"
> > -
> > - config MIPS_CMDLINE_FROM_BOOTLOADER
> > - bool "Bootloader kernel arguments if available"
> > -
> > - config MIPS_CMDLINE_BUILTIN_EXTEND
> > - depends on CMDLINE_BOOL
> > - bool "Extend builtin kernel arguments with bootloader 
> > arguments"
> > -endchoice
> >%
> > -#define USE_PROM_CMDLINE 
> > IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER)
> > -#define USE_DTB_CMDLINE  
> > IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB)
> > -#define EXTEND_WITH_PROM IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND)
> > -#define BUILTIN_EXTEND_WITH_PROM \
> > - IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND)
> > -
> >  static void __init arch_mem_init(char **cmdline_p)
> >  {
> >   struct memblock_region *reg;
> >   extern void plat_mem_setup(void);
> >
> > -#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE)
> > - strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
> > -#else
> > - if ((USE_PROM_CMDLINE && arcs_cmdline[0]) ||
> > - (USE_DTB_CMDLINE && !boot_command_line[0]))
> > - strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
> > -
> > - if (EXTEND_WITH_PROM && arcs_cmdline[0]) {
> > - if (boot_command_line[0])
> > - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> > - strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
> > - }
> > -
> > -#if defined(CONFIG_CMDLINE_BOOL)
> > - if (builtin_cmdline[0]) {
> > - if (boot_command_line[0])
> > - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> > - strlcat(boot_command_line, builtin_cmdline, 
> > COMMAND_LINE_SIZE);
> > - }
> > -
> > - if (BUILTIN_EXTEND_WITH_PROM && arcs_cmdline[0]) {
> > - if (boot_command_line[0])
> > - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> > - strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
> > - }
> > -#endif
> > -#endif
> > -
> >   /* call board setup routine */
> >   plat_mem_setup();
> >
> > @@ -893,6 +856,8 @@ static void __init arch_mem_init(char **cmdline_p)
> >   pr_info("Determined physical RAM map:\n");
> >   print_memory_map();
> >
> > + cmdline_add_builtin(boot_command_line, arcs_cmdline, 
> > COMMAND_LINE_SIZE);
> > +
> >   strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
> >
> >   *cmdline_p = command_line;
>
> I love the idea of simplifying this & sharing code with other
> architectures, but unfortunately I believe the above will be problematic
> for systems using arguments from device tree.
>
> At the point you call cmdline_add_builtin we should expect that:
>
>   - boot_command_line contains arguments from the DT, if any, and
> otherwise may contain CONFIG_CMDLINE copied there by
> early_init_dt_scan_chosen().
>
>   - arcs_cmdline contains arguments from the bootloader, if any.
>
> If I understand correctly you overwrite boot_command_line with the
> concatenation of CONFIG_CMDLINE_PREPEND, arcs_cmdline &
> CONFIG_CMDLINE_APPEND. This will clobber/lose the DT arguments.
>
> I'd expect this to be reproducible under QEMU using its boston emulation
> (ie. -M boston) and a kernel built for the generic platform that
> includes boston support (eg. 64r6el_defconfig).

You are right, there is a mistake in our implementation, thank you for
your observation. This bug can be easil

Re: [PATCH] mips: delete duplication of BUILTIN_DTB selection

2018-10-04 Thread Maksym Kokhan
On Thu, Oct 4, 2018 at 12:14 PM Geert Uytterhoeven  wrote:
>
> On Thu, Oct 4, 2018 at 10:38 AM Sergei Shtylyov
>  wrote:
> > On 10/3/2018 8:23 PM, Maksym Kokhan wrote:
> > > CONFIG_BUILTIN_DTB selection is duplicated in menu
> > > "Machine selection" under MIPS_MALTA.
> > >
> > > Fixes: e81a8c7dabac ("MIPS: Malta: Setup RAM regions via DT")
> > > Signed-off-by: Maksym Kokhan 
> > > Signed-off-by: Andrii Bordunov 
> > > ---
> > >   arch/mips/Kconfig | 1 -
> > >   1 file changed, 1 deletion(-)
> > >
> > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > > index 3551199..71d6549 100644
> > > --- a/arch/mips/Kconfig
> > > +++ b/arch/mips/Kconfig
> > > @@ -539,7 +539,6 @@ config MIPS_MALTA
> > >   select USE_OF
> > >   select LIBFDT
> > >   select ZONE_DMA32 if 64BIT
> > > - select BUILTIN_DTB
> > >   select LIBFDT
> >
> > LIBFDT seems duplicated too.
>
> Using random sort order doesn't help. Keep them sorted, please?

We are going to deal with it in the separate patch.

---
Regards,
Maksym Kokhan


Re: [PATCH] mips: delete duplication of BUILTIN_DTB selection

2018-10-04 Thread Maksym Kokhan
On Thu, Oct 4, 2018 at 12:14 PM Geert Uytterhoeven  wrote:
>
> On Thu, Oct 4, 2018 at 10:38 AM Sergei Shtylyov
>  wrote:
> > On 10/3/2018 8:23 PM, Maksym Kokhan wrote:
> > > CONFIG_BUILTIN_DTB selection is duplicated in menu
> > > "Machine selection" under MIPS_MALTA.
> > >
> > > Fixes: e81a8c7dabac ("MIPS: Malta: Setup RAM regions via DT")
> > > Signed-off-by: Maksym Kokhan 
> > > Signed-off-by: Andrii Bordunov 
> > > ---
> > >   arch/mips/Kconfig | 1 -
> > >   1 file changed, 1 deletion(-)
> > >
> > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > > index 3551199..71d6549 100644
> > > --- a/arch/mips/Kconfig
> > > +++ b/arch/mips/Kconfig
> > > @@ -539,7 +539,6 @@ config MIPS_MALTA
> > >   select USE_OF
> > >   select LIBFDT
> > >   select ZONE_DMA32 if 64BIT
> > > - select BUILTIN_DTB
> > >   select LIBFDT
> >
> > LIBFDT seems duplicated too.
>
> Using random sort order doesn't help. Keep them sorted, please?

We are going to deal with it in the separate patch.

---
Regards,
Maksym Kokhan


[PATCH] mips: delete duplication of BUILTIN_DTB selection

2018-10-03 Thread Maksym Kokhan
CONFIG_BUILTIN_DTB selection is duplicated in menu
"Machine selection" under MIPS_MALTA.

Fixes: e81a8c7dabac ("MIPS: Malta: Setup RAM regions via DT")
Signed-off-by: Maksym Kokhan 
Signed-off-by: Andrii Bordunov 
---
 arch/mips/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3551199..71d6549 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -539,7 +539,6 @@ config MIPS_MALTA
select USE_OF
select LIBFDT
select ZONE_DMA32 if 64BIT
-   select BUILTIN_DTB
select LIBFDT
help
  This enables support for the MIPS Technologies Malta evaluation
-- 
2.7.4



[PATCH] mips: delete duplication of BUILTIN_DTB selection

2018-10-03 Thread Maksym Kokhan
CONFIG_BUILTIN_DTB selection is duplicated in menu
"Machine selection" under MIPS_MALTA.

Fixes: e81a8c7dabac ("MIPS: Malta: Setup RAM regions via DT")
Signed-off-by: Maksym Kokhan 
Signed-off-by: Andrii Bordunov 
---
 arch/mips/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3551199..71d6549 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -539,7 +539,6 @@ config MIPS_MALTA
select USE_OF
select LIBFDT
select ZONE_DMA32 if 64BIT
-   select BUILTIN_DTB
select LIBFDT
help
  This enables support for the MIPS Technologies Malta evaluation
-- 
2.7.4



[PATCH 5/8] arm: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the arm 32bit code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/arm/Kconfig  | 38 +-
 arch/arm/kernel/atags_parse.c | 14 --
 arch/arm/kernel/devtree.c |  2 ++
 3 files changed, 7 insertions(+), 47 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e8cd55a..a1dca346d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -38,6 +38,7 @@ config ARM
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
select GENERIC_CPU_AUTOPROBE
select GENERIC_EARLY_IOREMAP
+   select GENERIC_CMDLINE
select GENERIC_IDLE_POLL_SETUP
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
@@ -1924,43 +1925,6 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
 
 endchoice
 
-config CMDLINE
-   string "Default kernel command string"
-   default ""
-   help
- On some architectures (EBSA110 and CATS), there is currently no way
- for the boot loader to pass arguments to the kernel. For these
- architectures, you should supply some command-line options at build
- time by entering them here. As a minimum, you should specify the
- memory size and the root device (e.g., mem=64M 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"
-   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 XIP_KERNEL
bool "Kernel Execute-In-Place from ROM"
depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c
index c10a3e8..4cf1c5b 100644
--- a/arch/arm/kernel/atags_parse.c
+++ b/arch/arm/kernel/atags_parse.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -32,7 +33,7 @@
 
 #include "atags.h"
 
-static char default_command_line[COMMAND_LINE_SIZE] __initdata = 
CONFIG_CMDLINE;
+static char default_command_line[COMMAND_LINE_SIZE] __initdata;
 
 #ifndef MEM_SIZE
 #define MEM_SIZE   (16*1024*1024)
@@ -124,16 +125,9 @@ __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)
-   pr_warn("Ignoring tag cmdline (using the default kernel command 
line)\n");
-#else
-   strlcpy(default_command_line, tag->u.cmdline.cmdline,
-   COMMAND_LINE_SIZE);
-#endif
+
return 0;
 }
 
@@ -228,7 +222,7 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned 
int machine_nr)
}
 
/* parse_early_param needs a boot_command_line */
-   strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
+   cmdline_add_builtin(boot_command_line, from, COMMAND_LINE_SIZE);
 
return mdesc;
 }
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index ecaa68d..85442b5 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -258,6 +259,7 @@ const struct machine_desc * __init 
setup_machine_fdt(unsigned int dt_phys)
mdesc->dt_fixup();
 
early_init_dt_scan_nodes();
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
 
/* Change machine number to match the mdesc we're using */
__machine_arch_type = mdesc->nr;
-- 
2.7.4



[PATCH 5/8] arm: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the arm 32bit code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/arm/Kconfig  | 38 +-
 arch/arm/kernel/atags_parse.c | 14 --
 arch/arm/kernel/devtree.c |  2 ++
 3 files changed, 7 insertions(+), 47 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e8cd55a..a1dca346d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -38,6 +38,7 @@ config ARM
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
select GENERIC_CPU_AUTOPROBE
select GENERIC_EARLY_IOREMAP
+   select GENERIC_CMDLINE
select GENERIC_IDLE_POLL_SETUP
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
@@ -1924,43 +1925,6 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
 
 endchoice
 
-config CMDLINE
-   string "Default kernel command string"
-   default ""
-   help
- On some architectures (EBSA110 and CATS), there is currently no way
- for the boot loader to pass arguments to the kernel. For these
- architectures, you should supply some command-line options at build
- time by entering them here. As a minimum, you should specify the
- memory size and the root device (e.g., mem=64M 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"
-   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 XIP_KERNEL
bool "Kernel Execute-In-Place from ROM"
depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c
index c10a3e8..4cf1c5b 100644
--- a/arch/arm/kernel/atags_parse.c
+++ b/arch/arm/kernel/atags_parse.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -32,7 +33,7 @@
 
 #include "atags.h"
 
-static char default_command_line[COMMAND_LINE_SIZE] __initdata = 
CONFIG_CMDLINE;
+static char default_command_line[COMMAND_LINE_SIZE] __initdata;
 
 #ifndef MEM_SIZE
 #define MEM_SIZE   (16*1024*1024)
@@ -124,16 +125,9 @@ __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)
-   pr_warn("Ignoring tag cmdline (using the default kernel command 
line)\n");
-#else
-   strlcpy(default_command_line, tag->u.cmdline.cmdline,
-   COMMAND_LINE_SIZE);
-#endif
+
return 0;
 }
 
@@ -228,7 +222,7 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned 
int machine_nr)
}
 
/* parse_early_param needs a boot_command_line */
-   strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
+   cmdline_add_builtin(boot_command_line, from, COMMAND_LINE_SIZE);
 
return mdesc;
 }
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index ecaa68d..85442b5 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -258,6 +259,7 @@ const struct machine_desc * __init 
setup_machine_fdt(unsigned int dt_phys)
mdesc->dt_fixup();
 
early_init_dt_scan_nodes();
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
 
/* Change machine number to match the mdesc we're using */
__machine_arch_type = mdesc->nr;
-- 
2.7.4



[PATCH 7/8] mips: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the mips code to use the CONFIG_GENERIC_CMDLINE
option.

[maksym.kok...@globallogic.com: remove new mips arch-specific
command line implementation]
Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/mips/Kconfig| 24 +---
 arch/mips/Kconfig.debug  | 47 ---
 arch/mips/kernel/setup.c | 41 +++--
 3 files changed, 4 insertions(+), 108 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3551199..642e31b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -78,6 +78,7 @@ config MIPS
select RTC_LIB if !MACH_LOONGSON64
select SYSCTL_EXCEPTION_TRACE
select VIRT_TO_BUS
+   select GENERIC_CMDLINE
 
 menu "Machine selection"
 
@@ -2942,29 +2943,6 @@ choice
  if you don't intend to always append a DTB.
 endchoice
 
-choice
-   prompt "Kernel command line type" if !CMDLINE_OVERRIDE
-   default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \
-!MIPS_MALTA && \
-!CAVIUM_OCTEON_SOC
-   default MIPS_CMDLINE_FROM_BOOTLOADER
-
-   config MIPS_CMDLINE_FROM_DTB
-   depends on USE_OF
-   bool "Dtb kernel arguments if available"
-
-   config MIPS_CMDLINE_DTB_EXTEND
-   depends on USE_OF
-   bool "Extend dtb kernel arguments with bootloader arguments"
-
-   config MIPS_CMDLINE_FROM_BOOTLOADER
-   bool "Bootloader kernel arguments if available"
-
-   config MIPS_CMDLINE_BUILTIN_EXTEND
-   depends on CMDLINE_BOOL
-   bool "Extend builtin kernel arguments with bootloader arguments"
-endchoice
-
 endmenu
 
 config LOCKDEP_SUPPORT
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 0c86b2a..bcf11c2 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -30,53 +30,6 @@ config EARLY_PRINTK_8250
 config USE_GENERIC_EARLY_PRINTK_8250
bool
 
-config CMDLINE_BOOL
-   bool "Built-in kernel command line"
-   default n
-   help
- For most systems, it is firmware or second stage bootloader that
- by default specifies the kernel command line options.  However,
- it might be necessary or advantageous to either override the
- default kernel command line or add a few extra options to it.
- For such cases, this option allows you to hardcode your own
- command line options directly into the kernel.  For that, you
- should choose 'Y' here, and fill in the extra boot arguments
- in CONFIG_CMDLINE.
-
- The built-in options will be concatenated to the default command
- line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
- command line will be ignored and replaced by the built-in string.
-
- Most MIPS systems will normally expect 'N' here and rely upon
- the command line from the firmware or the second-stage bootloader.
-
-config CMDLINE
-   string "Default kernel command string"
-   depends on CMDLINE_BOOL
-   default ""
-   help
- On some platforms, there is currently no way for the boot loader to
- pass arguments to the kernel.  For these platforms, and for the cases
- when you want to add some extra options to the command line or ignore
- the default command line, you can supply some command-line options at
- build time by entering them here.  In other cases you can specify
- kernel args so that you don't have to set them up in board prom
- initialization routines.
-
- For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
- options.
-
-config CMDLINE_OVERRIDE
-   bool "Built-in command line overrides firmware arguments"
-   default n
-   depends on CMDLINE_BOOL
-   help
- By setting this option to 'Y' you will have your kernel ignore
- command line arguments from firmware or second stage bootloader.
- Instead, the built-in command line will be used exclusively.
-
- Normally, you will choose 'N' here.
-
 config SB1XXX_CORELIS
bool "Corelis Debugger"
depends on SIBYTE_SB1xxx_SOC
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c71d1eb..60638dd 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -68,10 +69,6 @@ struct boot_mem_map boot_mem_map;
 static char __initdata command_line[COMMAND_LINE_SIZE];
 char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
 
-#ifdef CONFIG_CMDLINE_BOOL
-static char __initdata

[PATCH 7/8] mips: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the mips code to use the CONFIG_GENERIC_CMDLINE
option.

[maksym.kok...@globallogic.com: remove new mips arch-specific
command line implementation]
Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/mips/Kconfig| 24 +---
 arch/mips/Kconfig.debug  | 47 ---
 arch/mips/kernel/setup.c | 41 +++--
 3 files changed, 4 insertions(+), 108 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3551199..642e31b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -78,6 +78,7 @@ config MIPS
select RTC_LIB if !MACH_LOONGSON64
select SYSCTL_EXCEPTION_TRACE
select VIRT_TO_BUS
+   select GENERIC_CMDLINE
 
 menu "Machine selection"
 
@@ -2942,29 +2943,6 @@ choice
  if you don't intend to always append a DTB.
 endchoice
 
-choice
-   prompt "Kernel command line type" if !CMDLINE_OVERRIDE
-   default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \
-!MIPS_MALTA && \
-!CAVIUM_OCTEON_SOC
-   default MIPS_CMDLINE_FROM_BOOTLOADER
-
-   config MIPS_CMDLINE_FROM_DTB
-   depends on USE_OF
-   bool "Dtb kernel arguments if available"
-
-   config MIPS_CMDLINE_DTB_EXTEND
-   depends on USE_OF
-   bool "Extend dtb kernel arguments with bootloader arguments"
-
-   config MIPS_CMDLINE_FROM_BOOTLOADER
-   bool "Bootloader kernel arguments if available"
-
-   config MIPS_CMDLINE_BUILTIN_EXTEND
-   depends on CMDLINE_BOOL
-   bool "Extend builtin kernel arguments with bootloader arguments"
-endchoice
-
 endmenu
 
 config LOCKDEP_SUPPORT
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 0c86b2a..bcf11c2 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -30,53 +30,6 @@ config EARLY_PRINTK_8250
 config USE_GENERIC_EARLY_PRINTK_8250
bool
 
-config CMDLINE_BOOL
-   bool "Built-in kernel command line"
-   default n
-   help
- For most systems, it is firmware or second stage bootloader that
- by default specifies the kernel command line options.  However,
- it might be necessary or advantageous to either override the
- default kernel command line or add a few extra options to it.
- For such cases, this option allows you to hardcode your own
- command line options directly into the kernel.  For that, you
- should choose 'Y' here, and fill in the extra boot arguments
- in CONFIG_CMDLINE.
-
- The built-in options will be concatenated to the default command
- line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
- command line will be ignored and replaced by the built-in string.
-
- Most MIPS systems will normally expect 'N' here and rely upon
- the command line from the firmware or the second-stage bootloader.
-
-config CMDLINE
-   string "Default kernel command string"
-   depends on CMDLINE_BOOL
-   default ""
-   help
- On some platforms, there is currently no way for the boot loader to
- pass arguments to the kernel.  For these platforms, and for the cases
- when you want to add some extra options to the command line or ignore
- the default command line, you can supply some command-line options at
- build time by entering them here.  In other cases you can specify
- kernel args so that you don't have to set them up in board prom
- initialization routines.
-
- For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
- options.
-
-config CMDLINE_OVERRIDE
-   bool "Built-in command line overrides firmware arguments"
-   default n
-   depends on CMDLINE_BOOL
-   help
- By setting this option to 'Y' you will have your kernel ignore
- command line arguments from firmware or second stage bootloader.
- Instead, the built-in command line will be used exclusively.
-
- Normally, you will choose 'N' here.
-
 config SB1XXX_CORELIS
bool "Corelis Debugger"
depends on SIBYTE_SB1xxx_SOC
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c71d1eb..60638dd 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -68,10 +69,6 @@ struct boot_mem_map boot_mem_map;
 static char __initdata command_line[COMMAND_LINE_SIZE];
 char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
 
-#ifdef CONFIG_CMDLINE_BOOL
-static char __initdata

[PATCH 3/8] efi: modify EFI stub code for arm/arm64

2018-09-27 Thread Maksym Kokhan
Original EFI stub code parses command line, using old configs: CMDLINE,
CMDLINE_EXTEND and CMDLINE_FORCE. New generic builtin command line use
new configs: CMDLINE_PREPEND, CMDLINE_APPEND and CMDLINE_OVERRIDE, which
depend on CMDLINE_BOOL.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 drivers/firmware/efi/libstub/arm-stub.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c 
b/drivers/firmware/efi/libstub/arm-stub.c
index 6920033..40396e1 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -146,12 +146,12 @@ unsigned long efi_entry(void *handle, efi_system_table_t 
*sys_table,
goto fail;
}
 
-   if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
-   IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
-   cmdline_size == 0)
-   efi_parse_options(CONFIG_CMDLINE);
+   #if IS_ENABLED(CONFIG_CMDLINE_BOOL)
+   efi_parse_options(CONFIG_CMDLINE_PREPEND);
+   efi_parse_options(CONFIG_CMDLINE_APPEND);
+   #endif
 
-   if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0)
+   if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE) && cmdline_size > 0)
efi_parse_options(cmdline_ptr);
 
pr_efi(sys_table, "Booting Linux Kernel...\n");
-- 
2.7.4



[PATCH 2/8] drivers: of: ifdef out cmdline section

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

It looks like there's some seepage of cmdline stuff into
the generic device tree code. This conflicts with the
generic cmdline implementation so I remove it in the case
when that's enabled.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 drivers/of/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 800ad25..74b85ad 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1096,7 +1096,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, 
const char *uname,
 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
 * is set in which case we override whatever was found earlier.
 */
-#ifdef CONFIG_CMDLINE
+#if defined(CONFIG_CMDLINE) && !defined(CONFIG_GENERIC_CMDLINE)
 #if defined(CONFIG_CMDLINE_EXTEND)
strlcat(data, " ", COMMAND_LINE_SIZE);
strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-- 
2.7.4



[PATCH 3/8] efi: modify EFI stub code for arm/arm64

2018-09-27 Thread Maksym Kokhan
Original EFI stub code parses command line, using old configs: CMDLINE,
CMDLINE_EXTEND and CMDLINE_FORCE. New generic builtin command line use
new configs: CMDLINE_PREPEND, CMDLINE_APPEND and CMDLINE_OVERRIDE, which
depend on CMDLINE_BOOL.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 drivers/firmware/efi/libstub/arm-stub.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c 
b/drivers/firmware/efi/libstub/arm-stub.c
index 6920033..40396e1 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -146,12 +146,12 @@ unsigned long efi_entry(void *handle, efi_system_table_t 
*sys_table,
goto fail;
}
 
-   if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
-   IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
-   cmdline_size == 0)
-   efi_parse_options(CONFIG_CMDLINE);
+   #if IS_ENABLED(CONFIG_CMDLINE_BOOL)
+   efi_parse_options(CONFIG_CMDLINE_PREPEND);
+   efi_parse_options(CONFIG_CMDLINE_APPEND);
+   #endif
 
-   if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0)
+   if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE) && cmdline_size > 0)
efi_parse_options(cmdline_ptr);
 
pr_efi(sys_table, "Booting Linux Kernel...\n");
-- 
2.7.4



[PATCH 2/8] drivers: of: ifdef out cmdline section

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

It looks like there's some seepage of cmdline stuff into
the generic device tree code. This conflicts with the
generic cmdline implementation so I remove it in the case
when that's enabled.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 drivers/of/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 800ad25..74b85ad 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1096,7 +1096,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, 
const char *uname,
 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
 * is set in which case we override whatever was found earlier.
 */
-#ifdef CONFIG_CMDLINE
+#if defined(CONFIG_CMDLINE) && !defined(CONFIG_GENERIC_CMDLINE)
 #if defined(CONFIG_CMDLINE_EXTEND)
strlcat(data, " ", COMMAND_LINE_SIZE);
strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-- 
2.7.4



[PATCH 8/8] powerpc: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE
option.

[maksym.kok...@globallogic.com: add strlcat to prom_init_check.sh
whitelist]
Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/powerpc/Kconfig   | 23 +--
 arch/powerpc/kernel/prom.c |  4 
 arch/powerpc/kernel/prom_init.c|  8 
 arch/powerpc/kernel/prom_init_check.sh |  2 +-
 4 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a806692..f87906a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -172,6 +172,7 @@ config PPC
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
select GENERIC_TIME_VSYSCALL
+   select GENERIC_CMDLINE
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_JUMP_LABEL
select HAVE_ARCH_KGDB
@@ -787,28 +788,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_BOOL
-   bool "Default bootloader kernel arguments"
-
-config CMDLINE
-   string "Initial kernel command string"
-   depends on CMDLINE_BOOL
-   default "console=ttyS0,9600 console=tty0 root=/dev/sda2"
-   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.
-
-config CMDLINE_FORCE
-   bool "Always use the default kernel command string"
-   depends on CMDLINE_BOOL
-   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.
-
 config EXTRA_TARGETS
string "Additional default image types"
help
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index c4d7078..f8c6e63 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -716,6 +717,9 @@ void __init early_init_devtree(void *params)
 */
of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line);
 
+   /* append and prepend any arguments built into the kernel. */
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
+
/* Scan memory nodes and rebuild MEMBLOCKs */
of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 9b38a2e..e9214c6 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -634,11 +635,10 @@ static void __init early_cmdline_parse(void)
p = prom_cmd_line;
if ((long)prom.chosen > 0)
l = prom_getprop(prom.chosen, "bootargs", p, 
COMMAND_LINE_SIZE-1);
-#ifdef CONFIG_CMDLINE
+
if (l <= 0 || p[0] == '\0') /* dbl check */
-   strlcpy(prom_cmd_line,
-   CONFIG_CMDLINE, sizeof(prom_cmd_line));
-#endif /* CONFIG_CMDLINE */
+   cmdline_add_builtin(prom_cmd_line, NULL, sizeof(prom_cmd_line));
+
prom_printf("command line: %s\n", prom_cmd_line);
 
 #ifdef CONFIG_PPC64
diff --git a/arch/powerpc/kernel/prom_init_check.sh 
b/arch/powerpc/kernel/prom_init_check.sh
index acb6b92..b1d7ca1 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -18,7 +18,7 @@
 
 WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
 _end enter_prom memcpy memset reloc_offset __secondary_hold
-__secondary_hold_acknowledge __secondary_hold_spinloop __start
+__secondary_hold_acknowledge __secondary_hold_spinloop __start strlcat
 strcmp strcpy strlcpy strlen strncmp strstr kstrtobool logo_linux_clut224
 reloc_got2 kernstart_addr memstart_addr linux_banner _stext
 __prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
-- 
2.7.4



[PATCH 8/8] powerpc: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE
option.

[maksym.kok...@globallogic.com: add strlcat to prom_init_check.sh
whitelist]
Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/powerpc/Kconfig   | 23 +--
 arch/powerpc/kernel/prom.c |  4 
 arch/powerpc/kernel/prom_init.c|  8 
 arch/powerpc/kernel/prom_init_check.sh |  2 +-
 4 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a806692..f87906a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -172,6 +172,7 @@ config PPC
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
select GENERIC_TIME_VSYSCALL
+   select GENERIC_CMDLINE
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_JUMP_LABEL
select HAVE_ARCH_KGDB
@@ -787,28 +788,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_BOOL
-   bool "Default bootloader kernel arguments"
-
-config CMDLINE
-   string "Initial kernel command string"
-   depends on CMDLINE_BOOL
-   default "console=ttyS0,9600 console=tty0 root=/dev/sda2"
-   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.
-
-config CMDLINE_FORCE
-   bool "Always use the default kernel command string"
-   depends on CMDLINE_BOOL
-   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.
-
 config EXTRA_TARGETS
string "Additional default image types"
help
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index c4d7078..f8c6e63 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -716,6 +717,9 @@ void __init early_init_devtree(void *params)
 */
of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line);
 
+   /* append and prepend any arguments built into the kernel. */
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
+
/* Scan memory nodes and rebuild MEMBLOCKs */
of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 9b38a2e..e9214c6 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -634,11 +635,10 @@ static void __init early_cmdline_parse(void)
p = prom_cmd_line;
if ((long)prom.chosen > 0)
l = prom_getprop(prom.chosen, "bootargs", p, 
COMMAND_LINE_SIZE-1);
-#ifdef CONFIG_CMDLINE
+
if (l <= 0 || p[0] == '\0') /* dbl check */
-   strlcpy(prom_cmd_line,
-   CONFIG_CMDLINE, sizeof(prom_cmd_line));
-#endif /* CONFIG_CMDLINE */
+   cmdline_add_builtin(prom_cmd_line, NULL, sizeof(prom_cmd_line));
+
prom_printf("command line: %s\n", prom_cmd_line);
 
 #ifdef CONFIG_PPC64
diff --git a/arch/powerpc/kernel/prom_init_check.sh 
b/arch/powerpc/kernel/prom_init_check.sh
index acb6b92..b1d7ca1 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -18,7 +18,7 @@
 
 WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
 _end enter_prom memcpy memset reloc_offset __secondary_hold
-__secondary_hold_acknowledge __secondary_hold_spinloop __start
+__secondary_hold_acknowledge __secondary_hold_spinloop __start strlcat
 strcmp strcpy strlcpy strlen strncmp strstr kstrtobool logo_linux_clut224
 reloc_got2 kernstart_addr memstart_addr linux_banner _stext
 __prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
-- 
2.7.4



[PATCH 6/8] arm64: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the arm64 code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/arm64/Kconfig| 17 +
 arch/arm64/kernel/setup.c |  3 +++
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b1a0e9..e596414 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -166,6 +166,7 @@ config ARM64
select SWIOTLB
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
+   select GENERIC_CMDLINE
help
  ARM 64-bit (AArch64) Linux support.
 
@@ -1231,22 +1232,6 @@ config ARM64_ACPI_PARKING_PROTOCOL
  protocol even if the corresponding data is present in the ACPI
  MADT table.
 
-config CMDLINE
-   string "Default kernel command string"
-   default ""
-   help
- Provide a set of default command-line options at build time by
- entering them here. As a minimum, you should specify the the
- root device (e.g. root=/dev/nfs).
-
-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.
-
 config EFI_STUB
bool
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 5b4fac4..33b929b 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -295,6 +296,8 @@ void __init setup_arch(char **cmdline_p)
 
setup_machine_fdt(__fdt_pointer);
 
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
+
parse_early_param();
 
/*
-- 
2.7.4



[PATCH 6/8] arm64: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the arm64 code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/arm64/Kconfig| 17 +
 arch/arm64/kernel/setup.c |  3 +++
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b1a0e9..e596414 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -166,6 +166,7 @@ config ARM64
select SWIOTLB
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
+   select GENERIC_CMDLINE
help
  ARM 64-bit (AArch64) Linux support.
 
@@ -1231,22 +1232,6 @@ config ARM64_ACPI_PARKING_PROTOCOL
  protocol even if the corresponding data is present in the ACPI
  MADT table.
 
-config CMDLINE
-   string "Default kernel command string"
-   default ""
-   help
- Provide a set of default command-line options at build time by
- entering them here. As a minimum, you should specify the the
- root device (e.g. root=/dev/nfs).
-
-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.
-
 config EFI_STUB
bool
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 5b4fac4..33b929b 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -295,6 +296,8 @@ void __init setup_arch(char **cmdline_p)
 
setup_machine_fdt(__fdt_pointer);
 
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
+
parse_early_param();
 
/*
-- 
2.7.4



[PATCH 4/8] x86: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the x86 code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/x86/Kconfig| 44 +---
 arch/x86/kernel/setup.c | 19 +++
 2 files changed, 4 insertions(+), 59 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1a0be02..7821b23 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -96,6 +96,7 @@ config X86
select GENERIC_CLOCKEVENTS_BROADCASTif X86_64 || (X86_32 && 
X86_LOCAL_APIC)
select GENERIC_CLOCKEVENTS_MIN_ADJUST
select GENERIC_CMOS_UPDATE
+   select GENERIC_CMDLINE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
@@ -2327,49 +2328,6 @@ choice
 
 endchoice
 
-config CMDLINE_BOOL
-   bool "Built-in kernel command line"
-   ---help---
- Allow for specifying boot arguments to the kernel at
- build time.  On some systems (e.g. embedded ones), it is
- necessary or convenient to provide some or all of the
- kernel boot arguments with the kernel itself (that is,
- to not rely on the boot loader to provide them.)
-
- To compile command line arguments into the kernel,
- set this option to 'Y', then fill in the
- boot arguments in CONFIG_CMDLINE.
-
- Systems with fully functional boot loaders (i.e. non-embedded)
- should leave this option set to 'N'.
-
-config CMDLINE
-   string "Built-in kernel command string"
-   depends on CMDLINE_BOOL
-   default ""
-   ---help---
- Enter arguments here that should be compiled into the kernel
- image and used at boot time.  If the boot loader provides a
- command line at boot time, it is appended to this string to
- form the full kernel command line, when the system boots.
-
- However, you can use the CONFIG_CMDLINE_OVERRIDE option to
- change this behavior.
-
- In most cases, the command line (whether built-in or provided
- by the boot loader) should specify the device for the root
- file system.
-
-config CMDLINE_OVERRIDE
-   bool "Built-in command line overrides boot loader arguments"
-   depends on CMDLINE_BOOL
-   ---help---
- Set this option to 'Y' to have the kernel ignore the boot loader
- command line, and use ONLY the built-in command line.
-
- This is used to work around broken boot loaders.  This should
- be set to 'N' under normal conditions.
-
 config MODIFY_LDT_SYSCALL
bool "Enable the LDT (local descriptor table)" if EXPERT
default y
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index b4866ba..ee109f4 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -221,9 +222,6 @@ unsigned long saved_video_mode;
 #define RAMDISK_LOAD_FLAG  0x4000
 
 static char __initdata command_line[COMMAND_LINE_SIZE];
-#ifdef CONFIG_CMDLINE_BOOL
-static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
-#endif
 
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
 struct edd edd;
@@ -934,20 +932,9 @@ void __init setup_arch(char **cmdline_p)
bss_resource.start = __pa_symbol(__bss_start);
bss_resource.end = __pa_symbol(__bss_stop)-1;
 
-#ifdef CONFIG_CMDLINE_BOOL
-#ifdef CONFIG_CMDLINE_OVERRIDE
-   strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-#else
-   if (builtin_cmdline[0]) {
-   /* append boot loader cmdline to builtin */
-   strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
-   strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-   strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-   }
-#endif
-#endif
-
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
+
*cmdline_p = command_line;
 
/*
-- 
2.7.4



[PATCH 4/8] x86: convert to generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

This updates the x86 code to use the CONFIG_GENERIC_CMDLINE
option.

Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 arch/x86/Kconfig| 44 +---
 arch/x86/kernel/setup.c | 19 +++
 2 files changed, 4 insertions(+), 59 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1a0be02..7821b23 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -96,6 +96,7 @@ config X86
select GENERIC_CLOCKEVENTS_BROADCASTif X86_64 || (X86_32 && 
X86_LOCAL_APIC)
select GENERIC_CLOCKEVENTS_MIN_ADJUST
select GENERIC_CMOS_UPDATE
+   select GENERIC_CMDLINE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
@@ -2327,49 +2328,6 @@ choice
 
 endchoice
 
-config CMDLINE_BOOL
-   bool "Built-in kernel command line"
-   ---help---
- Allow for specifying boot arguments to the kernel at
- build time.  On some systems (e.g. embedded ones), it is
- necessary or convenient to provide some or all of the
- kernel boot arguments with the kernel itself (that is,
- to not rely on the boot loader to provide them.)
-
- To compile command line arguments into the kernel,
- set this option to 'Y', then fill in the
- boot arguments in CONFIG_CMDLINE.
-
- Systems with fully functional boot loaders (i.e. non-embedded)
- should leave this option set to 'N'.
-
-config CMDLINE
-   string "Built-in kernel command string"
-   depends on CMDLINE_BOOL
-   default ""
-   ---help---
- Enter arguments here that should be compiled into the kernel
- image and used at boot time.  If the boot loader provides a
- command line at boot time, it is appended to this string to
- form the full kernel command line, when the system boots.
-
- However, you can use the CONFIG_CMDLINE_OVERRIDE option to
- change this behavior.
-
- In most cases, the command line (whether built-in or provided
- by the boot loader) should specify the device for the root
- file system.
-
-config CMDLINE_OVERRIDE
-   bool "Built-in command line overrides boot loader arguments"
-   depends on CMDLINE_BOOL
-   ---help---
- Set this option to 'Y' to have the kernel ignore the boot loader
- command line, and use ONLY the built-in command line.
-
- This is used to work around broken boot loaders.  This should
- be set to 'N' under normal conditions.
-
 config MODIFY_LDT_SYSCALL
bool "Enable the LDT (local descriptor table)" if EXPERT
default y
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index b4866ba..ee109f4 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -221,9 +222,6 @@ unsigned long saved_video_mode;
 #define RAMDISK_LOAD_FLAG  0x4000
 
 static char __initdata command_line[COMMAND_LINE_SIZE];
-#ifdef CONFIG_CMDLINE_BOOL
-static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
-#endif
 
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
 struct edd edd;
@@ -934,20 +932,9 @@ void __init setup_arch(char **cmdline_p)
bss_resource.start = __pa_symbol(__bss_start);
bss_resource.end = __pa_symbol(__bss_stop)-1;
 
-#ifdef CONFIG_CMDLINE_BOOL
-#ifdef CONFIG_CMDLINE_OVERRIDE
-   strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-#else
-   if (builtin_cmdline[0]) {
-   /* append boot loader cmdline to builtin */
-   strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
-   strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-   strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-   }
-#endif
-#endif
-
+   cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE);
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
+
*cmdline_p = command_line;
 
/*
-- 
2.7.4



[PATCH 1/8] add generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

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.

[maksym.kok...@globallogic.com: fix cmdline_add_builtin() macro]
Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 include/linux/cmdline.h | 70 +
 init/Kconfig| 68 +++
 2 files changed, 138 insertions(+)
 create mode 100644 include/linux/cmdline.h

diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
new file mode 100644
index 000..75ef278
--- /dev/null
+++ b/include/linux/cmdline.h
@@ -0,0 +1,70 @@
+/* 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);
+   }
+
+   strlcat(dest, " ", 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, " ", length);
+   strlcat(tmp, dest, length);
+   strlcpy(dest, tmp, length);
+   }
+}
+
+#define cmdline_add_builtin(dest, src, length) \
+{  \
+   if (sizeof(CONFIG_CMDLINE_PREPEND) > 1) {   \
+   static char cmdline_tmp_space[length] __initdata;   \
+   _cmdline_add_builtin(dest, src, cmdline_tmp_space, length); \
+   } else {\
+   _cmdline_add_builtin(dest, src, NULL, length);  \
+   }   \
+}
+#else
+#define cmdline_add_builtin(dest, src, length)\
+{ \
+   strlcpy(dest, CONFIG_CMDLINE_PREPEND " " CONFIG_CMDLINE_APPEND,\
+   length);   \
+}
+#endif /* !CONFIG_CMDLINE_OVERRIDE */
+
+#else
+#define cmdline_add_builtin(dest, src, length) { \
+   if (src != NULL)   \
+   strlcpy(dest, src, length);\
+}
+#endif /* CONFIG_GENERIC_CMDLINE */
+
+
+#endif /* _LINUX_CMDLINE_H */
diff --git a/init/Kconfig b/init/Kconfig
index 1e234e2..e5aa676 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1751,6 +1751,74 @@ config PROFILING
 config TRACEPOINTS
bool
 
+config GENERIC_CMDLINE
+   bool
+
+if GENERIC_CMDLINE
+
+config CMDLINE_BOOL
+   bool "Built-in kernel command line"
+   help
+ Allow for specifying boot arguments to the kernel at
+ build time.  On some systems (e.g. embedded ones), it is
+ necessary or convenient to provide some or all of the
+ kernel boot arguments with the kernel itself (that is,
+ to not rely on the boot loader to provide them.)
+
+ To compile command line arguments into the kernel,
+ set this option to 'Y', then fill in the
+ the boot arguments in CONFIG_CMDLINE.
+
+ Systems with fully functional boot loaders (i.e. non-embedded)
+ should leave this option set to 'N'.
+
+config CMDLINE_APPEND
+   string "Built-in kernel command string append"
+   depends on CMDLINE_BOOL
+   default ""
+   

[PATCH 0/8] add generic builtin command line

2018-09-27 Thread Maksym Kokhan
There were series of patches [1] for 4.3.0-rc3, that allowed
architectures to use a generic builtin command line. I have rebased
these patches on kernel 4.19.0-rc4.

Things, modified in comparison with original patches:   
 
* There was some bug for mips, in the case when CONFIG_CMDLINE_PREPEND
and CONFIG_CMDLINE_APPEND are empty and CMDLINE_OVERRIDE is not set,
command line from bootloader was ignored, so I fixed it, modifying
patch "add generic builtin command line".

* Implemented new patch to resolve conflict with new kernel, which
modify EFI stub code. Unfortunately, I don't have capability to test
this modification on real arm board with EFI.

* Removed new realisation of mips builtin command line, which was
created after 4.3.0-rc3.

* Kernel 4.3.0-rc3 with original patches could not be compiled for
powerpc due to prom_init.c checking by prom_init_check.sh. So I added
strlcat (which is used by cmdline_add_builtin macro) to
prom_init_check.sh whitelist.

Patches have been tested in QEMU for x86, arm (little-endian), arm64
(little-endian), mips (little-endian, 32-bit) and powerpc
(big-endian, 64-bit), everything works perfectly. Also it was tested
on linux-next (next-20180924 tag) for all listed above architectures.

[1] : https://lore.kernel.org/patchwork/patch/604992/

Daniel Walker (7):
  add generic builtin command line
  drivers: of: ifdef out cmdline section
  x86: convert to generic builtin command line
  arm: convert to generic builtin command line
  arm64: convert to generic builtin command line
  mips: convert to generic builtin command line
  powerpc: convert to generic builtin command line

Maksym Kokhan (1):
  efi: modify EFI stub code for arm/arm64

 arch/arm/Kconfig| 38 +-
 arch/arm/kernel/atags_parse.c   | 14 ++-
 arch/arm/kernel/devtree.c   |  2 +
 arch/arm64/Kconfig  | 17 +---
 arch/arm64/kernel/setup.c   |  3 ++
 arch/mips/Kconfig   | 24 +--
 arch/mips/Kconfig.debug | 47 --
 arch/mips/kernel/setup.c| 41 ++-
 arch/powerpc/Kconfig| 23 +--
 arch/powerpc/kernel/prom.c  |  4 ++
 arch/powerpc/kernel/prom_init.c |  8 ++--
 arch/powerpc/kernel/prom_init_check.sh  |  2 +-
 arch/x86/Kconfig| 44 +
 arch/x86/kernel/setup.c | 19 ++---
 drivers/firmware/efi/libstub/arm-stub.c | 10 ++---
 drivers/of/fdt.c|  2 +-
 include/linux/cmdline.h | 70 +
 init/Kconfig| 68 
 18 files changed, 173 insertions(+), 263 deletions(-)
 create mode 100644 include/linux/cmdline.h

-- 
2.7.4



[PATCH 1/8] add generic builtin command line

2018-09-27 Thread Maksym Kokhan
From: Daniel Walker 

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.

[maksym.kok...@globallogic.com: fix cmdline_add_builtin() macro]
Cc: Daniel Walker 
Cc: Daniel Walker 
Signed-off-by: Daniel Walker 
Signed-off-by: Maksym Kokhan 
---
 include/linux/cmdline.h | 70 +
 init/Kconfig| 68 +++
 2 files changed, 138 insertions(+)
 create mode 100644 include/linux/cmdline.h

diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
new file mode 100644
index 000..75ef278
--- /dev/null
+++ b/include/linux/cmdline.h
@@ -0,0 +1,70 @@
+/* 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);
+   }
+
+   strlcat(dest, " ", 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, " ", length);
+   strlcat(tmp, dest, length);
+   strlcpy(dest, tmp, length);
+   }
+}
+
+#define cmdline_add_builtin(dest, src, length) \
+{  \
+   if (sizeof(CONFIG_CMDLINE_PREPEND) > 1) {   \
+   static char cmdline_tmp_space[length] __initdata;   \
+   _cmdline_add_builtin(dest, src, cmdline_tmp_space, length); \
+   } else {\
+   _cmdline_add_builtin(dest, src, NULL, length);  \
+   }   \
+}
+#else
+#define cmdline_add_builtin(dest, src, length)\
+{ \
+   strlcpy(dest, CONFIG_CMDLINE_PREPEND " " CONFIG_CMDLINE_APPEND,\
+   length);   \
+}
+#endif /* !CONFIG_CMDLINE_OVERRIDE */
+
+#else
+#define cmdline_add_builtin(dest, src, length) { \
+   if (src != NULL)   \
+   strlcpy(dest, src, length);\
+}
+#endif /* CONFIG_GENERIC_CMDLINE */
+
+
+#endif /* _LINUX_CMDLINE_H */
diff --git a/init/Kconfig b/init/Kconfig
index 1e234e2..e5aa676 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1751,6 +1751,74 @@ config PROFILING
 config TRACEPOINTS
bool
 
+config GENERIC_CMDLINE
+   bool
+
+if GENERIC_CMDLINE
+
+config CMDLINE_BOOL
+   bool "Built-in kernel command line"
+   help
+ Allow for specifying boot arguments to the kernel at
+ build time.  On some systems (e.g. embedded ones), it is
+ necessary or convenient to provide some or all of the
+ kernel boot arguments with the kernel itself (that is,
+ to not rely on the boot loader to provide them.)
+
+ To compile command line arguments into the kernel,
+ set this option to 'Y', then fill in the
+ the boot arguments in CONFIG_CMDLINE.
+
+ Systems with fully functional boot loaders (i.e. non-embedded)
+ should leave this option set to 'N'.
+
+config CMDLINE_APPEND
+   string "Built-in kernel command string append"
+   depends on CMDLINE_BOOL
+   default ""
+   

[PATCH 0/8] add generic builtin command line

2018-09-27 Thread Maksym Kokhan
There were series of patches [1] for 4.3.0-rc3, that allowed
architectures to use a generic builtin command line. I have rebased
these patches on kernel 4.19.0-rc4.

Things, modified in comparison with original patches:   
 
* There was some bug for mips, in the case when CONFIG_CMDLINE_PREPEND
and CONFIG_CMDLINE_APPEND are empty and CMDLINE_OVERRIDE is not set,
command line from bootloader was ignored, so I fixed it, modifying
patch "add generic builtin command line".

* Implemented new patch to resolve conflict with new kernel, which
modify EFI stub code. Unfortunately, I don't have capability to test
this modification on real arm board with EFI.

* Removed new realisation of mips builtin command line, which was
created after 4.3.0-rc3.

* Kernel 4.3.0-rc3 with original patches could not be compiled for
powerpc due to prom_init.c checking by prom_init_check.sh. So I added
strlcat (which is used by cmdline_add_builtin macro) to
prom_init_check.sh whitelist.

Patches have been tested in QEMU for x86, arm (little-endian), arm64
(little-endian), mips (little-endian, 32-bit) and powerpc
(big-endian, 64-bit), everything works perfectly. Also it was tested
on linux-next (next-20180924 tag) for all listed above architectures.

[1] : https://lore.kernel.org/patchwork/patch/604992/

Daniel Walker (7):
  add generic builtin command line
  drivers: of: ifdef out cmdline section
  x86: convert to generic builtin command line
  arm: convert to generic builtin command line
  arm64: convert to generic builtin command line
  mips: convert to generic builtin command line
  powerpc: convert to generic builtin command line

Maksym Kokhan (1):
  efi: modify EFI stub code for arm/arm64

 arch/arm/Kconfig| 38 +-
 arch/arm/kernel/atags_parse.c   | 14 ++-
 arch/arm/kernel/devtree.c   |  2 +
 arch/arm64/Kconfig  | 17 +---
 arch/arm64/kernel/setup.c   |  3 ++
 arch/mips/Kconfig   | 24 +--
 arch/mips/Kconfig.debug | 47 --
 arch/mips/kernel/setup.c| 41 ++-
 arch/powerpc/Kconfig| 23 +--
 arch/powerpc/kernel/prom.c  |  4 ++
 arch/powerpc/kernel/prom_init.c |  8 ++--
 arch/powerpc/kernel/prom_init_check.sh  |  2 +-
 arch/x86/Kconfig| 44 +
 arch/x86/kernel/setup.c | 19 ++---
 drivers/firmware/efi/libstub/arm-stub.c | 10 ++---
 drivers/of/fdt.c|  2 +-
 include/linux/cmdline.h | 70 +
 init/Kconfig| 68 
 18 files changed, 173 insertions(+), 263 deletions(-)
 create mode 100644 include/linux/cmdline.h

-- 
2.7.4