Skip to content

Commit e8639b7

Browse files
maurermasahir0y
authored andcommitted
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. Signed-off-by: Matthew Maurer <mmaurer@google.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent fc7d5e3 commit e8639b7

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

kernel/module/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ config EXTENDED_MODVERSIONS
217217
The most likely reason you would enable this is to enable Rust
218218
support. If unsure, say N.
219219

220+
config 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+
220235
config MODULE_SRCVERSION_ALL
221236
bool "Source checksum for all modules"
222237
help

scripts/Makefile.modpost

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ MODPOST = $(objtree)/scripts/mod/modpost
4343
modpost-args = \
4444
$(if $(CONFIG_MODULES),-M) \
4545
$(if $(CONFIG_MODVERSIONS),-m) \
46+
$(if $(CONFIG_BASIC_MODVERSIONS),-b) \
4647
$(if $(CONFIG_EXTENDED_MODVERSIONS),-x) \
4748
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
4849
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \

scripts/mod/modpost.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static bool module_enabled;
3333
static bool modversions;
3434
/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
3535
static bool all_versions;
36+
/* Is CONFIG_BASIC_MODVERSIONS set? */
37+
static bool basic_modversions;
3638
/* Is CONFIG_EXTENDED_MODVERSIONS set? */
3739
static bool extended_modversions;
3840
/* If we are modposting external module set to 1 */
@@ -1857,7 +1859,7 @@ static void add_versions(struct buffer *b, struct module *mod)
18571859
{
18581860
struct symbol *s;
18591861

1860-
if (!modversions)
1862+
if (!basic_modversions)
18611863
return;
18621864

18631865
buf_printf(b, "\n");
@@ -2177,7 +2179,7 @@ int main(int argc, char **argv)
21772179
LIST_HEAD(dump_lists);
21782180
struct dump_list *dl, *dl2;
21792181

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) {
21812183
switch (opt) {
21822184
case 'e':
21832185
external_module = true;
@@ -2226,6 +2228,9 @@ int main(int argc, char **argv)
22262228
case 'd':
22272229
missing_namespace_deps = optarg;
22282230
break;
2231+
case 'b':
2232+
basic_modversions = true;
2233+
break;
22292234
case 'x':
22302235
extended_modversions = true;
22312236
break;

0 commit comments

Comments
 (0)