Skip to content

Commit b743852

Browse files
paulmckrcumhiramat
authored andcommitted
Allow forcing unconditional bootconfig processing
The BOOT_CONFIG family of Kconfig options allows a bootconfig file containing kernel boot parameters to be embedded into an initrd or into the kernel itself. This can be extremely useful when deploying kernels in cases where some of the boot parameters depend on the kernel version rather than on the server hardware, firmware, or workload. Unfortunately, the "bootconfig" kernel parameter must be specified in order to cause the kernel to look for the embedded bootconfig file, and it clearly does not help to embed this "bootconfig" kernel parameter into that file. Therefore, provide a new BOOT_CONFIG_FORCE Kconfig option that causes the kernel to act as if the "bootconfig" kernel parameter had been specified. In other words, kernels built with CONFIG_BOOT_CONFIG_FORCE=y will look for the embedded bootconfig file even when the "bootconfig" kernel parameter is omitted. This permits kernel-version-dependent kernel boot parameters to be embedded into the kernel image without the need to (for example) update large numbers of boot loaders. Link: https://lore.kernel.org/all/20230105005838.GA1772817@paulmck-ThinkPad-P17-Gen-1/ Signed-off-by: Paul E. McKenney <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent cf8c59a commit b743852

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Documentation/admin-guide/bootconfig.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ To remove the config from the image, you can use -d option as below::
201201

202202
Then add "bootconfig" on the normal kernel command line to tell the
203203
kernel to look for the bootconfig at the end of the initrd file.
204+
Alternatively, build your kernel with the ``CONFIG_BOOT_CONFIG_FORCE``
205+
Kconfig option selected.
204206

205207
Embedding a Boot Config into Kernel
206208
-----------------------------------
@@ -217,7 +219,9 @@ path to the bootconfig file from source tree or object tree.
217219
The kernel will embed it as the default bootconfig.
218220

219221
Just as when attaching the bootconfig to the initrd, you need ``bootconfig``
220-
option on the kernel command line to enable the embedded bootconfig.
222+
option on the kernel command line to enable the embedded bootconfig, or,
223+
alternatively, build your kernel with the ``CONFIG_BOOT_CONFIG_FORCE``
224+
Kconfig option selected.
221225

222226
Note that even if you set this option, you can override the embedded
223227
bootconfig by another bootconfig which attached to the initrd.

init/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,18 @@ config BOOT_CONFIG
13801380

13811381
If unsure, say Y.
13821382

1383+
config BOOT_CONFIG_FORCE
1384+
bool "Force unconditional bootconfig processing"
1385+
depends on BOOT_CONFIG
1386+
help
1387+
With this Kconfig option set, BOOT_CONFIG processing is carried
1388+
out even when the "bootconfig" kernel-boot parameter is omitted.
1389+
In fact, with this Kconfig option set, there is no way to
1390+
make the kernel ignore the BOOT_CONFIG-supplied kernel-boot
1391+
parameters.
1392+
1393+
If unsure, say N.
1394+
13831395
config BOOT_CONFIG_EMBED
13841396
bool "Embed bootconfig file in the kernel"
13851397
depends on BOOT_CONFIG

init/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static char *extra_init_args;
156156

157157
#ifdef CONFIG_BOOT_CONFIG
158158
/* Is bootconfig on command line? */
159-
static bool bootconfig_found;
159+
static bool bootconfig_found = IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE);
160160
static size_t initargs_offs;
161161
#else
162162
# define bootconfig_found false

0 commit comments

Comments
 (0)