WSL2-Linux-Kernel/arch/mn10300/kernel
Akira Takeuchi e3f12a5304 mn10300: Use early_param() to parse "mem=" parameter
This fixes the problem that "init=" options may not be passed to kernel
correctly.

parse_mem_cmdline() of mn10300 arch gets rid of "mem=" string from
redboot_command_line. Then init_setup() parses the "init=" options from
static_command_line, which is a copy of redboot_command_line, and keeps
the pointer to the init options in execute_command variable.

Since the commit 026cee0 upstream (params: <level>_initcall-like kernel
parameters), static_command_line becomes overwritten by saved_command_line at
do_initcall_level(). Notice that saved_command_line is a command line
which includes "mem=" string.

As a result, execute_command may point to weird string by the length of
"mem=" parameter.
I noticed this problem when using the command line like this:

    mem=128M console=ttyS0,115200 init=/bin/sh

Here is the processing flow of command line parameters.
    start_kernel()
      setup_arch(&command_line)
         parse_mem_cmdline(cmdline_p)
           * strcpy(boot_command_line, redboot_command_line);
           * Remove "mem=xxx" from redboot_command_line.
           * *cmdline_p = redboot_command_line;
      setup_command_line(command_line) <-- command_line is redboot_command_line
        * strcpy(saved_command_line, boot_command_line)
        * strcpy(static_command_line, command_line)
      parse_early_param()
        strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
        parse_early_options(tmp_cmdline);
          parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param);
      parse_args("Booting ..", static_command_line, ...);
        init_setup() <-- save the pointer in execute_command
      rest_init()
        kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);

At this point, execute_command points to "/bin/sh" string.

    kernel_init()
      kernel_init_freeable()
        do_basic_setup()
          do_initcalls()
            do_initcall_level()
              (*) strcpy(static_command_line, saved_command_line);

Here, execute_command gets to point to "200" string !!

Signed-off-by: David Howells <dhowells@redhat.com>
2013-06-28 16:53:03 +01:00
..
Makefile mn10300: switch to generic kernel_execve() 2012-10-01 00:53:59 -04:00
asm-offsets.c MN10300: fix SMP synchronization between txdma and serial driver 2012-12-12 15:46:14 +00:00
cevt-mn10300.c mn10300: move setup_jiffies_interrupt() to cevt-mn10300.c 2012-07-11 16:04:41 -07:00
csrc-mn10300.c MN10300: Use clocksource_register_hz() 2011-03-18 16:52:50 +00:00
entry.S MN10300: Enable IRQs more in system call exit work path 2013-05-30 13:38:48 +09:00
fpu-low.S MN10300: Make the FPU operate in non-lazy mode under SMP 2010-10-27 17:28:52 +01:00
fpu-nofpu-low.S MN10300: Make the FPU operate in non-lazy mode under SMP 2010-10-27 17:28:52 +01:00
fpu-nofpu.c MN10300: Make the FPU operate in non-lazy mode under SMP 2010-10-27 17:28:52 +01:00
fpu.c Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
gdb-io-serial-low.S MN10300: And Panasonic AM34 subarch and implement SMP 2010-10-27 17:28:55 +01:00
gdb-io-serial.c Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
gdb-io-ttysm-low.S Separate out the proc- and unit-specific header directories from the general 2009-04-10 14:33:48 +01:00
gdb-io-ttysm.c Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
gdb-low.S mn10300: add the MN10300/AM33 architecture to the kernel 2008-02-08 09:22:30 -08:00
gdb-stub.c Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
head.S MN10300: And Panasonic AM34 subarch and implement SMP 2010-10-27 17:28:55 +01:00
internal.h mn10300: split ret_from_fork, simplify kernel_thread() 2012-10-01 00:53:24 -04:00
io.c mn10300: add the MN10300/AM33 architecture to the kernel 2008-02-08 09:22:30 -08:00
irq.c MN10300: cleanup IRQ affinity setting 2012-12-12 15:46:14 +00:00
kgdb.c mn10300: Use common threadinfo allocator 2012-05-08 14:08:45 +02:00
kprobes.c MN10300: Allow some cacheflushes to be avoided if cache snooping is available 2010-10-27 17:28:46 +01:00
mn10300-debug.c mn10300: add the MN10300/AM33 architecture to the kernel 2008-02-08 09:22:30 -08:00
mn10300-serial-low.S MN10300: fix SMP synchronization between txdma and serial driver 2012-12-12 15:46:14 +00:00
mn10300-serial.c TTY: mn10300-serial, fix build breakage 2013-01-16 07:36:47 -08:00
mn10300-serial.h MN10300: ttySM: clean up unnecessary casting 2012-12-12 15:46:14 +00:00
mn10300-watchdog-low.S MN10300: And Panasonic AM34 subarch and implement SMP 2010-10-27 17:28:55 +01:00
mn10300-watchdog.c Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
mn10300_ksyms.c mn10300: provide __ucmpdi2() for MN10300 2008-07-04 10:40:07 -07:00
module.c modules: make arch's use default loader hooks 2011-07-24 22:06:04 +09:30
process.c dump_stack: unify debug information printed by show_regs() 2013-04-30 17:04:02 -07:00
profile-low.S mn10300: add the MN10300/AM33 architecture to the kernel 2008-02-08 09:22:30 -08:00
profile.c MN10300: And Panasonic AM34 subarch and implement SMP 2010-10-27 17:28:55 +01:00
ptrace.c Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
rtc.c set_rtc_mmss: show warning message only once 2011-01-13 08:03:07 -08:00
setup.c mn10300: Use early_param() to parse "mem=" parameter 2013-06-28 16:53:03 +01:00
sigframe.h mn10300: add the MN10300/AM33 architecture to the kernel 2008-02-08 09:22:30 -08:00
signal.c mn10300: switch to generic old sigaction() 2013-02-03 18:16:04 -05:00
smp-low.S Disintegrate asm/system.h for MN10300 2012-03-28 18:30:02 +01:00
smp.c mn10300: Use generic idle loop 2013-04-08 17:39:27 +02:00
switch_to.S MN10300: Emulate single stepping in KGDB on MN10300 2011-03-18 16:54:32 +00:00
sys_mn10300.c Add generic sys_ipc wrapper 2010-03-12 15:52:32 -08:00
time.c MN10300: Use clockevents_calc_mult_shift() 2011-03-18 16:52:50 +00:00
traps.c dump_stack: consolidate dump_stack() implementations and unify their behaviors 2013-04-30 17:04:02 -07:00
vmlinux.lds.S MN10300: Add missing _sdata declaration 2011-06-07 19:03:53 -07:00