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

From: sayo

Date: Mon Oct 05 2026 - 13:34:33 EST


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.

Link: https://lore.kernel.org/all/20240331200546.869343-1-m.younesbadr@xxxxxxxxx/
Link: https://lore.kernel.org/all/20250114145521.GDZ4Z62dOwYffaUrsr@fat_crate.local/

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(+)