linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign'
@ 2023-08-23 11:50 Masahiro Yamada
  2023-08-23 11:50 ` [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets Masahiro Yamada
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

Commit 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to
scripts/Makefile.modinst") started to run depmod at the end of
'make modules_sign'.

Move the depmod rule to scripts/Makefile.modinst and run it only when
$(modules_sign_only) is empty.

Fixes: 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index e0d52539a0f1..7d54a0700c6e 100644
--- a/Makefile
+++ b/Makefile
@@ -1877,7 +1877,9 @@ quiet_cmd_depmod = DEPMOD  $(MODLIB)
 
 modules_install:
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
+ifndef modules_sign_only
 	$(call cmd,depmod)
+endif
 
 else # CONFIG_MODULES
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-23 19:53   ` Nicolas Schier
  2023-08-23 11:50 ` [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst Masahiro Yamada
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

Like modules_install, modules_sign should avoid the syncconfig.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 7d54a0700c6e..e2dfa3b994f7 100644
--- a/Makefile
+++ b/Makefile
@@ -280,8 +280,8 @@ no-dot-config-targets := $(clean-targets) \
 # Installation targets should not require compiler. Unfortunately, vdso_install
 # is an exception where build artifacts may be updated. This must be fixed.
 no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
-			headers_install modules_install kernelrelease image_name
-no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
+			headers_install modules_install modules_sign kernelrelease image_name
+no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
  2023-08-23 11:50 ` [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-23 19:53   ` Nicolas Schier
  2023-08-23 11:50 ` [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink Masahiro Yamada
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

depmod is a part of the module installation.

scripts/Makefile.modinst is a better place to run it.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile                 |  8 --------
 scripts/Makefile.modinst |  9 +++++++++
 scripts/depmod.sh        | 10 ++++++----
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index e2dfa3b994f7..c9c8019e4720 100644
--- a/Makefile
+++ b/Makefile
@@ -509,7 +509,6 @@ LEX		= flex
 YACC		= bison
 AWK		= awk
 INSTALLKERNEL  := installkernel
-DEPMOD		= depmod
 PERL		= perl
 PYTHON3		= python3
 CHECK		= sparse
@@ -1871,15 +1870,8 @@ PHONY += modules_check
 modules_check: $(MODORDER)
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
 
-quiet_cmd_depmod = DEPMOD  $(MODLIB)
-      cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
-                   $(KERNELRELEASE)
-
 modules_install:
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
-ifndef modules_sign_only
-	$(call cmd,depmod)
-endif
 
 else # CONFIG_MODULES
 
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index ab0c5bd1a60f..7a64ece9b826 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -86,6 +86,15 @@ $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
 	$(call cmd,strip)
 	$(call cmd,sign)
 
+__modinst: depmod
+
+PHONY += depmod
+depmod: $(modules)
+	$(call cmd,depmod)
+
+quiet_cmd_depmod = DEPMOD  $(MODLIB)
+      cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
+
 else
 
 $(dst)/%.ko: FORCE
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index fca689ba4f21..ee771ccb1f9c 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -3,12 +3,14 @@
 #
 # A depmod wrapper used by the toplevel Makefile
 
-if test $# -ne 2; then
-	echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
+if test $# -ne 1; then
+	echo "Usage: $0 <kernelrelease>" >&2
 	exit 1
 fi
-DEPMOD=$1
-KERNELRELEASE=$2
+
+KERNELRELEASE=$1
+
+: ${DEPMOD:=depmod}
 
 if ! test -r System.map ; then
 	echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
  2023-08-23 11:50 ` [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets Masahiro Yamada
  2023-08-23 11:50 ` [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-23 20:17   ` Nicolas Schier
  2023-08-23 11:50 ` [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install Masahiro Yamada
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

This reverts the old commit "kbuild: Introduce source symlink in
/lib/modules/.../". [1]

The current Kbuild does not require $(MODLIB)/source. If the kernel was
built in a separate output directory, $(MODLIB)/build/Makefile wraps
the Makefile in the source tree. It is enough for building external
modules.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=e09e58867154b8aae0a3ac26a9b1c05962f5a355

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index c9c8019e4720..7d9cab3d2186 100644
--- a/Makefile
+++ b/Makefile
@@ -1486,14 +1486,10 @@ modules_install: $(modinst_pre)
 PHONY += __modinst_pre
 __modinst_pre:
 	@rm -rf $(MODLIB)/kernel
-	@rm -f $(MODLIB)/source
+	@rm -f $(MODLIB)/build
 	@mkdir -p $(MODLIB)
 ifdef CONFIG_MODULES
-	@ln -s $(abspath $(srctree)) $(MODLIB)/source
-	@if [ ! $(objtree) -ef  $(MODLIB)/build ]; then \
-		rm -f $(MODLIB)/build ; \
-		ln -s $(CURDIR) $(MODLIB)/build ; \
-	fi
+	@ln -s $(CURDIR) $(MODLIB)/build
 	@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
 endif
 	@cp -f modules.builtin $(MODLIB)/
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
                   ` (2 preceding siblings ...)
  2023-08-23 11:50 ` [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-23 20:22   ` Nicolas Schier
  2023-08-23 11:50 ` [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst Masahiro Yamada
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

Calling 'mkdir' for every module results in redundant syscalls.

Use $(sort ...) to drop the duplicated directories.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.modinst | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 7a64ece9b826..5d687a453d90 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -9,6 +9,13 @@ __modinst:
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
 
+install-y :=
+
+PHONY += prepare
+
+prepare:
+	$(Q)mkdir -p $(sort $(dir $(install-y)))
+
 modules := $(call read-file, $(MODORDER))
 
 ifeq ($(KBUILD_EXTMOD),)
@@ -27,6 +34,7 @@ suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
 
 modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
+install-y += $(modules)
 
 __modinst: $(modules)
 	@:
@@ -35,7 +43,7 @@ __modinst: $(modules)
 # Installation
 #
 quiet_cmd_install = INSTALL $@
-      cmd_install = mkdir -p $(dir $@); cp $< $@
+      cmd_install = cp $< $@
 
 # Strip
 #
@@ -95,6 +103,8 @@ depmod: $(modules)
 quiet_cmd_depmod = DEPMOD  $(MODLIB)
       cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
 
+$(install-y): prepare
+
 else
 
 $(dst)/%.ko: FORCE
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
                   ` (3 preceding siblings ...)
  2023-08-23 11:50 ` [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-28 14:25   ` Nicolas Schier
  2023-08-23 11:50 ` [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n Masahiro Yamada
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

Move more relevant code to scripts/Makefile.modinst.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile                 | 34 +++++++--------------------------
 scripts/Makefile.modinst | 41 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/Makefile b/Makefile
index 7d9cab3d2186..82d22debf6c9 100644
--- a/Makefile
+++ b/Makefile
@@ -1477,24 +1477,6 @@ endif
 
 endif # CONFIG_MODULES
 
-modinst_pre :=
-ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
-modinst_pre := __modinst_pre
-endif
-
-modules_install: $(modinst_pre)
-PHONY += __modinst_pre
-__modinst_pre:
-	@rm -rf $(MODLIB)/kernel
-	@rm -f $(MODLIB)/build
-	@mkdir -p $(MODLIB)
-ifdef CONFIG_MODULES
-	@ln -s $(CURDIR) $(MODLIB)/build
-	@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
-endif
-	@cp -f modules.builtin $(MODLIB)/
-	@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
-
 ###
 # Cleaning is done on three levels.
 # make clean     Delete most generated files
@@ -1836,12 +1818,15 @@ help:
 	@echo  '  clean           - remove generated files in module directory only'
 	@echo  ''
 
+ifndef CONFIG_MODULES
+modules modules_install: __external_modules_error
 __external_modules_error:
 	@echo >&2 '***'
 	@echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
 	@echo >&2 '*** You cannot build or install external modules.'
 	@echo >&2 '***'
 	@false
+endif
 
 endif # KBUILD_EXTMOD
 
@@ -1850,6 +1835,9 @@ endif # KBUILD_EXTMOD
 
 PHONY += modules modules_install modules_prepare
 
+modules_install:
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
+
 ifdef CONFIG_MODULES
 
 $(MODORDER): $(build-dir)
@@ -1866,17 +1854,9 @@ PHONY += modules_check
 modules_check: $(MODORDER)
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
 
-modules_install:
-	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
-
 else # CONFIG_MODULES
 
-# Modules not configured
-# ---------------------------------------------------------------------------
-
-PHONY += __external_modules_error
-
-modules modules_install: __external_modules_error
+modules:
 	@:
 
 KBUILD_MODULES :=
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 5d687a453d90..dc7c54669082 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -13,9 +13,41 @@ install-y :=
 
 PHONY += prepare
 
+ifeq ($(KBUILD_EXTMOD)$(modules_sign_only),)
+
+# Install more files for in-tree modules_install
+
+prepare:
+	$(Q)rm -fr $(MODLIB)/kernel $(MODLIB)/build
+	$(Q)mkdir -p $(sort $(dir $(install-y)))
+
+install-$(CONFIG_MODULES) += $(addprefix $(MODLIB)/, build modules.order)
+
+$(MODLIB)/build: FORCE
+	$(call cmd,symlink)
+
+quiet_cmd_symlink = SYMLINK $@
+      cmd_symlink = ln -s $(CURDIR) $@
+
+$(MODLIB)/modules.order: modules.order FORCE
+	$(call cmd,install_modorder)
+
+quiet_cmd_install_modorder = INSTALL $@
+      cmd_install_modorder = sed 's:^\(.*\)\.o$$:kernel/\1.ko:' $< > $@
+
+# Install modules.builtin(.modinfo) even when CONFIG_MODULES is disabled.
+install-y += $(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo)
+
+$(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo): $(MODLIB)/%: % FORCE
+	$(call cmd,install)
+
+else
+
 prepare:
 	$(Q)mkdir -p $(sort $(dir $(install-y)))
 
+endif
+
 modules := $(call read-file, $(MODORDER))
 
 ifeq ($(KBUILD_EXTMOD),)
@@ -34,9 +66,10 @@ suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
 
 modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
-install-y += $(modules)
 
-__modinst: $(modules)
+install-$(CONFIG_MODULES) += $(modules)
+
+__modinst: $(install-y)
 	@:
 
 #
@@ -94,14 +127,16 @@ $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
 	$(call cmd,strip)
 	$(call cmd,sign)
 
+ifdef CONFIG_MODULES
 __modinst: depmod
 
 PHONY += depmod
-depmod: $(modules)
+depmod: $(install-y)
 	$(call cmd,depmod)
 
 quiet_cmd_depmod = DEPMOD  $(MODLIB)
       cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
+endif
 
 $(install-y): prepare
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
                   ` (4 preceding siblings ...)
  2023-08-23 11:50 ` [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-28 14:31   ` Nicolas Schier
  2023-08-23 11:50 ` [PATCH 8/8] kbuild: support modules_sign for external modules as well Masahiro Yamada
  2023-08-23 19:52 ` [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Nicolas Schier
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

Commit d890f510c8e4 ("MODSIGN: Add modules_sign make target") introduced
'make modules_sign' to manually sign modules.

Some time later, commit d9d8d7ed498e ("MODSIGN: Add option to not sign
modules during modules_install") introduced CONFIG_MODULE_SIG_ALL.
If it was disabled, mod_sign_cmd was set to no-op ('true' command).
It affected not only 'make modules_install' but also 'make modules_sign'.
With CONFIG_MODULE_SIG_ALL=n, 'make modules_install' did not sign modules
and 'make modules_sign' could not sign modules either.

Kbuild has kept that behavior, and nobody has complained about it, but
I think it is weird.

CONFIG_MODULE_SIG_ALL=n should turn off signing only for modules_install.
If users want to sign modules manually, they should be allowed to use
'make modules_sign'.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.modinst | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index dc7c54669082..33d424a3f265 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -106,7 +106,6 @@ endif
 # Signing
 # Don't stop modules_install even if we can't sign external modules.
 #
-ifeq ($(CONFIG_MODULE_SIG_ALL),y)
 ifeq ($(filter pkcs11:%, $(CONFIG_MODULE_SIG_KEY)),)
 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY)
 else
@@ -115,13 +114,15 @@ endif
 quiet_cmd_sign = SIGN    $@
       cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
                  $(if $(KBUILD_EXTMOD),|| true)
-else
+
+ifeq ($(modules_sign_only),)
+
+# During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.
+ifndef CONFIG_MODULE_SIG_ALL
 quiet_cmd_sign :=
       cmd_sign := :
 endif
 
-ifeq ($(modules_sign_only),)
-
 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
 	$(call cmd,install)
 	$(call cmd,strip)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 8/8] kbuild: support modules_sign for external modules as well
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
                   ` (5 preceding siblings ...)
  2023-08-23 11:50 ` [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n Masahiro Yamada
@ 2023-08-23 11:50 ` Masahiro Yamada
  2023-08-28 14:52   ` Nicolas Schier
  2023-08-23 19:52 ` [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Nicolas Schier
  7 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-23 11:50 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

The modules_sign target is currently only available for in-tree modules,
but it actually works for external modules as well.

Move the modules_sign rule to the common part.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile                 | 32 ++++++++++++++++----------------
 scripts/Makefile.modinst |  4 ++--
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index 82d22debf6c9..87a9eef3fb4b 100644
--- a/Makefile
+++ b/Makefile
@@ -1461,20 +1461,6 @@ modules: modules_prepare
 modules_prepare: prepare
 	$(Q)$(MAKE) $(build)=scripts scripts/module.lds
 
-export modules_sign_only :=
-
-ifeq ($(CONFIG_MODULE_SIG),y)
-PHONY += modules_sign
-modules_sign: modules_install
-	@:
-
-# modules_sign is a subset of modules_install.
-# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
-ifeq ($(filter modules_install,$(MAKECMDGOALS)),)
-modules_sign_only := y
-endif
-endif
-
 endif # CONFIG_MODULES
 
 ###
@@ -1833,10 +1819,24 @@ endif # KBUILD_EXTMOD
 # ---------------------------------------------------------------------------
 # Modules
 
-PHONY += modules modules_install modules_prepare
+PHONY += modules modules_install modules_sign modules_prepare
 
 modules_install:
-	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
+	sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
+
+ifeq ($(CONFIG_MODULE_SIG),y)
+# modules_sign is a subset of modules_install.
+# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
+modules_sign: modules_install
+	@:
+else
+modules_sign:
+	@echo >&2 '***'
+	@echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
+	@echo >&2 '***'
+	@false
+endif
 
 ifdef CONFIG_MODULES
 
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 33d424a3f265..459cb1fed223 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -13,7 +13,7 @@ install-y :=
 
 PHONY += prepare
 
-ifeq ($(KBUILD_EXTMOD)$(modules_sign_only),)
+ifeq ($(KBUILD_EXTMOD)$(sign-only),)
 
 # Install more files for in-tree modules_install
 
@@ -115,7 +115,7 @@ quiet_cmd_sign = SIGN    $@
       cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
                  $(if $(KBUILD_EXTMOD),|| true)
 
-ifeq ($(modules_sign_only),)
+ifeq ($(sign-only),)
 
 # During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.
 ifndef CONFIG_MODULE_SIG_ALL
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign'
  2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
                   ` (6 preceding siblings ...)
  2023-08-23 11:50 ` [PATCH 8/8] kbuild: support modules_sign for external modules as well Masahiro Yamada
@ 2023-08-23 19:52 ` Nicolas Schier
  2023-08-26 13:36   ` Masahiro Yamada
  7 siblings, 1 reply; 20+ messages in thread
From: Nicolas Schier @ 2023-08-23 19:52 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]

On Wed 23 Aug 2023 20:50:41 GMT, Masahiro Yamada wrote:
> Commit 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to
> scripts/Makefile.modinst") started to run depmod at the end of
> 'make modules_sign'.
> 
> Move the depmod rule to scripts/Makefile.modinst and run it only when
> $(modules_sign_only) is empty.

Moving the depmod rule is in patch 3/8, first half of the sentence 
seems to be left over?

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

> 
> Fixes: 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst")
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index e0d52539a0f1..7d54a0700c6e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1877,7 +1877,9 @@ quiet_cmd_depmod = DEPMOD  $(MODLIB)
>  
>  modules_install:
>  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> +ifndef modules_sign_only
>  	$(call cmd,depmod)
> +endif
>  
>  else # CONFIG_MODULES
>  
> -- 
> 2.39.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets
  2023-08-23 11:50 ` [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets Masahiro Yamada
@ 2023-08-23 19:53   ` Nicolas Schier
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Schier @ 2023-08-23 19:53 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]

On Wed 23 Aug 2023 20:50:42 GMT, Masahiro Yamada wrote:
> Like modules_install, modules_sign should avoid the syncconfig.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 7d54a0700c6e..e2dfa3b994f7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -280,8 +280,8 @@ no-dot-config-targets := $(clean-targets) \
>  # Installation targets should not require compiler. Unfortunately, vdso_install
>  # is an exception where build artifacts may be updated. This must be fixed.
>  no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
> -			headers_install modules_install kernelrelease image_name
> -no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
> +			headers_install modules_install modules_sign kernelrelease image_name
> +no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
>  			  image_name
>  single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/
>  
> -- 
> 2.39.2

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst
  2023-08-23 11:50 ` [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst Masahiro Yamada
@ 2023-08-23 19:53   ` Nicolas Schier
  2023-08-26 13:50     ` Masahiro Yamada
  0 siblings, 1 reply; 20+ messages in thread
From: Nicolas Schier @ 2023-08-23 19:53 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 2744 bytes --]

On Wed 23 Aug 2023 20:50:43 GMT, Masahiro Yamada wrote:
> depmod is a part of the module installation.
> 
> scripts/Makefile.modinst is a better place to run it.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile                 |  8 --------
>  scripts/Makefile.modinst |  9 +++++++++
>  scripts/depmod.sh        | 10 ++++++----
>  3 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index e2dfa3b994f7..c9c8019e4720 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -509,7 +509,6 @@ LEX		= flex
>  YACC		= bison
>  AWK		= awk
>  INSTALLKERNEL  := installkernel
> -DEPMOD		= depmod
>  PERL		= perl
>  PYTHON3		= python3
>  CHECK		= sparse
> @@ -1871,15 +1870,8 @@ PHONY += modules_check
>  modules_check: $(MODORDER)
>  	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
>  
> -quiet_cmd_depmod = DEPMOD  $(MODLIB)
> -      cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
> -                   $(KERNELRELEASE)
> -
>  modules_install:
>  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> -ifndef modules_sign_only
> -	$(call cmd,depmod)
> -endif
>  
>  else # CONFIG_MODULES
>  
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index ab0c5bd1a60f..7a64ece9b826 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -86,6 +86,15 @@ $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
>  	$(call cmd,strip)
>  	$(call cmd,sign)
>  
> +__modinst: depmod
> +
> +PHONY += depmod
> +depmod: $(modules)
> +	$(call cmd,depmod)
> +
> +quiet_cmd_depmod = DEPMOD  $(MODLIB)
> +      cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)

Did you remove the $(CONFIG_SHELL) by intention?

> +
>  else
>  
>  $(dst)/%.ko: FORCE
> diff --git a/scripts/depmod.sh b/scripts/depmod.sh
> index fca689ba4f21..ee771ccb1f9c 100755
> --- a/scripts/depmod.sh
> +++ b/scripts/depmod.sh
> @@ -3,12 +3,14 @@
>  #
>  # A depmod wrapper used by the toplevel Makefile

toplevel Makefile -> scripts/Makefile.modinst

>  
> -if test $# -ne 2; then
> -	echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
> +if test $# -ne 1; then
> +	echo "Usage: $0 <kernelrelease>" >&2
>  	exit 1
>  fi
> -DEPMOD=$1
> -KERNELRELEASE=$2
> +
> +KERNELRELEASE=$1
> +
> +: ${DEPMOD:=depmod}
>  
>  if ! test -r System.map ; then
>  	echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
> -- 
> 2.39.2

A minor observation: with this patch, the "quiet_cmd_*" examples in 
Makefile and in Documentation/kbuild/makefiles.rst become out-dated.

But technically, it looks good to me, thus:
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink
  2023-08-23 11:50 ` [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink Masahiro Yamada
@ 2023-08-23 20:17   ` Nicolas Schier
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Schier @ 2023-08-23 20:17 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]

On Wed, Aug 23, 2023 at 08:50:44PM +0900 Masahiro Yamada wrote:
> This reverts the old commit "kbuild: Introduce source symlink in
> /lib/modules/.../". [1]
> 
> The current Kbuild does not require $(MODLIB)/source. If the kernel was
> built in a separate output directory, $(MODLIB)/build/Makefile wraps
> the Makefile in the source tree. It is enough for building external
> modules.
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=e09e58867154b8aae0a3ac26a9b1c05962f5a355
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c9c8019e4720..7d9cab3d2186 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1486,14 +1486,10 @@ modules_install: $(modinst_pre)
>  PHONY += __modinst_pre
>  __modinst_pre:
>  	@rm -rf $(MODLIB)/kernel
> -	@rm -f $(MODLIB)/source
> +	@rm -f $(MODLIB)/build
>  	@mkdir -p $(MODLIB)
>  ifdef CONFIG_MODULES
> -	@ln -s $(abspath $(srctree)) $(MODLIB)/source
> -	@if [ ! $(objtree) -ef  $(MODLIB)/build ]; then \
> -		rm -f $(MODLIB)/build ; \
> -		ln -s $(CURDIR) $(MODLIB)/build ; \
> -	fi
> +	@ln -s $(CURDIR) $(MODLIB)/build
>  	@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
>  endif
>  	@cp -f modules.builtin $(MODLIB)/
> -- 
> 2.39.2

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install
  2023-08-23 11:50 ` [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install Masahiro Yamada
@ 2023-08-23 20:22   ` Nicolas Schier
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Schier @ 2023-08-23 20:22 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 1629 bytes --]

On Wed, Aug 23, 2023 at 08:50:45PM +0900 Masahiro Yamada wrote:
> Calling 'mkdir' for every module results in redundant syscalls.
> 
> Use $(sort ...) to drop the duplicated directories.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/Makefile.modinst | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index 7a64ece9b826..5d687a453d90 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -9,6 +9,13 @@ __modinst:
>  include include/config/auto.conf
>  include $(srctree)/scripts/Kbuild.include
>  
> +install-y :=
> +
> +PHONY += prepare
> +
> +prepare:
> +	$(Q)mkdir -p $(sort $(dir $(install-y)))
> +
>  modules := $(call read-file, $(MODORDER))
>  
>  ifeq ($(KBUILD_EXTMOD),)
> @@ -27,6 +34,7 @@ suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
>  suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
>  
>  modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
> +install-y += $(modules)
>  
>  __modinst: $(modules)
>  	@:
> @@ -35,7 +43,7 @@ __modinst: $(modules)
>  # Installation
>  #
>  quiet_cmd_install = INSTALL $@
> -      cmd_install = mkdir -p $(dir $@); cp $< $@
> +      cmd_install = cp $< $@
>  
>  # Strip
>  #
> @@ -95,6 +103,8 @@ depmod: $(modules)
>  quiet_cmd_depmod = DEPMOD  $(MODLIB)
>        cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
>  
> +$(install-y): prepare
> +
>  else
>  
>  $(dst)/%.ko: FORCE
> -- 
> 2.39.2

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign'
  2023-08-23 19:52 ` [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Nicolas Schier
@ 2023-08-26 13:36   ` Masahiro Yamada
  0 siblings, 0 replies; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-26 13:36 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

On Fri, Aug 25, 2023 at 2:55 PM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Wed 23 Aug 2023 20:50:41 GMT, Masahiro Yamada wrote:
> > Commit 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to
> > scripts/Makefile.modinst") started to run depmod at the end of
> > 'make modules_sign'.
> >
> > Move the depmod rule to scripts/Makefile.modinst and run it only when
> > $(modules_sign_only) is empty.
>
> Moving the depmod rule is in patch 3/8, first half of the sentence
> seems to be left over?


Theoretically, 1/8 and 3/8 can be squashed together, but
3/8 is too big to be back-ported.

1/8 was split out for easy back-porting.






> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
>
> >
> > Fixes: 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst")
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  Makefile | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/Makefile b/Makefile
> > index e0d52539a0f1..7d54a0700c6e 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1877,7 +1877,9 @@ quiet_cmd_depmod = DEPMOD  $(MODLIB)
> >
> >  modules_install:
> >       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> > +ifndef modules_sign_only
> >       $(call cmd,depmod)
> > +endif
> >
> >  else # CONFIG_MODULES
> >
> > --
> > 2.39.2



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst
  2023-08-23 19:53   ` Nicolas Schier
@ 2023-08-26 13:50     ` Masahiro Yamada
  0 siblings, 0 replies; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-26 13:50 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

On Thu, Aug 24, 2023 at 8:30 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Wed 23 Aug 2023 20:50:43 GMT, Masahiro Yamada wrote:
> > depmod is a part of the module installation.
> >
> > scripts/Makefile.modinst is a better place to run it.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  Makefile                 |  8 --------
> >  scripts/Makefile.modinst |  9 +++++++++
> >  scripts/depmod.sh        | 10 ++++++----
> >  3 files changed, 15 insertions(+), 12 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index e2dfa3b994f7..c9c8019e4720 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -509,7 +509,6 @@ LEX               = flex
> >  YACC         = bison
> >  AWK          = awk
> >  INSTALLKERNEL  := installkernel
> > -DEPMOD               = depmod
> >  PERL         = perl
> >  PYTHON3              = python3
> >  CHECK                = sparse
> > @@ -1871,15 +1870,8 @@ PHONY += modules_check
> >  modules_check: $(MODORDER)
> >       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
> >
> > -quiet_cmd_depmod = DEPMOD  $(MODLIB)
> > -      cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
> > -                   $(KERNELRELEASE)
> > -
> >  modules_install:
> >       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> > -ifndef modules_sign_only
> > -     $(call cmd,depmod)
> > -endif
> >
> >  else # CONFIG_MODULES
> >
> > diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> > index ab0c5bd1a60f..7a64ece9b826 100644
> > --- a/scripts/Makefile.modinst
> > +++ b/scripts/Makefile.modinst
> > @@ -86,6 +86,15 @@ $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
> >       $(call cmd,strip)
> >       $(call cmd,sign)
> >
> > +__modinst: depmod
> > +
> > +PHONY += depmod
> > +depmod: $(modules)
> > +     $(call cmd,depmod)
> > +
> > +quiet_cmd_depmod = DEPMOD  $(MODLIB)
> > +      cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
>
> Did you remove the $(CONFIG_SHELL) by intention?


Yes.
I do not know why $(CONFIG_SHELL) is needed.

I remove $(CONFIG_SHELL) when I have a chance to touch the line.


> > +
> >  else
> >
> >  $(dst)/%.ko: FORCE
> > diff --git a/scripts/depmod.sh b/scripts/depmod.sh
> > index fca689ba4f21..ee771ccb1f9c 100755
> > --- a/scripts/depmod.sh
> > +++ b/scripts/depmod.sh
> > @@ -3,12 +3,14 @@
> >  #
> >  # A depmod wrapper used by the toplevel Makefile
>
> toplevel Makefile -> scripts/Makefile.modinst


Good catch.
I will fix it.


> >
> > -if test $# -ne 2; then
> > -     echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
> > +if test $# -ne 1; then
> > +     echo "Usage: $0 <kernelrelease>" >&2
> >       exit 1
> >  fi
> > -DEPMOD=$1
> > -KERNELRELEASE=$2
> > +
> > +KERNELRELEASE=$1
> > +
> > +: ${DEPMOD:=depmod}
> >
> >  if ! test -r System.map ; then
> >       echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
> > --
> > 2.39.2
>
> A minor observation: with this patch, the "quiet_cmd_*" examples in
> Makefile and in Documentation/kbuild/makefiles.rst become out-dated.


I was opposed to eb38f37c3cee08a0197bdc7bbb9b4e02e40e2300

The section "Script invocation" is not what I ack'ed.

That is what Kees Cook and Andrew Morton did.









>
> But technically, it looks good to me, thus:
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>



--
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst
  2023-08-23 11:50 ` [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst Masahiro Yamada
@ 2023-08-28 14:25   ` Nicolas Schier
  2023-08-29  2:35     ` Masahiro Yamada
  0 siblings, 1 reply; 20+ messages in thread
From: Nicolas Schier @ 2023-08-28 14:25 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 5096 bytes --]

On Wed 23 Aug 2023 20:50:46 GMT, Masahiro Yamada wrote:
> Move more relevant code to scripts/Makefile.modinst.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile                 | 34 +++++++--------------------------
>  scripts/Makefile.modinst | 41 +++++++++++++++++++++++++++++++++++++---
>  2 files changed, 45 insertions(+), 30 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 7d9cab3d2186..82d22debf6c9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1477,24 +1477,6 @@ endif
>  
>  endif # CONFIG_MODULES
>  
> -modinst_pre :=
> -ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
> -modinst_pre := __modinst_pre
> -endif
> -
> -modules_install: $(modinst_pre)
> -PHONY += __modinst_pre
> -__modinst_pre:
> -	@rm -rf $(MODLIB)/kernel
> -	@rm -f $(MODLIB)/build
> -	@mkdir -p $(MODLIB)
> -ifdef CONFIG_MODULES
> -	@ln -s $(CURDIR) $(MODLIB)/build
> -	@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
> -endif
> -	@cp -f modules.builtin $(MODLIB)/
> -	@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
> -
>  ###
>  # Cleaning is done on three levels.
>  # make clean     Delete most generated files
> @@ -1836,12 +1818,15 @@ help:
>  	@echo  '  clean           - remove generated files in module directory only'
>  	@echo  ''
>  
> +ifndef CONFIG_MODULES
> +modules modules_install: __external_modules_error
>  __external_modules_error:
>  	@echo >&2 '***'
>  	@echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
>  	@echo >&2 '*** You cannot build or install external modules.'
>  	@echo >&2 '***'
>  	@false
> +endif
>  
>  endif # KBUILD_EXTMOD
>  
> @@ -1850,6 +1835,9 @@ endif # KBUILD_EXTMOD
>  
>  PHONY += modules modules_install modules_prepare
>  
> +modules_install:
> +	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst

I was a bit surprised to see 'modules_install' being allowed 
unconditionally for in-tree usage (thus, even if CONFIG_MODULES=n), but 
then realised that this is the same behaviour as we had before.  Out of 
curiosity:  _why_ do we need to install 
$(MODLIB)/modules.builtin{,.modinfo} also for configs w/ 
CONFIG_MODULES=n?

> +
>  ifdef CONFIG_MODULES
>  
>  $(MODORDER): $(build-dir)
> @@ -1866,17 +1854,9 @@ PHONY += modules_check
>  modules_check: $(MODORDER)
>  	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
>  
> -modules_install:
> -	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> -
>  else # CONFIG_MODULES
>  
> -# Modules not configured
> -# ---------------------------------------------------------------------------
> -
> -PHONY += __external_modules_error
> -
> -modules modules_install: __external_modules_error
> +modules:
>  	@:
>  
>  KBUILD_MODULES :=
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index 5d687a453d90..dc7c54669082 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -13,9 +13,41 @@ install-y :=
>  
>  PHONY += prepare
>  
> +ifeq ($(KBUILD_EXTMOD)$(modules_sign_only),)
> +
> +# Install more files for in-tree modules_install
> +
> +prepare:
> +	$(Q)rm -fr $(MODLIB)/kernel $(MODLIB)/build
> +	$(Q)mkdir -p $(sort $(dir $(install-y)))
> +
> +install-$(CONFIG_MODULES) += $(addprefix $(MODLIB)/, build modules.order)
> +
> +$(MODLIB)/build: FORCE
> +	$(call cmd,symlink)
> +
> +quiet_cmd_symlink = SYMLINK $@
> +      cmd_symlink = ln -s $(CURDIR) $@
> +
> +$(MODLIB)/modules.order: modules.order FORCE
> +	$(call cmd,install_modorder)
> +
> +quiet_cmd_install_modorder = INSTALL $@
> +      cmd_install_modorder = sed 's:^\(.*\)\.o$$:kernel/\1.ko:' $< > $@
> +
> +# Install modules.builtin(.modinfo) even when CONFIG_MODULES is disabled.
> +install-y += $(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo)
> +
> +$(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo): $(MODLIB)/%: % FORCE
> +	$(call cmd,install)
> +
> +else
> +
>  prepare:
>  	$(Q)mkdir -p $(sort $(dir $(install-y)))
>  
> +endif
> +
>  modules := $(call read-file, $(MODORDER))
>  
>  ifeq ($(KBUILD_EXTMOD),)
> @@ -34,9 +66,10 @@ suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
>  suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
>  
>  modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
> -install-y += $(modules)
>  
> -__modinst: $(modules)
> +install-$(CONFIG_MODULES) += $(modules)
> +
> +__modinst: $(install-y)
>  	@:
>  
>  #
> @@ -94,14 +127,16 @@ $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
>  	$(call cmd,strip)
>  	$(call cmd,sign)
>  
> +ifdef CONFIG_MODULES
>  __modinst: depmod
>  
>  PHONY += depmod
> -depmod: $(modules)
> +depmod: $(install-y)
>  	$(call cmd,depmod)
>  
>  quiet_cmd_depmod = DEPMOD  $(MODLIB)
>        cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
> +endif
>  
>  $(install-y): prepare
>  
> -- 
> 2.39.2

Thanks for cleaning up.  For me, the new rules look better than the 
original ones.

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n
  2023-08-23 11:50 ` [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n Masahiro Yamada
@ 2023-08-28 14:31   ` Nicolas Schier
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Schier @ 2023-08-28 14:31 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 2415 bytes --]

On Wed 23 Aug 2023 20:50:47 GMT, Masahiro Yamada wrote:
> Commit d890f510c8e4 ("MODSIGN: Add modules_sign make target") introduced
> 'make modules_sign' to manually sign modules.
> 
> Some time later, commit d9d8d7ed498e ("MODSIGN: Add option to not sign
> modules during modules_install") introduced CONFIG_MODULE_SIG_ALL.
> If it was disabled, mod_sign_cmd was set to no-op ('true' command).
> It affected not only 'make modules_install' but also 'make modules_sign'.
> With CONFIG_MODULE_SIG_ALL=n, 'make modules_install' did not sign modules
> and 'make modules_sign' could not sign modules either.
> 
> Kbuild has kept that behavior, and nobody has complained about it, but
> I think it is weird.
> 
> CONFIG_MODULE_SIG_ALL=n should turn off signing only for modules_install.
> If users want to sign modules manually, they should be allowed to use
> 'make modules_sign'.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

> 
>  scripts/Makefile.modinst | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index dc7c54669082..33d424a3f265 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -106,7 +106,6 @@ endif
>  # Signing
>  # Don't stop modules_install even if we can't sign external modules.
>  #
> -ifeq ($(CONFIG_MODULE_SIG_ALL),y)
>  ifeq ($(filter pkcs11:%, $(CONFIG_MODULE_SIG_KEY)),)
>  sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY)
>  else
> @@ -115,13 +114,15 @@ endif
>  quiet_cmd_sign = SIGN    $@
>        cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
>                   $(if $(KBUILD_EXTMOD),|| true)
> -else
> +
> +ifeq ($(modules_sign_only),)
> +
> +# During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.
> +ifndef CONFIG_MODULE_SIG_ALL
>  quiet_cmd_sign :=
>        cmd_sign := :
>  endif
>  
> -ifeq ($(modules_sign_only),)
> -
>  $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
>  	$(call cmd,install)
>  	$(call cmd,strip)
> -- 
> 2.39.2

-- 
Nicolas Schier
 
epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 8/8] kbuild: support modules_sign for external modules as well
  2023-08-23 11:50 ` [PATCH 8/8] kbuild: support modules_sign for external modules as well Masahiro Yamada
@ 2023-08-28 14:52   ` Nicolas Schier
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Schier @ 2023-08-28 14:52 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 3112 bytes --]

On Wed 23 Aug 2023 20:50:48 GMT, Masahiro Yamada wrote:
> The modules_sign target is currently only available for in-tree modules,
> but it actually works for external modules as well.
> 
> Move the modules_sign rule to the common part.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>


> 
>  Makefile                 | 32 ++++++++++++++++----------------
>  scripts/Makefile.modinst |  4 ++--
>  2 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 82d22debf6c9..87a9eef3fb4b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1461,20 +1461,6 @@ modules: modules_prepare
>  modules_prepare: prepare
>  	$(Q)$(MAKE) $(build)=scripts scripts/module.lds
>  
> -export modules_sign_only :=
> -
> -ifeq ($(CONFIG_MODULE_SIG),y)
> -PHONY += modules_sign
> -modules_sign: modules_install
> -	@:
> -
> -# modules_sign is a subset of modules_install.
> -# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
> -ifeq ($(filter modules_install,$(MAKECMDGOALS)),)
> -modules_sign_only := y
> -endif
> -endif
> -
>  endif # CONFIG_MODULES
>  
>  ###
> @@ -1833,10 +1819,24 @@ endif # KBUILD_EXTMOD
>  # ---------------------------------------------------------------------------
>  # Modules
>  
> -PHONY += modules modules_install modules_prepare
> +PHONY += modules modules_install modules_sign modules_prepare
>  
>  modules_install:
> -	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> +	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
> +	sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
> +
> +ifeq ($(CONFIG_MODULE_SIG),y)
> +# modules_sign is a subset of modules_install.
> +# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
> +modules_sign: modules_install
> +	@:
> +else
> +modules_sign:
> +	@echo >&2 '***'
> +	@echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
> +	@echo >&2 '***'
> +	@false
> +endif
>  
>  ifdef CONFIG_MODULES
>  
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index 33d424a3f265..459cb1fed223 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -13,7 +13,7 @@ install-y :=
>  
>  PHONY += prepare
>  
> -ifeq ($(KBUILD_EXTMOD)$(modules_sign_only),)
> +ifeq ($(KBUILD_EXTMOD)$(sign-only),)
>  
>  # Install more files for in-tree modules_install
>  
> @@ -115,7 +115,7 @@ quiet_cmd_sign = SIGN    $@
>        cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
>                   $(if $(KBUILD_EXTMOD),|| true)
>  
> -ifeq ($(modules_sign_only),)
> +ifeq ($(sign-only),)
>  
>  # During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.
>  ifndef CONFIG_MODULE_SIG_ALL
> -- 
> 2.39.2

-- 
Nicolas Schier
 
epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst
  2023-08-28 14:25   ` Nicolas Schier
@ 2023-08-29  2:35     ` Masahiro Yamada
  2023-08-29  3:50       ` Nicolas Schier
  0 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2023-08-29  2:35 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

On Tue, Aug 29, 2023 at 11:15 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Wed 23 Aug 2023 20:50:46 GMT, Masahiro Yamada wrote:
> > Move more relevant code to scripts/Makefile.modinst.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  Makefile                 | 34 +++++++--------------------------
> >  scripts/Makefile.modinst | 41 +++++++++++++++++++++++++++++++++++++---
> >  2 files changed, 45 insertions(+), 30 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 7d9cab3d2186..82d22debf6c9 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1477,24 +1477,6 @@ endif
> >
> >  endif # CONFIG_MODULES
> >
> > -modinst_pre :=
> > -ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
> > -modinst_pre := __modinst_pre
> > -endif
> > -
> > -modules_install: $(modinst_pre)
> > -PHONY += __modinst_pre
> > -__modinst_pre:
> > -     @rm -rf $(MODLIB)/kernel
> > -     @rm -f $(MODLIB)/build
> > -     @mkdir -p $(MODLIB)
> > -ifdef CONFIG_MODULES
> > -     @ln -s $(CURDIR) $(MODLIB)/build
> > -     @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
> > -endif
> > -     @cp -f modules.builtin $(MODLIB)/
> > -     @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
> > -
> >  ###
> >  # Cleaning is done on three levels.
> >  # make clean     Delete most generated files
> > @@ -1836,12 +1818,15 @@ help:
> >       @echo  '  clean           - remove generated files in module directory only'
> >       @echo  ''
> >
> > +ifndef CONFIG_MODULES
> > +modules modules_install: __external_modules_error
> >  __external_modules_error:
> >       @echo >&2 '***'
> >       @echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
> >       @echo >&2 '*** You cannot build or install external modules.'
> >       @echo >&2 '***'
> >       @false
> > +endif
> >
> >  endif # KBUILD_EXTMOD
> >
> > @@ -1850,6 +1835,9 @@ endif # KBUILD_EXTMOD
> >
> >  PHONY += modules modules_install modules_prepare
> >
> > +modules_install:
> > +     $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
>
> I was a bit surprised to see 'modules_install' being allowed
> unconditionally for in-tree usage (thus, even if CONFIG_MODULES=n), but
> then realised that this is the same behaviour as we had before.  Out of
> curiosity:  _why_ do we need to install
> $(MODLIB)/modules.builtin{,.modinfo} also for configs w/
> CONFIG_MODULES=n?


I see your tags in commit
8ae071fc216a25f4f797f33c56857f4dd6b4408e    :)


Some drivers need to load firmware.

To make such drivers working in initrd,
mkinitramfs needs to copy necessary firmware files
into the initrd.
So, the tool needs to know which drivers are enabled.

That is my understanding why modules.builtin(.modinfo)
is needed even with CONFIG_MODULES=n.





-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst
  2023-08-29  2:35     ` Masahiro Yamada
@ 2023-08-29  3:50       ` Nicolas Schier
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Schier @ 2023-08-29  3:50 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

[-- Attachment #1: Type: text/plain, Size: 3139 bytes --]

On Tue 29 Aug 2023 11:35:41 GMT, Masahiro Yamada wrote:
> On Tue, Aug 29, 2023 at 11:15 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
> >
> > On Wed 23 Aug 2023 20:50:46 GMT, Masahiro Yamada wrote:
> > > Move more relevant code to scripts/Makefile.modinst.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> > >
> > >  Makefile                 | 34 +++++++--------------------------
> > >  scripts/Makefile.modinst | 41 +++++++++++++++++++++++++++++++++++++---
> > >  2 files changed, 45 insertions(+), 30 deletions(-)
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 7d9cab3d2186..82d22debf6c9 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -1477,24 +1477,6 @@ endif
> > >
> > >  endif # CONFIG_MODULES
> > >
> > > -modinst_pre :=
> > > -ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
> > > -modinst_pre := __modinst_pre
> > > -endif
> > > -
> > > -modules_install: $(modinst_pre)
> > > -PHONY += __modinst_pre
> > > -__modinst_pre:
> > > -     @rm -rf $(MODLIB)/kernel
> > > -     @rm -f $(MODLIB)/build
> > > -     @mkdir -p $(MODLIB)
> > > -ifdef CONFIG_MODULES
> > > -     @ln -s $(CURDIR) $(MODLIB)/build
> > > -     @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
> > > -endif
> > > -     @cp -f modules.builtin $(MODLIB)/
> > > -     @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
> > > -
> > >  ###
> > >  # Cleaning is done on three levels.
> > >  # make clean     Delete most generated files
> > > @@ -1836,12 +1818,15 @@ help:
> > >       @echo  '  clean           - remove generated files in module directory only'
> > >       @echo  ''
> > >
> > > +ifndef CONFIG_MODULES
> > > +modules modules_install: __external_modules_error
> > >  __external_modules_error:
> > >       @echo >&2 '***'
> > >       @echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
> > >       @echo >&2 '*** You cannot build or install external modules.'
> > >       @echo >&2 '***'
> > >       @false
> > > +endif
> > >
> > >  endif # KBUILD_EXTMOD
> > >
> > > @@ -1850,6 +1835,9 @@ endif # KBUILD_EXTMOD
> > >
> > >  PHONY += modules modules_install modules_prepare
> > >
> > > +modules_install:
> > > +     $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
> >
> > I was a bit surprised to see 'modules_install' being allowed
> > unconditionally for in-tree usage (thus, even if CONFIG_MODULES=n), but
> > then realised that this is the same behaviour as we had before.  Out of
> > curiosity:  _why_ do we need to install
> > $(MODLIB)/modules.builtin{,.modinfo} also for configs w/
> > CONFIG_MODULES=n?
> 
> 
> I see your tags in commit
> 8ae071fc216a25f4f797f33c56857f4dd6b4408e    :)
> 
> 
> Some drivers need to load firmware.
> 
> To make such drivers working in initrd,
> mkinitramfs needs to copy necessary firmware files
> into the initrd.
> So, the tool needs to know which drivers are enabled.
> 
> That is my understanding why modules.builtin(.modinfo)
> is needed even with CONFIG_MODULES=n.

Ups, yes.  Thanks for the reminder!

Kind regards,
Nicolas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-08-29  3:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-23 11:50 [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Masahiro Yamada
2023-08-23 11:50 ` [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets Masahiro Yamada
2023-08-23 19:53   ` Nicolas Schier
2023-08-23 11:50 ` [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst Masahiro Yamada
2023-08-23 19:53   ` Nicolas Schier
2023-08-26 13:50     ` Masahiro Yamada
2023-08-23 11:50 ` [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink Masahiro Yamada
2023-08-23 20:17   ` Nicolas Schier
2023-08-23 11:50 ` [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install Masahiro Yamada
2023-08-23 20:22   ` Nicolas Schier
2023-08-23 11:50 ` [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst Masahiro Yamada
2023-08-28 14:25   ` Nicolas Schier
2023-08-29  2:35     ` Masahiro Yamada
2023-08-29  3:50       ` Nicolas Schier
2023-08-23 11:50 ` [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n Masahiro Yamada
2023-08-28 14:31   ` Nicolas Schier
2023-08-23 11:50 ` [PATCH 8/8] kbuild: support modules_sign for external modules as well Masahiro Yamada
2023-08-28 14:52   ` Nicolas Schier
2023-08-23 19:52 ` [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Nicolas Schier
2023-08-26 13:36   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).