All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: snambakam@microsoft.com, Steven Rostedt <rostedt@goodmis.org>,
	linux-trace-kernel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [RFC PATCH 5/5] Documentation: bootconfig: Document multiple bootconfigs and selection
Date: Fri, 27 Nov 2026 14:46:19 +0000	[thread overview]
Message-ID: <20261127144614.61194-6-mhiramat@kernel.org> (raw)
In-Reply-To: <20261127144614.61194-1-mhiramat@kernel.org>

Document stacked initrd bootconfigs, #BOOTCONFIG-ID naming rules,
index 0 default semantics, XBC_CONFIG_MAX (32) limits, backward
compatibility and single-image requirements, bootconfig= command-line
selection syntax, updated CONFIG_CMDLINE_FROM_BOOTCONFIG selection
rules, and tools/bootconfig -i usage in
Documentation/admin-guide/bootconfig.rst.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 Documentation/admin-guide/bootconfig.rst | 82 ++++++++++++++++++++++--
 1 file changed, 76 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/bootconfig.rst b/Documentation/admin-guide/bootconfig.rst
index 3d6412458c8b..72be0df4cb3d 100644
--- a/Documentation/admin-guide/bootconfig.rst
+++ b/Documentation/admin-guide/bootconfig.rst
@@ -199,11 +199,11 @@ to/from initrd image. You can build it by the following command::
  # make -C tools/bootconfig
 
 To add your boot config file to initrd image, run bootconfig as below
-(Old data is removed automatically if exists)::
+(Old default data is replaced if it exists)::
 
  # tools/bootconfig/bootconfig -a your-config /boot/initrd.img-X.Y.Z
 
-To remove the config from the image, you can use -d option as below::
+To remove all boot config files from the image, use the -d option as below::
 
  # tools/bootconfig/bootconfig -d /boot/initrd.img-X.Y.Z
 
@@ -212,6 +212,69 @@ kernel to look for the bootconfig at the end of the initrd file.
 Alternatively, build your kernel with the ``CONFIG_BOOT_CONFIG_FORCE``
 Kconfig option selected.
 
