* [PATCH v2 0/2] kbuild: add target to build a cpio containing modules
@ 2025-11-25 13:18 Ahmad Fatoum
2025-11-25 13:18 ` [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally Ahmad Fatoum
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2025-11-25 13:18 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Simon Glass, Thomas Weißschuh, kernel, linux-kernel,
linux-kbuild, Ahmad Fatoum, Sascha Hauer
---
Changes in v2:
- Add Simon's Tested-by and Reviewed-by
- rename to modules-cpio-pkg (Nathan)
- add separator/doc comment heading (Thomas)
- Make temp directory ignoring and cleanup automatic (Thomas)
- Use CONFIG_SHELL instead of shebang (Thomas)
- Use -o instead of redirecting stdout when creating cpio (Thomas)
- Drop superfluous -f as $(build)= overrides it (Thomas)
- Add extra preparatory patch that makes hostprogs := gen_init_cpio
unconditional
- Link to v1: https://lore.kernel.org/r/20251115-cpio-modules-pkg-v1-1-01d5a0748442@pengutronix.de
---
Ahmad Fatoum (1):
initramfs: add gen_init_cpio to hostprogs unconditionally
Sascha Hauer (1):
kbuild: add target to build a cpio containing modules
scripts/Makefile.package | 20 ++++++++++++++++++++
usr/Makefile | 4 ++--
2 files changed, 22 insertions(+), 2 deletions(-)
---
base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
change-id: 20251115-cpio-modules-pkg-70d85a69892b
Best regards,
--
Ahmad Fatoum <a.fatoum@pengutronix.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally
2025-11-25 13:18 [PATCH v2 0/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
@ 2025-11-25 13:18 ` Ahmad Fatoum
2025-11-25 22:15 ` Simon Glass
2025-11-25 13:18 ` [PATCH v2 2/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Ahmad Fatoum @ 2025-11-25 13:18 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Simon Glass, Thomas Weißschuh, kernel, linux-kernel,
linux-kbuild, Ahmad Fatoum
gen_init_cpio is currently only needed when an initramfs cpio archive is
to be created out of CONFIG_INITRAMFS_SOURCE's contents. In other cases,
it's not added to hostprogs and no make target is available.
In preparation to use the host program from Makefile.package, define it
unconditionally. The program will still only be built as needed.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
usr/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/usr/Makefile b/usr/Makefile
index f1779496bca78b4a56651b6af7221675ec7ade7a..e8f42478a0b76540180d191042cd58d3e4381f19 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -16,6 +16,8 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
$(obj)/initramfs_data.o: $(obj)/initramfs_inc_data
+hostprogs := gen_init_cpio
+
ramfs-input := $(CONFIG_INITRAMFS_SOURCE)
cpio-data :=
@@ -48,8 +50,6 @@ ifeq ($(cpio-data),)
cpio-data := $(obj)/initramfs_data.cpio
-hostprogs := gen_init_cpio
-
# .initramfs_data.cpio.d is used to identify all files included
# in initramfs and to detect if any files are added/removed.
# Removed files are identified by directory timestamp being updated
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] kbuild: add target to build a cpio containing modules
2025-11-25 13:18 [PATCH v2 0/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
2025-11-25 13:18 ` [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally Ahmad Fatoum
@ 2025-11-25 13:18 ` Ahmad Fatoum
2025-11-26 20:48 ` Nicolas Schier
2025-11-25 23:56 ` [PATCH v2 0/2] " Nathan Chancellor
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Ahmad Fatoum @ 2025-11-25 13:18 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Simon Glass, Thomas Weißschuh, kernel, linux-kernel,
linux-kbuild, Sascha Hauer, Ahmad Fatoum
From: Sascha Hauer <s.hauer@pengutronix.de>
Add a new package target to build a cpio archive containing the kernel
modules. This is particularly useful to supplement an existing initramfs
with the kernel modules so that the root filesystem can be started with
all needed kernel modules without modifying it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Co-developed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
scripts/Makefile.package | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 74bcb9e7f7a4516473481468a0fcf700c3bead33..83bfcf7cb09fd2d69b97e0c19a2b99c728835e8d 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -189,6 +189,25 @@ tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar
tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
@:
+# modules-cpio-pkg - generate an initramfs with the modules
+# ---------------------------------------------------------------------------
+
+.tmp_modules_cpio: FORCE
+ $(Q)$(MAKE) -f $(srctree)/Makefile
+ $(Q)rm -rf $@
+ $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
+
+quiet_cmd_cpio = CPIO $@
+ cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
+
+modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio
+ $(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
+ $(call cmd,cpio)
+
+PHONY += modules-cpio-pkg
+modules-cpio-pkg: modules-$(KERNELRELEASE)-$(ARCH).cpio
+ @:
+
# perf-tar*-src-pkg - generate a source tarball with perf source
# ---------------------------------------------------------------------------
@@ -245,6 +264,7 @@ help:
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
@echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
@echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
+ @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
@echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
@echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
@echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally
2025-11-25 13:18 ` [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally Ahmad Fatoum
@ 2025-11-25 22:15 ` Simon Glass
0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2025-11-25 22:15 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: Nathan Chancellor, Nicolas Schier, Thomas Weißschuh, kernel,
linux-kernel, linux-kbuild
On Tue, 25 Nov 2025 at 06:18, Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> gen_init_cpio is currently only needed when an initramfs cpio archive is
> to be created out of CONFIG_INITRAMFS_SOURCE's contents. In other cases,
> it's not added to hostprogs and no make target is available.
>
> In preparation to use the host program from Makefile.package, define it
> unconditionally. The program will still only be built as needed.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> usr/Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] kbuild: add target to build a cpio containing modules
2025-11-25 13:18 [PATCH v2 0/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
2025-11-25 13:18 ` [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally Ahmad Fatoum
2025-11-25 13:18 ` [PATCH v2 2/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
@ 2025-11-25 23:56 ` Nathan Chancellor
2025-11-26 7:06 ` Thomas Weißschuh
2025-11-28 21:42 ` Nicolas Schier
4 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2025-11-25 23:56 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: Nicolas Schier, Simon Glass, Thomas Weißschuh, kernel,
linux-kernel, linux-kbuild, Sascha Hauer
On Tue, Nov 25, 2025 at 02:18:18PM +0100, Ahmad Fatoum wrote:
>
> ---
> Changes in v2:
> - Add Simon's Tested-by and Reviewed-by
> - rename to modules-cpio-pkg (Nathan)
> - add separator/doc comment heading (Thomas)
> - Make temp directory ignoring and cleanup automatic (Thomas)
> - Use CONFIG_SHELL instead of shebang (Thomas)
> - Use -o instead of redirecting stdout when creating cpio (Thomas)
> - Drop superfluous -f as $(build)= overrides it (Thomas)
> - Add extra preparatory patch that makes hostprogs := gen_init_cpio
> unconditional
> - Link to v1: https://lore.kernel.org/r/20251115-cpio-modules-pkg-v1-1-01d5a0748442@pengutronix.de
>
> ---
> Ahmad Fatoum (1):
> initramfs: add gen_init_cpio to hostprogs unconditionally
>
> Sascha Hauer (1):
> kbuild: add target to build a cpio containing modules
>
> scripts/Makefile.package | 20 ++++++++++++++++++++
> usr/Makefile | 4 ++--
> 2 files changed, 22 insertions(+), 2 deletions(-)
> ---
> base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
> change-id: 20251115-cpio-modules-pkg-70d85a69892b
>
> Best regards,
> --
> Ahmad Fatoum <a.fatoum@pengutronix.de>
>
Thanks a lot for implementing all of Thomas's suggestions (and thanks to
him for providing them). This series looks good to me and I can imagine
this being quite useful for testing.
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Cheers,
Nathan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] kbuild: add target to build a cpio containing modules
2025-11-25 13:18 [PATCH v2 0/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
` (2 preceding siblings ...)
2025-11-25 23:56 ` [PATCH v2 0/2] " Nathan Chancellor
@ 2025-11-26 7:06 ` Thomas Weißschuh
2025-11-28 21:42 ` Nicolas Schier
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-11-26 7:06 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: Nathan Chancellor, Nicolas Schier, Simon Glass, kernel,
linux-kernel, linux-kbuild, Sascha Hauer
On Tue, Nov 25, 2025 at 02:18:18PM +0100, Ahmad Fatoum wrote:
>
> ---
> Changes in v2:
> - Add Simon's Tested-by and Reviewed-by
> - rename to modules-cpio-pkg (Nathan)
> - add separator/doc comment heading (Thomas)
> - Make temp directory ignoring and cleanup automatic (Thomas)
> - Use CONFIG_SHELL instead of shebang (Thomas)
> - Use -o instead of redirecting stdout when creating cpio (Thomas)
> - Drop superfluous -f as $(build)= overrides it (Thomas)
> - Add extra preparatory patch that makes hostprogs := gen_init_cpio
> unconditional
> - Link to v1: https://lore.kernel.org/r/20251115-cpio-modules-pkg-v1-1-01d5a0748442@pengutronix.de
>
> ---
> Ahmad Fatoum (1):
> initramfs: add gen_init_cpio to hostprogs unconditionally
>
> Sascha Hauer (1):
> kbuild: add target to build a cpio containing modules
For the series:
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>
> scripts/Makefile.package | 20 ++++++++++++++++++++
> usr/Makefile | 4 ++--
> 2 files changed, 22 insertions(+), 2 deletions(-)
> ---
> base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
> change-id: 20251115-cpio-modules-pkg-70d85a69892b
>
> Best regards,
> --
> Ahmad Fatoum <a.fatoum@pengutronix.de>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] kbuild: add target to build a cpio containing modules
2025-11-25 13:18 ` [PATCH v2 2/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
@ 2025-11-26 20:48 ` Nicolas Schier
0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2025-11-26 20:48 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: Nathan Chancellor, Simon Glass, Thomas Weißschuh, kernel,
linux-kernel, linux-kbuild, Sascha Hauer
[-- Attachment #1: Type: text/plain, Size: 2781 bytes --]
On Tue, Nov 25, 2025 at 02:18:20PM +0100, Ahmad Fatoum wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> Add a new package target to build a cpio archive containing the kernel
> modules. This is particularly useful to supplement an existing initramfs
> with the kernel modules so that the root filesystem can be started with
> all needed kernel modules without modifying it.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Tested-by: Simon Glass <sjg@chromium.org>
> Co-developed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> scripts/Makefile.package | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 74bcb9e7f7a4516473481468a0fcf700c3bead33..83bfcf7cb09fd2d69b97e0c19a2b99c728835e8d 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -189,6 +189,25 @@ tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar
> tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
> @:
>
> +# modules-cpio-pkg - generate an initramfs with the modules
> +# ---------------------------------------------------------------------------
> +
> +.tmp_modules_cpio: FORCE
> + $(Q)$(MAKE) -f $(srctree)/Makefile
> + $(Q)rm -rf $@
> + $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
Do you know why '-f $(srctree)/Makefile' is necessary here? As this
and the make call two lines above call common top-level targets, I do
not see the reason for explicitly adding the Makefile path. Am I
missing something; or have you observed problems without '-f'?
> +
> +quiet_cmd_cpio = CPIO $@
> + cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
> +
> +modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio
> + $(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
> + $(call cmd,cpio)
Removing the '$(MAKE) $(build)=usr usr/gen_init_cpio' line and adding
PHONY += usr_gen_init_cpio
usr_gen_init_cpio: scripts_basic
$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
modules-cpio-pkg: usr_gen_init_cpio
to top-level Makefile could be used to allow make to compile
gen_init_cpio in parallel instead of sequential. And it simplifies a
possible move of gen_init_cpio from usr/ to scripts/, as Nathan
suggested.
What do you think? (Top-level Makefile addition should probably better
be integrated into patch 1.) I can also send this as a follow-up patch
after merging your patches.
Nevertheless,
Tested-by: Nicolas Schier <nsc@kernel.org>
If there are no further remarks, I am going to merge the patch set
before the weekend.
Thanks and kind regards,
Nicolas
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] kbuild: add target to build a cpio containing modules
2025-11-25 13:18 [PATCH v2 0/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
` (3 preceding siblings ...)
2025-11-26 7:06 ` Thomas Weißschuh
@ 2025-11-28 21:42 ` Nicolas Schier
4 siblings, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2025-11-28 21:42 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Ahmad Fatoum
Cc: Nicolas Schier, Simon Glass, Thomas Weißschuh, kernel,
linux-kernel, linux-kbuild, Sascha Hauer
On Tue, 25 Nov 2025 14:18:18 +0100, Ahmad Fatoum wrote:
>
>
Applied, thanks!
[1/2] initramfs: add gen_init_cpio to hostprogs unconditionally
https://git.kernel.org/kbuild/c/c83c9564
[2/2] kbuild: add target to build a cpio containing modules
https://git.kernel.org/kbuild/c/2a9c8c0b
Best regards,
--
Nicolas
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-11-30 15:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 13:18 [PATCH v2 0/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
2025-11-25 13:18 ` [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally Ahmad Fatoum
2025-11-25 22:15 ` Simon Glass
2025-11-25 13:18 ` [PATCH v2 2/2] kbuild: add target to build a cpio containing modules Ahmad Fatoum
2025-11-26 20:48 ` Nicolas Schier
2025-11-25 23:56 ` [PATCH v2 0/2] " Nathan Chancellor
2025-11-26 7:06 ` Thomas Weißschuh
2025-11-28 21:42 ` Nicolas Schier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox