Hi Linus,
Please pull the nolibc update for Linux 6.8-rc1.
This nolibc update for Linux 6.8-rc1 consists of:
* Support for PIC mode on MIPS.
* Support for getrlimit()/setrlimit().
* Replace some custom declarations with UAPI includes.
* A new script "run-tests.sh" to run the testsuite over different architectures
and configurations.
* A few non-functional code cleanups.
* Minor improvements to nolibc-test, primarily to support the test script.
There are no urgent fixes available at this time.
diff is attached. Build and nolibc tests were run on next.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:
Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-nolibc-6.8-rc1
for you to fetch changes up to d543d9ddf593b1f4cb1d57d9ac0ad279fe18adaf:
selftests/nolibc: disable coredump via setrlimit (2023-12-11 22:38:37 +0100)
----------------------------------------------------------------
linux_kselftest-nolibc-6.8-rc1
This nolibc update for Linux 6.8-rc1 consists of:
* Support for PIC mode on MIPS.
* Support for getrlimit()/setrlimit().
* Replace some custom declarations with UAPI includes.
* A new script "run-tests.sh" to run the testsuite over different architectures
and configurations.
* A few non-functional code cleanups.
* Minor improvements to nolibc-test, primarily to support the test script.
There are no urgent fixes available at this time.
----------------------------------------------------------------
Mark Brown (1):
tools/nolibc: Use linux/wait.h rather than duplicating it
Thomas Weißschuh (21):
selftests/nolibc: don't hang on config input
selftests/nolibc: use EFI -bios for LoongArch qemu
selftests/nolibc: anchor paths in $(srcdir) if possible
selftests/nolibc: support out-of-tree builds
selftests/nolibc: add script to run testsuite
tools/nolibc: error out on unsupported architecture
tools/nolibc: move MIPS ABI validation into arch-mips.h
selftests/nolibc: use XARCH for MIPS
selftests/nolibc: explicitly specify ABI for MIPS
selftests/nolibc: extraconfig support
selftests/nolibc: add configuration for mipso32be
selftests/nolibc: fix testcase status alignment
selftests/nolibc: introduce QEMU_ARCH_USER
selftests/nolibc: run-tests.sh: enable testing via qemu-user
tools/nolibc: mips: add support for PIC
selftests/nolibc: make result alignment more robust
tools/nolibc: annotate va_list printf formats
tools/nolibc: drop duplicated testcase ioctl_tiocinq
tools/nolibc: drop custom definition of struct rusage
tools/nolibc: add support for getrlimit/setrlimit
selftests/nolibc: disable coredump via setrlimit
tools/include/nolibc/arch-mips.h | 11 +-
tools/include/nolibc/arch.h | 4 +-
tools/include/nolibc/stdio.h | 4 +-
tools/include/nolibc/sys.h | 38 ++++++
tools/include/nolibc/types.h | 25 +---
tools/testing/selftests/nolibc/.gitignore | 1 +
tools/testing/selftests/nolibc/Makefile | 65 ++++++++---
tools/testing/selftests/nolibc/nolibc-test.c | 51 ++++++--
tools/testing/selftests/nolibc/run-tests.sh | 169 +++++++++++++++++++++++++++
9 files changed, 318 insertions(+), 50 deletions(-)
create mode 100755 tools/testing/selftests/nolibc/run-tests.sh
----------------------------------------------------------------
Hi Linus,
Please pull the following Kselftest update for Linux 6.8-rc1.
This kselftest update for Linux 6.8-rc1 consists of enhancements
to reporting test results, fixes to root and user run behavior
and fixing ksft_print_msg() calls.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:
Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-next-6.8-rc1
for you to fetch changes up to ee9793be08b1a1c29308a099c01790a3befb390a:
tracing/selftests: Add ownership modification tests for eventfs (2023-12-22 10:01:41 -0700)
----------------------------------------------------------------
linux_kselftest-next-6.8-rc1
This kselftest update for Linux 6.8-rc1 consists of enhancements
to reporting test results, fixes to root and user run behavior
and fixing ksft_print_msg() calls.
----------------------------------------------------------------
Atul Kumar Pant (1):
selftests: sched: Remove initialization to 0 for a static variable
Mark Brown (3):
kselftest/vDSO: Make test name reporting for vdso_abi_test tooling friendly
kselftest/vDSO: Fix message formatting for clock_id logging
kselftest/vDSO: Use ksft_print_msg() rather than printf in vdso_test_abi
Osama Muhammad (1):
selftests: prctl: Add prctl test for PR_GET_NAME
Steven Rostedt (Google) (1):
tracing/selftests: Add ownership modification tests for eventfs
Swarup Laxman Kotiaklapudi (1):
selftests: capabilities: namespace create varies for root and normal user
angquan yu (3):
selftests:breakpoints: Fix Format String Warning in breakpoint_test
selftests/breakpoints: Fix format specifier in ksft_print_msg in step_after_suspend_test.c
selftests:x86: Fix Format String Warnings in lam.c
.../selftests/breakpoints/breakpoint_test.c | 4 +-
.../breakpoints/step_after_suspend_test.c | 2 +-
tools/testing/selftests/capabilities/test_execve.c | 6 +-
.../ftrace/test.d/00basic/test_ownership.tc | 114 +++++++++++++++++++++
tools/testing/selftests/prctl/set-process-name.c | 32 ++++++
tools/testing/selftests/sched/cs_prctl_test.c | 2 +-
tools/testing/selftests/vDSO/vdso_test_abi.c | 72 +++++++------
tools/testing/selftests/x86/lam.c | 4 +-
8 files changed, 192 insertions(+), 44 deletions(-)
create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
----------------------------------------------------------------
Hi Linus,
Please pull the following KUnit next update for Linux 6.8-rc1.
This KUnit update for Linux 6.8-rc1 consists of:
- a new feature that adds APIs for managing devices introducing
a set of helper functions which allow devices (internally a
struct kunit_device) to be created and managed by KUnit.
These devices will be automatically unregistered on
test exit. These helpers can either use a user-provided
struct device_driver, or have one automatically created and
managed by KUnit. In both cases, the device lives on a new
kunit_bus.
- changes to switch drm/tests to use kunit devices
- several fixes and enhancements to attribute feature
- changes to reorganize deferred action function introducing
KUNIT_DEFINE_ACTION_WRAPPER
- new feature adds ability to run tests after boot using debugfs
- fixes and enhancements to string-stream-test:
- parse ERR_PTR in string_stream_destroy()
- unchecked dereference in bug fix in debugfs_print_results()
- handling errors from alloc_string_stream()
- NULL-dereference bug fix in kunit_init_suite()
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit ceb6a6f023fd3e8b07761ed900352ef574010bcb:
Linux 6.7-rc6 (2023-12-17 15:19:28 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-6.8-rc1
for you to fetch changes up to 539e582a375dedee95a4fa9ca3f37cdb25c441ec:
kunit: Fix some comments which were mistakenly kerneldoc (2024-01-03 09:10:37 -0700)
----------------------------------------------------------------
linux_kselftest-kunit-6.8-rc1
This KUnit update for Linux 6.8-rc1 consists of:
- a new feature that adds APIs for managing devices introducing
a set of helper functions which allow devices (internally a
struct kunit_device) to be created and managed by KUnit.
These devices will be automatically unregistered on
test exit. These helpers can either use a user-provided
struct device_driver, or have one automatically created and
managed by KUnit. In both cases, the device lives on a new
kunit_bus.
- changes to switch drm/tests to use kunit devices
- several fixes and enhancements to attribute feature
- changes to reorganize deferred action function introducing
KUNIT_DEFINE_ACTION_WRAPPER
- new feature adds ability to run tests after boot using debugfs
- fixes and enhancements to string-stream-test:
- parse ERR_PTR in string_stream_destroy()
- unchecked dereference in bug fix in debugfs_print_results()
- handling errors from alloc_string_stream()
- NULL-dereference bug fix in kunit_init_suite()
----------------------------------------------------------------
David Gow (4):
kunit: Add a macro to wrap a deferred action function
drm/tests: Use KUNIT_DEFINE_ACTION_WRAPPER()
drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER
kunit: Fix some comments which were mistakenly kerneldoc
Maxime Ripard (1):
drm/tests: Switch to kunit devices
Michal Wajdeczko (2):
kunit: Add example for using test->priv
kunit: Reset test->priv after each param iteration
Rae Moar (8):
kunit: tool: fix parsing of test attributes
kunit: tool: add test for parsing attributes
kunit: move KUNIT_TABLE out of INIT_DATA
kunit: add KUNIT_INIT_TABLE to init linker section
kunit: add example suite to test init suites
kunit: add is_init test attribute
kunit: add ability to run tests after boot using debugfs
Documentation: Add debugfs docs with run after boot
Richard Fitzgerald (8):
kunit: string-stream-test: Avoid cast warning when testing gfp_t flags
kunit: string-stream: Allow ERR_PTR to be passed to string_stream_destroy()
kunit: debugfs: Fix unchecked dereference in debugfs_print_results()
kunit: debugfs: Handle errors from alloc_string_stream()
kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL
kunit: Allow passing function pointer to kunit_activate_static_stub()
kunit: Add example of kunit_activate_static_stub() with pointer-to-function
kunit: Protect string comparisons against NULL
davidgow(a)google.com (4):
kunit: Add APIs for managing devices
fortify: test: Use kunit_device
overflow: Replace fake root_device with kunit_device
ASoC: topology: Replace fake root_device with kunit_device in tests
Documentation/dev-tools/kunit/api/resource.rst | 9 +
Documentation/dev-tools/kunit/run_manual.rst | 51 +++++-
Documentation/dev-tools/kunit/running_tips.rst | 7 +
Documentation/dev-tools/kunit/usage.rst | 60 ++++++-
drivers/gpu/drm/tests/drm_kunit_helpers.c | 78 +--------
drivers/gpu/drm/vc4/tests/vc4_mock.c | 9 +-
include/asm-generic/vmlinux.lds.h | 11 +-
include/kunit/device.h | 80 +++++++++
include/kunit/resource.h | 21 +++
include/kunit/static_stub.h | 2 +-
include/kunit/test.h | 33 ++--
include/linux/module.h | 2 +
kernel/module/main.c | 3 +
lib/fortify_kunit.c | 5 +-
lib/kunit/Makefile | 3 +-
lib/kunit/attributes.c | 60 +++++++
lib/kunit/debugfs.c | 102 +++++++++++-
lib/kunit/device-impl.h | 17 ++
lib/kunit/device.c | 181 +++++++++++++++++++++
lib/kunit/executor.c | 68 +++++++-
lib/kunit/kunit-example-test.c | 87 ++++++++++
lib/kunit/kunit-test.c | 139 +++++++++++++++-
lib/kunit/string-stream-test.c | 2 +-
lib/kunit/string-stream.c | 2 +-
lib/kunit/test.c | 48 +++++-
lib/overflow_kunit.c | 5 +-
sound/soc/soc-topology-test.c | 10 +-
tools/testing/kunit/kunit_parser.py | 4 +-
tools/testing/kunit/kunit_tool_test.py | 16 ++
.../kunit/test_data/test_parse_attributes.log | 9 +
30 files changed, 978 insertions(+), 146 deletions(-)
create mode 100644 include/kunit/device.h
create mode 100644 lib/kunit/device-impl.h
create mode 100644 lib/kunit/device.c
create mode 100644 tools/testing/kunit/test_data/test_parse_attributes.log
----------------------------------------------------------------
Changes in v4:
* Documented how to compile the livepatch selftests without running the
tests (Joe)
* Removed the mention to lib/livepatch on MAINTAINERS file, reported by
checkpatch.
Changes in v3:
* Rebased on top of v6.6-rc5
* The commits messages were improved (Thanks Petr!)
* Created TEST_GEN_MODS_DIR variable to point to a directly that contains kernel
modules, and adapt selftests to build it before running the test.
* Moved test_klp-call_getpid out of test_programs, since the gen_tar
would just copy the generated test programs to the livepatches dir,
and so scripts relying on test_programs/test_klp-call_getpid will fail.
* Added a module_param for klp_pids, describing it's usage.
* Simplified the call_getpid program to ignore the return of getpid syscall,
since we only want to make sure the process transitions correctly to the
patched stated
* The test-syscall.sh not prints a log message showing the number of remaining
processes to transition into to livepatched state, and check_output expects it
to be 0.
* Added MODULE_AUTHOR and MODULE_DESCRIPTION to test_klp_syscall.c
- Link to v3: https://lore.kernel.org/r/20231031-send-lp-kselftests-v3-0-2b1655c2605f@sus…
- Link to v2: https://lore.kernel.org/linux-kselftest/20220630141226.2802-1-mpdesouza@sus…
This patchset moves the current kernel testing livepatch modules from
lib/livepatches to tools/testing/selftest/livepatch/test_modules, and compiles
them as out-of-tree modules before testing.
There is also a new test being added. This new test exercises multiple processes
calling a syscall, while a livepatch patched the syscall.
Why this move is an improvement:
* The modules are now compiled as out-of-tree modules against the current
running kernel, making them capable of being tested on different systems with
newer or older kernels.
* Such approach now needs kernel-devel package to be installed, since they are
out-of-tree modules. These can be generated by running "make rpm-pkg" in the
kernel source.
What needs to be solved:
* Currently gen_tar only packages the resulting binaries of the tests, and not
the sources. For the current approach, the newly added modules would be
compiled and then packaged. It works when testing on a system with the same
kernel version. But it will fail when running on a machine with different kernel
version, since module was compiled against the kernel currently running.
This is not a new problem, just aligning the expectations. For the current
approach to be truly system agnostic gen_tar would need to include the module
and program sources to be compiled in the target systems.
Thanks in advance!
Marcos
Signed-off-by: Marcos Paulo de Souza <mpdesouza(a)suse.com>
---
Marcos Paulo de Souza (3):
kselftests: lib.mk: Add TEST_GEN_MODS_DIR variable
livepatch: Move tests from lib/livepatch to selftests/livepatch
selftests: livepatch: Test livepatching a heavily called syscall
Documentation/dev-tools/kselftest.rst | 4 +
MAINTAINERS | 1 -
arch/s390/configs/debug_defconfig | 1 -
arch/s390/configs/defconfig | 1 -
lib/Kconfig.debug | 22 ----
lib/Makefile | 2 -
lib/livepatch/Makefile | 14 ---
tools/testing/selftests/lib.mk | 20 +++-
tools/testing/selftests/livepatch/Makefile | 5 +-
tools/testing/selftests/livepatch/README | 25 +++--
tools/testing/selftests/livepatch/config | 1 -
tools/testing/selftests/livepatch/functions.sh | 34 +++---
.../testing/selftests/livepatch/test-callbacks.sh | 50 ++++-----
tools/testing/selftests/livepatch/test-ftrace.sh | 6 +-
.../testing/selftests/livepatch/test-livepatch.sh | 10 +-
.../selftests/livepatch/test-shadow-vars.sh | 2 +-
tools/testing/selftests/livepatch/test-state.sh | 18 ++--
tools/testing/selftests/livepatch/test-syscall.sh | 53 ++++++++++
tools/testing/selftests/livepatch/test-sysfs.sh | 6 +-
.../selftests/livepatch/test_klp-call_getpid.c | 44 ++++++++
.../selftests/livepatch/test_modules/Makefile | 20 ++++
.../test_modules}/test_klp_atomic_replace.c | 0
.../test_modules}/test_klp_callbacks_busy.c | 0
.../test_modules}/test_klp_callbacks_demo.c | 0
.../test_modules}/test_klp_callbacks_demo2.c | 0
.../test_modules}/test_klp_callbacks_mod.c | 0
.../livepatch/test_modules}/test_klp_livepatch.c | 0
.../livepatch/test_modules}/test_klp_shadow_vars.c | 0
.../livepatch/test_modules}/test_klp_state.c | 0
.../livepatch/test_modules}/test_klp_state2.c | 0
.../livepatch/test_modules}/test_klp_state3.c | 0
.../livepatch/test_modules/test_klp_syscall.c | 116 +++++++++++++++++++++
32 files changed, 334 insertions(+), 121 deletions(-)
---
base-commit: 206ed72d6b33f53b2a8bf043f54ed6734121d26b
change-id: 20231031-send-lp-kselftests-4c917dcd4565
Best regards,
--
Marcos Paulo de Souza <mpdesouza(a)suse.com>
Minor consistency fixes.
They clear a couple of compiler format string warnings.
[1/2] is the fix of an obvious typo in the format specifier
[2/2] is securing the print function against spurious format specifiers
in passed paramater string
Mirsad Todorovac (2):
selftest: breakpoints: fix a minor typo in the format string
selftest: breakpoints: clear the format string warning and secure the
output
tools/testing/selftests/breakpoints/breakpoint_test.c | 4 ++--
tools/testing/selftests/breakpoints/step_after_suspend_test.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
--
2.40.1
Minor fixes of compiler warnings and one bug in the number of parameters which
would not crash the test but it is better fixed for correctness sake.
As the general climate in the Linux kernel community is to fix all compiler
warnings, this could be on the right track, even if only in the testing suite.
Changelog:
v1 -> v2:
- Compared to v1, commit subject lines have been adjusted to reflect the style
of the subsystem, as suggested by Mark.
- 1/4 was already acked and unchanged (adjusted the subject line as suggested)
(code unchanged)
- 2/4 was acked with suggestion to adjust the subject line (done).
(code unchanged)
- 3/4 The format specifier was changed from %d to %u as suggested.
- The 4/4 submitted for review (in the v1 it was delayed by an omission).
(code unchanged)
Mirsad Todorovac (4):
kselftest/alsa - mixer-test: fix the number of parameters to
ksft_exit_fail_msg()
kselftest/alsa - mixer-test: Fix the print format specifier warning
kselftest/alsa - mixer-test: Fix the print format specifier warning
kselftest/alsa - conf: Stringify the printed errno in sysfs_get()
tools/testing/selftests/alsa/conf.c | 2 +-
tools/testing/selftests/alsa/mixer-test.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
--
2.40.1
Some aarch64 systems running a PREEMPT_RT patched kernel, needs
more time to complete the test.
This change mirrors:
commit ba83af059153 ("Improve stability of find_vma BPF test")
addressing similar requirements and allowing the QTI SA8775P based
systems, and others, to complete the test when running RT kernel.
Signed-off-by: Alessandro Carminati (Red Hat) <alessandro.carminati(a)gmail.com>
---
tools/testing/selftests/bpf/prog_tests/find_vma.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/find_vma.c b/tools/testing/selftests/bpf/prog_tests/find_vma.c
index 5165b38f0e59..43d62db8d57b 100644
--- a/tools/testing/selftests/bpf/prog_tests/find_vma.c
+++ b/tools/testing/selftests/bpf/prog_tests/find_vma.c
@@ -51,7 +51,7 @@ static void test_find_vma_pe(struct find_vma *skel)
struct bpf_link *link = NULL;
volatile int j = 0;
int pfd, i;
- const int one_bn = 1000000000;
+ const int dummy_wait = 2500000000;
pfd = open_pe();
if (pfd < 0) {
@@ -68,10 +68,10 @@ static void test_find_vma_pe(struct find_vma *skel)
if (!ASSERT_OK_PTR(link, "attach_perf_event"))
goto cleanup;
- for (i = 0; i < one_bn && find_vma_pe_condition(skel); ++i)
+ for (i = 0; i < dummy_wait && find_vma_pe_condition(skel); ++i)
++j;
- test_and_reset_skel(skel, -EBUSY /* in nmi, irq_work is busy */, i == one_bn);
+ test_and_reset_skel(skel, -EBUSY /* in nmi, irq_work is busy */, i == dummy_wait);
cleanup:
bpf_link__destroy(link);
close(pfd);
--
2.34.1
Now that we have the VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT macros,
update the instructions to stop recommending including .c files.
Signed-off-by: Arthur Grillo <arthurgrillo(a)riseup.net>
---
Changes in v2:
- Fix #if condition
- Link to v1: https://lore.kernel.org/r/20240108-kunit-doc-export-v1-1-119368df0d96@riseu…
---
Documentation/dev-tools/kunit/usage.rst | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index c27e1646ecd9..f095c6bb76ff 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -671,19 +671,22 @@ Testing Static Functions
------------------------
If we do not want to expose functions or variables for testing, one option is to
-conditionally ``#include`` the test file at the end of your .c file. For
-example:
+conditionally export the used symbol.
.. code-block:: c
/* In my_file.c */
- static int do_interesting_thing();
+ VISIBLE_IF_KUNIT int do_interesting_thing();
+ EXPORT_SYMBOL_IF_KUNIT(do_interesting_thing);
- #ifdef CONFIG_MY_KUNIT_TEST
- #include "my_kunit_test.c"
+ /* In my_file.h */
+
+ #if IS_ENABLED(CONFIG_KUNIT)
+ int do_interesting_thing(void);
#endif
+
Injecting Test-Only Code
------------------------
---
base-commit: eeb8e8d9f124f279e80ae679f4ba6e822ce4f95f
change-id: 20240108-kunit-doc-export-eec1f910ab67
Best regards,
--
Arthur Grillo <arthurgrillo(a)riseup.net>
Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") fixed a wild-memory-access bug that could have
happened during the loading phase of test suites built and executed as
loadable modules. However, it also introduced a problematic side effect
that causes test suites modules to crash when they attempt to register
fake devices.
When a module is loaded, it traverses the MODULE_STATE_UNFORMED and
MODULE_STATE_COMING states before reaching the normal operating state
MODULE_STATE_LIVE. Finally, when the module is removed, it moves to
MODULE_STATE_GOING before being released. However, if the loading
function load_module() fails between complete_formation() and
do_init_module(), the module goes directly from MODULE_STATE_COMING to
MODULE_STATE_GOING without passing through MODULE_STATE_LIVE.
This behavior was causing kunit_module_exit() to be called without
having first executed kunit_module_init(). Since kunit_module_exit() is
responsible for freeing the memory allocated by kunit_module_init()
through kunit_filter_suites(), this behavior was resulting in a
wild-memory-access bug.
Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") fixed this issue by running the tests when the
module is still in MODULE_STATE_COMING. However, modules in that state
are not fully initialized, lacking sysfs kobjects. Therefore, if a test
module attempts to register a fake device, it will inevitably crash.
This patch proposes a different approach to fix the original
wild-memory-access bug while restoring the normal module execution flow
by making kunit_module_exit() able to detect if kunit_module_init() has
previously initialized the tests suite set. In this way, test modules
can once again register fake devices without crashing.
This behavior is achieved by checking whether mod->kunit_suites is a
virtual or direct mapping address. If it is a virtual address, then
kunit_module_init() has allocated the suite_set in kunit_filter_suites()
using kmalloc_array(). On the contrary, if mod->kunit_suites is still
pointing to the original address that was set when looking up the
.kunit_test_suites section of the module, then the loading phase has
failed and there's no memory to be freed.
v3:
- add a comment to clarify why the start address is checked
v2:
- add include <linux/mm.h>
Fixes: 2810c1e99867 ("kunit: Fix wild-memory-access bug in kunit_free_suite_set()")
Tested-by: Richard Fitzgerald <rf(a)opensource.cirrus.com>
Reviewed-by: Javier Martinez Canillas <javierm(a)redhat.com>
Signed-off-by: Marco Pagani <marpagan(a)redhat.com>
---
lib/kunit/test.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 7aceb07a1af9..3263e0d5e0f6 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -16,6 +16,7 @@
#include <linux/panic.h>
#include <linux/sched/debug.h>
#include <linux/sched.h>
+#include <linux/mm.h>
#include "debugfs.h"
#include "hooks-impl.h"
@@ -775,12 +776,19 @@ static void kunit_module_exit(struct module *mod)
};
const char *action = kunit_action();
+ /*
+ * Check if the start address is a valid virtual address to detect
+ * if the module load sequence has failed and the suite set has not
+ * been initialized and filtered.
+ */
+ if (!suite_set.start || !virt_addr_valid(suite_set.start))
+ return;
+
if (!action)
__kunit_test_suites_exit(mod->kunit_suites,
mod->num_kunit_suites);
- if (suite_set.start)
- kunit_free_suite_set(suite_set);
+ kunit_free_suite_set(suite_set);
}
static int kunit_module_notify(struct notifier_block *nb, unsigned long val,
@@ -790,12 +798,12 @@ static int kunit_module_notify(struct notifier_block *nb, unsigned long val,
switch (val) {
case MODULE_STATE_LIVE:
+ kunit_module_init(mod);
break;
case MODULE_STATE_GOING:
kunit_module_exit(mod);
break;
case MODULE_STATE_COMING:
- kunit_module_init(mod);
break;
case MODULE_STATE_UNFORMED:
break;
base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a
--
2.43.0
This is the second part to add Intel VT-d nested translation based on IOMMUFD
nesting infrastructure. As the iommufd nesting infrastructure series [1],
iommu core supports new ops to invalidate the cache after the modifictions
in stage-1 page table. So far, the cache invalidation data is vendor specific,
the data_type (IOMMU_HWPT_DATA_VTD_S1) defined for the vendor specific HWPT
allocation is reused in the cache invalidation path. User should provide the
correct data_type that suit with the type used in HWPT allocation.
IOMMU_HWPT_INVALIDATE iotcl returns an error in @out_driver_error_code. However
Intel VT-d does not define error code so far, so it's not easy to pre-define it
in iommufd neither. As a result, this field should just be ignored on VT-d platform.
Complete code can be found in [2], corresponding QEMU could can be found in [3].
[1] https://lore.kernel.org/linux-iommu/20231117130717.19875-1-yi.l.liu@intel.c…
[2] https://github.com/yiliu1765/iommufd/tree/iommufd_nesting
[3] https://github.com/yiliu1765/qemu/tree/zhenzhong/wip/iommufd_nesting_rfcv1
Change log:
v7:
- No much change, just rebase on top of 6.7-rc1
v6: https://lore.kernel.org/linux-iommu/20231020093719.18725-1-yi.l.liu@intel.c…
- Address comments from Kevin
- Split the VT-d nesting series into two parts (Jason)
v5: https://lore.kernel.org/linux-iommu/20230921075431.125239-1-yi.l.liu@intel.…
- Add Kevin's r-b for patch 2, 3 ,5 8, 10
- Drop enforce_cache_coherency callback from the nested type domain ops (Kevin)
- Remove duplicate agaw check in patch 04 (Kevin)
- Remove duplicate domain_update_iommu_cap() in patch 06 (Kevin)
- Check parent's force_snooping to set pgsnp in the pasid entry (Kevin)
- uapi data structure check (Kevin)
- Simplify the errata handling as user can allocate nested parent domain
v4: https://lore.kernel.org/linux-iommu/20230724111335.107427-1-yi.l.liu@intel.…
- Remove ascii art tables (Jason)
- Drop EMT (Tina, Jason)
- Drop MTS and related definitions (Kevin)
- Rename macro IOMMU_VTD_PGTBL_ to IOMMU_VTD_S1_ (Kevin)
- Rename struct iommu_hwpt_intel_vtd_ to iommu_hwpt_vtd_ (Kevin)
- Rename struct iommu_hwpt_intel_vtd to iommu_hwpt_vtd_s1 (Kevin)
- Put the vendor specific hwpt alloc data structure before enuma iommu_hwpt_type (Kevin)
- Do not trim the higher page levels of S2 domain in nested domain attachment as the
S2 domain may have been used independently. (Kevin)
- Remove the first-stage pgd check against the maximum address of s2_domain as hw
can check it anyhow. It makes sense to check every pfns used in the stage-1 page
table. But it cannot make it. So just leave it to hw. (Kevin)
- Split the iotlb flush part into an order of uapi, helper and callback implementation (Kevin)
- Change the policy of VT-d nesting errata, disallow RO mapping once a domain is used
as parent domain of a nested domain. This removes the nested_users counting. (Kevin)
- Minor fix for "make htmldocs"
v3: https://lore.kernel.org/linux-iommu/20230511145110.27707-1-yi.l.liu@intel.c…
- Further split the patches into an order of adding helpers for nested
domain, iotlb flush, nested domain attachment and nested domain allocation
callback, then report the hw_info to userspace.
- Add batch support in cache invalidation from userspace
- Disallow nested translation usage if RO mappings exists in stage-2 domain
due to errata on readonly mappings on Sapphire Rapids platform.
v2: https://lore.kernel.org/linux-iommu/20230309082207.612346-1-yi.l.liu@intel.…
- The iommufd infrastructure is split to be separate series.
v1: https://lore.kernel.org/linux-iommu/20230209043153.14964-1-yi.l.liu@intel.c…
Regards,
Yi Liu
Yi Liu (3):
iommufd: Add data structure for Intel VT-d stage-1 cache invalidation
iommu/vt-d: Make iotlb flush helpers to be extern
iommu/vt-d: Add iotlb flush for nested domain
drivers/iommu/intel/iommu.c | 10 +++----
drivers/iommu/intel/iommu.h | 6 ++++
drivers/iommu/intel/nested.c | 54 ++++++++++++++++++++++++++++++++++++
include/uapi/linux/iommufd.h | 36 ++++++++++++++++++++++++
4 files changed, 101 insertions(+), 5 deletions(-)
--
2.34.1