From patchwork Wed Aug 23 11:50:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362206 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 72B84EE49B0 for ; Wed, 23 Aug 2023 11:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234262AbjHWLu6 (ORCPT ); Wed, 23 Aug 2023 07:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjHWLu6 (ORCPT ); Wed, 23 Aug 2023 07:50:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED900CF; Wed, 23 Aug 2023 04:50:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7A60561501; Wed, 23 Aug 2023 11:50:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28566C433C8; Wed, 23 Aug 2023 11:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791455; bh=8LLUhYnER6NHg4If5ClhYQ11jKYl73hLNR9IjMOFoGU=; h=From:To:Cc:Subject:Date:From; b=qBZtdO/9vyUhHsODPx8d0VyXNahln2jOHjZBqsyvfmIBlegnLviDp5op9bIQbFm8Z ghNk4o7dv7nKSJL9Atatsill3CYoACxItpAbvSq9scosyA86wzjqQF6Dx3FTYQQ4hA g08jr2areF1du2duz7doSZyCxH34lxaxH98lnqvjfY5dPpspFBJIoqHAvVxFt4DSLi oAJ4V3cf9Yhxe+HfXFqCz3rAtxPXiqI3UYbEtJa2GlkFNnIk8puPSdHPNTVCyUa/M+ eWe77kLeYjh47RsGDHc0mLaVDlxiqkykMHR6tPABa2o/0zU5uxFUr4CNNxMbXZQUor MfZBuS/+nFo0g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 1/8] kbuild: do not run depmod for 'make modules_sign' Date: Wed, 23 Aug 2023 20:50:41 +0900 Message-Id: <20230823115048.823011-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Nicolas Schier --- 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 From patchwork Wed Aug 23 11:50:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362207 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 728E1EE49B2 for ; Wed, 23 Aug 2023 11:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbjHWLvA (ORCPT ); Wed, 23 Aug 2023 07:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjHWLvA (ORCPT ); Wed, 23 Aug 2023 07:51:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC32CCF; Wed, 23 Aug 2023 04:50:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5C44561B0B; Wed, 23 Aug 2023 11:50:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E939C433CB; Wed, 23 Aug 2023 11:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791457; bh=KumweqIbBGlQu/QW8/T6YUQUSRrF4UR/0XH8qL+VBn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJK7LN11MkN21EN+wnv0xeHHquHZoCJ5HNP9a77L2swSRzM+PsNSB5zTSAP2Tr9RE 3YCqblj4Ko78zSmsMU67ZLl08u3SJmPIbcaEwG/sPQicTyQOvFr+HTs5RnyOSyf3Vx QPtGYRoJtjv3gfMreOa5AkKd7D9WR55Go2HPI1DvzFiG5gA7+kO9d291nTt2vGDJk7 zmO0/K0iF1OewUVu4NXOK25skKPuwo8yeZ7czpNStx9kF7IgU7KvOJa7U7cEuvCRen c1UcHuB7OBBgi8xCT4jHrMy54Yrqac4m16U7kHnzfqJHH2Di9itS5YeLLu//0L83Ww oRKjY8U7U17zA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 2/8] kbuild: add modules_sign to no-{compiler,sync-config}-targets Date: Wed, 23 Aug 2023 20:50:42 +0900 Message-Id: <20230823115048.823011-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Like modules_install, modules_sign should avoid the syncconfig. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- 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 %/ From patchwork Wed Aug 23 11:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362208 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 6EEA8EE49B0 for ; Wed, 23 Aug 2023 11:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjHWLvC (ORCPT ); Wed, 23 Aug 2023 07:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbjHWLvC (ORCPT ); Wed, 23 Aug 2023 07:51:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A8FFDB; Wed, 23 Aug 2023 04:51:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3542B64A6D; Wed, 23 Aug 2023 11:51:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 081F0C433C7; Wed, 23 Aug 2023 11:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791459; bh=at6MwZstCK4YYvJ/JENZT9OnY5U7qwdQvQ8iXxtDGtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+dzP8W5sVJegKiGHku5Bp2hI0RCOwciogN11sjhg9SBjngWylSnHg2IPA4SE93wP sQN7AutlFsQwCVEB5jLiUdwtXrymkAX7f9OHl8Jb6rQbiW8YEFSrEq1VhFKdJLoE/d lORgMFqHAmFe9z3w/6D5vX79QA8iBjVLl4vnmBYLtMkLYDLafhjvuhI8QQIXwNActw GNFD/UZ5LbWHlIbsHHetdLrU1I7TC8aH+gqVH56g+Ajn54BtFxTdJ5zN8DEQ5mHyIH HvQ7TP8SacJOB2Om8IJVKLCm6IiEm/3JNFWPTo969bk349/mwDHiIC2Yv0IVBPRqMU XKZkGal/chvJg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 3/8] kbuild: move depmod rule to scripts/Makefile.modinst Date: Wed, 23 Aug 2023 20:50:43 +0900 Message-Id: <20230823115048.823011-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org depmod is a part of the module installation. scripts/Makefile.modinst is a better place to run it. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- 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 " >&2 +if test $# -ne 1; then + echo "Usage: $0 " >&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 From patchwork Wed Aug 23 11:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362209 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 E9D19EE49B5 for ; Wed, 23 Aug 2023 11:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234019AbjHWLvF (ORCPT ); Wed, 23 Aug 2023 07:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234545AbjHWLvE (ORCPT ); Wed, 23 Aug 2023 07:51:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE285DB; Wed, 23 Aug 2023 04:51:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3B73964B5F; Wed, 23 Aug 2023 11:51:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFE55C433BB; Wed, 23 Aug 2023 11:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791461; bh=17ZI9OuOHnRLfA+Aw4o40RdR2fIS9vJw5OhR2qQpZiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eUxX4xhsUQgev7TX7KnUzypflQUoGPIqH8x29uyoEn26LluX/etqEJ1udaR/94PEz GRJiMpf1EMIA9nJAp64bvT3EdAn+HalMD8WVX6ed7DwYReKntOvr0zF5c+VeB45iYp yqqux7rPhmld+o67J4rmILzy8FflfnQ4JRWe/CPYcsxDS9+LFlKN6p6dEQ13GzQDrx SCqzA7gT/mo0ujZGj3kVfM0/VTUj8K+3uzVkZGHSDCmq3uLor8uV1N8xfV5IyeRjFX Wd+PweV490O6s4pKn5yZ3XDD5DFXE5E3lqHNm4gzgg9sGAQD+SD+SC3oPknXYVovAV m2/bbSFidLEgQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 4/8] kbuild: remove $(MODLIB)/source symlink Date: Wed, 23 Aug 2023 20:50:44 +0900 Message-Id: <20230823115048.823011-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Nicolas Schier --- 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)/ From patchwork Wed Aug 23 11:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362210 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 E8C26EE49A0 for ; Wed, 23 Aug 2023 11:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234577AbjHWLvM (ORCPT ); Wed, 23 Aug 2023 07:51:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234556AbjHWLvG (ORCPT ); Wed, 23 Aug 2023 07:51:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAF31E5E; Wed, 23 Aug 2023 04:51:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4BBF1657A1; Wed, 23 Aug 2023 11:51:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06A59C433C8; Wed, 23 Aug 2023 11:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791463; bh=37LRz30ny/2YtsWajTxwFgePE/bkcRu4z9qqVGYU0fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gASx3gsERnDseTFtIvf6L+RZKnriMxcsLx4fT++ZCeuPubUkRzOAQMbuHwJnjd/yF 59iFq70WIRzWHW7tTzI8upycG1vSzXDw6ajx+/lTWBSFbyj8bp4Tk9HuZG09Ylh8xT azmqOIzbn6ke44rNtBbyXoItg7iv3ipp/ltods8cXsP9itCBzHTkvUSzaawfacVgRD nJQVP6B/s/0J02nSZO8RKMvF8k6DgRKDd9fBqOnvfiG3+6yrs2W0x0Cqdy3TtyV7Ig 6BRiugtjqUXfGqtyVmckGysdW71jFtBwdV9ea/efGqd1BBdgrQANG+fmRVqTCAEelc S7RfKfg8PsUzA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 5/8] kbuild: reduce the number of mkdir calls during modules_install Date: Wed, 23 Aug 2023 20:50:45 +0900 Message-Id: <20230823115048.823011-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Calling 'mkdir' for every module results in redundant syscalls. Use $(sort ...) to drop the duplicated directories. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- 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 From patchwork Wed Aug 23 11:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362211 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 300E8EE49B0 for ; Wed, 23 Aug 2023 11:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234555AbjHWLvO (ORCPT ); Wed, 23 Aug 2023 07:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234579AbjHWLvM (ORCPT ); Wed, 23 Aug 2023 07:51:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74D49E7C; Wed, 23 Aug 2023 04:51:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0301864B5F; Wed, 23 Aug 2023 11:51:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F39E8C433C9; Wed, 23 Aug 2023 11:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791465; bh=wFUASYLi3QguTEkF0la7u7GiwBTMM+3rNu1Qw/Z6zxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C4Kx9V4+sIMX88xrczTyop2w+DSwwF0R9aJVWzO3tODOykestZcECIYKTJEsNm3Bg U9yxJmIqcZ4Xju47rDyTJFcBZMkMYYuvD34N93BGjZWfJZ24fZpQVf4EtvfCuGJbB/ XJA9C/1wh+JODoqWOSiS1g8Cn1KyGMWhW7d0yjzMO1eWck+3tlCo77sUBxVbz216TQ aG7iCAMRWxPXa0HS49X5DOyk4xquNQfZtb848XhHyIaDd9ABwFy1rXdLSI47G9zNer 6+0uCGSEV1gwvffzBnp3ANka8ccyjE+wD7QfCal0WOz8QG5CYlrnah1bChXtQ93Pk1 m9Br/qS6OARvA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 6/8] kbuild: move more module installation code to scripts/Makefile.modinst Date: Wed, 23 Aug 2023 20:50:46 +0900 Message-Id: <20230823115048.823011-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Move more relevant code to scripts/Makefile.modinst. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- 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 From patchwork Wed Aug 23 11:50:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362212 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 254D2EE49A0 for ; Wed, 23 Aug 2023 11:51:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234572AbjHWLvW (ORCPT ); Wed, 23 Aug 2023 07:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbjHWLvV (ORCPT ); Wed, 23 Aug 2023 07:51:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E00110D8; Wed, 23 Aug 2023 04:51:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC9F165EE5; Wed, 23 Aug 2023 11:51:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE280C433BC; Wed, 23 Aug 2023 11:51:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791467; bh=ppMUv0qLwsFmCUlGZJ1h69t/Ezpj7sAWUVh2xcrRGhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u55izHtNM83xo+KNviVMW6hJuLR0ipOxmL++Qw726xia7DnlmR+IhknA1t8iHR7lp AS2P762LWUcvgSqANgDl3aUFiD2vrTMQfQ+cgN7dtr8Pnmti10l7IpYsHH+JnX+fAy 0Q7xhCfyaW6Jwxj4HCYLOkci6MepfljpcUVPDWvianMj0ISgPG8alH9TZeeF16R0Ee I9H3/QjGxEXfpf4v5THgyvp8e0wrhGR4a9rWgg6KN0qr4W047kVUm9Iqi5ZOsW6IHi PCoUE3vrH/WDgrsNwGgH57lENYZBT32rcW+JPBosHMjXSgyO8rsXKJsfnapylA6dLC PVzdu1wvZ28kQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 7/8] kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=n Date: Wed, 23 Aug 2023 20:50:47 +0900 Message-Id: <20230823115048.823011-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Nicolas Schier --- 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) From patchwork Wed Aug 23 11:50:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13362213 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 AFAA1EE49B0 for ; Wed, 23 Aug 2023 11:51:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234564AbjHWLvY (ORCPT ); Wed, 23 Aug 2023 07:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234596AbjHWLvW (ORCPT ); Wed, 23 Aug 2023 07:51:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5129410F4; Wed, 23 Aug 2023 04:51:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CB8B2660A4; Wed, 23 Aug 2023 11:51:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 879EEC433C8; Wed, 23 Aug 2023 11:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692791469; bh=Qxv/8a7cbDHGce4PkpsCd77nqaf021G/M1emjTuC+4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tx0ESURFqrHydXrybxmIpYZTIhJEuAsKNs3bhXCl9l7/vaNAslvhvZNWOwaVAommV HEGWCH2RqW2QflFgnOx4jqY9i4KAmar4UE2HvNfOn4KYG0ZctUdntPF1MfbrOH5Z4g GrtgVDXhYrOHkHJQmiKxcVwGxDoodpqmSaRzD+BYliYjoJIMROmJ2iNoRoO1JDNOqq nDs6ziyZtaxn4iwXwqAdtkj7Ps4J3G4y1fE6qksLkN9UcwTs3HmsT9sQAgC2Wv53cf dLxUJgXUMRHQZrgJ0WvmbGwuHi3pvPSjLbcXDicYD1EGTu0yKz5dyiXL/z5qR51XrO s/OjwihEqusig== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 8/8] kbuild: support modules_sign for external modules as well Date: Wed, 23 Aug 2023 20:50:48 +0900 Message-Id: <20230823115048.823011-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823115048.823011-1-masahiroy@kernel.org> References: <20230823115048.823011-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Nicolas Schier --- 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