Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misinterpretation of dashes used as separators for init arguments #226

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3435,10 +3435,10 @@ at the very end of the boot logs.

=== Init environment

Documented at https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html[]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, never ever use latest on a link. It WILL break one day. I'll fix this later on with my commit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh alright! I will keep that in mind

Documented at https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html[]:

____
The kernel parses parameters from the kernel command line up to "-"; if it doesn't recognize a parameter and it doesn't contain a '.', the parameter gets passed to init: parameters with '=' go into init's environment, others are passed as command line arguments to init. Everything after "-" is passed as an argument to init.
The kernel parses parameters from the kernel command line up to "--"; if it doesn't recognize a parameter and it doesn't contain a '.', the parameter gets passed to init: parameters with '=' go into init's environment, others are passed as command line arguments to init. Everything after "--" is passed as an argument to init.
____

And you can try it out with:
Expand All @@ -3450,22 +3450,21 @@ And you can try it out with:
From the <<dry-run,generated QEMU command>>, we see that the kernel CLI at LKMC 69f5745d3df11d5c741551009df86ea6c61a09cf now contains:

....
init=/lkmc/linux/init_env_poweroff.out console=ttyS0 - lkmc_home=/lkmc asdf=qwer zxcv
init=/lkmc/linux/init_env_poweroff.out console=ttyS0 -- lkmc_home=/lkmc asdf=qwer zxcv
....

and the init program outputs:

....
args:
/lkmc/linux/init_env_poweroff.out
-
lkmc_home=/lkmc
asdf=qwer
zxcv

env:
HOME=/
TERM=linux
lkmc_home=/lkmc
asdf=qwer
....

Source: link:userland/linux/init_env_poweroff.c[].
Expand Down Expand Up @@ -6089,7 +6088,7 @@ See also:
* https://unix.stackexchange.com/questions/48601/how-to-display-the-linux-kernel-command-line-parameters-given-for-the-current-bo
* https://askubuntu.com/questions/32654/how-do-i-find-the-boot-parameters-used-by-the-running-kernel

The arguments are documented in the kernel documentation: https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html
The arguments are documented in the kernel documentation: https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

When dealing with real boards, extra command line options are provided on some magic bootloader configuration file, e.g.:

Expand Down
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ Extra options to append at the end of the emulator command line.
if self.env['kgdb']:
kernel_cli += ' kgdboc={},115200'.format(extra_console)
if kernel_cli_after_dash:
kernel_cli += " -{}".format(kernel_cli_after_dash)
kernel_cli += " --{}".format(kernel_cli_after_dash)
extra_env = {}
if self.env['trace_insts_stdout']:
if self.env['emulator'] == 'qemu':
Expand Down
2 changes: 1 addition & 1 deletion setup
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ -f /.dockerenv ]; then
apt install -y software-properties-common
add-apt-repository -y ppa:git-core/ppa
$sudo apt update
git='git=1:2.36.*'
git='git=1:2.*'
else
git=git
fi
Expand Down