From nobody Tue Sep 16 08:47:31 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E254C53210 for ; Thu, 5 Jan 2023 01:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjAEBAM (ORCPT ); Wed, 4 Jan 2023 20:00:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbjAEA7r (ORCPT ); Wed, 4 Jan 2023 19:59:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CA4947309; Wed, 4 Jan 2023 16:58:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 29907B81716; Thu, 5 Jan 2023 00:58:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9903C433EF; Thu, 5 Jan 2023 00:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672880318; bh=G20leUtEUw9tobzMM7YamKZ/d8zVXVzh16H30wqZ98k=; h=Date:From:To:Cc:Subject:Reply-To:From; b=ND3hK1V4ql4Hb6KaQuLMW94lOLEWEXsHlCZvgf4lIvnoSRlyKW6KVpv9Z7ZdDfpC/ ocUiahp2qwV0v3C9vvlpc/ZMyeLrgl+SzWdiDU+4ejZxq63ycZPgUl8/HugV7xCEVX qdIZolBwiISP12lUQEvt69lChuUpGXG7h2bLOX+tBkEbjhbNWfLFUaSSRvVrJRLXbF DDQfN9HutqRFUBzdgDo0Ukl2p9xRbsJGHVLvhx1fQC/aRxhXrcBsUpYBtzKcwdgQOV HPT4NNTiVWbEIrBpVJBifazckfmXY5ETi4VVMPdandtdDOjINALhDz8a7Tarqwg6mz eV/smDZr+Akiw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 75A7C5C05CA; Wed, 4 Jan 2023 16:58:38 -0800 (PST) Date: Wed, 4 Jan 2023 16:58:38 -0800 From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: mhiramat@kernel.org, corbet@lwn.net, akpm@linux-foundation.org, ndesaulniers@google.com, vbabka@suse.cz, hannes@cmpxchg.org, joel@joelfernandes.org, quic_neeraju@quicinc.com, urezki@gmail.com Subject: [PATCH RFC bootconfig] Allow forcing unconditional bootconfig processing Message-ID: <20230105005838.GA1772817@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3Dy 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. Signed-off-by: Paul E. McKenney Cc: Masami Hiramatsu Cc: Jonathan Corbet Cc: Andrew Morton Cc: Nick Desaulniers Cc: Vlastimil Babka Cc: Johannes Weiner Cc: diff --git a/Documentation/admin-guide/bootconfig.rst b/Documentation/admin= -guide/bootconfig.rst index 9355c525fbe0a..91339efdcb541 100644 Acked-by: Masami Hiramatsu (Google) --- a/Documentation/admin-guide/bootconfig.rst +++ b/Documentation/admin-guide/bootconfig.rst @@ -201,6 +201,8 @@ To remove the config from the image, you can use -d opt= ion as below:: =20 Then add "bootconfig" on the normal kernel command line to tell the 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. =20 Embedding a Boot Config into Kernel ----------------------------------- @@ -217,7 +219,9 @@ path to the bootconfig file from source tree or object = tree. The kernel will embed it as the default bootconfig. =20 Just as when attaching the bootconfig to the initrd, you need ``bootconfig= `` -option on the kernel command line to enable the embedded bootconfig. +option on the kernel command line to enable the embedded bootconfig, or, +alternatively, build your kernel with the ``CONFIG_BOOT_CONFIG_FORCE`` +Kconfig option selected. =20 Note that even if you set this option, you can override the embedded bootconfig by another bootconfig which attached to the initrd. diff --git a/init/Kconfig b/init/Kconfig index 7e5c3ddc341de..f894fb004bad4 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1376,6 +1376,18 @@ config BOOT_CONFIG =20 If unsure, say Y. =20 +config BOOT_CONFIG_FORCE + bool "Force unconditional bootconfig processing" + depends on BOOT_CONFIG + help + With this Kconfig option set, BOOT_CONFIG processing is carried + out even when the "bootconfig" kernel-boot parameter is omitted. + In fact, with this Kconfig option set, there is no way to + make the kernel ignore the BOOT_CONFIG-supplied kernel-boot + parameters. + + If unsure, say N. + config BOOT_CONFIG_EMBED bool "Embed bootconfig file in the kernel" depends on BOOT_CONFIG diff --git a/init/main.c b/init/main.c index e1c3911d7c707..669cb892e6c17 100644 --- a/init/main.c +++ b/init/main.c @@ -156,7 +156,7 @@ static char *extra_init_args; =20 #ifdef CONFIG_BOOT_CONFIG /* Is bootconfig on command line? */ -static bool bootconfig_found; +static bool bootconfig_found =3D IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE); static size_t initargs_offs; #else # define bootconfig_found false