The kmod project actually uses LGPL 2.1 or later for libkmod. Clarify
this and use proper SPDX license identifier as done in source files.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
linux-edge-dev is failing in alpine:
ERROR: unable to select packages:
linux-edge-dev (no such package):
required by: world[linux-edge-dev]
Error: Process completed with exit code 1.
Use linux-stable instead.
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
The former has been EOL for a bit now and somewhat recently has been
(re)moved from the repos -> our CI was failing.
Swap for bookworm, which gives us the "try a slightly older distro"
coverage, while still being green in CI.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/395
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Variable declaration inside a switch case works with gcc 15, but fails
pretty much everywhere else with a message like below:
../testsuite/init_module.c: In function ‘syscall’:
../testsuite/init_module.c:343:3: error: a label can only be part of a statement and a declaration is not a statement
343 | const char *args;
| ^~~~~
Add an empty statement to fix it.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/390
Use a switch() statement for syscall override handling, making it a
little bit less verbose.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/387
The libcrypto library constructor calls the riscv_hwprobe syscall through
the syscall wrapper. Return an error with ENOSYS.
Signed-off-by: Andreas Schwab <schwab@suse.de>
Link: https://github.com/kmod-project/kmod/pull/387
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Currently we call exit() in a handful of places within test_run_child().
Where the latter is annotated as `noreturn int` and we never check the
return value.
Just move the exit() further up the call stack and remove the noreturn
notation.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Currently we can pass any number of tests as arguments - be that in
oneshot mode or not.
At the same time, oneshot requires only one test while normal mode can
have up-to one.
Fix that up and as a bonus we no longer need the exit() in
test_run_spawned() \o/
While in here, add a few comments around our arg/argc handling.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Remove the alignment from the struct declaration. The macro
instantiating it DEFINE_TEST_WITH_FUNC already has (proper) alignment.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
We have a single _always_inline_ instance in-tree, which lives in a
header file. Just make it a "static inline", which will practically do
the same thing and what we already have elsewhere in-tree.
While in there drop the CAPS from ALIGN_POWER2 - it's a function, so we
don't need the shouting.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Instead of playing a game of whack-a-mole, disable any -Wattribute
warnings globally. This means, people won't get the warnings when
building with older compilers which lack certain attributes.
Thus we can remove the _Pragma. With that gone, we no longer need the
clang-format off segment.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The module description is now required, otherwise a warning is emitted
by modpost:
WARNING: modpost: missing MODULE_DESCRIPTION() in mod-loop-k.o
Fix all of them with:
sed -i '/MODULE_LICENSE("LGPL");/a MODULE_DESCRIPTION("dummy test module");' testsuite/module-playground/mod-*.c
sed -i '/MODULE_LICENSE("GPL");/a MODULE_DESCRIPTION("dummy test module");' testsuite/module-playground/mod-simple.c
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Drop .github/print-kdir.sh and just use KDIR=any to handle the kernel
headers.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/384
I update my kernel frequently and may not be running a kernel with
headers installed. That always leads me to:
1) run `meson test -C build`
2) Oh, crap, it fails: no kernel headers
3) Find whatever kernel header is installed and point KDIR to it
We can do better and tell KDIR=any to use whatever it finds.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/384
This might make the code easier to read.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If module cannot be removed in time, return with a failure, not success:
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If a large delta is given, the multiplication might overflow.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If current time t is already past tend, the while loop in
get_backoff_delta_msec never ends.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Move the variants into their own section, similar to the moduledir and
co. This bears no functional change in the CI run.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/383
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Both -Dopenssl=enabled and -Dtools=true are the default. Omit them from
the meson_setup.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/383
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Currently running 32bit tests alongside sanitizers, segfaults due to our
syscall wrapper. Just disable the sanitizers, which means we get at
least some 32bit test coverage.
On a couple of attempts, I wasn't able to get a proper/robust solution,
as outlined in init_module.c - we need vsyscall() which does not exist.
Considering some distributions are dropping 32bit/i686 support, it may
be that we'll nuke these builds from CI sooner than later.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/383
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Adjust the markdown variant, so it renders correctly in both GitHub and
cgit (... vim also seems happier fwiw). AFAICT the latter is using
CommonMarkdown as handled by python-markdown.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/380
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Adjust the markdown variant, so it renders correctly in both GitHub and
cgit (... vim also seems happier fwiw). AFAICT the latter is using
CommonMarkdown as handled by python-markdown.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/380
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Earlier commit used a global sed to remove the no-longer needed
exit(EXIT_FAILURE) calls. In the process it also removed one instance
in the error path, which should remain.
Fixes: e09acf2e ("testsuite: remove exit from EXEC_TOOL tests")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/379
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Co-authored-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/378
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
There is no particular reason for us to use exit(), so just avoid it.
As result, the only instances using of exit() are within the child
process and our cleanup is complete :-)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Update the existing code-paths to always exit() for the child process.
We already handle that in a few places, but the error-paths are
(understandably) off.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Purge the remaining exit/noreturn instances, which means we now get a
consistent return path on all tests and across both success and failure
paths.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The EXEC_TOOL macros calls test_spawn_prog() which returns EXIT_FAILURE
in the unlikely case of a return from execv().
Thus the explicit exit() is dead code that we can remove and alongside
it the noreturn notation of the respective tests.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Swap the currect EXEC_DEPMOD and EXEC_MODPROBE with a slightly more
generic macro - EXEC_TOOL based off them.
Update all in-tree instances of test_spawn_prog() to use it.
This will make follow-up work (removing the noreturn/exit) a bit easier
and more consistent.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
With the upcoming patches, removing exit() usage, ASan started reporting
that our test leaks kmod_module handles.
Resolve those leaks - we shouldn't be doing that in the normal (success)
path.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
With the upcoming patches, removing exit() usage, ASan started reporting
that our test leaks kmod_module handles.
Resolve those leaks - we shouldn't be doing that in the normal (success)
path.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Currently we use a mix of ARRAY_SIZE() and iterator pointer, where the
latter needs an extra instance for the NULL sentinel. Plus as evidenced
by the EXIT_SUCCESS -> EXIT_FAILURE changes in test-new-module - is
error prone.
Consistently use ARRAY_SIZE(), fixing the logical error in the test
which was flagged by ASan as memory leak :-)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
A while ago we annotated a bunch of of the tests although I missed some
during grepping. Update the final instances, taking the chance to move
the strdup instances into the test loop and failing the test should the
duplication fails.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
--remove-holders was not implying --remove, which means that if the user
called `modprobe --remove-holders xe` it would actually try to insert
the xe module. Fix it and spell it out in the man page about one option
implying the other.
Considering i915 is not currently loaded:
Before:
kmod $ ./build/modprobe -v --dry-run --remove-holders i915
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/char/agp/intel-gtt.ko.zst
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/gpu/drm/i915/i915.ko.zst
kmod $
After:
kmod $ ./build/modprobe -v --dry-run --remove-holders i915
kmod $
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/372
A while ago the Alpine gtk-doc tool chain was having issues building our
docs. That got resolved at some point over the past months, so we can
drop this local workaround.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/373
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Use the newly introduced helper module_new_from_any(), so we accept both
files as well as modules. This means you can now do:
- modprobe --show-modversions drm-vram-helper, alongside the existing
- modprobe --show-modversions /full/path/to/the/module/drm_vram_helper.ko
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Add test for the newly introduced --show-exports code path.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Even though we don't give the user any feedback, the --quiet option is
only applicable with --remove. Remove it from any modprobe --show*
invocations.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Use the newly introduced helper module_new_from_any(), so we accept both
files as well as modules. This means you can now do:
- modprobe --show-exports drm-vram-helper, alongside the existing
- modprobe --show-exports /full/path/to/the/module/drm_vram_helper.ko
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Split the functionality into a helper function, which will be used with
later commits.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The option was introduced a few years ago, yet the manual page went
without an update. Add some basic documentation.
Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Fixes: 3ada8df8 ("modprobe: add --show-exports")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Currently we have a range of options which show specific details,
although they vary in prefix or spelling:
- prefix: dump vs resolve vs show
- with and without dash after show
Converge on --show-foo and deprecate the rest. The old options are still
accepted but will throw a warning. Only the (new) consistent names are
listed in --help, while the manual page lists both but spells out that
the old ones will be removed.
To avoid any confusion with --show (aka --dry-run) the option is also
soft-deprecated.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The option was annotated as deprecated a while ago, although we never
flagged a warning when it is in use.
Do that, remove it from the --help screen and add an explicit "will be
removed" notice in the manual page.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The option was introduced a few years ago, yet the manual page went
without an update. Add some basic documentation.
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Fixes: 42b32d30 ("modprobe: Fix holders removal")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The function returns the error code itself, so we should be using
strerror(-err) instead.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>