* [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo
@ 2025-05-27 9:07 Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary Alexey Gladkov
` (6 more replies)
0 siblings, 7 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:07 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov
The modules.builtin.modinfo file is used by userspace (kmod to be specific) to
get information about builtin modules. Among other information about the module,
information about module aliases is stored. This is very important to determine
that a particular modalias will be handled by a module that is inside the
kernel.
There are several mechanisms for creating modalias for modules:
The first is to explicitly specify the MODULE_ALIAS of the macro. In this case,
the aliases go into the '.modinfo' section of the module if it is compiled
separately or into vmlinux.o if it is builtin into the kernel.
The second is the use of MODULE_DEVICE_TABLE followed by the use of the
modpost utility. In this case, vmlinux.o no longer has this information and
does not get it into modules.builtin.modinfo.
For example:
$ modinfo pci:v00008086d0000A36Dsv00001043sd00008694bc0Csc03i30
modinfo: ERROR: Module pci:v00008086d0000A36Dsv00001043sd00008694bc0Csc03i30 not found.
$ modinfo xhci_pci
name: xhci_pci
filename: (builtin)
license: GPL
file: drivers/usb/host/xhci-pci
description: xHCI PCI Host Controller Driver
The builtin module is missing alias "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 add the generated by modpost modalias to
modules.builtin.modinfo.
Fortunately modpost already generates .vmlinux.export.c for exported symbols. It
is possible to use this file to create a '.modinfo' section for builtin modules.
The modules.builtin.modinfo file becomes a composite file. One part is extracted
from vmlinux.o, the other part from .vmlinux.export.o.
Notes:
- v3:
* Add `Reviewed-by` tag to patches from Petr Pavlu.
* Rebase to v6.15.
* v2: https://lore.kernel.org/all/20250509164237.2886508-1-legion@kernel.org/
- v2:
* Drop patch for mfd because it was already applied and is in linux-next.
* The generation of aliases for builtin modules has been redone as
suggested by Masahiro Yamada.
* Rebase to v6.15-rc5-136-g9c69f8884904
* v1: https://lore.kernel.org/all/cover.1745591072.git.legion@kernel.org/
Alexey Gladkov (6):
scsi: Define MODULE_DEVICE_TABLE only if necessary
modules: Add macros to specify modinfo prefix
modpost: Make mod_device_table aliases more unique
modpost: Create modalias for builtin modules
kbuild: Move modules.builtin.modinfo to another makefile
kbuild: Create modules.builtin.modinfo for modpost results
drivers/scsi/BusLogic.c | 2 +-
include/linux/module.h | 21 +++++++++++-----
include/linux/moduleparam.h | 7 ++++--
scripts/Makefile.vmlinux | 48 +++++++++++++++++++++++++++++++++++++
scripts/Makefile.vmlinux_o | 26 +-------------------
scripts/mod/file2alias.c | 34 ++++++++++++++++++++++----
scripts/mod/modpost.c | 13 +++++++++-
scripts/mod/modpost.h | 2 ++
8 files changed, 114 insertions(+), 39 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
@ 2025-05-27 9:07 ` Alexey Gladkov
2025-05-27 11:28 ` James Bottomley
2025-05-27 14:06 ` [PATCH v4 1/6] scsi: Always define blogic_pci_tbl structure Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 2/6] modules: Add macros to specify modinfo prefix Alexey Gladkov
` (5 subsequent siblings)
6 siblings, 2 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:07 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov,
Khalid Aziz, James E.J. Bottomley, Martin K. Petersen
Define MODULE_DEVICE_TABLE only if a structure is defined for it.
drivers/scsi/BusLogic.c:3735:26: error: use of undeclared identifier 'blogic_pci_tbl'
3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
Fixes: 1079a2d251f2 ("[SCSI] BusLogic: stop using check_region")
Cc: Khalid Aziz <khalid@gonehiking.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
drivers/scsi/BusLogic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 1f100270cd38..8ce2ac9293a3 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3731,8 +3731,8 @@ static const struct pci_device_id blogic_pci_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)},
{0, },
};
-#endif
MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
+#endif
module_init(blogic_init);
module_exit(blogic_exit);
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v3 2/6] modules: Add macros to specify modinfo prefix
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary Alexey Gladkov
@ 2025-05-27 9:07 ` Alexey Gladkov
2025-06-02 7:49 ` Masahiro Yamada
2025-05-27 9:07 ` [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique Alexey Gladkov
` (4 subsequent siblings)
6 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:07 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov
The __MODULE_INFO macros always use __MODULE_INFO_PREFIX. The only way
to use a different prefix is to override __MODULE_INFO_PREFIX, which is
not very useful.
The new macro will be used in file2alias.c to generate modalias for
builtin modules.
Signed-off-by: Alexey Gladkov <legion@kernel.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
---
include/linux/module.h | 3 +++
include/linux/moduleparam.h | 7 +++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index 8050f77c3b64..88048561360f 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -170,6 +170,9 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
/* For userspace: you can also call me... */
#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
+#define MODULE_ALIAS_MODNAME(_modname, _alias) \
+ __MODULE_INFO_WITH_PREFIX(_modname ".", alias, alias, _alias)
+
/* Soft module dependencies. See man modprobe.d for details.
* Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
*/
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index bfb85fd13e1f..3f819fc67c43 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -20,10 +20,13 @@
/* Chosen so that structs with an unsigned long line up. */
#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
-#define __MODULE_INFO(tag, name, info) \
+#define __MODULE_INFO_WITH_PREFIX(prefix, tag, name, info) \
static const char __UNIQUE_ID(name)[] \
__used __section(".modinfo") __aligned(1) \
- = __MODULE_INFO_PREFIX __stringify(tag) "=" info
+ = prefix __stringify(tag) "=" info
+
+#define __MODULE_INFO(tag, name, info) \
+ __MODULE_INFO_WITH_PREFIX(__MODULE_INFO_PREFIX, tag, name, info)
#define __MODULE_PARM_TYPE(name, _type) \
__MODULE_INFO(parmtype, name##type, #name ":" _type)
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 2/6] modules: Add macros to specify modinfo prefix Alexey Gladkov
@ 2025-05-27 9:07 ` Alexey Gladkov
2025-06-02 7:45 ` Masahiro Yamada
2025-06-02 7:52 ` Masahiro Yamada
2025-05-27 9:07 ` [PATCH v3 4/6] modpost: Create modalias for builtin modules Alexey Gladkov
` (3 subsequent siblings)
6 siblings, 2 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:07 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov
In order to avoid symbol conflicts if they appear in the same binary, a
more unique alias identifier can be generated.
Signed-off-by: Alexey Gladkov <legion@kernel.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
---
include/linux/module.h | 14 ++++++++++++--
scripts/mod/file2alias.c | 18 ++++++++++++++----
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index 88048561360f..e7506684069d 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
/* What your module does. */
#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
+/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
+#define __mod_device_table(type, name) \
+ __PASTE(__mod_device_table__, \
+ __PASTE(__COUNTER__, \
+ __PASTE(__, \
+ __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) \
-extern typeof(name) __mod_device_table__##type##__##name \
+#define MODULE_DEVICE_TABLE(type, name) \
+extern typeof(name) __mod_device_table(type, name) \
__attribute__ ((unused, alias(__stringify(name))))
#else /* !MODULE */
#define MODULE_DEVICE_TABLE(type, name)
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 00586119a25b..dff1799a4c79 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1476,8 +1476,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
{
void *symval;
char *zeros = NULL;
- const char *type, *name;
- size_t typelen;
+ const char *type, *name, *modname;
+ size_t typelen, modnamelen;
static const char *prefix = "__mod_device_table__";
/* 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) != STT_OBJECT)
return;
- /* All our symbols are of form __mod_device_table__<type>__<name>. */
+ /* All our symbols are of form __mod_device_table__<counter>__kmod_<modname>__<type>__<name>. */
if (!strstarts(symname, prefix))
return;
- type = symname + strlen(prefix);
+
+ modname = strstr(symname, "__kmod_");
+ if (!modname)
+ return;
+ modname += strlen("__kmod_");
+
+ type = strstr(modname, "__");
+ if (!type)
+ return;
+ modnamelen = type - modname;
+ type += strlen("__");
name = strstr(type, "__");
if (!name)
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v3 4/6] modpost: Create modalias for builtin modules
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
` (2 preceding siblings ...)
2025-05-27 9:07 ` [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique Alexey Gladkov
@ 2025-05-27 9:07 ` Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 5/6] kbuild: Move modules.builtin.modinfo to another makefile Alexey Gladkov
` (2 subsequent siblings)
6 siblings, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:07 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov
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 <masahiroy@kernel.org>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
---
include/linux/module.h | 4 ----
scripts/mod/file2alias.c | 16 ++++++++++++++++
scripts/mod/modpost.c | 13 ++++++++++++-
scripts/mod/modpost.h | 2 ++
4 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index e7506684069d..0be9b0f1660e 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -259,14 +259,10 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
__PASTE(type, \
__PASTE(__, name)))))))
-#ifdef MODULE
/* Creates an alias so file2alias.c can find device table. */
#define MODULE_DEVICE_TABLE(type, name) \
extern typeof(name) __mod_device_table(type, name) \
__attribute__ ((unused, alias(__stringify(name))))
-#else /* !MODULE */
-#define MODULE_DEVICE_TABLE(type, name)
-#endif
/* Version of form [<epoch>:]<version>[-<extra-version>].
* Or for CVS/RCS ID version, everything but the number is stripped.
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index dff1799a4c79..d42f2c742fd6 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1527,5 +1527,21 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
}
}
+ 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 = xstrndup(modname, modnamelen);
+ }
+ }
+
free(zeros);
}
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index be89921d60b6..c7c601c6f82d 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2021,11 +2021,22 @@ static void write_if_changed(struct buffer *b, const char *fname)
static void write_vmlinux_export_c_file(struct module *mod)
{
struct buffer buf = { };
+ struct module_alias *alias, *next;
buf_printf(&buf,
- "#include <linux/export-internal.h>\n");
+ "#include <linux/export-internal.h>\n"
+ "#include <linux/module.h>\n");
add_exported_symbols(&buf, mod);
+
+ list_for_each_entry_safe(alias, next, &mod->aliases, node) {
+ buf_printf(&buf, "MODULE_ALIAS_MODNAME(\"%s\", \"%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[];
};
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v3 5/6] kbuild: Move modules.builtin.modinfo to another makefile
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
` (3 preceding siblings ...)
2025-05-27 9:07 ` [PATCH v3 4/6] modpost: Create modalias for builtin modules Alexey Gladkov
@ 2025-05-27 9:07 ` Alexey Gladkov
2025-05-27 9:08 ` [PATCH v3 6/6] kbuild: Create modules.builtin.modinfo for modpost results Alexey Gladkov
2025-05-27 13:15 ` [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE Alexey Gladkov
6 siblings, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:07 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov
The creation of modules.builtin.modinfo is going to depend on
.vmlinux.export.o so it is worth moving its creation closer to it.
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
scripts/Makefile.vmlinux | 24 ++++++++++++++++++++++++
scripts/Makefile.vmlinux_o | 26 +-------------------------
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index b64862dc6f08..250c0492b7e0 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -97,6 +97,30 @@ ifdef CONFIG_BUILDTIME_TABLE_SORT
$(vmlinux-final): scripts/sorttable
endif
+# modules.builtin.modinfo
+# ---------------------------------------------------------------------------
+
+OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
+
+targets += 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 = GEN $@
+ cmd_modules_builtin = \
+ tr '\0' '\n' < $< | \
+ sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
+ tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
+
+targets += 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
PHONY := __default
-__default: vmlinux.o modules.builtin.modinfo modules.builtin
+__default: vmlinux.o
include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
@@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
targets += vmlinux.o
-# modules.builtin.modinfo
-# ---------------------------------------------------------------------------
-
-OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
-
-targets += 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 = GEN $@
- cmd_modules_builtin = \
- tr '\0' '\n' < $< | \
- sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
- tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
-
-targets += 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 rebuilt.
# ---------------------------------------------------------------------------
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v3 6/6] kbuild: Create modules.builtin.modinfo for modpost results
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
` (4 preceding siblings ...)
2025-05-27 9:07 ` [PATCH v3 5/6] kbuild: Move modules.builtin.modinfo to another makefile Alexey Gladkov
@ 2025-05-27 9:08 ` Alexey Gladkov
2025-05-27 13:15 ` [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE Alexey Gladkov
6 siblings, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 9:08 UTC (permalink / raw)
To: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov
Create modules.builtin.modinfo as a combination of modinfo from vmlinux
and the result of generating modalias by modpost.
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
scripts/Makefile.vmlinux | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 250c0492b7e0..8fed895fd858 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -70,6 +70,18 @@ endif
ifdef CONFIG_MODULES
targets += .vmlinux.export.o
$(vmlinux-final): .vmlinux.export.o
+
+# .module.builtin.modinfo.modpost
+# ---------------------------------------------------------------------------
+__default: .modules.builtin.modinfo.modpost
+
+OBJCOPYFLAGS_.modules.builtin.modinfo.modpost := -j .modinfo -O binary
+
+targets += .modules.builtin.modinfo.modpost
+.modules.builtin.modinfo.modpost: .vmlinux.export.o FORCE
+ $(call if_changed,objcopy)
+
+modules.builtin.modinfo: .modules.builtin.modinfo.modpost
endif
ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX
@@ -97,14 +109,26 @@ ifdef CONFIG_BUILDTIME_TABLE_SORT
$(vmlinux-final): scripts/sorttable
endif
+# .module.builtin.modinfo.vmlinux
+# ---------------------------------------------------------------------------
+__default: .modules.builtin.modinfo.vmlinux
+
+OBJCOPYFLAGS_.modules.builtin.modinfo.vmlinux := -j .modinfo -O binary
+
+targets += .modules.builtin.modinfo.vmlinux
+.modules.builtin.modinfo.vmlinux: vmlinux.o FORCE
+ $(call if_changed,objcopy)
+
# modules.builtin.modinfo
# ---------------------------------------------------------------------------
-OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
+quiet_cmd_modules_builtin_modinfo = GEN $@
+ cmd_modules_builtin_modinfo = \
+ cat $< $(wildcard .modules.builtin.modinfo.modpost) > $@
targets += modules.builtin.modinfo
-modules.builtin.modinfo: vmlinux.o FORCE
- $(call if_changed,objcopy)
+modules.builtin.modinfo: .modules.builtin.modinfo.vmlinux FORCE
+ $(call if_changed,modules_builtin_modinfo)
# modules.builtin
# ---------------------------------------------------------------------------
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary
2025-05-27 9:07 ` [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary Alexey Gladkov
@ 2025-05-27 11:28 ` James Bottomley
2025-05-27 11:54 ` Alexey Gladkov
2025-05-27 14:06 ` [PATCH v4 1/6] scsi: Always define blogic_pci_tbl structure Alexey Gladkov
1 sibling, 1 reply; 31+ messages in thread
From: James Bottomley @ 2025-05-27 11:28 UTC (permalink / raw)
To: Alexey Gladkov, Petr Pavlu, Luis Chamberlain, Sami Tolvanen,
Daniel Gomez, Masahiro Yamada, Nathan Chancellor, Nicolas Schier
Cc: linux-kernel, linux-modules, linux-kbuild, Khalid Aziz,
Martin K. Petersen, linux-scsi
On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote:
> Define MODULE_DEVICE_TABLE only if a structure is defined for it.
>
> drivers/scsi/BusLogic.c:3735:26: error: use of undeclared identifier
> 'blogic_pci_tbl'
> 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
Well, a) need to cc the scsi list and b) how is this possible when
MODULE_DEVICE_TABLE() has an empty definition if MODULE isn't defined
(so the guard you move should be over an empty statement)?
Regards,
James
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary
2025-05-27 11:28 ` James Bottomley
@ 2025-05-27 11:54 ` Alexey Gladkov
2025-05-27 11:58 ` James Bottomley
0 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 11:54 UTC (permalink / raw)
To: James Bottomley
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier, linux-kernel,
linux-modules, linux-kbuild, Khalid Aziz, Martin K. Petersen,
linux-scsi
On Tue, May 27, 2025 at 07:28:59AM -0400, James Bottomley wrote:
> On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote:
> > Define MODULE_DEVICE_TABLE only if a structure is defined for it.
> >
> > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared identifier
> > 'blogic_pci_tbl'
> > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
>
> Well, a) need to cc the scsi list
Sorry. I miss it.
> and b) how is this possible when
> MODULE_DEVICE_TABLE() has an empty definition if MODULE isn't defined
> (so the guard you move should be over an empty statement)?
In the next patch:
[PATCH v3 4/6] modpost: Create modalias for builtin modules
I remove this condition for the MODULE_DEVICE_TABLE macro and it will be
always defined.
I put the drivers/scsi/BusLogic.c change before these changes to avoid
errors. Besides, even an empty macro uses a structure name that is not
defined (if MODULE isn't defined). This seems wrong in any case.
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary
2025-05-27 11:54 ` Alexey Gladkov
@ 2025-05-27 11:58 ` James Bottomley
2025-05-27 12:58 ` Alexey Gladkov
0 siblings, 1 reply; 31+ messages in thread
From: James Bottomley @ 2025-05-27 11:58 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier, linux-kernel,
linux-modules, linux-kbuild, Khalid Aziz, Martin K. Petersen,
linux-scsi
On Tue, 2025-05-27 at 13:54 +0200, Alexey Gladkov wrote:
> On Tue, May 27, 2025 at 07:28:59AM -0400, James Bottomley wrote:
> > On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote:
> > > Define MODULE_DEVICE_TABLE only if a structure is defined for it.
> > >
> > > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared
> > > identifier
> > > 'blogic_pci_tbl'
> > > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
> >
> > Well, a) need to cc the scsi list
>
> Sorry. I miss it.
>
> > and b) how is this possible when MODULE_DEVICE_TABLE() has an empty
> > definition if MODULE isn't defined (so the guard you move should be
> > over an empty statement)?
>
> In the next patch:
>
> [PATCH v3 4/6] modpost: Create modalias for builtin modules
>
> I remove this condition for the MODULE_DEVICE_TABLE macro and it will
> be always defined.
Well, why? If there's a reason for the table to always exist, wouldn't
the best fix then be to remove the module guards from the PCI table in
the buslogic ... they only really exist to prevent a defined but not
used error which it sounds like you're getting rid of?
Regards,
James
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary
2025-05-27 11:58 ` James Bottomley
@ 2025-05-27 12:58 ` Alexey Gladkov
0 siblings, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 12:58 UTC (permalink / raw)
To: James Bottomley
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier, linux-kernel,
linux-modules, linux-kbuild, Khalid Aziz, Martin K. Petersen,
linux-scsi
On Tue, May 27, 2025 at 07:58:27AM -0400, James Bottomley wrote:
> On Tue, 2025-05-27 at 13:54 +0200, Alexey Gladkov wrote:
> > On Tue, May 27, 2025 at 07:28:59AM -0400, James Bottomley wrote:
> > > On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote:
> > > > Define MODULE_DEVICE_TABLE only if a structure is defined for it.
> > > >
> > > > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared
> > > > identifier
> > > > 'blogic_pci_tbl'
> > > > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
> > >
> > > Well, a) need to cc the scsi list
> >
> > Sorry. I miss it.
> >
> > > and b) how is this possible when MODULE_DEVICE_TABLE() has an empty
> > > definition if MODULE isn't defined (so the guard you move should be
> > > over an empty statement)?
> >
> > In the next patch:
> >
> > [PATCH v3 4/6] modpost: Create modalias for builtin modules
> >
> > I remove this condition for the MODULE_DEVICE_TABLE macro and it will
> > be always defined.
>
> Well, why? If there's a reason for the table to always exist, wouldn't
> the best fix then be to remove the module guards from the PCI table in
> the buslogic ... they only really exist to prevent a defined but not
> used error which it sounds like you're getting rid of?
I wanted to keep the original logic and remove the build error. Before my
changes blogic_pci_tbl was only used when the module was built separately
(MODULE case).
But yes, you are right. In this case, it would be more appropriate to
remove the MODULE condition at all since MODULE_DEVICE_TABLE always
makes sense after my changes.
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
` (5 preceding siblings ...)
2025-05-27 9:08 ` [PATCH v3 6/6] kbuild: Create modules.builtin.modinfo for modpost results Alexey Gladkov
@ 2025-05-27 13:15 ` Alexey Gladkov
2025-05-27 13:22 ` James Bottomley
6 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 13:15 UTC (permalink / raw)
To: James Bottomley, Petr Pavlu, Luis Chamberlain, Sami Tolvanen,
Daniel Gomez, Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
Khalid Aziz, Martin K. Petersen
Cc: linux-kernel, linux-modules, linux-kbuild, linux-scsi,
Alexey Gladkov
Since MODULE_DEVICE_TABLE no longer depends on whether the module is
built separately or compiled into the kernel, it now makes sense to
always define DEVICE_TABLE. In this case, even if the module is in the
kernel, correct module.builtin.modaliases will be generated.
Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
drivers/scsi/BusLogic.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 8ce2ac9293a3..08e12a3d6703 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void)
__setup("BusLogic=", blogic_setup);
-#ifdef MODULE
/*static const struct pci_device_id blogic_pci_tbl[] = {
{ PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -3732,7 +3731,6 @@ static const struct pci_device_id blogic_pci_tbl[] = {
{0, },
};
MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
-#endif
module_init(blogic_init);
module_exit(blogic_exit);
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE
2025-05-27 13:15 ` [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE Alexey Gladkov
@ 2025-05-27 13:22 ` James Bottomley
2025-05-27 13:44 ` Alexey Gladkov
0 siblings, 1 reply; 31+ messages in thread
From: James Bottomley @ 2025-05-27 13:22 UTC (permalink / raw)
To: Alexey Gladkov, Petr Pavlu, Luis Chamberlain, Sami Tolvanen,
Daniel Gomez, Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
Khalid Aziz, Martin K. Petersen
Cc: linux-kernel, linux-modules, linux-kbuild, linux-scsi
On Tue, 2025-05-27 at 15:15 +0200, Alexey Gladkov wrote:
> Since MODULE_DEVICE_TABLE no longer depends on whether the module is
> built separately or compiled into the kernel, it now makes sense to
> always define DEVICE_TABLE. In this case, even if the module is in
> the
> kernel, correct module.builtin.modaliases will be generated.
>
> Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>
> ---
> drivers/scsi/BusLogic.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
> index 8ce2ac9293a3..08e12a3d6703 100644
> --- a/drivers/scsi/BusLogic.c
> +++ b/drivers/scsi/BusLogic.c
> @@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void)
>
> __setup("BusLogic=", blogic_setup);
>
> -#ifdef MODULE
> /*static const struct pci_device_id blogic_pci_tbl[] = {
> { PCI_VENDOR_ID_BUSLOGIC,
> PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
> PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
> @@ -3732,7 +3731,6 @@ static const struct pci_device_id
> blogic_pci_tbl[] = {
> {0, },
> };
> MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
> -#endif
You don't need to do this in two steps. The original problem of
defined but not used table stopped being a problem when the structure
was converted to static const over ten years ago (the compiler doesn't
warn about unused static consts).
Regards,
James
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE
2025-05-27 13:22 ` James Bottomley
@ 2025-05-27 13:44 ` Alexey Gladkov
0 siblings, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 13:44 UTC (permalink / raw)
To: James Bottomley
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier, Khalid Aziz,
Martin K. Petersen, linux-kernel, linux-modules, linux-kbuild,
linux-scsi
On Tue, May 27, 2025 at 09:22:09AM -0400, James Bottomley wrote:
> On Tue, 2025-05-27 at 15:15 +0200, Alexey Gladkov wrote:
> > Since MODULE_DEVICE_TABLE no longer depends on whether the module is
> > built separately or compiled into the kernel, it now makes sense to
> > always define DEVICE_TABLE. In this case, even if the module is in
> > the
> > kernel, correct module.builtin.modaliases will be generated.
> >
> > Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > ---
> > drivers/scsi/BusLogic.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
> > index 8ce2ac9293a3..08e12a3d6703 100644
> > --- a/drivers/scsi/BusLogic.c
> > +++ b/drivers/scsi/BusLogic.c
> > @@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void)
> >
> > __setup("BusLogic=", blogic_setup);
> >
> > -#ifdef MODULE
> > /*static const struct pci_device_id blogic_pci_tbl[] = {
> > { PCI_VENDOR_ID_BUSLOGIC,
> > PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
> > PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
> > @@ -3732,7 +3731,6 @@ static const struct pci_device_id
> > blogic_pci_tbl[] = {
> > {0, },
> > };
> > MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
> > -#endif
>
> You don't need to do this in two steps. The original problem of
> defined but not used table stopped being a problem when the structure
> was converted to static const over ten years ago (the compiler doesn't
> warn about unused static consts).
Ah. Ok, I will recreate this patch shortly.
Basically my original plan was to fix compilation errors as a first step,
and second step make MODULE_DEVICE_TABLE be used independently of MODULE.
Because there are a bunch of modules that also use MODULE_DEVICE_TABLE
only if MODULE is defined.
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v4 1/6] scsi: Always define blogic_pci_tbl structure
2025-05-27 9:07 ` [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary Alexey Gladkov
2025-05-27 11:28 ` James Bottomley
@ 2025-05-27 14:06 ` Alexey Gladkov
1 sibling, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-05-27 14:06 UTC (permalink / raw)
To: James Bottomley, Petr Pavlu, Luis Chamberlain, Sami Tolvanen,
Daniel Gomez, Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
Khalid Aziz, Martin K. Petersen
Cc: linux-kernel, linux-modules, linux-kbuild, linux-scsi,
Alexey Gladkov
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.
Cc: Khalid Aziz <khalid@gonehiking.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
drivers/scsi/BusLogic.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 1f100270cd38..08e12a3d6703 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void)
__setup("BusLogic=", blogic_setup);
-#ifdef MODULE
/*static const struct pci_device_id blogic_pci_tbl[] = {
{ PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -3731,7 +3730,6 @@ static const struct pci_device_id blogic_pci_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)},
{0, },
};
-#endif
MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
module_init(blogic_init);
--
2.49.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-05-27 9:07 ` [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique Alexey Gladkov
@ 2025-06-02 7:45 ` Masahiro Yamada
2025-06-02 8:06 ` Alexey Gladkov
2025-06-02 7:52 ` Masahiro Yamada
1 sibling, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-02 7:45 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> In order to avoid symbol conflicts if they appear in the same binary, a
> more unique alias identifier can be generated.
Why must this be unique?
What problem would happen if the same symbol names
appear in MODULE_DEVICE_TABLE()?
>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> ---
> include/linux/module.h | 14 ++++++++++++--
> scripts/mod/file2alias.c | 18 ++++++++++++++----
> 2 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 88048561360f..e7506684069d 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> /* What your module does. */
> #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
>
> +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
> +#define __mod_device_table(type, name) \
> + __PASTE(__mod_device_table__, \
> + __PASTE(__COUNTER__, \
> + __PASTE(__, \
> + __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) \
> -extern typeof(name) __mod_device_table__##type##__##name \
> +#define MODULE_DEVICE_TABLE(type, name) \
> +extern typeof(name) __mod_device_table(type, name) \
> __attribute__ ((unused, alias(__stringify(name))))
> #else /* !MODULE */
> #define MODULE_DEVICE_TABLE(type, name)
> diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> index 00586119a25b..dff1799a4c79 100644
> --- a/scripts/mod/file2alias.c
> +++ b/scripts/mod/file2alias.c
> @@ -1476,8 +1476,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
> {
> void *symval;
> char *zeros = NULL;
> - const char *type, *name;
> - size_t typelen;
> + const char *type, *name, *modname;
> + size_t typelen, modnamelen;
> static const char *prefix = "__mod_device_table__";
>
> /* 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) != STT_OBJECT)
> return;
>
> - /* All our symbols are of form __mod_device_table__<type>__<name>. */
> + /* All our symbols are of form __mod_device_table__<counter>__kmod_<modname>__<type>__<name>. */
> if (!strstarts(symname, prefix))
> return;
> - type = symname + strlen(prefix);
> +
> + modname = strstr(symname, "__kmod_");
> + if (!modname)
> + return;
> + modname += strlen("__kmod_");
> +
> + type = strstr(modname, "__");
> + if (!type)
> + return;
> + modnamelen = type - modname;
> + type += strlen("__");
>
> name = strstr(type, "__");
> if (!name)
> --
> 2.49.0
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 2/6] modules: Add macros to specify modinfo prefix
2025-05-27 9:07 ` [PATCH v3 2/6] modules: Add macros to specify modinfo prefix Alexey Gladkov
@ 2025-06-02 7:49 ` Masahiro Yamada
2025-06-09 9:37 ` Alexey Gladkov
0 siblings, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-02 7:49 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> The __MODULE_INFO macros always use __MODULE_INFO_PREFIX. The only way
> to use a different prefix is to override __MODULE_INFO_PREFIX, which is
> not very useful.
Not necessarily.
This would be a very special case only used in modpost,
and modpost can use MODULE_INFO() instead.
list_for_each_entry_safe(alias, next, &mod->aliases, node) {
- buf_printf(&buf, "MODULE_ALIAS_MODNAME(\"%s\", \"%s\");\n",
+ buf_printf(&buf, "MODULE_INFO(\"%s\".alias, \"%s\");\n",
alias->builtin_modname, alias->str);
list_del(&alias->node);
free(alias->builtin_modname);
> The new macro will be used in file2alias.c to generate modalias for
> builtin modules.
>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> ---
> include/linux/module.h | 3 +++
> include/linux/moduleparam.h | 7 +++++--
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 8050f77c3b64..88048561360f 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -170,6 +170,9 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> /* For userspace: you can also call me... */
> #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
>
> +#define MODULE_ALIAS_MODNAME(_modname, _alias) \
> + __MODULE_INFO_WITH_PREFIX(_modname ".", alias, alias, _alias)
> +
> /* Soft module dependencies. See man modprobe.d for details.
> * Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
> */
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index bfb85fd13e1f..3f819fc67c43 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -20,10 +20,13 @@
> /* Chosen so that structs with an unsigned long line up. */
> #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
>
> -#define __MODULE_INFO(tag, name, info) \
> +#define __MODULE_INFO_WITH_PREFIX(prefix, tag, name, info) \
> static const char __UNIQUE_ID(name)[] \
> __used __section(".modinfo") __aligned(1) \
> - = __MODULE_INFO_PREFIX __stringify(tag) "=" info
> + = prefix __stringify(tag) "=" info
> +
> +#define __MODULE_INFO(tag, name, info) \
> + __MODULE_INFO_WITH_PREFIX(__MODULE_INFO_PREFIX, tag, name, info)
>
> #define __MODULE_PARM_TYPE(name, _type) \
> __MODULE_INFO(parmtype, name##type, #name ":" _type)
> --
> 2.49.0
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-05-27 9:07 ` [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique Alexey Gladkov
2025-06-02 7:45 ` Masahiro Yamada
@ 2025-06-02 7:52 ` Masahiro Yamada
2025-06-02 8:24 ` Alexey Gladkov
1 sibling, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-02 7:52 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> In order to avoid symbol conflicts if they appear in the same binary, a
> more unique alias identifier can be generated.
>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> ---
> include/linux/module.h | 14 ++++++++++++--
> scripts/mod/file2alias.c | 18 ++++++++++++++----
> 2 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 88048561360f..e7506684069d 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> /* What your module does. */
> #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
>
> +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
This format relies on module-name mangling, but
I hope we will be able to stop doing it some day.
Can we come up with a different idea
in case <modname> contains hyphens?
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 7:45 ` Masahiro Yamada
@ 2025-06-02 8:06 ` Alexey Gladkov
2025-06-02 10:58 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-02 8:06 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 02, 2025 at 04:45:36PM +0900, Masahiro Yamada wrote:
> On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > In order to avoid symbol conflicts if they appear in the same binary, a
> > more unique alias identifier can be generated.
>
> Why must this be unique?
>
> What problem would happen if the same symbol names
> appear in MODULE_DEVICE_TABLE()?
Before these patches this was not a problem as non-unique characters are
in separate object files when the module is compiled separately.
But when the modules are compiled into the kernel, there is a symbol
conflict when linking vmlinuz. We have modules that export multiple device
tables from different object files.
>
> >
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> > ---
> > include/linux/module.h | 14 ++++++++++++--
> > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > 2 files changed, 26 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 88048561360f..e7506684069d 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > /* What your module does. */
> > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> >
> > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
> > +#define __mod_device_table(type, name) \
> > + __PASTE(__mod_device_table__, \
> > + __PASTE(__COUNTER__, \
> > + __PASTE(__, \
> > + __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) \
> > -extern typeof(name) __mod_device_table__##type##__##name \
> > +#define MODULE_DEVICE_TABLE(type, name) \
> > +extern typeof(name) __mod_device_table(type, name) \
> > __attribute__ ((unused, alias(__stringify(name))))
> > #else /* !MODULE */
> > #define MODULE_DEVICE_TABLE(type, name)
> > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> > index 00586119a25b..dff1799a4c79 100644
> > --- a/scripts/mod/file2alias.c
> > +++ b/scripts/mod/file2alias.c
> > @@ -1476,8 +1476,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
> > {
> > void *symval;
> > char *zeros = NULL;
> > - const char *type, *name;
> > - size_t typelen;
> > + const char *type, *name, *modname;
> > + size_t typelen, modnamelen;
> > static const char *prefix = "__mod_device_table__";
> >
> > /* 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) != STT_OBJECT)
> > return;
> >
> > - /* All our symbols are of form __mod_device_table__<type>__<name>. */
> > + /* All our symbols are of form __mod_device_table__<counter>__kmod_<modname>__<type>__<name>. */
> > if (!strstarts(symname, prefix))
> > return;
> > - type = symname + strlen(prefix);
> > +
> > + modname = strstr(symname, "__kmod_");
> > + if (!modname)
> > + return;
> > + modname += strlen("__kmod_");
> > +
> > + type = strstr(modname, "__");
> > + if (!type)
> > + return;
> > + modnamelen = type - modname;
> > + type += strlen("__");
> >
> > name = strstr(type, "__");
> > if (!name)
> > --
> > 2.49.0
> >
>
>
> --
> Best Regards
> Masahiro Yamada
>
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 7:52 ` Masahiro Yamada
@ 2025-06-02 8:24 ` Alexey Gladkov
2025-06-02 18:00 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-02 8:24 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 02, 2025 at 04:52:36PM +0900, Masahiro Yamada wrote:
> On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > In order to avoid symbol conflicts if they appear in the same binary, a
> > more unique alias identifier can be generated.
> >
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> > ---
> > include/linux/module.h | 14 ++++++++++++--
> > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > 2 files changed, 26 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 88048561360f..e7506684069d 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > /* What your module does. */
> > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> >
> > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
>
> This format relies on module-name mangling, but
> I hope we will be able to stop doing it some day.
I didn't like this approach either when I found out how it was
implemented.
We can only add the module name to the structure to which the alias is
made. But the problem with this is that right now there is no common
structure for DEVICE_TABLE. Each module comes up with its own.
It is possible to add a common structure, but that would be a big
refactoring.
> Can we come up with a different idea
> in case <modname> contains hyphens?
The hyphen is not a problem for my implementation. In the __KBUILD_MODNAME
macro, hyphens are replaced by underscores.
scripts/Makefile.lib:
name-fix-token = $(subst $(comma),_,$(subst -,_,$1))
name-fix = $(call stringify,$(call name-fix-token,$1))
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \
-D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname))
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 8:06 ` Alexey Gladkov
@ 2025-06-02 10:58 ` Masahiro Yamada
2025-06-02 14:03 ` Alexey Gladkov
0 siblings, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-02 10:58 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 2, 2025 at 5:07 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> On Mon, Jun 02, 2025 at 04:45:36PM +0900, Masahiro Yamada wrote:
> > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > >
> > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > more unique alias identifier can be generated.
> >
> > Why must this be unique?
> >
> > What problem would happen if the same symbol names
> > appear in MODULE_DEVICE_TABLE()?
>
> Before these patches this was not a problem as non-unique characters are
> in separate object files when the module is compiled separately.
>
> But when the modules are compiled into the kernel, there is a symbol
> conflict when linking vmlinuz. We have modules that export multiple device
> tables from different object files.
This is because the __mod_device_table__* symbols are global, but
I suspect they do not need to be.
Let's test this
https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 10:58 ` Masahiro Yamada
@ 2025-06-02 14:03 ` Alexey Gladkov
2025-06-02 16:18 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-02 14:03 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 02, 2025 at 07:58:41PM +0900, Masahiro Yamada wrote:
> On Mon, Jun 2, 2025 at 5:07 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > On Mon, Jun 02, 2025 at 04:45:36PM +0900, Masahiro Yamada wrote:
> > > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > > >
> > > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > > more unique alias identifier can be generated.
> > >
> > > Why must this be unique?
> > >
> > > What problem would happen if the same symbol names
> > > appear in MODULE_DEVICE_TABLE()?
> >
> > Before these patches this was not a problem as non-unique characters are
> > in separate object files when the module is compiled separately.
> >
> > But when the modules are compiled into the kernel, there is a symbol
> > conflict when linking vmlinuz. We have modules that export multiple device
> > tables from different object files.
>
> This is because the __mod_device_table__* symbols are global, but
> I suspect they do not need to be.
>
> Let's test this
> https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
I tested this patch with the config:
make allmodconfig
make mod2yesconfig
and it works.
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 14:03 ` Alexey Gladkov
@ 2025-06-02 16:18 ` Masahiro Yamada
2025-06-02 17:09 ` Alexey Gladkov
2025-06-04 11:26 ` Alexey Gladkov
0 siblings, 2 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-02 16:18 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 2, 2025 at 11:04 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> On Mon, Jun 02, 2025 at 07:58:41PM +0900, Masahiro Yamada wrote:
> > On Mon, Jun 2, 2025 at 5:07 PM Alexey Gladkov <legion@kernel.org> wrote:
> > >
> > > On Mon, Jun 02, 2025 at 04:45:36PM +0900, Masahiro Yamada wrote:
> > > > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > > > >
> > > > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > > > more unique alias identifier can be generated.
> > > >
> > > > Why must this be unique?
> > > >
> > > > What problem would happen if the same symbol names
> > > > appear in MODULE_DEVICE_TABLE()?
> > >
> > > Before these patches this was not a problem as non-unique characters are
> > > in separate object files when the module is compiled separately.
> > >
> > > But when the modules are compiled into the kernel, there is a symbol
> > > conflict when linking vmlinuz. We have modules that export multiple device
> > > tables from different object files.
> >
> > This is because the __mod_device_table__* symbols are global, but
> > I suspect they do not need to be.
> >
> > Let's test this
> > https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
>
> I tested this patch with the config:
>
> make allmodconfig
> make mod2yesconfig
>
> and it works.
Good.
Then, __COUNTER__ is unnecessary.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 16:18 ` Masahiro Yamada
@ 2025-06-02 17:09 ` Alexey Gladkov
2025-06-04 11:26 ` Alexey Gladkov
1 sibling, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-02 17:09 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, Jun 03, 2025 at 01:18:25AM +0900, Masahiro Yamada wrote:
> On Mon, Jun 2, 2025 at 11:04 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > On Mon, Jun 02, 2025 at 07:58:41PM +0900, Masahiro Yamada wrote:
> > > On Mon, Jun 2, 2025 at 5:07 PM Alexey Gladkov <legion@kernel.org> wrote:
> > > >
> > > > On Mon, Jun 02, 2025 at 04:45:36PM +0900, Masahiro Yamada wrote:
> > > > > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > > > > >
> > > > > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > > > > more unique alias identifier can be generated.
> > > > >
> > > > > Why must this be unique?
> > > > >
> > > > > What problem would happen if the same symbol names
> > > > > appear in MODULE_DEVICE_TABLE()?
> > > >
> > > > Before these patches this was not a problem as non-unique characters are
> > > > in separate object files when the module is compiled separately.
> > > >
> > > > But when the modules are compiled into the kernel, there is a symbol
> > > > conflict when linking vmlinuz. We have modules that export multiple device
> > > > tables from different object files.
> > >
> > > This is because the __mod_device_table__* symbols are global, but
> > > I suspect they do not need to be.
> > >
> > > Let's test this
> > > https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
> >
> > I tested this patch with the config:
> >
> > make allmodconfig
> > make mod2yesconfig
> >
> > and it works.
>
> Good.
> Then, __COUNTER__ is unnecessary.
I will send a new version asap. Thanks!
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 8:24 ` Alexey Gladkov
@ 2025-06-02 18:00 ` Masahiro Yamada
2025-06-02 18:44 ` Alexey Gladkov
0 siblings, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-02 18:00 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 2, 2025 at 5:24 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> On Mon, Jun 02, 2025 at 04:52:36PM +0900, Masahiro Yamada wrote:
> > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > >
> > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > more unique alias identifier can be generated.
> > >
> > > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > > Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> > > ---
> > > include/linux/module.h | 14 ++++++++++++--
> > > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > > 2 files changed, 26 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/include/linux/module.h b/include/linux/module.h
> > > index 88048561360f..e7506684069d 100644
> > > --- a/include/linux/module.h
> > > +++ b/include/linux/module.h
> > > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > > /* What your module does. */
> > > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> > >
> > > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
> >
> > This format relies on module-name mangling, but
> > I hope we will be able to stop doing it some day.
>
> I didn't like this approach either when I found out how it was
> implemented.
Yeah, I dislike it.
I hope we can stop this historical mistake:
https://lore.kernel.org/lkml/20250602130609.402581-1-masahiroy@kernel.org/
Once we stop doing that, __KBUILD_MODNAME will not match to KBUILD_MODNAME.
Also, you need to be careful about the rust side, as
you did not take care of it.
https://github.com/torvalds/linux/blob/v6.15/rust/kernel/device_id.rs#L157
>
> We can only add the module name to the structure to which the alias is
> made. But the problem with this is that right now there is no common
> structure for DEVICE_TABLE. Each module comes up with its own.
>
> It is possible to add a common structure, but that would be a big
> refactoring.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 18:00 ` Masahiro Yamada
@ 2025-06-02 18:44 ` Alexey Gladkov
2025-06-06 5:12 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-02 18:44 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, Jun 03, 2025 at 03:00:07AM +0900, Masahiro Yamada wrote:
> On Mon, Jun 2, 2025 at 5:24 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > On Mon, Jun 02, 2025 at 04:52:36PM +0900, Masahiro Yamada wrote:
> > > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > > >
> > > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > > more unique alias identifier can be generated.
> > > >
> > > > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > > > Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> > > > ---
> > > > include/linux/module.h | 14 ++++++++++++--
> > > > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > > > 2 files changed, 26 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/include/linux/module.h b/include/linux/module.h
> > > > index 88048561360f..e7506684069d 100644
> > > > --- a/include/linux/module.h
> > > > +++ b/include/linux/module.h
> > > > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > > > /* What your module does. */
> > > > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> > > >
> > > > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
> > >
> > > This format relies on module-name mangling, but
> > > I hope we will be able to stop doing it some day.
> >
> > I didn't like this approach either when I found out how it was
> > implemented.
>
> Yeah, I dislike it.
>
> I hope we can stop this historical mistake:
> https://lore.kernel.org/lkml/20250602130609.402581-1-masahiroy@kernel.org/
>
> Once we stop doing that, __KBUILD_MODNAME will not match to KBUILD_MODNAME.
Do I understand you correctly that I cannot use __KBUILD_MODNAME now ?
> Also, you need to be careful about the rust side, as
> you did not take care of it.
>
> https://github.com/torvalds/linux/blob/v6.15/rust/kernel/device_id.rs#L157
Oh. This will make it much more complicated because I don't know rust
well. :(
I found a few more issues with modules when they compile as part of the
kernel, but was hoping to fix them after these patches.
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 16:18 ` Masahiro Yamada
2025-06-02 17:09 ` Alexey Gladkov
@ 2025-06-04 11:26 ` Alexey Gladkov
2025-06-06 5:10 ` Masahiro Yamada
1 sibling, 1 reply; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-04 11:26 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, Jun 03, 2025 at 01:18:25AM +0900, Masahiro Yamada wrote:
> > > > Before these patches this was not a problem as non-unique characters are
> > > > in separate object files when the module is compiled separately.
> > > >
> > > > But when the modules are compiled into the kernel, there is a symbol
> > > > conflict when linking vmlinuz. We have modules that export multiple device
> > > > tables from different object files.
> > >
> > > This is because the __mod_device_table__* symbols are global, but
> > > I suspect they do not need to be.
> > >
> > > Let's test this
> > > https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
> >
> > I tested this patch with the config:
> >
> > make allmodconfig
> > make mod2yesconfig
> >
> > and it works.
>
> Good.
> Then, __COUNTER__ is unnecessary.
I didn't immediately notice. The patch you suggested works, but these
symbols remain in System.map and it seems in vmlinuz.
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-04 11:26 ` Alexey Gladkov
@ 2025-06-06 5:10 ` Masahiro Yamada
2025-06-06 11:20 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-06 5:10 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Wed, Jun 4, 2025 at 8:26 PM Alexey Gladkov <legion@kernel.org> wrote:
>
> On Tue, Jun 03, 2025 at 01:18:25AM +0900, Masahiro Yamada wrote:
> > > > > Before these patches this was not a problem as non-unique characters are
> > > > > in separate object files when the module is compiled separately.
> > > > >
> > > > > But when the modules are compiled into the kernel, there is a symbol
> > > > > conflict when linking vmlinuz. We have modules that export multiple device
> > > > > tables from different object files.
> > > >
> > > > This is because the __mod_device_table__* symbols are global, but
> > > > I suspect they do not need to be.
> > > >
> > > > Let's test this
> > > > https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
> > >
> > > I tested this patch with the config:
> > >
> > > make allmodconfig
> > > make mod2yesconfig
> > >
> > > and it works.
> >
> > Good.
> > Then, __COUNTER__ is unnecessary.
>
> I didn't immediately notice. The patch you suggested works, but these
> symbols remain in System.map and it seems in vmlinuz.
>
Ah, yes, if your patch set is applied.
Currently, MODULE_DEVICE_TABLE() is no-op in vmlinux.
This makes me realize that your v3 4/6
increased the vmlinux image, as MODULE_DEVICE_TABLE()
is kept for modpost.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-02 18:44 ` Alexey Gladkov
@ 2025-06-06 5:12 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-06 5:12 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Tue, Jun 3, 2025 at 3:44 AM Alexey Gladkov <legion@kernel.org> wrote:
>
> On Tue, Jun 03, 2025 at 03:00:07AM +0900, Masahiro Yamada wrote:
> > On Mon, Jun 2, 2025 at 5:24 PM Alexey Gladkov <legion@kernel.org> wrote:
> > >
> > > On Mon, Jun 02, 2025 at 04:52:36PM +0900, Masahiro Yamada wrote:
> > > > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> > > > >
> > > > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > > > more unique alias identifier can be generated.
> > > > >
> > > > > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > > > > Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> > > > > ---
> > > > > include/linux/module.h | 14 ++++++++++++--
> > > > > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > > > > 2 files changed, 26 insertions(+), 6 deletions(-)
> > > > >
> > > > > diff --git a/include/linux/module.h b/include/linux/module.h
> > > > > index 88048561360f..e7506684069d 100644
> > > > > --- a/include/linux/module.h
> > > > > +++ b/include/linux/module.h
> > > > > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > > > > /* What your module does. */
> > > > > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> > > > >
> > > > > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
> > > >
> > > > This format relies on module-name mangling, but
> > > > I hope we will be able to stop doing it some day.
> > >
> > > I didn't like this approach either when I found out how it was
> > > implemented.
> >
> > Yeah, I dislike it.
> >
> > I hope we can stop this historical mistake:
> > https://lore.kernel.org/lkml/20250602130609.402581-1-masahiroy@kernel.org/
> >
> > Once we stop doing that, __KBUILD_MODNAME will not match to KBUILD_MODNAME.
>
> Do I understand you correctly that I cannot use __KBUILD_MODNAME now ?
Honestly, I dislike __KBUILD_MODNAME, but I know it is more challenging.
So, at least you need to fix the rust issue.
> > Also, you need to be careful about the rust side, as
> > you did not take care of it.
> >
> > https://github.com/torvalds/linux/blob/v6.15/rust/kernel/device_id.rs#L157
>
> Oh. This will make it much more complicated because I don't know rust
> well. :(
>
> I found a few more issues with modules when they compile as part of the
> kernel, but was hoping to fix them after these patches.
>
> --
> Rgrds, legion
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
2025-06-06 5:10 ` Masahiro Yamada
@ 2025-06-06 11:20 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-06-06 11:20 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Fri, Jun 6, 2025 at 2:10 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Wed, Jun 4, 2025 at 8:26 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > On Tue, Jun 03, 2025 at 01:18:25AM +0900, Masahiro Yamada wrote:
> > > > > > Before these patches this was not a problem as non-unique characters are
> > > > > > in separate object files when the module is compiled separately.
> > > > > >
> > > > > > But when the modules are compiled into the kernel, there is a symbol
> > > > > > conflict when linking vmlinuz. We have modules that export multiple device
> > > > > > tables from different object files.
> > > > >
> > > > > This is because the __mod_device_table__* symbols are global, but
> > > > > I suspect they do not need to be.
> > > > >
> > > > > Let's test this
> > > > > https://lore.kernel.org/lkml/20250602105539.392362-1-masahiroy@kernel.org/T/#u
> > > >
> > > > I tested this patch with the config:
> > > >
> > > > make allmodconfig
> > > > make mod2yesconfig
> > > >
> > > > and it works.
> > >
> > > Good.
> > > Then, __COUNTER__ is unnecessary.
> >
> > I didn't immediately notice. The patch you suggested works, but these
> > symbols remain in System.map and it seems in vmlinuz.
> >
>
> Ah, yes, if your patch set is applied.
>
> Currently, MODULE_DEVICE_TABLE() is no-op in vmlinux.
>
> This makes me realize that your v3 4/6
> increased the vmlinux image, as MODULE_DEVICE_TABLE()
> is kept for modpost.
With your patch set, __mod_device_table_* will be
included in vmlinux.
My patch changes them from global to local ('D' is changed to 'd'),
but there is no difference in the fact that v3 4/6 will grow
the symbol table in vmlinux.
(1) Your patch set
$ arm-linux-gnueabihf-nm vmlinux | grep __mod_device | head -n 10
c0527678 D __mod_device_table__164__kmod_clk_scmi__scmi__scmi_id_table
c053f458 D __mod_device_table__164__kmod_reset_scmi__scmi__scmi_id_table
c05421bc D __mod_device_table__164__kmod_reset_uniphier_glue__of__uniphier_glue_reset_match
c05334ac D __mod_device_table__164__kmod_scmi_pm_domain__scmi__scmi_id_table
c054cbd0 D __mod_device_table__164__kmod_twl4030_power__of__twl4030_power_of_match
c0548e8c D __mod_device_table__165__kmod_omap3_rom_rng__of__omap_rom_rng_match
c05124a0 D __mod_device_table__165__kmod_simple_pm_bus__of__simple_pm_bus_of_match
c05559ac D __mod_device_table__165__kmod_timer_ti_dm__of__omap_timer_match
c0528a68 D __mod_device_table__166__kmod_adpll__of__ti_adpll_match
c0520a68 D __mod_device_table__166__kmod_gpio_en7523__of__airoha_gpio_of_match
(2) Your patch set + my one (extern -> static)
$ arm-linux-gnueabihf-nm vmlinux | grep __mod_device | head -n 10
c0527678 d __mod_device_table__164__kmod_clk_scmi__scmi__scmi_id_table
c053f458 d __mod_device_table__164__kmod_reset_scmi__scmi__scmi_id_table
c05421bc d __mod_device_table__164__kmod_reset_uniphier_glue__of__uniphier_glue_reset_match
c05334ac d __mod_device_table__164__kmod_scmi_pm_domain__scmi__scmi_id_table
c054cbd0 d __mod_device_table__164__kmod_twl4030_power__of__twl4030_power_of_match
c0548e8c d __mod_device_table__165__kmod_omap3_rom_rng__of__omap_rom_rng_match
c05124a0 d __mod_device_table__165__kmod_simple_pm_bus__of__simple_pm_bus_of_match
c05559ac d __mod_device_table__165__kmod_timer_ti_dm__of__omap_timer_match
c0528a68 d __mod_device_table__166__kmod_adpll__of__ti_adpll_match
c0520a68 d __mod_device_table__166__kmod_gpio_en7523__of__airoha_gpio_of_match
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 2/6] modules: Add macros to specify modinfo prefix
2025-06-02 7:49 ` Masahiro Yamada
@ 2025-06-09 9:37 ` Alexey Gladkov
0 siblings, 0 replies; 31+ messages in thread
From: Alexey Gladkov @ 2025-06-09 9:37 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Petr Pavlu, Luis Chamberlain, Sami Tolvanen, Daniel Gomez,
Nathan Chancellor, Nicolas Schier, linux-kernel, linux-modules,
linux-kbuild
On Mon, Jun 02, 2025 at 04:49:24PM +0900, Masahiro Yamada wrote:
> On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > The __MODULE_INFO macros always use __MODULE_INFO_PREFIX. The only way
> > to use a different prefix is to override __MODULE_INFO_PREFIX, which is
> > not very useful.
>
> Not necessarily.
> This would be a very special case only used in modpost,
> and modpost can use MODULE_INFO() instead.
>
>
> list_for_each_entry_safe(alias, next, &mod->aliases, node) {
> - buf_printf(&buf, "MODULE_ALIAS_MODNAME(\"%s\", \"%s\");\n",
> + buf_printf(&buf, "MODULE_INFO(\"%s\".alias, \"%s\");\n",
> alias->builtin_modname, alias->str);
> list_del(&alias->node);
> free(alias->builtin_modname);
You can't do that because a character can't contain quotation marks
and periods.
.vmlinux.export.c:16163:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
16163 | MODULE_INFO(ahci.alias, "pci:v*d*sv*sd*bc01sc06i01*");
| ^
././include/linux/compiler_types.h:83:23: note: in definition of macro ‘___PASTE’
83 | #define ___PASTE(a,b) a##b
| ^
The same thing for variant with quotes:
.vmlinux.export.c:16163:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before string constant
16163 | MODULE_INFO("ahci".alias, "pci:v*d*sv*sd*bc01sc06i01*");
| ^~~~~~
But I can do something like this to make it work:
buf_printf(&buf,
"#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, unused, \"%s\");\n",
alias->builtin_modname, alias->str);
>
> > The new macro will be used in file2alias.c to generate modalias for
> > builtin modules.
> >
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> > ---
> > include/linux/module.h | 3 +++
> > include/linux/moduleparam.h | 7 +++++--
> > 2 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 8050f77c3b64..88048561360f 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -170,6 +170,9 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > /* For userspace: you can also call me... */
> > #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
> >
> > +#define MODULE_ALIAS_MODNAME(_modname, _alias) \
> > + __MODULE_INFO_WITH_PREFIX(_modname ".", alias, alias, _alias)
> > +
> > /* Soft module dependencies. See man modprobe.d for details.
> > * Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
> > */
> > diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> > index bfb85fd13e1f..3f819fc67c43 100644
> > --- a/include/linux/moduleparam.h
> > +++ b/include/linux/moduleparam.h
> > @@ -20,10 +20,13 @@
> > /* Chosen so that structs with an unsigned long line up. */
> > #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
> >
> > -#define __MODULE_INFO(tag, name, info) \
> > +#define __MODULE_INFO_WITH_PREFIX(prefix, tag, name, info) \
> > static const char __UNIQUE_ID(name)[] \
> > __used __section(".modinfo") __aligned(1) \
> > - = __MODULE_INFO_PREFIX __stringify(tag) "=" info
> > + = prefix __stringify(tag) "=" info
> > +
> > +#define __MODULE_INFO(tag, name, info) \
> > + __MODULE_INFO_WITH_PREFIX(__MODULE_INFO_PREFIX, tag, name, info)
> >
> > #define __MODULE_PARM_TYPE(name, _type) \
> > __MODULE_INFO(parmtype, name##type, #name ":" _type)
> > --
> > 2.49.0
> >
>
>
> --
> Best Regards
> Masahiro Yamada
>
--
Rgrds, legion
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2025-06-09 9:37 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 9:07 [PATCH v3 0/6] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 1/6] scsi: Define MODULE_DEVICE_TABLE only if necessary Alexey Gladkov
2025-05-27 11:28 ` James Bottomley
2025-05-27 11:54 ` Alexey Gladkov
2025-05-27 11:58 ` James Bottomley
2025-05-27 12:58 ` Alexey Gladkov
2025-05-27 14:06 ` [PATCH v4 1/6] scsi: Always define blogic_pci_tbl structure Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 2/6] modules: Add macros to specify modinfo prefix Alexey Gladkov
2025-06-02 7:49 ` Masahiro Yamada
2025-06-09 9:37 ` Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique Alexey Gladkov
2025-06-02 7:45 ` Masahiro Yamada
2025-06-02 8:06 ` Alexey Gladkov
2025-06-02 10:58 ` Masahiro Yamada
2025-06-02 14:03 ` Alexey Gladkov
2025-06-02 16:18 ` Masahiro Yamada
2025-06-02 17:09 ` Alexey Gladkov
2025-06-04 11:26 ` Alexey Gladkov
2025-06-06 5:10 ` Masahiro Yamada
2025-06-06 11:20 ` Masahiro Yamada
2025-06-02 7:52 ` Masahiro Yamada
2025-06-02 8:24 ` Alexey Gladkov
2025-06-02 18:00 ` Masahiro Yamada
2025-06-02 18:44 ` Alexey Gladkov
2025-06-06 5:12 ` Masahiro Yamada
2025-05-27 9:07 ` [PATCH v3 4/6] modpost: Create modalias for builtin modules Alexey Gladkov
2025-05-27 9:07 ` [PATCH v3 5/6] kbuild: Move modules.builtin.modinfo to another makefile Alexey Gladkov
2025-05-27 9:08 ` [PATCH v3 6/6] kbuild: Create modules.builtin.modinfo for modpost results Alexey Gladkov
2025-05-27 13:15 ` [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE Alexey Gladkov
2025-05-27 13:22 ` James Bottomley
2025-05-27 13:44 ` Alexey Gladkov
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).