From nobody Mon Jun 8 17:55:01 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEE5C43C05B; Wed, 27 May 2026 16:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900144; cv=none; b=bQ81r4gSxOI2EJnamtSlphJvpj6muvujuItrjhgzGsNjKuvPUjxbrkqpU2ls2X3IAeycOALhu4zLHxZ/jHPDayRr3glLJdlbJnpFZOFIPasPBZh2OsL+W9+BFkqX1f+UrZArWi+IyjI8GzJT7BPLsNFR9nIqq6AL2DF+2sUSTeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900144; c=relaxed/simple; bh=X4mGDA4esgRIQEJF9sxare2igjopQXrRYxDQwzDdu+Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=djzGKOYWW4ngfnrIZOs1/cNgAN+pnsBQYj1xl2l6A8OLtXzEN1/qKzZyW/ZreihZ+LwBSyvORB/iPEfO1AyGG++ePSnaDLrL2ADH1DV24g9JuAxcFj6UlkX84zbIaT12Bc56c9kb9bVdBEtZ5YC/fnUNslm8QyV3bwztlJMm11s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=OztPd8iv; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="OztPd8iv" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=7moABFLCmmNZhtc/dXiLfbR8Q2gsMvAbGjyVpQo9sZ8=; b=OztPd8iv01fqORXxh7GXcephJp iO9o+j3nE6Kj6fJ7pkZBueSO2uEskHI3TqkorbppPzfJvzuwZ6Eqdii5d+jImoZ5QCW+1ahiyFUpq BaRHYkIp1VLNnCCs0gqvY3SBblIOAjW9YiqKbz/g7alvSpCZSaF0n55GLo8gNHYuhJ+wdjjcg4Xxc eBVctELQrrVS1Zx1krEERmc4SYHd87e0p6QQQa8E3N3XpMl9pWwYMRSujoATJaOrw/cIpUSa+onq3 CyJIThohn/RMVWz7qX8ToxXf3HlYgwLXKrwAlNH8iQdOj8Gl09Hm9pG8ywx/O2xBe0TA/j33tPT7r LtM4OjGA==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wSHKR-003JPd-2h; Wed, 27 May 2026 16:42:00 +0000 From: Breno Leitao Date: Wed, 27 May 2026 09:41:34 -0700 Subject: [PATCH 1/4] bootconfig: return 0 from xbc_snprint_cmdline() for a leaf root Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260527-bootconfig_using_tools-v1-1-b6906a86e7d5@debian.org> References: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> In-Reply-To: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> To: Masami Hiramatsu , Andrew Morton , Nathan Chancellor , paulmck@kernel.org, Nicolas Schier Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=1432; i=leitao@debian.org; h=from:subject:message-id; bh=X4mGDA4esgRIQEJF9sxare2igjopQXrRYxDQwzDdu+Q=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqFx7NaP8LXXap85VkwAMoYdAKK9Hv6uUYzHt9o +OUyd6BqjaJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahcezQAKCRA1o5Of/Hh3 bR+XD/4pL22NX+nNoRVaxZF+jQWcUVTth6DWOz58O8RxeC+Fp4X8JIKXnGky0M/IQ/Nf5bWi7i7 6dWAmqN7IMzqE9bQEDijwiBQBOsG3s6Vdg0ht547uoJwGrMU6xJEvZignWIxKrccxrd9J7merMq 8V8DibN9wQe2qNz3JRh9R8R+EQPqXsJUPu5zisJXAPuBqKYquAmjiQ9o0DPV5KpN2QwyHDGjYxx fYSlJc1ovQ0PQddk4fGXYl67+dApkvxqGgur2WMK9GYo+TnhgU61QWfWGJ6WBVwhNTb9oXv33hY 1hqtrrHdBaYnG8gHj73uOZfoOcPangBnxCClgXwRUpy5cgiEGrddsi5STCBqVnR03YfJnZs9pHe p9dhLIN9Eszsx+jwNOK1yibfmaKmdD6rzWxhjewGP5qivI5alJZrlWtUz/09shK/53luTxMs60M B2yxYABpmzv5jxaSTyUsohfYs5IdOIoSy9NGJ/HZL+BR6UcLPpOOVq2UOaTC1SwaBdMSUtkawFB oTPKMBARVUjq1DAa63nfT8qGuMKXuHhAHHTjnvADPqOLlJWzGAhoAnMstW4/8pp3eHQWxVowYp/ 6cf+X9a2OX2J3jvAlRr9AAB2Ao65lEokB8c3yBDp+Qb5VTpW+vrwJwIvRHrzkzSLpt6tKs5GNxR FtQD9GmmUKkMfAQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Returning -EINVAL when @root has no descendant key nodes is a quirky result for a renderer: "nothing to render" is not an error. The only existing caller, xbc_make_cmdline(), papers over it with a `len <=3D 0` check, so the misbehavior is harmless today. The new -C user in tools/bootconfig added by the follow-up patches propagates the error and turns an empty "kernel {}" subtree into a build failure. Short-circuit the leaf-root case and return 0 so the rendered length matches the rendered content. Signed-off-by: Breno Leitao --- lib/bootconfig.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/bootconfig.c b/lib/bootconfig.c index f445b7703fdd..3a102c9122f7 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -431,6 +431,16 @@ int __init xbc_snprint_cmdline(char *buf, size_t size,= struct xbc_node *root) const char *val, *q; int ret; =20 + /* + * A leaf @root (e.g. an empty "kernel {}" subtree, or a key whose + * only child is a value node) has no descendant key/value pairs to + * render. The leaf-finding iterator below would otherwise return + * @root itself, which xbc_node_compose_key_after() rejects with + * -EINVAL. + */ + if (root && xbc_node_is_leaf(root)) + return 0; + xbc_node_for_each_key_value(root, knode, val) { ret =3D xbc_node_compose_key_after(root, knode, xbc_namebuf, XBC_KEYLEN_MAX); --=20 2.54.0 From nobody Mon Jun 8 17:55:01 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 362BA43C04C; Wed, 27 May 2026 16:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900143; cv=none; b=uZ2oJoZF1UY8GKfFYjEp+OWmDRT8s2hkaEKe4P2cwUy7wdF7tcPIn4GKDHQ5Vn3VdbyBIe+5RCIL6HjZeDXHdf71l/Qtqkjew/EOJy8n5fc00bQgNgwPW7hKvphzYCZ2r6FB/TF9dFOA2TmxFcwqWOxSx8vBLvxhxHXjXurOXYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900143; c=relaxed/simple; bh=qjd3tguTj0WFwiPlEIeVbyzh3f1Zu6w1BXCkFvwK7q8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EU/bn5+gyGCDtlaVxIObaLKerNa9t6/WyjPjEWCOERWtxc/I35d9KY4RcxJDDizO4aXxSsTOQzKCM6fxnBXkiiFXBGXNh6gT7JUQvK2Yhp77fJ4w/HQAX+Cph9t7tFBygXHfJEih2YJzlM/okmyE/xf7dWlXgG51g62dyAiXZVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=K6UsFZbj; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="K6UsFZbj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=M13mLGQRBGUn1JxQb9Dlyz/7Efn1k3VV1WqpaU1q/a4=; b=K6UsFZbj+JXviEdG9m6WNbH9Tw 5QSlnUl9QvrvMWS4HDJGbv9Z7yAooG7PE8b7H90qq2NoRILPxivZQ6vI+F971jdfTgqlCxuIQZki0 HDJJ6UtSeXe1kOLz8hGZ5nHBdnDqwpLRmaxGQZ5elAob6WuW5MBWFpXyqlO0tW2EMU+q9aBUUOFQM ZxlFj/rOUwmp7IybXI4tFl70jln5pb7ydn5nBhKTb3q3u4oIOomoRq0ue6DKT33TsvsB1D+YgQ0w3 Mye8dMT560SfSDjfwuTeOw4IwjkylTNCtTSo2hAmy8Zk+PTlr3cuLqNcEp7EsGdRO1e/EyHFUwqSg dAetBJWw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wSHKW-003JPh-2O; Wed, 27 May 2026 16:42:05 +0000 From: Breno Leitao Date: Wed, 27 May 2026 09:41:35 -0700 Subject: [PATCH 2/4] bootconfig: render embedded bootconfig as a kernel cmdline at build time Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260527-bootconfig_using_tools-v1-2-b6906a86e7d5@debian.org> References: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> In-Reply-To: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> To: Masami Hiramatsu , Andrew Morton , Nathan Chancellor , paulmck@kernel.org, Nicolas Schier Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=6974; i=leitao@debian.org; h=from:subject:message-id; bh=qjd3tguTj0WFwiPlEIeVbyzh3f1Zu6w1BXCkFvwK7q8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqFx7N/lN7BhCSbH5GyUOsWhONOBrZ7ohZPrPON R0xqw+moQ6JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahcezQAKCRA1o5Of/Hh3 bZTtEACbVcAO3TU/zsDr8yMKV8XfYFC+IbG/J+PhYQAny8E4igdDdFIwTHWmCs0wwF6KiLFVX2e h3q9vjgOiqc2yXfSE/poRW7rEO+LVfv7kPQBGHtcQjJmt1lp4ivKrXzdSEfSwS6s7lE+UE4iWVc DC5u4FpjklxYBVddUleJKIVBjvxKi7fbJsH0vthVeWyhb8T7P0Hr6xop/2R+kKN0ZLWPTQh8F7w CreMF1OHwoa/Q+8QEuWTGUj0X7ZtVaDdll5lL1ZXFvl/WuO5l+Xc6hc5BCx8iyNYuhSTtqzbK3M lvf/LkYwG9DJ8A43xInUnpCU3np5/NEdGEAsL39HA1o+CcItVP4+7lyEyvg5EwdOL1mqBGYF8yy gXiZpSVSI6iFCr9H46QwItINk8coMXG8Bbx/KvCvQM8zBe2f+oGXr1kQ3fpdoKz2xD0u6g6HSct 6JxZvEVkidtqgo5RxKxgDSRowSoLh6EvLvT/4EZ+m8NQyEw6Vx1JexxzIWN6xKXMSQfBdzRhT7L TG1BW9mCyarX9HyCAdnadiXqa+LQ/AYY12PFG3Hxq4gvZld/5f5ccmQBpi56ixhbn9BuLIWJCRg w3kOaYI1ExzZqlEyOCOAX0gjy0ecyXr7nlOTS8Q14lkYOBm878LtyYn020z5IMapnBtXoS+L/x3 MnU2JqgBJlX9BuQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Add the build-time pipeline that renders the "kernel" subtree of CONFIG_BOOT_CONFIG_EMBED_FILE into a flat cmdline string and stashes it in .init.rodata as embedded_kernel_cmdline[]. A follow-up patch adds the runtime helper that prepends this string to boot_command_line during early architecture setup so parse_early_param() sees the values. The build wires up: tools/bootconfig -C kernel - userspace tool already shared with lib/bootconfig.c, used here in -C mode to render a bootconfig file to a cmdline lib/embedded-cmdline.S - .incbin's the rendered text plus a NUL lib/Makefile rule - runs tools/bootconfig at build time Makefile prepare dep - ensures tools/bootconfig is built first, same pattern as tools/objtool and tools/bpf/resolve_btfids Drop the test target from tools/bootconfig/Makefile's default 'all' recipe so that hooking the binary into the kernel build does not run test-bootconfig.sh on every prepare. The tests stay available as 'make -C tools/bootconfig test', matching the convention of tools/objtool and tools/bpf/resolve_btfids whose 'all' targets only build the binary. Require BOOT_CONFIG_EMBED_FILE to be non-empty before the new option can be enabled, otherwise tools/bootconfig -C runs against an empty file and prints a parse error on every kernel build. The feature gates on CONFIG_ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG, a silent symbol arches select once they've wired the prepend call into setup_arch(). No arch selects it in this patch, so the user-visible CONFIG_BOOT_CONFIG_EMBED_CMDLINE is not yet enableable; when an arch later opts in, the runtime behavior is added by the follow-up patches. Signed-off-by: Breno Leitao --- Makefile | 5 +++++ init/Kconfig | 33 +++++++++++++++++++++++++++++++++ lib/Makefile | 16 ++++++++++++++++ lib/embedded-cmdline.S | 16 ++++++++++++++++ tools/bootconfig/Makefile | 2 +- 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d59f703f9797..3ee259d00a9a 100644 --- a/Makefile +++ b/Makefile @@ -1543,6 +1543,11 @@ prepare: tools/bpf/resolve_btfids endif endif =20 +# lib/Makefile invokes tools/bootconfig to render the embedded bconf to cm= dline. +ifdef CONFIG_BOOT_CONFIG_EMBED_CMDLINE +prepare: tools/bootconfig +endif + # The tools build system is not a part of Kbuild and tends to introduce # its own unique issues. If you need to integrate a new tool into Kbuild, # please consider locating that tool outside the tools/ tree and using the diff --git a/init/Kconfig b/init/Kconfig index ca35184532dc..5f491a5ac4b8 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1569,6 +1569,39 @@ config BOOT_CONFIG_EMBED_FILE This bootconfig will be used if there is no initrd or no other bootconfig in the initrd. =20 +config ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG + bool + help + Selected by architectures whose setup_arch() prepends the + build-time-rendered embedded bootconfig cmdline to + boot_command_line before parse_early_param() runs. + +config BOOT_CONFIG_EMBED_CMDLINE + bool "Render embedded bootconfig as kernel cmdline at build time" + depends on BOOT_CONFIG_EMBED + depends on BOOT_CONFIG_EMBED_FILE !=3D "" + depends on ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG + default n + help + Render the "kernel" subtree of the embedded bootconfig file into a + flat cmdline string at kernel build time and prepend it to + boot_command_line during early architecture setup. This makes + early_param() handlers (e.g. mem=3D, earlycon=3D, loglevel=3D) see the + values supplied via the embedded bootconfig. + + The runtime bootconfig parser is unaffected, so tree-structured + consumers such as ftrace boot-time tracing keep working. + + Note: when an initrd also carries a bootconfig, its "kernel" + subtree is still parsed at runtime, but the embedded "kernel" + keys remain in boot_command_line for parse_early_param() and + end up later than the initrd keys in saved_command_line, so + parse_args() last-wins favors the embedded values. If you need + initrd to override embedded kernel.* keys, leave this option + off. + + If unsure, say N. + config CMDLINE_LOG_WRAP_IDEAL_LEN int "Length to try to wrap the cmdline when logged at boot" default 1021 diff --git a/lib/Makefile b/lib/Makefile index 6e72d2c1cce7..9de0ac7732a2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -273,6 +273,22 @@ filechk_defbconf =3D cat $(or $(real-prereqs), /dev/nu= ll) $(obj)/default.bconf: $(CONFIG_BOOT_CONFIG_EMBED_FILE) FORCE $(call filechk,defbconf) =20 +obj-$(CONFIG_BOOT_CONFIG_EMBED_CMDLINE) +=3D embedded-cmdline.o +$(obj)/embedded-cmdline.o: $(obj)/embedded_cmdline.bin + +# Render the bootconfig "kernel" subtree to a flat cmdline string using +# the userspace tools/bootconfig parser (-C mode). The runtime prepend +# helper enforces COMMAND_LINE_SIZE at boot, so no build-time size +# check is performed here (COMMAND_LINE_SIZE is an arch header +# constant, not a Kconfig value). +quiet_cmd_render_cmdline =3D BCONF2C $@ + cmd_render_cmdline =3D \ + $(objtree)/tools/bootconfig/bootconfig -C $< > $@ + +targets +=3D embedded_cmdline.bin +$(obj)/embedded_cmdline.bin: $(obj)/default.bconf $(objtree)/tools/bootcon= fig/bootconfig FORCE + $(call if_changed,render_cmdline) + obj-$(CONFIG_RBTREE_TEST) +=3D rbtree_test.o obj-$(CONFIG_INTERVAL_TREE_TEST) +=3D interval_tree_test.o =20 diff --git a/lib/embedded-cmdline.S b/lib/embedded-cmdline.S new file mode 100644 index 000000000000..7e2e1d81af96 --- /dev/null +++ b/lib/embedded-cmdline.S @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Embed the build-time-rendered bootconfig "kernel" subtree as a flat + * cmdline string. setup_arch() prepends this to boot_command_line on + * architectures that select ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG. + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates + * Copyright (c) 2026 Breno Leitao + */ + .section .init.rodata, "aw" + .global embedded_kernel_cmdline +embedded_kernel_cmdline: + .incbin "lib/embedded_cmdline.bin" + .byte 0 + .global embedded_kernel_cmdline_end +embedded_kernel_cmdline_end: diff --git a/tools/bootconfig/Makefile b/tools/bootconfig/Makefile index 90eb47c9d8de..4e82fd9553cd 100644 --- a/tools/bootconfig/Makefile +++ b/tools/bootconfig/Makefile @@ -15,7 +15,7 @@ override CFLAGS +=3D -Wall -g -I$(CURDIR)/include ALL_TARGETS :=3D bootconfig ALL_PROGRAMS :=3D $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) =20 -all: $(ALL_PROGRAMS) test +all: $(ALL_PROGRAMS) =20 $(OUTPUT)bootconfig: main.c include/linux/bootconfig.h $(LIBSRC) $(CC) $(filter %.c,$^) $(CFLAGS) $(LDFLAGS) -o $@ --=20 2.54.0 From nobody Mon Jun 8 17:55:01 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6839C43D51A; Wed, 27 May 2026 16:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900147; cv=none; b=EXYdfpVoWHN0ZEH6C5OboFiBuM9WAFooc2CS1kVJqobWcFuVS8QiIMlfPL+Es5PRBXuLnhDdYtl7boOCwsA1VUSops0KX2DDJ65RgPxCWTWe6KyuqftdvzMOtJIdDlfmbB9vf3Xc0UtKOcApvP0MDUGce9wLTWZmSMv9BCQVLvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900147; c=relaxed/simple; bh=u8TivqtfuxjXhVadzsvzmKZSENicQ9GEXwCok1K8r5c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F7VDUkdaU5ZDHchKm2rKnP2Ezm2EgKrFaT+lTqIS4pmWOGJ6ElnTXzpcBwK1lOXPaBvrMgj5jy/7uIRyaVDRZULhSrJHfDiLXx6m8OKtWueai1G2woxDoZobOxrBULpJDqoaa1usDUIk5e6S0U5mcit10TF9LVSr94Tyt8k5ibI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=Nz7giBmb; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="Nz7giBmb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=k0G/1hIbcwmtxPWuX+E3Ksr2kN5fJ2sgTjtC/gyLWxY=; b=Nz7giBmbwNisqgY+a5gG6Eb+qy bV+eKAg/SRf0ePKhglzJnle8RmWYE9B3VeTPS3f1Iaxq2KMyznOcx65UW5/aXyunnAbYhOEDJsWjM 1Ot5atLUweQ0C4rWBzDyneEWZQtKicgctTtIEQWBVlBgXikpuYuusa7CV1UKN+UIBdFNjX10LUENz 7R0ozz36ct2TXdLeDNo1v35HUBNqkgGmpxp8FIhsIeC9uSvbW3GspvJtvkFh0K7Fjkiee7NpiC0dT Kv7/8SvBl4DsKaksR+KHFYNPChL2vANCPBh6C8dtdw44UdZxJ2k+yRGHIOYz66/tkhv5DhBKPfk/T ct35a6Tg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wSHKb-003JPp-1p; Wed, 27 May 2026 16:42:09 +0000 From: Breno Leitao Date: Wed, 27 May 2026 09:41:36 -0700 Subject: [PATCH 3/4] bootconfig: add xbc_prepend_embedded_cmdline() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260527-bootconfig_using_tools-v1-3-b6906a86e7d5@debian.org> References: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> In-Reply-To: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> To: Masami Hiramatsu , Andrew Morton , Nathan Chancellor , paulmck@kernel.org, Nicolas Schier Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=3922; i=leitao@debian.org; h=from:subject:message-id; bh=u8TivqtfuxjXhVadzsvzmKZSENicQ9GEXwCok1K8r5c=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqFx7NGCQMUYnbaKnSbk7h4OGGd3VLD4EJ2cz4T CMvgvv8qbqJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahcezQAKCRA1o5Of/Hh3 bVrNEACu7MeK46jFKUKXtk8wKh3StVbD3VleWAz6o4Sq83L2tXb+o3dbCT4GpUvJZ82s6UzU1H2 zTCC/b/0UVJeayLxUhXa48mjX93F9DfvBZ2u0R+kn511/HngFc9hzjSl4LY3saA+9T+VNc3KANw 7fk4t4c27F9X4oW4nZsDEjoVAiWStZxUs5zJzOS8vwEDAIi0lFAYcd2rhqa+XM/9vv3BRe7a7uy mHFOp2/xBkmtv0v7om8/3CwMLs7xP0B64QkE237meSOsVcom4P29YsPfPKF5wFD5jBHXJQJzYiI ov5BMLYJ8VPZ3FZYsMWj2W3HPOV7HuKr+iffNmugYZSwdlE96986bBDT7GfHHe6Se0iS2CMuZv3 DgZSAvjqkIHI08Kj5GfKbBch7esA5AbyjtVtPD6bdPXObsgqwi3RF+9AOsIAYso5fEzQPbB4olv NpjFQvp4O0EWQ4BT6THBQtmRSpyGD4uwytXGET0Sv93cmF0av2ak30nlmsyBUupugEG67rc9ul5 5z6F5jkj3RhDi5dF+WF/V/i646A3LVvzOQV8aGIrOmsnVNQHLT7UMAv9vWEa4yE2jy1G2yT+LG5 ApOjZ/FfSqxeOM67Ynt8QIb+6RwifJ/i3v7EuJ8Sac2iD1pcxF2Khj2mrcpbQBRs8xVlRtJVPRG UvdK2SxEycyOCqQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Add a helper that prepends the build-time-rendered embedded bootconfig "kernel" subtree (embedded_kernel_cmdline[] from embedded-cmdline.S) to a cmdline buffer with a separating space. Architectures call this from setup_arch() before parse_early_param() so early_param() handlers (mem=3D, earlycon=3D, loglevel=3D, ...) see values supplied via the embedded bootconfig. On overflow the helper logs an error and leaves the cmdline untouched rather than panicking. Booting without the embedded values is better than refusing to boot, and the error tells the user why their embedded keys are missing. When CONFIG_BOOT_CONFIG_EMBED_CMDLINE=3Dn, the public declaration in resolves to a no-op stub so callers compile unchanged. Signed-off-by: Breno Leitao --- include/linux/bootconfig.h | 7 +++++++ lib/bootconfig.c | 48 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 55 insertions(+) diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h index 1c7f3b74ffcf..dcb0c86cbc54 100644 --- a/include/linux/bootconfig.h +++ b/include/linux/bootconfig.h @@ -308,4 +308,11 @@ static inline const char *xbc_get_embedded_bootconfig(= size_t *size) } #endif =20 +/* Build-time-rendered bootconfig cmdline prepended in setup_arch() */ +#ifdef CONFIG_BOOT_CONFIG_EMBED_CMDLINE +void __init xbc_prepend_embedded_cmdline(char *dst, size_t size); +#else +static inline void xbc_prepend_embedded_cmdline(char *dst, size_t size) { } +#endif + #endif diff --git a/lib/bootconfig.c b/lib/bootconfig.c index 3a102c9122f7..10c62c8600c8 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,53 @@ const char * __init xbc_get_embedded_bootconfig(size_t *= size) return (*size) ? embedded_bootconfig_data : NULL; } #endif + +#ifdef CONFIG_BOOT_CONFIG_EMBED_CMDLINE +/* embedded_kernel_cmdline is defined in embedded-cmdline.S */ +extern __visible const char embedded_kernel_cmdline[]; +extern __visible const char embedded_kernel_cmdline_end[]; + +/** + * xbc_prepend_embedded_cmdline() - Prepend embedded bootconfig cmdline + * @dst: cmdline buffer to prepend into (must already contain a NUL byte) + * @size: total capacity of @dst in bytes + * + * Prepend the build-time-rendered "kernel" subtree of the embedded + * bootconfig to @dst. The rendered string already ends with a single + * space (the xbc_snprint_cmdline() invariant), which serves as the + * separator between the embedded keys and any existing content of @dst. + * On overflow, log an error and leave @dst untouched rather than + * silently truncating: booting without the embedded values is better + * than refusing to boot, and the error message tells the user why + * their embedded keys are missing. + * + * Intended to be called from setup_arch() before parse_early_param() so + * that early_param() handlers see the embedded values. + */ +void __init xbc_prepend_embedded_cmdline(char *dst, size_t size) +{ + size_t embed_len =3D embedded_kernel_cmdline_end - embedded_kernel_cmdlin= e; + size_t dst_len; + + if (!size || embed_len <=3D 1) /* trailing NUL only */ + return; + embed_len--; /* exclude trailing NUL byte */ + + dst_len =3D strnlen(dst, size); + if (embed_len + dst_len + 1 > size) { + pr_err("embedded bootconfig cmdline (%zu bytes) does not fit in COMMAND_= LINE_SIZE with %zu bytes already used; ignoring embedded values\n", + embed_len, dst_len); + return; + } + + if (dst_len) + memmove(dst + embed_len, dst, dst_len + 1); + else + dst[embed_len] =3D '\0'; + memcpy(dst, embedded_kernel_cmdline, embed_len); +} +#endif + #endif =20 /* --=20 2.54.0 From nobody Mon Jun 8 17:55:01 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 878D142B75A; Wed, 27 May 2026 16:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900145; cv=none; b=KKzRAFHOqf0DKLGHr/k9uAR43RilVaitPvVKJXEjF21ZqzR3vZyvNdhhkaWwG4Qyw2WTc8gPaMUDiEgH1N4P+slGL5v8WOAKY53lidPFp5Dbe0GhGojwJi1SDHpn9YSUWBA82Ng1XrIxr0ZlDJhWDtm7u9Fqak1LPp7h/Odc4Ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779900145; c=relaxed/simple; bh=ENLneK8xBeKmCQGwJZLA8r/UEpwj6k2/RtjAZzWN0d4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZsERPi/vZNfHz/qnjjmaZ1L5R6UFSAZGlcDuUOUkRAZEyCsYqMnolcfMRrrI2dx1yCbx0sIgaQOZlWOTzdLQS/jFbtcDyhEbAMbimfI1YK0r8lQgSTCZEmdzDfEzoay/UXbaPzGhIWJwHOkuwYP0l5Kzi7oKh53f6XyMjiGYDHg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=Y74hv0Pi; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="Y74hv0Pi" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=LjJ5UiE639iXrNLvVtVEZ0IF+WZQaMaRUMl009rvAFc=; b=Y74hv0PiZQy1VlV0JQQq/JjRal ycgUGvOAg8YupO6DI4Hj5cm9IjS+jI324sBWcYfQ2NNDv6NnhSb5ADywTV3oUO7qUsWwvFjzys1Zr I/MKjT0FbskgYGIsxw+TPkL8MhzH+vxTVemSFPUCr6W7dd1VXaetgUhrNAyAAjbW+NCfmyld1Orkd pFB2B+7/NnCt02yuld8sMQmgOxkJ06/ETtfdF54a9nQwO16EZs8LVALEpR+L0HOyTnygNQbx77rt+ 3eScO+umZ92I0Tct8pQEwU18RUovfMo+xAMAZSodUiTYszHJ9e4yuNQT616NxgExv3WsLftbquS7J iQyDLRTg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wSHKg-003JPx-0W; Wed, 27 May 2026 16:42:14 +0000 From: Breno Leitao Date: Wed, 27 May 2026 09:41:37 -0700 Subject: [PATCH 4/4] x86/setup: prepend embedded bootconfig cmdline before parse_early_param Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260527-bootconfig_using_tools-v1-4-b6906a86e7d5@debian.org> References: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> In-Reply-To: <20260527-bootconfig_using_tools-v1-0-b6906a86e7d5@debian.org> To: Masami Hiramatsu , Andrew Morton , Nathan Chancellor , paulmck@kernel.org, Nicolas Schier Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=4155; i=leitao@debian.org; h=from:subject:message-id; bh=ENLneK8xBeKmCQGwJZLA8r/UEpwj6k2/RtjAZzWN0d4=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqFx7NjBMxBJyOY//uFemPR8XbTitBOk9KJJxQU WvsTxkimN6JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahcezQAKCRA1o5Of/Hh3 bcvjEACM9g+xCW/ta9XvmQ7RQkYXcju2/5IOCzGjzCw0tAwLgqtgAv4K+kSxPXs4XP2/KSLqbaF NfKQmLiNnWdFbMi19qJcvno9SEOHprSWUE/gaUjr5Jj5hBSel9dqlu/hqb4mZdhNRd6ONq71Jcc 26zVF1OeO6NHk9/xTQKNObNM2hYMbLvZMQW/emnu6DmxA/U0aEeykD+MB/SrRLRqyu834t5R7FJ 6drZ6CT/wthjvftdxijBmA0QMPxQJ0vvLIS21fAD2diVCGCSIlfIkrVINsSZs28FGTh5t92kMD4 /Xp2dm3QXwUs2dS8V9bNLWPcpJVkeZrEInJVnJMtfxcAvnjSmumbbNVCU/1YWS9flQHsFjkDDq0 jyjrwX54rkiKjXz0JawqZcQeWlEzpwY7Tx3mNiiZ1DfIuykQl64+rHUGMQn01bFZSyWFpVEjgLp M3svCKE+nPx7D90QlrbjDQRXU8sqQXPp6aCGAJDveKFj7O5EhrVILlm6yBY2HXgPQibmncJgEBA xXvFZDnK0Tr9PK3EXgP06Z1ibCWok64hZsbRPwloRrJnBLWXBTKIqbaDx3s8jyH+ftNPP+8PR8v LBgSarSPl6srRmgWWHVqMBZbtpbU5HCDvBjjBKZx277rF1DwQ6iyPNPYoufOHkF67is4PGjDwjZ yhio7qw5w+alcng== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao 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=3D, earlycon=3D, loglevel=3D, ...) now see values supplied via CONFIG_BOOT_CONFIG_EMBED_FILE without parsing bootconfig at runtime. Select ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG so the user-visible CONFIG_BOOT_CONFIG_EMBED_CMDLINE option becomes selectable on x86. With this select in place, setup_boot_config() in init/main.c would otherwise render the embedded "kernel" subtree a second time via xbc_make_cmdline("kernel") and prepend it to saved_command_line / static_command_line through extra_command_line, duplicating every embedded kernel.* key in /proc/cmdline and causing accumulating handlers (console=3D, earlycon=3D, ...) to register the same value twice. Track whether the bootconfig data came from the embedded source and skip the duplicate render in that case. Signed-off-by: Breno Leitao --- arch/x86/Kconfig | 1 + arch/x86/kernel/setup.c | 3 +++ init/main.c | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f24810015234..f839795692b4 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -126,6 +126,7 @@ config X86 select ARCH_SUPPORTS_NUMA_BALANCING if X86_64 select ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP if NR_CPUS <=3D 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 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 46882ce79c3a..592c4c79c974 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -6,6 +6,7 @@ * parts of early kernel initialization. */ #include +#include #include #include #include @@ -924,6 +925,8 @@ void __init setup_arch(char **cmdline_p) builtin_cmdline_added =3D true; #endif =20 + xbc_prepend_embedded_cmdline(boot_command_line, COMMAND_LINE_SIZE); + strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE); *cmdline_p =3D command_line; =20 diff --git a/init/main.c b/init/main.c index e363232b428b..8264bfa97aa2 100644 --- a/init/main.c +++ b/init/main.c @@ -378,12 +378,15 @@ static void __init setup_boot_config(void) int pos, ret; size_t size; char *err; + bool from_embedded =3D false; =20 /* Cut out the bootconfig data even if we have no bootconfig option */ data =3D get_boot_config_from_initrd(&size); /* If there is no bootconfig in initrd, try embedded one. */ - if (!data) + if (!data) { data =3D xbc_get_embedded_bootconfig(&size); + from_embedded =3D true; + } =20 strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); err =3D parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, @@ -421,8 +424,18 @@ static void __init setup_boot_config(void) } else { xbc_get_info(&ret, NULL); pr_info("Load bootconfig: %ld bytes %d nodes\n", (long)size, ret); - /* keys starting with "kernel." are passed via cmdline */ - extra_command_line =3D xbc_make_cmdline("kernel"); + /* + * keys starting with "kernel." are passed via cmdline. When + * BOOT_CONFIG_EMBED_CMDLINE is enabled and this bootconfig + * came from the embedded source, setup_arch() already + * prepended the rendered "kernel" subtree to + * boot_command_line; rendering again here would duplicate + * the keys in saved_command_line / static_command_line and + * cause accumulating handlers (console=3D, earlycon=3D, ...) to + * re-register the same value. + */ + if (!IS_ENABLED(CONFIG_BOOT_CONFIG_EMBED_CMDLINE) || !from_embedded) + extra_command_line =3D xbc_make_cmdline("kernel"); /* Also, "init." keys are init arguments */ extra_init_args =3D xbc_make_cmdline("init"); } --=20 2.54.0