mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
x86/setup: prepend embedded bootconfig cmdline before parse_early_param
Call xbc_prepend_embedded_cmdline() in setup_arch() right after the CONFIG_CMDLINE merge and before strscpy(command_line, ...) so the build-time-rendered embedded bootconfig "kernel" subtree is part of boot_command_line by the time parse_early_param() runs. early_param() handlers (mem=, earlycon=, loglevel=, ...) now see values supplied via CONFIG_BOOT_CONFIG_EMBED_FILE without parsing bootconfig at runtime. Gate the prepend on the same opt-in the runtime parser uses: prepend when "bootconfig" is present on the command line, or when CONFIG_BOOT_CONFIG_FORCE is set. Detect it with parse_args(), exactly as setup_boot_config() does, so both agree on what counts as opt-in: any "bootconfig" key regardless of value (bare, =0, =1, ...), and only before the "--" that separates init arguments. Sharing the parser keeps the early and late paths from diverging -- e.g. "bootconfig=0" or a "-- bootconfig" meant for init must not apply the embedded keys early while the runtime parser skips them. The prepend necessarily runs before setup_boot_config() detects an initrd bootconfig, so an initrd cannot override the embedded "kernel" keys for early_param(). This is intentional: the embedded cmdline acts like a build-time CONFIG_CMDLINE. An initrd bootconfig's "kernel" keys never reached early_param() anyway (they apply late via extra_command_line), so nothing is lost -- the initrd keys still apply late, with last-wins keeping the embedded values in effect. Link: https://lore.kernel.org/all/20260626-bootconfig_using_tools-v7-7-24ab72139c29@debian.org/ Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
This commit is contained in:
parent
de0428ed55
commit
bfdf7ec54f
|
|
@ -127,6 +127,7 @@ config X86
|
|||
select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
|
||||
select ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP if NR_CPUS <= 4096
|
||||
select ARCH_SUPPORTS_CFI if X86_64
|
||||
select ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG
|
||||
select ARCH_USES_CFI_TRAPS if X86_64 && CFI
|
||||
select ARCH_SUPPORTS_LTO_CLANG
|
||||
select ARCH_SUPPORTS_LTO_CLANG_THIN
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* parts of early kernel initialization.
|
||||
*/
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/bootconfig.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/crash_dump.h>
|
||||
|
|
@ -880,7 +881,6 @@ static void __init x86_report_nx(void)
|
|||
*
|
||||
* Note: On x86_64, fixmaps are ready for use even before this is called.
|
||||
*/
|
||||
|
||||
void __init setup_arch(char **cmdline_p)
|
||||
{
|
||||
#ifdef CONFIG_X86_32
|
||||
|
|
@ -924,6 +924,18 @@ void __init setup_arch(char **cmdline_p)
|
|||
builtin_cmdline_added = true;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CMDLINE_FROM_BOOTCONFIG
|
||||
/*
|
||||
* Prepend the build-time-rendered embedded "kernel" keys here so
|
||||
* parse_early_param() below sees them, using the same opt-in as the
|
||||
* runtime parser, plus the build-time CONFIG_BOOT_CONFIG_FORCE.
|
||||
*/
|
||||
if (bootconfig_cmdline_requested(boot_command_line, NULL) ||
|
||||
IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE))
|
||||
xbc_prepend_embedded_cmdline(boot_command_line,
|
||||
COMMAND_LINE_SIZE);
|
||||
#endif
|
||||
|
||||
strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
|
||||
*cmdline_p = command_line;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user