From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA1343002A3; Thu, 14 Aug 2025 13:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176878; cv=none; b=SDnpcwsjWnbVctAxt42eRbQzW7gvGYlp0F/1Z5b+waOA4FhhU65D8O9wfgTVckT8kSNyeha3WVqBXQAZnzPeBVeceGvaJFEtWoL3ziQmwx5t1WrtzX3BUhinmikLd17KgkraeGzasiZXuHqZ1XUoD37+vyPXm8pBbC0jFyq5Arw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176878; c=relaxed/simple; bh=l4XLlaq+sgrse0xJUWH72xDUED3ph1VPSIT0SUNZVi8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LNdbs9FlQTp8UD81PCmf3nEBRKsyG9nFKScCjQLaA6rMH8yUrTMDfYZmUKSCrzbOs/JyQ8yIM11KE7/Wnoe66PNmwCBcKCNrgWOeEfONBWloCgsHwqd8rrwJ0EjdrwIY/k3YXUSSYX/tF0OS5PB3Ef5zP3JI83G/U8hf10j7208= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iSP/Nwra; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iSP/Nwra" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34062C4CEEF; Thu, 14 Aug 2025 13:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176878; bh=l4XLlaq+sgrse0xJUWH72xDUED3ph1VPSIT0SUNZVi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iSP/NwrawB9S7eLpuoXv5xvhCET0QVHSwuHbsBkANK5gmU4qjhD8G0Ezo7M4lOe4l aILkgPoV5/mPQ4jhT4IURw28kozATIjyaKFpv5W+jPvbu93VtRMGAFxPbS0dpcsG5/ aJ+aWwLBUUhfphEZ9K12xdf5uyPEpw5Q9pLMpGgkbkj/UcD+S/R7hjDrjRrmj6A3r5 7zN9SKNY/PEae3hsh9Rhx7NHOnaWx0mSB92qBVjAruaZKjfzEkbrm6rz3k6snIcwC3 cdE3SiPyPWouhDlqYpdYCnsvBxEt1Bam3SEIK41DRGapk5NL0X8fdRt2lPW+ZynzE8 TdrTUaBMgh9qw== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH v6 1/9] kbuild: always create intermediate vmlinux.unstripped Date: Thu, 14 Aug 2025 15:07:09 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada Generate the intermediate vmlinux.unstripped regardless of CONFIG_ARCH_VMLINUX_NEEDS_RELOCS. If CONFIG_ARCH_VMLINUX_NEEDS_RELOCS is unset, vmlinux.unstripped and vmlinux are identiacal. This simplifies the build rule, and allows to strip more sections by adding them to remove-section-y. Signed-off-by: Masahiro Yamada --- scripts/Makefile.vmlinux | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index b64862dc6f08..4f2d4c3fb737 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -9,20 +9,6 @@ include $(srctree)/scripts/Makefile.lib =20 targets :=3D =20 -ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS -vmlinux-final :=3D vmlinux.unstripped - -quiet_cmd_strip_relocs =3D RSTRIP $@ - cmd_strip_relocs =3D $(OBJCOPY) --remove-section=3D'.rel*' --remove-= section=3D!'.rel*.dyn' $< $@ - -vmlinux: $(vmlinux-final) FORCE - $(call if_changed,strip_relocs) - -targets +=3D vmlinux -else -vmlinux-final :=3D vmlinux -endif - %.o: %.c FORCE $(call if_changed_rule,cc_o_c) =20 @@ -61,19 +47,19 @@ targets +=3D .builtin-dtbs-list =20 ifdef CONFIG_GENERIC_BUILTIN_DTB targets +=3D .builtin-dtbs.S .builtin-dtbs.o -$(vmlinux-final): .builtin-dtbs.o +vmlinux.unstripped: .builtin-dtbs.o endif =20 -# vmlinux +# vmlinux.unstripped # ------------------------------------------------------------------------= --- =20 ifdef CONFIG_MODULES targets +=3D .vmlinux.export.o -$(vmlinux-final): .vmlinux.export.o +vmlinux.unstripped: .vmlinux.export.o endif =20 ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX -$(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o +vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o =20 arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE $(Q)$(MAKE) $(build)=3Darch/$(SRCARCH)/tools $@ @@ -86,17 +72,30 @@ cmd_link_vmlinux =3D \ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) =20 -targets +=3D $(vmlinux-final) -$(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +targets +=3D vmlinux.unstripped +vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +$(call if_changed_dep,link_vmlinux) ifdef CONFIG_DEBUG_INFO_BTF -$(vmlinux-final): $(RESOLVE_BTFIDS) +vmlinux.unstripped: $(RESOLVE_BTFIDS) endif =20 ifdef CONFIG_BUILDTIME_TABLE_SORT -$(vmlinux-final): scripts/sorttable +vmlinux.unstripped: scripts/sorttable endif =20 +# vmlinux +# ------------------------------------------------------------------------= --- + +remove-section-y :=3D +remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel*' + +quiet_cmd_strip_relocs =3D OBJCOPY $@ + cmd_strip_relocs =3D $(OBJCOPY) $(addprefix --remove-section=3D,$(re= move-section-y)) $< $@ + +targets +=3D vmlinux +vmlinux: vmlinux.unstripped FORCE + $(call if_changed,strip_relocs) + # modules.builtin.ranges # ------------------------------------------------------------------------= --- ifdef CONFIG_BUILTIN_MODULE_RANGES @@ -110,7 +109,7 @@ modules.builtin.ranges: $(srctree)/scripts/generate_bui= ltin_ranges.awk \ modules.builtin vmlinux.map vmlinux.o.map FORCE $(call if_changed,modules_builtin_ranges) =20 -vmlinux.map: $(vmlinux-final) +vmlinux.map: vmlinux.unstripped @: =20 endif --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97E433009E2; Thu, 14 Aug 2025 13:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176881; cv=none; b=H5XsT7DW9PDakcKswctk9Gx1jzSWgjqHh47pcQsX7SzGf926t2PuQEZt74MJJqA7B2DKp2m+qyOmfrtDySaN7XHqtc0uuKLVnG1lBCbfd3l71FJuMTfKkfTUnkdr1cEBpENVEa6PPDUX9QTcyeOiAMwtcv+RU5HlVOKhEJ8QXN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176881; c=relaxed/simple; bh=j3sdaQZPKptTw8rHjWPPPeRJiy7P+Pdobg3gv3L4SEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kxrNfJAX7IIlMtW+M7Bm8GGFKSi+zVUschjTIvC81YZlyAm2OYnuwha+uF5wSB+qygguKuxIaEX4B87MB78HRQOr7xJVrjZ0QXGars39Mb9MkFtWJjZkOG3UQUXqW12BSEeHmxpH+xtMT6dhLUKuS2vxLZ76ArAuJi5IsAUeLcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rHsEQkM+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rHsEQkM+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6FA2C4CEF7; Thu, 14 Aug 2025 13:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176881; bh=j3sdaQZPKptTw8rHjWPPPeRJiy7P+Pdobg3gv3L4SEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rHsEQkM+Rdx7q3R8SFOT/gbqvb/L+TgB6UBR7LCyjDP2ptL0eML17J49JgvVDnpCt on8adBK7y40jHcJggAXynpuJeRV8qeHMjWR7gWYKc6ufBSOk0Bnc8dfSk/l3H4qJFP OcUKid5hilBbJdqcp9pufE+AYZ2RKHbbjzYaOAeUbUYbYHI6o01AHvwjYgd4lEqfO0 Yhx5VR2PwYI5N6rjxeR7ZpZuSUuzOXDICm8/7n1/EejHUPl6T2EvJYkH4R/x2o+VRZ Ivje1lASaJqNCb4P7pjw+5tTPQ4XibVQFvPXovrA661f4BuU0ZMC8AcmLXljYLXrlY Fc8oSSlsdBfdA== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH v6 2/9] kbuild: keep .modinfo section in vmlinux.unstripped Date: Thu, 14 Aug 2025 15:07:10 +0200 Message-ID: <243fb41d0b5309920365c5a3c00017a3021ccf1e.1755170493.git.legion@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada Keep the .modinfo section during linking, but strip it from the final vmlinux. Adjust scripts/mksysmap to exclude modinfo symbols from kallsyms. This change will allow the next commit to extract the .modinfo section from the vmlinux.unstripped intermediate. Signed-off-by: Masahiro Yamada --- include/asm-generic/vmlinux.lds.h | 2 +- scripts/Makefile.vmlinux | 2 +- scripts/mksysmap | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index ae2d2359b79e..cfa63860dfd4 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -831,6 +831,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) =20 /* Required sections not related to debugging. */ #define ELF_DETAILS \ + .modinfo : { *(.modinfo) } \ .comment 0 : { *(.comment) } \ .symtab 0 : { *(.symtab) } \ .strtab 0 : { *(.strtab) } \ @@ -1044,7 +1045,6 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPE= LLER_CLANG) *(.discard.*) \ *(.export_symbol) \ *(.no_trim_symbol) \ - *(.modinfo) \ /* ld.bfd warns about .gnu.version* even when not emitted */ \ *(.gnu.version*) \ =20 diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 4f2d4c3fb737..e2ceeb9e168d 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -86,7 +86,7 @@ endif # vmlinux # ------------------------------------------------------------------------= --- =20 -remove-section-y :=3D +remove-section-y :=3D .modinfo remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel*' =20 quiet_cmd_strip_relocs =3D OBJCOPY $@ diff --git a/scripts/mksysmap b/scripts/mksysmap index 3accbdb269ac..a607a0059d11 100755 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -79,6 +79,9 @@ / _SDA_BASE_$/d / _SDA2_BASE_$/d =20 +# MODULE_INFO() +/ __UNIQUE_ID_modinfo[0-9]*$/d + # ------------------------------------------------------------------------= --- # Ignored patterns # (symbols that contain the pattern are ignored) --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6ADE5301034; Thu, 14 Aug 2025 13:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176884; cv=none; b=cjBA26pyO951bxSOjSDJZ/qQaV4eOVwc8l/ogOjmYoW2K8AGK4BpC1SbNOoXhxQ2kSSgLZuohK8XnydgE13xkUkCT1nisCBBNmHNwQ5/19EDCXks50hT1KjWzM/HDBPPddk31SOStYQwghyQxZcYcSawIlu+mMqxDmxAaUqSO08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176884; c=relaxed/simple; bh=CQahKUZNepr3ndoD9y9Pqz4UQWbQPmtI3It1pqtZh4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uKpKfReC7Tmk3PS/96i7XazWHUFuJQ4FjKdiAISHfS23YbCuC5TNmxwC2DIGnLxI+6BTGChq/i5A7NLtuPPKbQ/MutwWpp4Wq3weS40HbYwNgHbSZqm2UGiZXUSNTohZcUVqJIq7HT9+/819ETRd1+Me2hQQOwObRlEz1nNwBDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NZIqgMqE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NZIqgMqE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A7FC4CEFF; Thu, 14 Aug 2025 13:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176883; bh=CQahKUZNepr3ndoD9y9Pqz4UQWbQPmtI3It1pqtZh4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NZIqgMqEQXMWlh1wxMOcMf8I+N4tZ990AAbLQYEnRLBnNOp61+iJmWwwH2cjrbMm+ 8MCm+X4D7Ot12azoG2SajK4qVk8AEH5xTw6lIr26KNwOUe1vxAjA+kTY1chsfTx6U6 M+0oE6ILYt7H2RF+x6zp0AlvGdCAFllxlXSoqBP8CGJg6h62/kn45vpdNepgN3W1eX AkK/S58hToh48id4eARsElQv3Bzl+4I+doNS0rt3PRzX6GyJtpxrrRSHU0RKYge9sC /nIh2gNyAg17hX9rVZI0mXBfuxrZxvdfH8exGFoHN62dFXL3kNW/XFc1m8G3BJq3DX QgvxMePVIMw0w== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov Subject: [PATCH v6 3/9] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Date: Thu, 14 Aug 2025 15:07:11 +0200 Message-ID: <16859d94a2c8e4b1bb305defdb8b7be238499c66.1755170493.git.legion@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada Currently, we assume all the data for modules.builtin.modinfo are available in vmlinux.o. This makes it impossible for modpost, which is invoked after vmlinux.o, to add additional module info. This commit moves the modules.builtin.modinfo rule after modpost. Signed-off-by: Masahiro Yamada Signed-off-by: Alexey Gladkov --- scripts/Makefile.vmlinux | 26 ++++++++++++++++++++++++++ scripts/Makefile.vmlinux_o | 26 +------------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index e2ceeb9e168d..fdab5aa90215 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -96,6 +96,32 @@ targets +=3D vmlinux vmlinux: vmlinux.unstripped FORCE $(call if_changed,strip_relocs) =20 +# modules.builtin.modinfo +# ------------------------------------------------------------------------= --- + +OBJCOPYFLAGS_modules.builtin.modinfo :=3D -j .modinfo -O binary + +targets +=3D modules.builtin.modinfo +modules.builtin.modinfo: vmlinux.unstripped FORCE + $(call if_changed,objcopy) + +# modules.builtin +# ------------------------------------------------------------------------= --- + +__default: modules.builtin + +# The second line aids cases where multiple modules share the same object. + +quiet_cmd_modules_builtin =3D GEN $@ + cmd_modules_builtin =3D \ + tr '\0' '\n' < $< | \ + sed -n 's/^[[:alnum:]:_]*\.file=3D//p' | \ + tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ + +targets +=3D modules.builtin +modules.builtin: modules.builtin.modinfo FORCE + $(call if_changed,modules_builtin) + # modules.builtin.ranges # ------------------------------------------------------------------------= --- ifdef CONFIG_BUILTIN_MODULE_RANGES diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index b024ffb3e201..23c8751285d7 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only =20 PHONY :=3D __default -__default: vmlinux.o modules.builtin.modinfo modules.builtin +__default: vmlinux.o =20 include include/config/auto.conf include $(srctree)/scripts/Kbuild.include @@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_L= IBS) FORCE =20 targets +=3D vmlinux.o =20 -# modules.builtin.modinfo -# ------------------------------------------------------------------------= --- - -OBJCOPYFLAGS_modules.builtin.modinfo :=3D -j .modinfo -O binary - -targets +=3D modules.builtin.modinfo -modules.builtin.modinfo: vmlinux.o FORCE - $(call if_changed,objcopy) - -# modules.builtin -# ------------------------------------------------------------------------= --- - -# The second line aids cases where multiple modules share the same object. - -quiet_cmd_modules_builtin =3D GEN $@ - cmd_modules_builtin =3D \ - tr '\0' '\n' < $< | \ - sed -n 's/^[[:alnum:]:_]*\.file=3D//p' | \ - tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ - -targets +=3D modules.builtin -modules.builtin: modules.builtin.modinfo FORCE - $(call if_changed,modules_builtin) - # Add FORCE to the prerequisites of a target to force it to be always rebu= ilt. # ------------------------------------------------------------------------= --- =20 --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6377D301010; Thu, 14 Aug 2025 13:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176888; cv=none; b=Ffc8RJXD/Fnv6zwWlxaHCDFytBGF9n33+2a/w4QZxQVwcfZ7TeFJJRZNooabxpgF9l0yZ1zpY/lpnofhmci8PXJzaG/wjByWX2b9LtKzSoYh1fushpnMwhNdUx3qaF3N6YKONgbFaCB3anHtCnkJl5gTYjebDzH+p8aqyW/lPZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176888; c=relaxed/simple; bh=7VIlza3DFZd9t15O6Mnto/RGJe+xCXiRNcV7zBDq5AU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t6/JWMN3ZPPuJokLCd9B4momPWChDzJEP7epvWhVrGDST9c2PEaF8qIF5IdvUaPuJjibSr4M+U/wNvMXqjWKcj0XCofFjLt4u+MZ1uf5lNethhIg4BRqNC9Q8FtJLaSA4FnOIRwd8YiDpFTvjQP2rszVdB7TQ3z9IfL4ebIwpFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uA2e5TOV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uA2e5TOV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60C94C19423; Thu, 14 Aug 2025 13:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176887; bh=7VIlza3DFZd9t15O6Mnto/RGJe+xCXiRNcV7zBDq5AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uA2e5TOVfhtF17EBnkfEGXxo9CS51/8+GK4605OKP/tMlY3Kxb3TT5OgOeNTHWVlE AYeEAJqxUQu4Skql5POGhkjtRQPMZaCGhzKhw+fSpWLtJBaLhsRf3Ywhwj5frV7Bu4 coTqkjyeYfQjy+QHHf3PgIB8yphiGnHCbnR82pR+IGbF5dt4gOSN9RFxWyvRMSHxo3 U3+xyL4QMqm2mQefDWCQbBnOa/wwoa3wIqjDYO82BZHP7z/gumgiRKhFJkKHayVVRG 2johg/FXlh9FoE0eXfF4qotrGiEQAVgp49RJAGw/8ET5+GEhR7q+DKbyskTyghslnK b1kCUEt/eU3rA== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Khalid Aziz , "Martin K. Petersen" , linux-scsi@vger.kernel.org, James Bottomley , Arnd Bergmann , Damien Le Moal Subject: [PATCH v6 4/9] scsi: Always define blogic_pci_tbl structure Date: Thu, 14 Aug 2025 15:07:12 +0200 Message-ID: <93ca6c988e2d8a294ae0941747a6e654e6e8e8b8.1755170493.git.legion@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The blogic_pci_tbl structure is used by the MODULE_DEVICE_TABLE macro. There is no longer a need to protect it with the MODULE condition, since this no longer causes the compiler to warn about an unused variable. To avoid warnings when -Wunused-const-variable option is used, mark it as __maybe_unused for such configuration. Cc: Khalid Aziz Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Suggested-by: James Bottomley Signed-off-by: Alexey Gladkov Signed-off-by: Arnd Bergmann Reviewed-by: Damien Le Moal Acked-by: Martin K. Petersen --- drivers/scsi/BusLogic.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 1f100270cd38..82597bd96525 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void) =20 __setup("BusLogic=3D", blogic_setup); =20 -#ifdef MODULE /*static const struct pci_device_id blogic_pci_tbl[] =3D { { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -3725,13 +3724,12 @@ __setup("BusLogic=3D", blogic_setup); PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { } };*/ -static const struct pci_device_id blogic_pci_tbl[] =3D { +static const struct pci_device_id blogic_pci_tbl[] __maybe_unused =3D { {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER)}, {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC= )}, {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)}, {0, }, }; -#endif MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); =20 module_init(blogic_init); --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 690673019B4; Thu, 14 Aug 2025 13:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176892; cv=none; b=lyS2w6nCFs1v2PP5NbRybwgdfS/2Kcm5Rj6GDrCh3nWtHujwVhrTtSvZJTdrZ8Zin+j6/OjLYm26CqVZ04Sqhsut2zkSq2rFO1RmNNdoG2VddzMoZpBFhXvX5X1XiF9pA1BVi9Aeif9Mx7vGWPkf73WBDWX6Kj2qBNoKScpnb0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176892; c=relaxed/simple; bh=eeXOQDuIkC91qNmZOOxwnqrLxIkQOGin6epB2IqmH7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZybH4l+QBz7Off/vo5ttt1UCfFVhpXGnj0uTGy+/2o0sXUSgBsEWNEJiJm+4jiYB23ZTV0bo8B7UZJtdIVeN64ZZCvhvm1IX5IiFiC8BtW0lNktcCccPcfmTtIqczdbx2mn2R3hfEFaDAiCtnUxvb4gy8qy0E6CEV5kX84wOWvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sl3ylAQt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sl3ylAQt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E515C4CEED; Thu, 14 Aug 2025 13:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176891; bh=eeXOQDuIkC91qNmZOOxwnqrLxIkQOGin6epB2IqmH7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sl3ylAQt6xcnwmBDX19BgFv3nCt8rKnq8FYXErHESwYo1LnnbgeZqNFzisMX2qABE P7NIrS/eRk7a5aeVZQIVI0106gu3AQY9Y90BWN/N/ZXB7D0C8bq+PFgz/LBME+EXl+ XbYT5Q5YhxwB0eUnibeDmJNEIXpSdZVDG/Vi/usKedPVF96Cja8G6K7BZIIoyYVuEx tDoA8M/2BOIM8YYQfRylnrFeN2JdwdwT6iLwbUaEwfXWRY+KyFX0W7z5YKQkZVJvNa XrUSSwRkVZD0cwkFDSQBwObuzMxHA2w9g6/Oe9izkchy/VtHJ1cXqjcD1XbAbpTVyO c22LP6ZldN4Dw== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Xianwei Zhao , Linus Walleij , Neil Armstrong , Kevin Hilman , linux-amlogic@lists.infradead.org, linux-gpio@vger.kernel.org, kernel test robot Subject: [PATCH v6 5/9] pinctrl: meson: Fix typo in device table macro Date: Thu, 14 Aug 2025 15:07:13 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The typo when using the MODULE_DEVICE_TABLE macro was not noticeable because the macro was defined only if the module was built as a separate module. Cc: Xianwei Zhao Cc: Linus Walleij Cc: Neil Armstrong Cc: Kevin Hilman Cc: linux-amlogic@lists.infradead.org Cc: linux-gpio@vger.kernel.org Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202507220009.8HKbNP16-lkp@int= el.com/ Signed-off-by: Alexey Gladkov Reviewed-by: Neil Armstrong --- drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/m= eson/pinctrl-amlogic-a4.c index e34e984c2b38..6132710aff68 100644 --- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c +++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c @@ -1093,7 +1093,7 @@ static const struct of_device_id aml_pctl_of_match[] = =3D { { .compatible =3D "amlogic,pinctrl-s6", .data =3D &s6_priv_data, }, { /* sentinel */ } }; -MODULE_DEVICE_TABLE(of, aml_pctl_dt_match); +MODULE_DEVICE_TABLE(of, aml_pctl_of_match); =20 static struct platform_driver aml_pctl_driver =3D { .driver =3D { --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCAEE301028; Thu, 14 Aug 2025 13:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176895; cv=none; b=m16JimS1jDiMWdQC0kVP/HZ/r1i6x7ukimvcxlPQedNGUXhfLS9PjjufPSWP3nvYI0EFaSi+/cGljKlCqCupd3uNCTgBu6giPMtL64brjdl5txvaT/LoAyexRM3JGaNIkmvAFa6/lxuXFMesYt0iwaZBL924VTTU0bmbe0wyC+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176895; c=relaxed/simple; bh=duM6/HCl5EVHZOaH04hOyQBnVjVr+4mdpy8dfoCQA6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GesKuy+mETnxY8kJPqGhP89xc+OCh/DtoO1okX4eIiKRvsJW2BEkG/ExkyUk/0Lh54UNZh2ucS6+vqIOFfLQsVilh2xGB64TuFhnYVoLiPx3LdR6no6lPgtpubXF2/BElT7QiW+4P9BHI3HQtqC8YM7ODWjd3PgJUp7cPb+8j3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sCqBt/GD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sCqBt/GD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CE9FC4CEF7; Thu, 14 Aug 2025 13:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176895; bh=duM6/HCl5EVHZOaH04hOyQBnVjVr+4mdpy8dfoCQA6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCqBt/GDwT3kUhOlOxnqzzMfX6WrKYKSceKGaueRQQKa9tPSfXUGDSIuiKwgZpR8B W9BkI/IxW9crgKmoMrvyme+lGH1e6pHtiu2azguBUOgI+h2gcikfsLxYmgFkBJPs38 3AwGWayqlgmTqOZbcwIu0UyY2GBGaWM41Zfupvjo5CahLBHU0MwrWSE20wE3k4vZzL fnW3/k42OAZfs+tqORzVERFVVrsHMG39bxigpzSpGsIpy6J12T3SybaUNIP7RIfBLv IpEmTT9otaH8cbZ26zMPL7FahWeNVrz6AYof2VtyBgXO557BPJEhx/Pp2Gey6Dhm6C vTcqbsJTtiFhg== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Miguel Ojeda , Andreas Hindborg , Danilo Krummrich , Alex Gaynor , rust-for-linux@vger.kernel.org Subject: [PATCH v6 6/9] modpost: Add modname to mod_device_table alias Date: Thu, 14 Aug 2025 15:07:14 +0200 Message-ID: <15724fb8669dae64e3c8d31ab620f977984b2177.1755170493.git.legion@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At this point, if a symbol is compiled as part of the kernel, information about which module the symbol belongs to is lost. To save this it is possible to add the module name to the alias name. It's not very pretty, but it's possible for now. Cc: Miguel Ojeda Cc: Andreas Hindborg Cc: Danilo Krummrich Cc: Alex Gaynor Cc: rust-for-linux@vger.kernel.org Signed-off-by: Alexey Gladkov Acked-by: Danilo Krummrich --- include/linux/module.h | 14 +++++++++++++- rust/kernel/device_id.rs | 8 ++++---- scripts/mod/file2alias.c | 18 ++++++++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 3319a5269d28..e31ee29fac6b 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -244,10 +244,22 @@ struct module_kobject *lookup_or_create_module_kobjec= t(const char *name); /* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _descrip= tion) =20 +/* + * Format: __mod_device_table__kmod_____ + * Parts of the string `__kmod_` and `__` are used as delimiters when pars= ing + * a symbol in file2alias.c + */ +#define __mod_device_table(type, name) \ + __PASTE(__mod_device_table__, \ + __PASTE(__KBUILD_MODNAME, \ + __PASTE(__, \ + __PASTE(type, \ + __PASTE(__, name))))) + #ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ -static typeof(name) __mod_device_table__##type##__##name \ +static typeof(name) __mod_device_table(type, name) \ __attribute__ ((used, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs index 70d57814ff79..62c42da12e9d 100644 --- a/rust/kernel/device_id.rs +++ b/rust/kernel/device_id.rs @@ -195,10 +195,10 @@ macro_rules! module_device_table { ($table_type: literal, $module_table_name:ident, $table_name:ident) = =3D> { #[rustfmt::skip] #[export_name =3D - concat!("__mod_device_table__", $table_type, - "__", module_path!(), - "_", line!(), - "_", stringify!($table_name)) + concat!("__mod_device_table__", line!(), + "__kmod_", module_path!(), + "__", $table_type, + "__", stringify!($table_name)) ] static $module_table_name: [::core::mem::MaybeUninit; $table_n= ame.raw_ids().size()] =3D unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) }; diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 00586119a25b..13021266a18f 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1476,8 +1476,8 @@ void handle_moddevtable(struct module *mod, struct el= f_info *info, { void *symval; char *zeros =3D NULL; - const char *type, *name; - size_t typelen; + const char *type, *name, *modname; + size_t typelen, modnamelen; static const char *prefix =3D "__mod_device_table__"; =20 /* We're looking for a section relative symbol */ @@ -1488,10 +1488,20 @@ void handle_moddevtable(struct module *mod, struct = elf_info *info, if (ELF_ST_TYPE(sym->st_info) !=3D STT_OBJECT) return; =20 - /* All our symbols are of form __mod_device_table____. */ + /* All our symbols are of form __mod_device_table__kmod___= __. */ if (!strstarts(symname, prefix)) return; - type =3D symname + strlen(prefix); + + modname =3D strstr(symname, "__kmod_"); + if (!modname) + return; + modname +=3D strlen("__kmod_"); + + type =3D strstr(modname, "__"); + if (!type) + return; + modnamelen =3D type - modname; + type +=3D strlen("__"); =20 name =3D strstr(type, "__"); if (!name) --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2741830102F; Thu, 14 Aug 2025 13:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176900; cv=none; b=NweQDyC1158ceuU6/UJ6X6ly9z5RFeX0Zljly+2BUgebWc786pGAJ7zUOPEiYyS4OmyRosIF3tW2iKaWvt7vS7qL2mMGNKvS6gXZVoc09YUnyKv5zkp8kEqdrvfJC4FwxYRW+kL8cXfJQpDO/akalxrjxfJCR1x6jvM0jdLvTdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176900; c=relaxed/simple; bh=qYZZIFVvMdEGmtyhDB1iuf/ZUDPpqbUlO/outcGMnZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DLlEgk+mOGPkJSNx/XAin2sZanGAJltbTcoPGCguj8PyHeJFzA56EHIFeaRBt8CCFMxnerontgOAMtITGpsBoNsm0ae8FREbk466Hc0/J14wm13KUKMgr9p13Ad8KfYCXF7RgeeP1byNNvwJUd5wXgobBIRtvo0fSwJB+sdu5Oo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E0rzeS1h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E0rzeS1h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1369AC4CEEF; Thu, 14 Aug 2025 13:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176898; bh=qYZZIFVvMdEGmtyhDB1iuf/ZUDPpqbUlO/outcGMnZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0rzeS1h/6f4lw+GCKrbwH2Ka/SDmKMsatLQPnnhRDJef7tMgfPBvFpYP97H9OuKw 3qUS4rWUcDAB8QJDTrXRXk8ovEwcQNwl5pq+aJ6ZQSPPWghiop4qexcHx6aWruepgL lxgm5aSdfodZcw1WY0rlRX0MoicMZJ/F+a8SU9UNwvlTNi9PLmCE5nUZmVp2B8q873 rRcXubsLSjW9K6nwUO0a6Av4xm1g70Wf6gcxWOk/RxvUBOM6oIQr5Lr7j6Fy9+upcK nG8ykkYBgHIntHJ0Ui18Cnsb/SYpf/Fw+5X/fhAj3I/VeRoulbfr8pu3dnNl59SENM TgGjg/2t4kgpw== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Stephen Rothwell Subject: [PATCH v6 7/9] modpost: Create modalias for builtin modules Date: Thu, 14 Aug 2025 15:07:15 +0200 Message-ID: <22b36a5807d943a84431298c18b41d093e01c371.1755170493.git.legion@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For some modules, modalias is generated using the modpost utility and the section is added to the module file. When a module is added inside vmlinux, modpost does not generate modalias for such modules and the information is lost. As a result kmod (which uses modules.builtin.modinfo in userspace) cannot determine that modalias is handled by a builtin kernel module. $ cat /sys/devices/pci0000:00/0000:00:14.0/modalias pci:v00008086d0000A36Dsv00001043sd00008694bc0Csc03i30 $ modinfo xhci_pci name: xhci_pci filename: (builtin) license: GPL file: drivers/usb/host/xhci-pci description: xHCI PCI Host Controller Driver Missing modalias "pci:v*d*sv*sd*bc0Csc03i30*" which will be generated by modpost if the module is built separately. To fix this it is necessary to generate the same modalias for vmlinux as for the individual modules. Fortunately '.vmlinux.export.o' is already generated from which '.modinfo' can be extracted in the same way as for vmlinux.o. Signed-off-by: Masahiro Yamada Signed-off-by: Alexey Gladkov Tested-by: Stephen Rothwell --- include/linux/module.h | 4 ---- scripts/Makefile.vmlinux | 5 ++++- scripts/mksysmap | 3 +++ scripts/mod/file2alias.c | 16 ++++++++++++++++ scripts/mod/modpost.c | 15 +++++++++++++++ scripts/mod/modpost.h | 2 ++ 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index e31ee29fac6b..e135cc79acee 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -256,14 +256,10 @@ struct module_kobject *lookup_or_create_module_kobjec= t(const char *name); __PASTE(type, \ __PASTE(__, name))))) =20 -#ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ static typeof(name) __mod_device_table(type, name) \ __attribute__ ((used, alias(__stringify(name)))) -#else /* !MODULE */ -#define MODULE_DEVICE_TABLE(type, name) -#endif =20 /* Version of form [:][-]. * Or for CVS/RCS ID version, everything but the number is stripped. diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index fdab5aa90215..fcc188d26ead 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -89,8 +89,11 @@ endif remove-section-y :=3D .modinfo remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel*' =20 +remove-symbols :=3D -w --strip-symbol=3D'__mod_device_table__*' + quiet_cmd_strip_relocs =3D OBJCOPY $@ - cmd_strip_relocs =3D $(OBJCOPY) $(addprefix --remove-section=3D,$(re= move-section-y)) $< $@ + cmd_strip_relocs =3D $(OBJCOPY) $(addprefix --remove-section=3D,$(re= move-section-y)) \ + $(remove-symbols) $< $@ =20 targets +=3D vmlinux vmlinux: vmlinux.unstripped FORCE diff --git a/scripts/mksysmap b/scripts/mksysmap index a607a0059d11..c4531eacde20 100755 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -59,6 +59,9 @@ # EXPORT_SYMBOL (namespace) / __kstrtabns_/d =20 +# MODULE_DEVICE_TABLE (symbol name) +/ __mod_device_table__/d + # ------------------------------------------------------------------------= --- # Ignored suffixes # (do not forget '$' after each pattern) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 13021266a18f..7da9735e7ab3 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1527,5 +1527,21 @@ void handle_moddevtable(struct module *mod, struct e= lf_info *info, } } =20 + if (mod->is_vmlinux) { + struct module_alias *alias; + + /* + * If this is vmlinux, record the name of the builtin module. + * Traverse the linked list in the reverse order, and set the + * builtin_modname unless it has already been set in the + * previous call. + */ + list_for_each_entry_reverse(alias, &mod->aliases, node) { + if (alias->builtin_modname) + break; + alias->builtin_modname =3D xstrndup(modname, modnamelen); + } + } + free(zeros); } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5ca7c268294e..47c8aa2a6939 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2067,11 +2067,26 @@ static void write_if_changed(struct buffer *b, cons= t char *fname) static void write_vmlinux_export_c_file(struct module *mod) { struct buffer buf =3D { }; + struct module_alias *alias, *next; =20 buf_printf(&buf, "#include \n"); =20 add_exported_symbols(&buf, mod); + + buf_printf(&buf, + "#include \n" + "#undef __MODULE_INFO_PREFIX\n" + "#define __MODULE_INFO_PREFIX\n"); + + list_for_each_entry_safe(alias, next, &mod->aliases, node) { + buf_printf(&buf, "MODULE_INFO(%s.alias, \"%s\");\n", + alias->builtin_modname, alias->str); + list_del(&alias->node); + free(alias->builtin_modname); + free(alias); + } + write_if_changed(&buf, ".vmlinux.export.c"); free(buf.p); } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 9133e4c3803f..2aecb8f25c87 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -99,10 +99,12 @@ buf_write(struct buffer *buf, const char *s, int len); * struct module_alias - auto-generated MODULE_ALIAS() * * @node: linked to module::aliases + * @modname: name of the builtin module (only for vmlinux) * @str: a string for MODULE_ALIAS() */ struct module_alias { struct list_head node; + char *builtin_modname; char str[]; }; =20 --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D84CD302776; Thu, 14 Aug 2025 13:08:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176902; cv=none; b=a9H9OfK2giMfID4JSgG4Dk3bF+pHBGCixH/k/nXLx1eHzQgcq3xNTN9XQMSGYcMpW7nJCypi5JFaHnf2ZFIZHqCdyy4ns8e0AfBK8f3rd695Bao9HAvfWYY4zkorptUdGLD4pg0mF9BXKs/WJtK/T4utqus9miDmeetxgD2YlOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176902; c=relaxed/simple; bh=BZNqAkUNOK9Nr6DHLj1baz+QKcwHjdeg9vOowOhVhiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GS7/IpK9fPUrpFwuGNOPfwCu2r2205KwahWUbVTWcRQir5KVEkxJ+JvfEZ247FRY+l93mi3Jv35B2j6FDidTSAU+UBJO1FnuBEjZ+c5QC3nxpyTncRBHKPmasbO7XMhtIRcq9lqmuSKm7VWhCk7qh5+jVVBOVopKp09GdeUNjUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q3QXMtBO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q3QXMtBO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EDA9C4CEF8; Thu, 14 Aug 2025 13:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176901; bh=BZNqAkUNOK9Nr6DHLj1baz+QKcwHjdeg9vOowOhVhiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3QXMtBOv6pVtTdV1TgSO/XYHl3wZqk2n/BoNJMYusSl/ZcpWz212uI3vo7NNQ115 5/MJNhjtp6H9E/YdcORrc+73XqfQO5lNDZVimQ1okRxUuSITWHc818RQQodyHQhOoA cJGGQfqpZpz7ynZK4Xc0l8aMSSPFzokS89LluMprI2TDRdI/IcK352Lvhvdeoz2+HW PcdKCtVXIl0Fbx/NlRQ+PhWge9bx1hr1W00ibyk7CSZ84U4lynDajz5ZXNIMmIJDUJ 9oVWNQkUzXIyDEyzNh47mAAnjzSCNkrgunY4TzkhDxvyUL4OM8DAGpRLzMecHmhvoR Dglq+v51Bjrrw== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov Subject: [PATCH v6 8/9] kbuild: vmlinux.unstripped should always depend on .vmlinux.export.o Date: Thu, 14 Aug 2025 15:07:16 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since .vmlinux.export.c is used to add generated by modpost modaliases for builtin modules the .vmlinux.export.o is no longer optional and should always be created. The generation of this file is not dependent on CONFIG_MODULES. Signed-off-by: Alexey Gladkov --- scripts/Makefile.vmlinux | 9 ++------- scripts/link-vmlinux.sh | 5 +---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index fcc188d26ead..dbbe3bf0cf23 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -53,11 +53,6 @@ endif # vmlinux.unstripped # ------------------------------------------------------------------------= --- =20 -ifdef CONFIG_MODULES -targets +=3D .vmlinux.export.o -vmlinux.unstripped: .vmlinux.export.o -endif - ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o =20 @@ -72,8 +67,8 @@ cmd_link_vmlinux =3D \ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) =20 -targets +=3D vmlinux.unstripped -vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +targets +=3D vmlinux.unstripped .vmlinux.export.o +vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o .vmlinux.export.o $(= KBUILD_LDS) FORCE +$(call if_changed_dep,link_vmlinux) ifdef CONFIG_DEBUG_INFO_BTF vmlinux.unstripped: $(RESOLVE_BTFIDS) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 51367c2bfc21..433849ff7529 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -73,10 +73,7 @@ vmlinux_link() objs=3D"${objs} .builtin-dtbs.o" fi =20 - if is_enabled CONFIG_MODULES; then - objs=3D"${objs} .vmlinux.export.o" - fi - + objs=3D"${objs} .vmlinux.export.o" objs=3D"${objs} init/version-timestamp.o" =20 if [ "${SRCARCH}" =3D "um" ]; then --=20 2.50.1 From nobody Sat Oct 4 15:55:22 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B0AB2F99BF; Thu, 14 Aug 2025 13:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176905; cv=none; b=HtMm2uxfHmwyopoaS7obVsF3ZET0tPrfcyD2yoMmGi5h8UU4nyuP70iFh5JzwJZ0H1tfiBIdNDCgf+7rBjMknnz6doRbUkA/UpAyRpb6vtCi9fuCz49HnWU5OUCnI0b8IeBt60RLfOkDKrvNUGWAEP8+mEuN9NP7cvLA4SVEyoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755176905; c=relaxed/simple; bh=jMZ5LWSabVQ7mCxQmeFMV6u0UXjP1UdNg7+VrYxFf58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K3B2OYjsVMxAPwMBIeL9seUqXxihy59ERKnXrS1Hnd8pbDm7QNlXgi+KN/hpSgafNuXbXuNjadz6eISXAVvELi85zR8vKNdJh17kEHM5d77nm9GQVdQ7rcXhx+1LtJCeF9vDk8Z701Y6o0nMwmjkgp4p8WXeTQNtVo5mAnFHrt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F/8BSErw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F/8BSErw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1D30C4CEF6; Thu, 14 Aug 2025 13:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755176905; bh=jMZ5LWSabVQ7mCxQmeFMV6u0UXjP1UdNg7+VrYxFf58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/8BSErwOlzjNvXlBbW8wsUkaOv5U5m9Z6BZzeV8784rYDrphzP/rg3FjIKsH5A9q 5zTltUzyyiQQXW1gFmPwbd1eQD1qSZhDUT3asNKqQPBZx5RjoKFmaxTNsP9IJU7vqJ mpcgiDpxeqx9viOwNnTHTKJxgEUoPVSPCkcawFGqGH4Lrb5kBKLjqYA0xhdPD00FLO v/hggaOKUmGIT9Xg1m5GLasuWhmI7MRIrYvEJ426T0+zz/kft7t6QLohMMzTNCG8hK JBHqAHg/km5o/pOJ8t4O9t4/JbEGLhWFvJ4tDioBkihAxRNL2w6y7kO5esc/EjN78v 99IDSzPfZkmxw== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-s390@vger.kernel.org, kernel test robot Subject: [PATCH v6 9/9] s390: vmlinux.lds.S: Reorder sections Date: Thu, 14 Aug 2025 15:07:17 +0200 Message-ID: <919570dc048786c4d07affaec4b761811c6c21c5.1755170493.git.legion@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reorder the sections to be placed in the default segment. The .vmlinux.info use :NONE to override the default segment and tell the linker to not put the section in any segment at all. >> s390x-linux-ld: .tmp_vmlinux1: warning: allocated section `.modinfo' not= in segment >> s390x-linux-ld: .tmp_vmlinux2: warning: allocated section `.modinfo' not= in segment >> s390x-linux-ld: vmlinux.unstripped: warning: allocated section `.modinfo= ' not in segment Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: linux-s390@vger.kernel.org Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202506062053.zbkFBEnJ-lkp@int= el.com/ Signed-off-by: Alexey Gladkov Acked-by: Heiko Carstens --- arch/s390/kernel/vmlinux.lds.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 1c606dfa595d..feecf1a6ddb4 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S @@ -209,6 +209,11 @@ SECTIONS . =3D ALIGN(PAGE_SIZE); _end =3D . ; =20 + /* Debugging sections. */ + STABS_DEBUG + DWARF_DEBUG + ELF_DETAILS + /* * uncompressed image info used by the decompressor * it should match struct vmlinux_info @@ -239,11 +244,6 @@ SECTIONS #endif } :NONE =20 - /* Debugging sections. */ - STABS_DEBUG - DWARF_DEBUG - ELF_DETAILS - /* * Make sure that the .got.plt is either completely empty or it * contains only the three reserved double words. --=20 2.50.1