History

modpost: Allow extended modversions without basic MODVERSIONS

If you know that your kernel modules will only ever be loaded by a newer kernel, you can disable BASIC_MODVERSIONS to save space. This also allows easy creation of test modules to see how tooling will respond to modules that only have the new format.

Matthew Maurer committed 1 year ago

Commit e8639b71 parent fc7d5e33 files · +23 −2Browse files

Unified · Split

3 files
  1. kernel/module/Kconfig +15 −0
  2. scripts/Makefile.modpost +1 −0
  3. scripts/mod/modpost.c +7 −2
kernel/module/Kconfig+15−0
@@ -217,6 +217,21 @@ config EXTENDED_MODVERSIONS · 216 unmodified lines
217 The most likely reason you would enable this is to enable Rust217 The most likely reason you would enable this is to enable Rust
218 support. If unsure, say N.218 support. If unsure, say N.
219 219
220config BASIC_MODVERSIONS
221 bool "Basic Module Versioning Support"
222 depends on MODVERSIONS
223 default y
224 help
225 This enables basic MODVERSIONS support, allowing older tools or
226 kernels to potentially load modules.
227
228 Disabling this may cause older `modprobe` or `kmod` to be unable
229 to read MODVERSIONS information from built modules. With this
230 disabled, older kernels may treat this module as unversioned.
231
232 This is enabled by default when MODVERSIONS are enabled.
233 If unsure, say Y.
234
220config MODULE_SRCVERSION_ALL235config MODULE_SRCVERSION_ALL
221 bool "Source checksum for all modules"236 bool "Source checksum for all modules"
222 help237 help
scripts/Makefile.modpost+1−0
@@ -43,6 +43,7 @@ MODPOST = $(objtree)/scripts/mod/modpost · 42 unmodified lines
43modpost-args = \43modpost-args = \
44 $(if $(CONFIG_MODULES),-M) \44 $(if $(CONFIG_MODULES),-M) \
45 $(if $(CONFIG_MODVERSIONS),-m) \45 $(if $(CONFIG_MODVERSIONS),-m) \
46 $(if $(CONFIG_BASIC_MODVERSIONS),-b) \
46 $(if $(CONFIG_EXTENDED_MODVERSIONS),-x) \47 $(if $(CONFIG_EXTENDED_MODVERSIONS),-x) \
47 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \48 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
48 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \49 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
scripts/mod/modpost.c+7−2
@@ -33,6 +33,8 @@ static bool module_enabled; · 32 unmodified lines
33static bool modversions;33static bool modversions;
34/* Is CONFIG_MODULE_SRCVERSION_ALL set? */34/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
35static bool all_versions;35static bool all_versions;
36/* Is CONFIG_BASIC_MODVERSIONS set? */
37static bool basic_modversions;
36/* Is CONFIG_EXTENDED_MODVERSIONS set? */38/* Is CONFIG_EXTENDED_MODVERSIONS set? */
37static bool extended_modversions;39static bool extended_modversions;
38/* If we are modposting external module set to 1 */40/* If we are modposting external module set to 1 */
@@ -1857,7 +1859,7 @@ static void add_versions(struct buffer *b, struct module *mod) · 1818 unmodified lines
1857{1859{
1858 struct symbol *s;1860 struct symbol *s;
1859 1861
1860 if (!modversions)1862 if (!basic_modversions)
1861 return;1863 return;
1862 1864
1863 buf_printf(b, "\n");1865 buf_printf(b, "\n");
@@ -2177,7 +2179,7 @@ int main(int argc, char **argv) · 313 unmodified lines
2177 LIST_HEAD(dump_lists);2179 LIST_HEAD(dump_lists);
2178 struct dump_list *dl, *dl2;2180 struct dump_list *dl, *dl2;
2179 2181
2180 while ((opt = getopt(argc, argv, "ei:MmnT:to:au:WwENd:x")) != -1) {2182 while ((opt = getopt(argc, argv, "ei:MmnT:to:au:WwENd:xb")) != -1) {
2181 switch (opt) {2183 switch (opt) {
2182 case 'e':2184 case 'e':
2183 external_module = true;2185 external_module = true;
@@ -2226,6 +2228,9 @@ int main(int argc, char **argv) · 42 unmodified lines
2226 case 'd':2228 case 'd':
2227 missing_namespace_deps = optarg;2229 missing_namespace_deps = optarg;
2228 break;2230 break;
2231 case 'b':
2232 basic_modversions = true;
2233 break;
2229 case 'x':2234 case 'x':
2230 extended_modversions = true;2235 extended_modversions = true;
2231 break;2236 break;