+Attaching Multiple Boot Configs to Initrd
+-----------------------------------------
+
+Multiple bootconfig files (up to 32) can be stacked at the end of an initrd
+image, which is useful for Unified Kernel Images (UKIs) that bundle a base
+configuration alongside scenario-specific or debug overlays::
+
+ [initrd][block 0 (default)][block 1 (id1)][block 2 (id2)]...
+
+Each block has its own ``#BOOTCONFIG\n`` footer. Named blocks carry an
+in-band comment header on their first line (``#BOOTCONFIG-ID: <id>\n``).
+Identifiers must be 1 to 31 characters long, start with an ASCII letter or
+underscore (``[A-Za-z_]`` -- leading digits are reserved for 0-based indices),
+and contain only ASCII letters, digits, ``_``, ``-``, or ``.``.
+
+To attach or replace a named bootconfig, pass ``-i <id>`` to ``bootconfig``::
+
+ # tools/bootconfig/bootconfig -a base.bconf /boot/initrd.img-X.Y.Z
+ # tools/bootconfig/bootconfig -i debug -a debug.bconf /boot/initrd.img-X.Y.Z
+ # tools/bootconfig/bootconfig -i trace -a trace.bconf /boot/initrd.img-X.Y.Z
+
+To inspect or preview the merged result on the host, or selectively delete
+configs::
+
+ # tools/bootconfig/bootconfig /boot/initrd.img-X.Y.Z
+ # tools/bootconfig/bootconfig -l -i ,debug /boot/initrd.img-X.Y.Z
+ # tools/bootconfig/bootconfig -d -i debug /boot/initrd.img-X.Y.Z
+
+The block at index ``0`` is the default bootconfig. ``bootconfig -a`` without
+``-i`` always places the unnamed block at index ``0``; deleting index ``0``
+(``bootconfig -d -i 0``) promotes the next block to index ``0`` (making it the
+new default). At boot time, ``bootconfig`` parameters before ``--`` are
+evaluated left-to-right:
+
+- ``bootconfig`` (bare): selects only the default config (index ``0``).
+- ``bootconfig=id1,id2`` (or ``bootconfig=0,2``): selects and merges the
+  listed IDs or 0-based indices in initrd stack order. An empty entry such as
+  ``bootconfig=,debug`` is shorthand for ``0,debug``.
+- ``bootconfig=+debug``: appends ``debug`` onto an earlier ``bootconfig=...``
+  selection on the command line (or onto index ``0`` if no prior
+  ``bootconfig`` parameter appeared).
+- ``bootconfig=`` (empty value): clears earlier selections and loads no
+  bootconfig (unless ``CONFIG_BOOT_CONFIG_FORCE=y`` is set, which forces
+  index ``0`` when no config is selected).
+
+Selected configs are merged in stack order (index ``0`` first, later overlays
+after), so overlays can use ``:=`` and ``+=`` to override or extend base keys.
+
+.. warning::
+
+   - **Older kernels**: A kernel without multi-bootconfig support strips and
+     loads only the outermost trailer (the last overlay) as the sole
+     bootconfig, leaving earlier trailers inside the initrd where
+     ``unpack_to_rootfs()`` will fail with ``Initramfs unpacking failed`` (or
+     fall back to ``CONFIG_BLK_DEV_RAM``).
+   - **Older tools**: An older ``tools/bootconfig -a/-d`` operates only on the
+     outermost trailer and leaves earlier stacked blocks behind.
+   - **Single contiguous trailer stack**: Inner trailers must end at the exact
+     start of the next trailer with no inter-image padding. All stacked
+     bootconfig blocks must therefore be attached at the tail of a single
+     initrd image via ``tools/bootconfig -i`` rather than split across
+     separately padded initrd images or UKI initrd addons.
+
 Embedding a Boot Config into Kernel
 -----------------------------------
 
@@ -254,10 +317,12 @@ an architecture that selects ``CONFIG_ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG``.
 Currently only x86 selects it; on other architectures the embedded
 bootconfig still works, but only through the late runtime parser.
 
-The same ``bootconfig`` opt-in applies as elsewhere: the rendered keys
-are prepended only when ``bootconfig`` (in any form) appears on the
-kernel command line, or when ``CONFIG_BOOT_CONFIG_FORCE`` is set, which
-defaults to ``y`` when ``CONFIG_BOOT_CONFIG_EMBED`` is set.
+The same ``bootconfig`` selection rules apply as elsewhere: the rendered
+keys are prepended only when index 0 (or the embedded bootconfig's ID) is
+selected via ``bootconfig`` on the kernel command line, or when
+``CONFIG_BOOT_CONFIG_FORCE`` is set (which defaults to ``y`` when
+``CONFIG_BOOT_CONFIG_EMBED`` is set) and no active ``bootconfig=...``
+selection overrides it.
 
 For example, given::
 
@@ -367,6 +432,11 @@ the padding null characters.)
 Anyway, since bootconfig command verifies it when appending a boot config
 to initrd image, user can notice it before boot.
 
+When stacking multiple bootconfig files in an initrd, up to 32 files can be
+attached. Each individual file must fit within 32KB, while the combined size
+of all stacked files in the initrd may exceed 32KB as long as the subset
+selected at boot fits within 32KB and the node limit.
+
 
 Bootconfig APIs
 ===============
-- 
2.43.0


      parent reply	other threads:[~2026-11-27 14:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 14:46 [RFC PATCH 0/5] bootconfig: Support multiple named bootconfigs in initrd Masami Hiramatsu (Google)
2026-11-27 14:46 ` [RFC PATCH 1/5] bootconfig: Add multi-config ID helpers and xbc_init_configs() support Masami Hiramatsu (Google)
2026-11-27 15:02   ` sashiko-bot
2026-11-29  0:47     ` Masami Hiramatsu (Google)
2026-11-27 14:46 ` [RFC PATCH 2/5] bootconfig: Support stacked initrd bootconfigs and bootconfig= selection Masami Hiramatsu (Google)
2026-11-27 15:11   ` sashiko-bot
2026-11-29  1:27     ` Masami Hiramatsu (Google)
2026-11-27 14:46 ` [RFC PATCH 3/5] tools/bootconfig: Support multiple named bootconfigs with -i option Masami Hiramatsu (Google)
2026-11-27 14:46 ` [RFC PATCH 4/5] selftests/ftrace: Add boottime tests for multiple bootconfig selection Masami Hiramatsu (Google)
2026-11-27 14:46 ` Masami Hiramatsu (Google) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127144614.61194-6-mhiramat@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=skhan@linuxfoundation.org \
    --cc=snambakam@microsoft.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.