Skip to content

x86: stop handing boot-stage parameters to init

sayo lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest2 patches 0 repliesNew

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2init: claim parameters consumed before the main kernelinclude/linux/init.h init/main.c+28 -00 replies
2/2x86: claim the parameters consumed by the boot stub and decompressorarch/x86/kernel/setup.c+40 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/2] x86: stop handing boot-stage parameters to init

Some kernel parameters are consumed before the main kernel is running: the boot stub, the decompressor and the EFI stub read the command line directly and act on options that the main kernel never registers, because they describe things that are already decided by then - the kernel's load address, the paging mode, the memory encryption mode. parse_args() cannot know they were eaten, so unknown_bootoption() hands them to init: valueless options in argv, "key=value" ones in the environment.

On x86 that is nokaslr [KNL,EARLY], no5lvl [X86-64,RISCV,EARLY], mem_encrypt= [X86-64] and edd= [EDD] - all documented kernel parameters.

That collides with init's own argument convention: busybox init does "if (argv[1]) xsetenv("RUNLEVEL", argv[1]);", openrc-init takes the runlevel from argv[1], and a shell used as init treats the argument as a script name and exits, so a plain "nokaslr" boot reaches userspace as a bogus RUNLEVEL.

Earlier attempts at this (2024-03, 2024-10, 2025-01) added a stub handler for "nokaslr" alone; Boris preferred the generic version over per-parameter stubs that only silence a warning. So patch 1 adds the hook and patch 2 fills in the x86 list. Nothing changes for parameters that are genuinely unknown - they still reach init, and the notice names only those again.

sayo (2):
init: claim parameters consumed before the main kernel
x86: claim the parameters consumed by the boot stub and decompressor

 arch/x86/kernel/setup.c | 40 ++++++++++++++++++++++++++++++++++++++++
 include/linux/init.h    | 12 ++++++++++++
 init/main.c             | 16 ++++++++++++++++
 3 files changed, 68 insertions(+)