* [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
@ 2026-03-13 20:58 Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER Marcos Paulo de Souza
` (8 more replies)
0 siblings, 9 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
These patches don't really change how the patches are run, just skip
some tests on kernels that don't support a feature (like kprobe and
livepatched living together) or when a livepatch sysfs attribute is
missing.
The last patch slightly adjusts check_result function to skip dmesg
messages on SLE kernels when a livepatch is removed.
These patches are based on printk/for-next branch.
Please review! Thanks!
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
Marcos Paulo de Souza (8):
selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0
selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches
selftests: livepatch: functions: Introduce check_sysfs_exists
selftests: livepatch: sysfs: Split tests of replace attribute
selftests: livepatch: sysfs: Split tests of stack_order attribute
selftests: livepatch: sysfs: Split tests of patched attribute
selftests: livepatch: functions.sh: Extend check for taint flag kernel message
tools/testing/selftests/livepatch/Makefile | 3 +
tools/testing/selftests/livepatch/functions.sh | 16 +-
tools/testing/selftests/livepatch/test-kprobe.sh | 54 ++++---
.../selftests/livepatch/test-sysfs-patched-attr.sh | 95 ++++++++++++
.../selftests/livepatch/test-sysfs-replace-attr.sh | 75 ++++++++++
.../selftests/livepatch/test-sysfs-stack-attr.sh | 121 +++++++++++++++
tools/testing/selftests/livepatch/test-sysfs.sh | 164 ---------------------
.../livepatch/test_modules/test_klp_syscall.c | 7 +-
8 files changed, 344 insertions(+), 191 deletions(-)
---
base-commit: 920e5001f4beb38685d5b8cac061cb1d2760eeab
change-id: 20260309-lp-tests-old-fixes-f955abc8ec27
Best regards,
--
Marcos Paulo de Souza <mpdesouza@suse.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-16 20:12 ` Joe Lawrence
2026-03-13 20:58 ` [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0 Marcos Paulo de Souza
` (7 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
Instead of checking if the architecture running the test was powerpc,
check if CONF_ARCH_HAS_SYSCALL_WRAPPER is defined or not.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
index dd802783ea849..c01a586866304 100644
--- a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
+++ b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
@@ -12,15 +12,14 @@
#include <linux/slab.h>
#include <linux/livepatch.h>
-#if defined(__x86_64__)
+#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
+#define FN_PREFIX
+#elif defined(__x86_64__)
#define FN_PREFIX __x64_
#elif defined(__s390x__)
#define FN_PREFIX __s390x_
#elif defined(__aarch64__)
#define FN_PREFIX __arm64_
-#else
-/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER */
-#define FN_PREFIX
#endif
/* Protects klp_pids */
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-19 13:03 ` Miroslav Benes
2026-03-13 20:58 ` [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches Marcos Paulo de Souza
` (6 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
Older kernels don't support true/false for boolean module parameters
because they lack commit 0d6ea3ac94ca
("lib/kstrtox.c: add "false"/"true" support to kstrtobool()"). Replace
true/false by 1/0 so the test module can be loaded on older kernels.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/test-kprobe.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/livepatch/test-kprobe.sh b/tools/testing/selftests/livepatch/test-kprobe.sh
index b67dfad03d97f..cdf31d0e51955 100755
--- a/tools/testing/selftests/livepatch/test-kprobe.sh
+++ b/tools/testing/selftests/livepatch/test-kprobe.sh
@@ -20,11 +20,11 @@ start_test "livepatch interaction with kprobed function with post_handler"
echo 1 > "$SYSFS_KPROBES_DIR/enabled"
-load_mod $MOD_KPROBE has_post_handler=true
+load_mod $MOD_KPROBE has_post_handler=1
load_failing_mod $MOD_LIVEPATCH
unload_mod $MOD_KPROBE
-check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=true
+check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=1
% insmod test_modules/$MOD_LIVEPATCH.ko
livepatch: enabling patch '$MOD_LIVEPATCH'
livepatch: '$MOD_LIVEPATCH': initializing patching transition
@@ -39,14 +39,14 @@ insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Device or
start_test "livepatch interaction with kprobed function without post_handler"
-load_mod $MOD_KPROBE has_post_handler=false
+load_mod $MOD_KPROBE has_post_handler=0
load_lp $MOD_LIVEPATCH
unload_mod $MOD_KPROBE
disable_lp $MOD_LIVEPATCH
unload_lp $MOD_LIVEPATCH
-check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=false
+check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=0
% insmod test_modules/$MOD_LIVEPATCH.ko
livepatch: enabling patch '$MOD_LIVEPATCH'
livepatch: '$MOD_LIVEPATCH': initializing patching transition
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0 Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-16 20:38 ` Joe Lawrence
2026-03-13 20:58 ` [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists Marcos Paulo de Souza
` (5 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
Running the upstream selftests on older kernels can presente some issues
regarding features being not present. One of such issues if the missing
capability of having both kprobes and livepatches on the same function.
The support was introduced in commit 0bc11ed5ab60c
("kprobes: Allow kprobes coexist with livepatch"), which means that older
kernels may lack this change.
The lack of this feature can be checked when a kprobe without a
post_handler is loaded and checking that the enabled_function's file
shows the flag "I". A kernel with the proper support for kprobes and
livepatches would presente the flag only when a post_handler is
registered.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/test-kprobe.sh | 52 ++++++++++++++----------
1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/tools/testing/selftests/livepatch/test-kprobe.sh b/tools/testing/selftests/livepatch/test-kprobe.sh
index cdf31d0e51955..44cd16156dbd4 100755
--- a/tools/testing/selftests/livepatch/test-kprobe.sh
+++ b/tools/testing/selftests/livepatch/test-kprobe.sh
@@ -16,30 +16,19 @@ setup_config
# when it uses a post_handler since only one IPMODIFY maybe be registered
# to any given function at a time.
-start_test "livepatch interaction with kprobed function with post_handler"
-
-echo 1 > "$SYSFS_KPROBES_DIR/enabled"
-
-load_mod $MOD_KPROBE has_post_handler=1
-load_failing_mod $MOD_LIVEPATCH
-unload_mod $MOD_KPROBE
-
-check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=1
-% insmod test_modules/$MOD_LIVEPATCH.ko
-livepatch: enabling patch '$MOD_LIVEPATCH'
-livepatch: '$MOD_LIVEPATCH': initializing patching transition
-livepatch: failed to register ftrace handler for function 'cmdline_proc_show' (-16)
-livepatch: failed to patch object 'vmlinux'
-livepatch: failed to enable patch '$MOD_LIVEPATCH'
-livepatch: '$MOD_LIVEPATCH': canceling patching transition, going to unpatch
-livepatch: '$MOD_LIVEPATCH': completing unpatching transition
-livepatch: '$MOD_LIVEPATCH': unpatching complete
-insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Device or resource busy
-% rmmod test_klp_kprobe"
-
start_test "livepatch interaction with kprobed function without post_handler"
load_mod $MOD_KPROBE has_post_handler=0
+
+# Check if commit 0bc11ed5ab60c ("kprobes: Allow kprobes coexist with livepatch")
+# is missing, meaning that livepatches and kprobes can't be used together.
+# When the commit is missing, kprobes always set IPMODIFY (the I flag), even
+# when the post handler is missing.
+if grep --quiet ") R I" "$SYSFS_DEBUG_DIR/tracing/enabled_functions"; then
+ unload_mod $MOD_KPROBE
+ skip "Running kernel doesn't support kprobes along livepatches"
+fi
+
load_lp $MOD_LIVEPATCH
unload_mod $MOD_KPROBE
@@ -61,4 +50,25 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
+start_test "livepatch interaction with kprobed function with post_handler"
+
+echo 1 > "$SYSFS_KPROBES_DIR/enabled"
+
+load_mod $MOD_KPROBE has_post_handler=1
+load_failing_mod $MOD_LIVEPATCH
+unload_mod $MOD_KPROBE
+
+check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=1
+% insmod test_modules/$MOD_LIVEPATCH.ko
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: failed to register ftrace handler for function 'cmdline_proc_show' (-16)
+livepatch: failed to patch object 'vmlinux'
+livepatch: failed to enable patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': canceling patching transition, going to unpatch
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Device or resource busy
+% rmmod test_klp_kprobe"
+
exit 0
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (2 preceding siblings ...)
2026-03-13 20:58 ` [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-16 20:47 ` Joe Lawrence
2026-03-13 20:58 ` [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute Marcos Paulo de Souza
` (4 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
Return 0 if the livepatch sysfs attribute don't exists, and 1 otherwise.
This new function will be used in the next patches.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/functions.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 8ec0cb64ad94a..781346d6e94e0 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -339,6 +339,20 @@ function check_result {
fi
}
+# check_sysfs_exists(modname, attr) - check sysfs attribute existence
+# modname - livepatch module creating the sysfs interface
+# attr - attribute name to be checked
+function check_sysfs_exists() {
+ local mod="$1"; shift
+ local attr="$1"; shift
+
+ if [[ ! -f "$SYSFS_KLP_DIR/$mod/$attr" ]]; then
+ return 0
+ fi
+
+ return 1
+}
+
# check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs
# path permissions
# modname - livepatch module creating the sysfs interface
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (3 preceding siblings ...)
2026-03-13 20:58 ` [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-20 13:03 ` Miroslav Benes
2026-03-20 13:12 ` Petr Mladek
2026-03-13 20:58 ` [PATCH 6/8] selftests: livepatch: sysfs: Split tests of stack_order attribute Marcos Paulo de Souza
` (3 subsequent siblings)
8 siblings, 2 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
In order to run the selftests on older kernels, split the sysfs tests to
another file, making it able to skip the tests when the attributes
don't exists.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/Makefile | 1 +
.../selftests/livepatch/test-sysfs-replace-attr.sh | 75 ++++++++++++++++++++++
tools/testing/selftests/livepatch/test-sysfs.sh | 48 --------------
3 files changed, 76 insertions(+), 48 deletions(-)
diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
index a080eb54a215d..b95aa6e78a273 100644
--- a/tools/testing/selftests/livepatch/Makefile
+++ b/tools/testing/selftests/livepatch/Makefile
@@ -10,6 +10,7 @@ TEST_PROGS := \
test-state.sh \
test-ftrace.sh \
test-sysfs.sh \
+ test-sysfs-replace-attr.sh \
test-syscall.sh \
test-kprobe.sh
diff --git a/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh b/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh
new file mode 100755
index 0000000000000..d1051211fe320
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Song Liu <song@kernel.org>
+
+. $(dirname $0)/functions.sh
+
+MOD_LIVEPATCH=test_klp_livepatch
+
+setup_config
+
+# - load a livepatch and verifies the sysfs replace attribute exists
+
+start_test "check sysfs replace attribute"
+
+load_lp $MOD_LIVEPATCH
+
+check_sysfs_exists "$MOD_LIVEPATCH" "replace"
+file_exists=$?
+
+disable_lp $MOD_LIVEPATCH
+
+unload_lp $MOD_LIVEPATCH
+
+if [[ "$file_exists" == "0" ]]; then
+ skip "sysfs attribute doesn't exists."
+fi
+
+start_test "sysfs test replace enabled"
+
+MOD_LIVEPATCH=test_klp_atomic_replace
+load_lp $MOD_LIVEPATCH replace=1
+
+check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
+check_sysfs_value "$MOD_LIVEPATCH" "replace" "1"
+
+disable_lp $MOD_LIVEPATCH
+unload_lp $MOD_LIVEPATCH
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=1
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: '$MOD_LIVEPATCH': starting patching transition
+livepatch: '$MOD_LIVEPATCH': completing patching transition
+livepatch: '$MOD_LIVEPATCH': patching complete
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
+livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+% rmmod $MOD_LIVEPATCH"
+
+start_test "sysfs test replace disabled"
+
+load_lp $MOD_LIVEPATCH replace=0
+
+check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
+check_sysfs_value "$MOD_LIVEPATCH" "replace" "0"
+
+disable_lp $MOD_LIVEPATCH
+unload_lp $MOD_LIVEPATCH
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=0
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: '$MOD_LIVEPATCH': starting patching transition
+livepatch: '$MOD_LIVEPATCH': completing patching transition
+livepatch: '$MOD_LIVEPATCH': patching complete
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
+livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+% rmmod $MOD_LIVEPATCH"
+
+exit 0
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
index 58fe1d96997cd..0865a7959496a 100755
--- a/tools/testing/selftests/livepatch/test-sysfs.sh
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -20,7 +20,6 @@ check_sysfs_rights "$MOD_LIVEPATCH" "" "drwxr-xr-x"
check_sysfs_rights "$MOD_LIVEPATCH" "enabled" "-rw-r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "enabled" "1"
check_sysfs_rights "$MOD_LIVEPATCH" "force" "--w-------"
-check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
check_sysfs_rights "$MOD_LIVEPATCH" "stack_order" "-r--r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--"
@@ -88,53 +87,6 @@ test_klp_callbacks_demo: post_unpatch_callback: vmlinux
livepatch: 'test_klp_callbacks_demo': unpatching complete
% rmmod test_klp_callbacks_demo"
-start_test "sysfs test replace enabled"
-
-MOD_LIVEPATCH=test_klp_atomic_replace
-load_lp $MOD_LIVEPATCH replace=1
-
-check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
-check_sysfs_value "$MOD_LIVEPATCH" "replace" "1"
-
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
-
-check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=1
-livepatch: enabling patch '$MOD_LIVEPATCH'
-livepatch: '$MOD_LIVEPATCH': initializing patching transition
-livepatch: '$MOD_LIVEPATCH': starting patching transition
-livepatch: '$MOD_LIVEPATCH': completing patching transition
-livepatch: '$MOD_LIVEPATCH': patching complete
-% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
-livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
-livepatch: '$MOD_LIVEPATCH': starting unpatching transition
-livepatch: '$MOD_LIVEPATCH': completing unpatching transition
-livepatch: '$MOD_LIVEPATCH': unpatching complete
-% rmmod $MOD_LIVEPATCH"
-
-start_test "sysfs test replace disabled"
-
-load_lp $MOD_LIVEPATCH replace=0
-
-check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
-check_sysfs_value "$MOD_LIVEPATCH" "replace" "0"
-
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
-
-check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=0
-livepatch: enabling patch '$MOD_LIVEPATCH'
-livepatch: '$MOD_LIVEPATCH': initializing patching transition
-livepatch: '$MOD_LIVEPATCH': starting patching transition
-livepatch: '$MOD_LIVEPATCH': completing patching transition
-livepatch: '$MOD_LIVEPATCH': patching complete
-% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
-livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
-livepatch: '$MOD_LIVEPATCH': starting unpatching transition
-livepatch: '$MOD_LIVEPATCH': completing unpatching transition
-livepatch: '$MOD_LIVEPATCH': unpatching complete
-% rmmod $MOD_LIVEPATCH"
-
start_test "sysfs test stack_order value"
load_lp $MOD_LIVEPATCH
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 6/8] selftests: livepatch: sysfs: Split tests of stack_order attribute
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (4 preceding siblings ...)
2026-03-13 20:58 ` [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 7/8] selftests: livepatch: sysfs: Split tests of patched attribute Marcos Paulo de Souza
` (2 subsequent siblings)
8 siblings, 0 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
In order to run the selftests on older kernels, split the sysfs tests to
another file, making it able to skip the tests when the attributes
don't exists.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/Makefile | 1 +
.../selftests/livepatch/test-sysfs-stack-attr.sh | 121 +++++++++++++++++++++
tools/testing/selftests/livepatch/test-sysfs.sh | 71 ------------
3 files changed, 122 insertions(+), 71 deletions(-)
diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
index b95aa6e78a273..1982056670fc2 100644
--- a/tools/testing/selftests/livepatch/Makefile
+++ b/tools/testing/selftests/livepatch/Makefile
@@ -11,6 +11,7 @@ TEST_PROGS := \
test-ftrace.sh \
test-sysfs.sh \
test-sysfs-replace-attr.sh \
+ test-sysfs-stack-attr.sh \
test-syscall.sh \
test-kprobe.sh
diff --git a/tools/testing/selftests/livepatch/test-sysfs-stack-attr.sh b/tools/testing/selftests/livepatch/test-sysfs-stack-attr.sh
new file mode 100755
index 0000000000000..2b8b72fe1f6dc
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test-sysfs-stack-attr.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Song Liu <song@kernel.org>
+
+. $(dirname $0)/functions.sh
+
+MOD_LIVEPATCH=test_klp_livepatch
+MOD_LIVEPATCH2=test_klp_callbacks_demo
+MOD_LIVEPATCH3=test_klp_syscall
+
+setup_config
+
+# - load a livepatch and verifies the sysfs stack_order attribute exists
+
+start_test "check sysfs stack_order attribute"
+
+load_lp $MOD_LIVEPATCH
+
+check_sysfs_exists "$MOD_LIVEPATCH" "stack_order"
+file_exists=$?
+
+disable_lp $MOD_LIVEPATCH
+
+unload_lp $MOD_LIVEPATCH
+
+if [[ "$file_exists" == "0" ]]; then
+ skip "sysfs attribute doesn't exists."
+fi
+
+start_test "check sysfs stack_order permissions"
+
+load_lp $MOD_LIVEPATCH
+
+check_sysfs_rights "$MOD_LIVEPATCH" "stack_order" "-r--r--r--"
+check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
+
+disable_lp $MOD_LIVEPATCH
+
+unload_lp $MOD_LIVEPATCH
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: '$MOD_LIVEPATCH': starting patching transition
+livepatch: '$MOD_LIVEPATCH': completing patching transition
+livepatch: '$MOD_LIVEPATCH': patching complete
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
+livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+% rmmod $MOD_LIVEPATCH"
+
+start_test "sysfs test stack_order value"
+
+load_lp $MOD_LIVEPATCH
+
+check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
+
+load_lp $MOD_LIVEPATCH2
+
+check_sysfs_value "$MOD_LIVEPATCH2" "stack_order" "2"
+
+load_lp $MOD_LIVEPATCH3
+
+check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "3"
+
+disable_lp $MOD_LIVEPATCH2
+unload_lp $MOD_LIVEPATCH2
+
+check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
+check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "2"
+
+disable_lp $MOD_LIVEPATCH3
+unload_lp $MOD_LIVEPATCH3
+
+disable_lp $MOD_LIVEPATCH
+unload_lp $MOD_LIVEPATCH
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: '$MOD_LIVEPATCH': starting patching transition
+livepatch: '$MOD_LIVEPATCH': completing patching transition
+livepatch: '$MOD_LIVEPATCH': patching complete
+% insmod test_modules/$MOD_LIVEPATCH2.ko
+livepatch: enabling patch '$MOD_LIVEPATCH2'
+livepatch: '$MOD_LIVEPATCH2': initializing patching transition
+$MOD_LIVEPATCH2: pre_patch_callback: vmlinux
+livepatch: '$MOD_LIVEPATCH2': starting patching transition
+livepatch: '$MOD_LIVEPATCH2': completing patching transition
+$MOD_LIVEPATCH2: post_patch_callback: vmlinux
+livepatch: '$MOD_LIVEPATCH2': patching complete
+% insmod test_modules/$MOD_LIVEPATCH3.ko
+livepatch: enabling patch '$MOD_LIVEPATCH3'
+livepatch: '$MOD_LIVEPATCH3': initializing patching transition
+livepatch: '$MOD_LIVEPATCH3': starting patching transition
+livepatch: '$MOD_LIVEPATCH3': completing patching transition
+livepatch: '$MOD_LIVEPATCH3': patching complete
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH2/enabled
+livepatch: '$MOD_LIVEPATCH2': initializing unpatching transition
+$MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux
+livepatch: '$MOD_LIVEPATCH2': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH2': completing unpatching transition
+$MOD_LIVEPATCH2: post_unpatch_callback: vmlinux
+livepatch: '$MOD_LIVEPATCH2': unpatching complete
+% rmmod $MOD_LIVEPATCH2
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH3/enabled
+livepatch: '$MOD_LIVEPATCH3': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH3': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH3': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH3': unpatching complete
+% rmmod $MOD_LIVEPATCH3
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
+livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+% rmmod $MOD_LIVEPATCH"
+
+exit 0
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
index 0865a7959496a..3327bde59e73d 100755
--- a/tools/testing/selftests/livepatch/test-sysfs.sh
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -5,8 +5,6 @@
. $(dirname $0)/functions.sh
MOD_LIVEPATCH=test_klp_livepatch
-MOD_LIVEPATCH2=test_klp_callbacks_demo
-MOD_LIVEPATCH3=test_klp_syscall
setup_config
@@ -20,8 +18,6 @@ check_sysfs_rights "$MOD_LIVEPATCH" "" "drwxr-xr-x"
check_sysfs_rights "$MOD_LIVEPATCH" "enabled" "-rw-r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "enabled" "1"
check_sysfs_rights "$MOD_LIVEPATCH" "force" "--w-------"
-check_sysfs_rights "$MOD_LIVEPATCH" "stack_order" "-r--r--r--"
-check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "transition" "0"
check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
@@ -87,71 +83,4 @@ test_klp_callbacks_demo: post_unpatch_callback: vmlinux
livepatch: 'test_klp_callbacks_demo': unpatching complete
% rmmod test_klp_callbacks_demo"
-start_test "sysfs test stack_order value"
-
-load_lp $MOD_LIVEPATCH
-
-check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
-
-load_lp $MOD_LIVEPATCH2
-
-check_sysfs_value "$MOD_LIVEPATCH2" "stack_order" "2"
-
-load_lp $MOD_LIVEPATCH3
-
-check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "3"
-
-disable_lp $MOD_LIVEPATCH2
-unload_lp $MOD_LIVEPATCH2
-
-check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
-check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "2"
-
-disable_lp $MOD_LIVEPATCH3
-unload_lp $MOD_LIVEPATCH3
-
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
-
-check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
-livepatch: enabling patch '$MOD_LIVEPATCH'
-livepatch: '$MOD_LIVEPATCH': initializing patching transition
-livepatch: '$MOD_LIVEPATCH': starting patching transition
-livepatch: '$MOD_LIVEPATCH': completing patching transition
-livepatch: '$MOD_LIVEPATCH': patching complete
-% insmod test_modules/$MOD_LIVEPATCH2.ko
-livepatch: enabling patch '$MOD_LIVEPATCH2'
-livepatch: '$MOD_LIVEPATCH2': initializing patching transition
-$MOD_LIVEPATCH2: pre_patch_callback: vmlinux
-livepatch: '$MOD_LIVEPATCH2': starting patching transition
-livepatch: '$MOD_LIVEPATCH2': completing patching transition
-$MOD_LIVEPATCH2: post_patch_callback: vmlinux
-livepatch: '$MOD_LIVEPATCH2': patching complete
-% insmod test_modules/$MOD_LIVEPATCH3.ko
-livepatch: enabling patch '$MOD_LIVEPATCH3'
-livepatch: '$MOD_LIVEPATCH3': initializing patching transition
-livepatch: '$MOD_LIVEPATCH3': starting patching transition
-livepatch: '$MOD_LIVEPATCH3': completing patching transition
-livepatch: '$MOD_LIVEPATCH3': patching complete
-% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH2/enabled
-livepatch: '$MOD_LIVEPATCH2': initializing unpatching transition
-$MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux
-livepatch: '$MOD_LIVEPATCH2': starting unpatching transition
-livepatch: '$MOD_LIVEPATCH2': completing unpatching transition
-$MOD_LIVEPATCH2: post_unpatch_callback: vmlinux
-livepatch: '$MOD_LIVEPATCH2': unpatching complete
-% rmmod $MOD_LIVEPATCH2
-% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH3/enabled
-livepatch: '$MOD_LIVEPATCH3': initializing unpatching transition
-livepatch: '$MOD_LIVEPATCH3': starting unpatching transition
-livepatch: '$MOD_LIVEPATCH3': completing unpatching transition
-livepatch: '$MOD_LIVEPATCH3': unpatching complete
-% rmmod $MOD_LIVEPATCH3
-% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
-livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
-livepatch: '$MOD_LIVEPATCH': starting unpatching transition
-livepatch: '$MOD_LIVEPATCH': completing unpatching transition
-livepatch: '$MOD_LIVEPATCH': unpatching complete
-% rmmod $MOD_LIVEPATCH"
-
exit 0
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 7/8] selftests: livepatch: sysfs: Split tests of patched attribute
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (5 preceding siblings ...)
2026-03-13 20:58 ` [PATCH 6/8] selftests: livepatch: sysfs: Split tests of stack_order attribute Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message Marcos Paulo de Souza
2026-03-20 13:31 ` [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Petr Mladek
8 siblings, 0 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
In order to run the selftests on older kernels, split the sysfs tests to
another file, making it able to skip the tests when the attributes
don't exists.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/Makefile | 1 +
.../selftests/livepatch/test-sysfs-patched-attr.sh | 95 ++++++++++++++++++++++
tools/testing/selftests/livepatch/test-sysfs.sh | 45 ----------
3 files changed, 96 insertions(+), 45 deletions(-)
diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
index 1982056670fc2..31ca4669b6ae7 100644
--- a/tools/testing/selftests/livepatch/Makefile
+++ b/tools/testing/selftests/livepatch/Makefile
@@ -12,6 +12,7 @@ TEST_PROGS := \
test-sysfs.sh \
test-sysfs-replace-attr.sh \
test-sysfs-stack-attr.sh \
+ test-sysfs-patched-attr.sh \
test-syscall.sh \
test-kprobe.sh
diff --git a/tools/testing/selftests/livepatch/test-sysfs-patched-attr.sh b/tools/testing/selftests/livepatch/test-sysfs-patched-attr.sh
new file mode 100755
index 0000000000000..2cefd1159fb11
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test-sysfs-patched-attr.sh
@@ -0,0 +1,95 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Song Liu <song@kernel.org>
+
+. $(dirname $0)/functions.sh
+
+MOD_LIVEPATCH=test_klp_livepatch
+
+setup_config
+
+# - load a livepatch and verifies the sysfs patched attribute
+
+start_test "check sysfs patched attribute"
+
+load_lp $MOD_LIVEPATCH
+
+check_sysfs_exists "$MOD_LIVEPATCH" "vmlinux/patched"
+file_exists=$?
+
+disable_lp $MOD_LIVEPATCH
+
+unload_lp $MOD_LIVEPATCH
+
+if [[ "$file_exists" == "0" ]]; then
+ skip "sysfs attribute doesn't exists."
+fi
+
+start_test "check sysfs patched values"
+
+load_lp $MOD_LIVEPATCH
+
+check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
+check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
+
+disable_lp $MOD_LIVEPATCH
+
+unload_lp $MOD_LIVEPATCH
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: '$MOD_LIVEPATCH': starting patching transition
+livepatch: '$MOD_LIVEPATCH': completing patching transition
+livepatch: '$MOD_LIVEPATCH': patching complete
+% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
+livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+% rmmod $MOD_LIVEPATCH"
+
+start_test "sysfs test object/patched"
+
+MOD_LIVEPATCH=test_klp_callbacks_demo
+MOD_TARGET=test_klp_callbacks_mod
+load_lp $MOD_LIVEPATCH
+
+# check the "patch" file changes as target module loads/unloads
+check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
+load_mod $MOD_TARGET
+check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "1"
+unload_mod $MOD_TARGET
+check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
+
+disable_lp $MOD_LIVEPATCH
+unload_lp $MOD_LIVEPATCH
+
+check_result "% insmod test_modules/test_klp_callbacks_demo.ko
+livepatch: enabling patch 'test_klp_callbacks_demo'
+livepatch: 'test_klp_callbacks_demo': initializing patching transition
+test_klp_callbacks_demo: pre_patch_callback: vmlinux
+livepatch: 'test_klp_callbacks_demo': starting patching transition
+livepatch: 'test_klp_callbacks_demo': completing patching transition
+test_klp_callbacks_demo: post_patch_callback: vmlinux
+livepatch: 'test_klp_callbacks_demo': patching complete
+% insmod test_modules/test_klp_callbacks_mod.ko
+livepatch: applying patch 'test_klp_callbacks_demo' to loading module 'test_klp_callbacks_mod'
+test_klp_callbacks_demo: pre_patch_callback: test_klp_callbacks_mod -> [MODULE_STATE_COMING] Full formed, running module_init
+test_klp_callbacks_demo: post_patch_callback: test_klp_callbacks_mod -> [MODULE_STATE_COMING] Full formed, running module_init
+test_klp_callbacks_mod: test_klp_callbacks_mod_init
+% rmmod test_klp_callbacks_mod
+test_klp_callbacks_mod: test_klp_callbacks_mod_exit
+test_klp_callbacks_demo: pre_unpatch_callback: test_klp_callbacks_mod -> [MODULE_STATE_GOING] Going away
+livepatch: reverting patch 'test_klp_callbacks_demo' on unloading module 'test_klp_callbacks_mod'
+test_klp_callbacks_demo: post_unpatch_callback: test_klp_callbacks_mod -> [MODULE_STATE_GOING] Going away
+% echo 0 > $SYSFS_KLP_DIR/test_klp_callbacks_demo/enabled
+livepatch: 'test_klp_callbacks_demo': initializing unpatching transition
+test_klp_callbacks_demo: pre_unpatch_callback: vmlinux
+livepatch: 'test_klp_callbacks_demo': starting unpatching transition
+livepatch: 'test_klp_callbacks_demo': completing unpatching transition
+test_klp_callbacks_demo: post_unpatch_callback: vmlinux
+livepatch: 'test_klp_callbacks_demo': unpatching complete
+% rmmod test_klp_callbacks_demo"
+
+exit 0
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
index 3327bde59e73d..d24c13ad86124 100755
--- a/tools/testing/selftests/livepatch/test-sysfs.sh
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -20,8 +20,6 @@ check_sysfs_value "$MOD_LIVEPATCH" "enabled" "1"
check_sysfs_rights "$MOD_LIVEPATCH" "force" "--w-------"
check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "transition" "0"
-check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
-check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
disable_lp $MOD_LIVEPATCH
@@ -40,47 +38,4 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
-start_test "sysfs test object/patched"
-
-MOD_LIVEPATCH=test_klp_callbacks_demo
-MOD_TARGET=test_klp_callbacks_mod
-load_lp $MOD_LIVEPATCH
-
-# check the "patch" file changes as target module loads/unloads
-check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
-load_mod $MOD_TARGET
-check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "1"
-unload_mod $MOD_TARGET
-check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
-
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
-
-check_result "% insmod test_modules/test_klp_callbacks_demo.ko
-livepatch: enabling patch 'test_klp_callbacks_demo'
-livepatch: 'test_klp_callbacks_demo': initializing patching transition
-test_klp_callbacks_demo: pre_patch_callback: vmlinux
-livepatch: 'test_klp_callbacks_demo': starting patching transition
-livepatch: 'test_klp_callbacks_demo': completing patching transition
-test_klp_callbacks_demo: post_patch_callback: vmlinux
-livepatch: 'test_klp_callbacks_demo': patching complete
-% insmod test_modules/test_klp_callbacks_mod.ko
-livepatch: applying patch 'test_klp_callbacks_demo' to loading module 'test_klp_callbacks_mod'
-test_klp_callbacks_demo: pre_patch_callback: test_klp_callbacks_mod -> [MODULE_STATE_COMING] Full formed, running module_init
-test_klp_callbacks_demo: post_patch_callback: test_klp_callbacks_mod -> [MODULE_STATE_COMING] Full formed, running module_init
-test_klp_callbacks_mod: test_klp_callbacks_mod_init
-% rmmod test_klp_callbacks_mod
-test_klp_callbacks_mod: test_klp_callbacks_mod_exit
-test_klp_callbacks_demo: pre_unpatch_callback: test_klp_callbacks_mod -> [MODULE_STATE_GOING] Going away
-livepatch: reverting patch 'test_klp_callbacks_demo' on unloading module 'test_klp_callbacks_mod'
-test_klp_callbacks_demo: post_unpatch_callback: test_klp_callbacks_mod -> [MODULE_STATE_GOING] Going away
-% echo 0 > $SYSFS_KLP_DIR/test_klp_callbacks_demo/enabled
-livepatch: 'test_klp_callbacks_demo': initializing unpatching transition
-test_klp_callbacks_demo: pre_unpatch_callback: vmlinux
-livepatch: 'test_klp_callbacks_demo': starting unpatching transition
-livepatch: 'test_klp_callbacks_demo': completing unpatching transition
-test_klp_callbacks_demo: post_unpatch_callback: vmlinux
-livepatch: 'test_klp_callbacks_demo': unpatching complete
-% rmmod test_klp_callbacks_demo"
-
exit 0
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (6 preceding siblings ...)
2026-03-13 20:58 ` [PATCH 7/8] selftests: livepatch: sysfs: Split tests of patched attribute Marcos Paulo de Souza
@ 2026-03-13 20:58 ` Marcos Paulo de Souza
2026-03-20 13:04 ` Miroslav Benes
2026-03-20 13:26 ` Petr Mladek
2026-03-20 13:31 ` [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Petr Mladek
8 siblings, 2 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-13 20:58 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel,
Marcos Paulo de Souza
On SLE kernels there is a warning when a livepatch is disabled:
livepatch: attempt to disable live patch test_klp_livepatch, setting
NO_SUPPORT taint flag
Extend lightly the detection of messages when a livepatch is disabled
to cover this case as well.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/functions.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 781346d6e94e0..73a1d4e6acaeb 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -324,7 +324,7 @@ function check_result {
# - filter out dmesg timestamp prefixes
result=$(dmesg | awk -v last_dmesg="$LAST_DMESG" 'p; $0 == last_dmesg { p=1 }' | \
grep -e 'livepatch:' -e 'test_klp' | \
- grep -v '\(tainting\|taints\) kernel' | \
+ grep -v '\(tainting\|taints\|taint\) \(kernel\|flag\)' | \
sed 's/^\[[ 0-9.]*\] //' | \
sed 's/^\[[ ]*[CT][0-9]*\] //')
--
2.52.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-13 20:58 ` [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER Marcos Paulo de Souza
@ 2026-03-16 20:12 ` Joe Lawrence
2026-03-19 12:54 ` Miroslav Benes
2026-03-27 13:16 ` Marcos Paulo de Souza
0 siblings, 2 replies; 29+ messages in thread
From: Joe Lawrence @ 2026-03-16 20:12 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, Mar 13, 2026 at 05:58:32PM -0300, Marcos Paulo de Souza wrote:
> Instead of checking if the architecture running the test was powerpc,
> check if CONF_ARCH_HAS_SYSCALL_WRAPPER is defined or not.
>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> index dd802783ea849..c01a586866304 100644
> --- a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> @@ -12,15 +12,14 @@
> #include <linux/slab.h>
> #include <linux/livepatch.h>
>
> -#if defined(__x86_64__)
> +#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
> +#define FN_PREFIX
> +#elif defined(__x86_64__)
> #define FN_PREFIX __x64_
> #elif defined(__s390x__)
> #define FN_PREFIX __s390x_
> #elif defined(__aarch64__)
> #define FN_PREFIX __arm64_
> -#else
> -/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER */
> -#define FN_PREFIX
The patch does maintain the previous behavior, but I'm wondering if the
original assertion about ARCH_HAS_SYSCALL_WRAPPER on Power was correct:
$ grep ARCH_HAS_SYSCALL_WRAPPER arch/powerpc/Kconfig
select ARCH_HAS_SYSCALL_WRAPPER if !SPU_BASE && !COMPAT
depends on PPC64 && ARCH_HAS_SYSCALL_WRAPPER
Perhaps I just forgot what that additional piece of information that
explains the comment (highly probable these days), and if so, might be
nice to add to this commit since I don't see it in 6a71770442b5
("selftests: livepatch: Test livepatching a heavily called syscall").
Thanks,
--
Joe
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches
2026-03-13 20:58 ` [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches Marcos Paulo de Souza
@ 2026-03-16 20:38 ` Joe Lawrence
2026-03-19 14:35 ` Marcos Paulo de Souza
0 siblings, 1 reply; 29+ messages in thread
From: Joe Lawrence @ 2026-03-16 20:38 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, Mar 13, 2026 at 05:58:34PM -0300, Marcos Paulo de Souza wrote:
> Running the upstream selftests on older kernels can presente some issues
> regarding features being not present. One of such issues if the missing
> capability of having both kprobes and livepatches on the same function.
>
nit picking, but slightly reworded for clarity and spelling:
Running upstream selftests on older kernels can be problematic when
features or fixes from newer versions are not present. For example,
older kernels may lack the capability to support kprobes and livepatches
on the same function simultaneously.
> The support was introduced in commit 0bc11ed5ab60c
> ("kprobes: Allow kprobes coexist with livepatch"), which means that older
> kernels may lack this change.
>
> The lack of this feature can be checked when a kprobe without a
> post_handler is loaded and checking that the enabled_function's file
> shows the flag "I". A kernel with the proper support for kprobes and
> livepatches would presente the flag only when a post_handler is
nit: s/presente/present
> registered.
>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> tools/testing/selftests/livepatch/test-kprobe.sh | 52 ++++++++++++++----------
> 1 file changed, 31 insertions(+), 21 deletions(-)
>
> diff --git a/tools/testing/selftests/livepatch/test-kprobe.sh b/tools/testing/selftests/livepatch/test-kprobe.sh
> index cdf31d0e51955..44cd16156dbd4 100755
> --- a/tools/testing/selftests/livepatch/test-kprobe.sh
> +++ b/tools/testing/selftests/livepatch/test-kprobe.sh
> @@ -16,30 +16,19 @@ setup_config
> # when it uses a post_handler since only one IPMODIFY maybe be registered
> # to any given function at a time.
>
> -start_test "livepatch interaction with kprobed function with post_handler"
> -
> -echo 1 > "$SYSFS_KPROBES_DIR/enabled"
> -
> -load_mod $MOD_KPROBE has_post_handler=1
> -load_failing_mod $MOD_LIVEPATCH
> -unload_mod $MOD_KPROBE
> -
> -check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=1
> -% insmod test_modules/$MOD_LIVEPATCH.ko
> -livepatch: enabling patch '$MOD_LIVEPATCH'
> -livepatch: '$MOD_LIVEPATCH': initializing patching transition
> -livepatch: failed to register ftrace handler for function 'cmdline_proc_show' (-16)
> -livepatch: failed to patch object 'vmlinux'
> -livepatch: failed to enable patch '$MOD_LIVEPATCH'
> -livepatch: '$MOD_LIVEPATCH': canceling patching transition, going to unpatch
> -livepatch: '$MOD_LIVEPATCH': completing unpatching transition
> -livepatch: '$MOD_LIVEPATCH': unpatching complete
> -insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Device or resource busy
> -% rmmod test_klp_kprobe"
> -
> start_test "livepatch interaction with kprobed function without post_handler"
>
> load_mod $MOD_KPROBE has_post_handler=0
> +
> +# Check if commit 0bc11ed5ab60c ("kprobes: Allow kprobes coexist with livepatch")
> +# is missing, meaning that livepatches and kprobes can't be used together.
> +# When the commit is missing, kprobes always set IPMODIFY (the I flag), even
> +# when the post handler is missing.
> +if grep --quiet ") R I" "$SYSFS_DEBUG_DIR/tracing/enabled_functions"; then
Will flags R I always be in this order?
--
Joe
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists
2026-03-13 20:58 ` [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists Marcos Paulo de Souza
@ 2026-03-16 20:47 ` Joe Lawrence
0 siblings, 0 replies; 29+ messages in thread
From: Joe Lawrence @ 2026-03-16 20:47 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, Mar 13, 2026 at 05:58:35PM -0300, Marcos Paulo de Souza wrote:
> Return 0 if the livepatch sysfs attribute don't exists, and 1 otherwise.
> This new function will be used in the next patches.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> tools/testing/selftests/livepatch/functions.sh | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
> index 8ec0cb64ad94a..781346d6e94e0 100644
> --- a/tools/testing/selftests/livepatch/functions.sh
> +++ b/tools/testing/selftests/livepatch/functions.sh
> @@ -339,6 +339,20 @@ function check_result {
> fi
> }
>
> +# check_sysfs_exists(modname, attr) - check sysfs attribute existence
> +# modname - livepatch module creating the sysfs interface
> +# attr - attribute name to be checked
> +function check_sysfs_exists() {
> + local mod="$1"; shift
> + local attr="$1"; shift
> +
> + if [[ ! -f "$SYSFS_KLP_DIR/$mod/$attr" ]]; then
> + return 0
> + fi
> +
> + return 1
> +}
> +
I don't have my shell coding hat on, but a few questions:
1. I thought shell functions usually returned 1 for a failed result and
0 on success?
2. Could this be reduced to (assuming inverting the return as well):
function check_sysfs_exists() {
local mod="$1"; shift
local attr="$1"; shift
[[ -f "$SYSFS_KLP_DIR/$mod/$attr" ]]
}
3. A higher level question, but the other check_* functions will die
"reason" on failure. Would it be better to name this one with
does_sysfs_exist() to indicate that subtle difference? (Or "has" or
some other kind of prefix.)
Regards,
--
Joe
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-16 20:12 ` Joe Lawrence
@ 2026-03-19 12:54 ` Miroslav Benes
2026-03-19 14:11 ` Marcos Paulo de Souza
2026-03-27 13:16 ` Marcos Paulo de Souza
1 sibling, 1 reply; 29+ messages in thread
From: Miroslav Benes @ 2026-03-19 12:54 UTC (permalink / raw)
To: Joe Lawrence
Cc: Marcos Paulo de Souza, Josh Poimboeuf, Jiri Kosina, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Mon, 16 Mar 2026, Joe Lawrence wrote:
> On Fri, Mar 13, 2026 at 05:58:32PM -0300, Marcos Paulo de Souza wrote:
> > Instead of checking if the architecture running the test was powerpc,
> > check if CONF_ARCH_HAS_SYSCALL_WRAPPER is defined or not.
There is a typo...
s/CONF_ARCH_HAS_SYSCALL_WRAPPER/CONFIG_ARCH_HAS_SYSCALL_WRAPPER/
> >
> > No functional changes.
> >
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > ---
> > tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > index dd802783ea849..c01a586866304 100644
> > --- a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > @@ -12,15 +12,14 @@
> > #include <linux/slab.h>
> > #include <linux/livepatch.h>
> >
> > -#if defined(__x86_64__)
> > +#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
> > +#define FN_PREFIX
> > +#elif defined(__x86_64__)
> > #define FN_PREFIX __x64_
> > #elif defined(__s390x__)
> > #define FN_PREFIX __s390x_
> > #elif defined(__aarch64__)
> > #define FN_PREFIX __arm64_
> > -#else
> > -/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER */
> > -#define FN_PREFIX
>
> The patch does maintain the previous behavior, but I'm wondering if the
> original assertion about ARCH_HAS_SYSCALL_WRAPPER on Power was correct:
>
> $ grep ARCH_HAS_SYSCALL_WRAPPER arch/powerpc/Kconfig
> select ARCH_HAS_SYSCALL_WRAPPER if !SPU_BASE && !COMPAT
> depends on PPC64 && ARCH_HAS_SYSCALL_WRAPPER
>
> Perhaps I just forgot what that additional piece of information that
> explains the comment (highly probable these days), and if so, might be
> nice to add to this commit since I don't see it in 6a71770442b5
> ("selftests: livepatch: Test livepatching a heavily called syscall").
I would take a bit further. We would rely on
CONFIG_ARCH_HAS_SYSCALL_WRAPPER being set/unset per listed architectures
"correctly" for us. If it changes somehow (though I cannot imagine reasons
for that but let's say we add new architecture. LoongArch also supports
live patching.), the above might evaluate to something broken.
So I would perhaps prefer to stay with the logic that defines FN_PREFIX
per architecture and has also #else branch for the rest. And more comments
never hurt.
Btw, see also
https://sashiko.dev/#/patchset/20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253%40suse.com
for the Sashiko AI review. It also commented on this patch. Marcos, I
guess that you will look there and I will just omit what Sashiko found in
my review if I spot the same thing.
Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0
2026-03-13 20:58 ` [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0 Marcos Paulo de Souza
@ 2026-03-19 13:03 ` Miroslav Benes
2026-03-19 14:16 ` Marcos Paulo de Souza
0 siblings, 1 reply; 29+ messages in thread
From: Miroslav Benes @ 2026-03-19 13:03 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
A nit but I think that "test-kprobe: " is unnecessary noise in the subject
and can be dropped. It applies to all patches in the series.
On Fri, 13 Mar 2026, Marcos Paulo de Souza wrote:
> Older kernels don't support true/false for boolean module parameters
> because they lack commit 0d6ea3ac94ca
> ("lib/kstrtox.c: add "false"/"true" support to kstrtobool()"). Replace
> true/false by 1/0 so the test module can be loaded on older kernels.
>
> No functional changes.
We also define a bool module parameter in
test_modules/test_klp_callbacks_busy.c. Does it have a similar problem?
Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-19 12:54 ` Miroslav Benes
@ 2026-03-19 14:11 ` Marcos Paulo de Souza
2026-03-20 10:45 ` Miroslav Benes
0 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-19 14:11 UTC (permalink / raw)
To: Miroslav Benes, Joe Lawrence
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Shuah Khan,
live-patching, linux-kselftest, linux-kernel
On Thu, 2026-03-19 at 13:54 +0100, Miroslav Benes wrote:
> On Mon, 16 Mar 2026, Joe Lawrence wrote:
>
> > On Fri, Mar 13, 2026 at 05:58:32PM -0300, Marcos Paulo de Souza
> > wrote:
> > > Instead of checking if the architecture running the test was
> > > powerpc,
> > > check if CONF_ARCH_HAS_SYSCALL_WRAPPER is defined or not.
>
> There is a typo...
> s/CONF_ARCH_HAS_SYSCALL_WRAPPER/CONFIG_ARCH_HAS_SYSCALL_WRAPPER/
Thanks, I'll fix it in my next version.
>
> > >
> > > No functional changes.
> > >
> > > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > > ---
> > > tools/testing/selftests/livepatch/test_modules/test_klp_syscall.
> > > c | 7 +++----
> > > 1 file changed, 3 insertions(+), 4 deletions(-)
> > >
> > > diff --git
> > > a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall
> > > .c
> > > b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall
> > > .c
> > > index dd802783ea849..c01a586866304 100644
> > > ---
> > > a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall
> > > .c
> > > +++
> > > b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall
> > > .c
> > > @@ -12,15 +12,14 @@
> > > #include <linux/slab.h>
> > > #include <linux/livepatch.h>
> > >
> > > -#if defined(__x86_64__)
> > > +#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
> > > +#define FN_PREFIX
> > > +#elif defined(__x86_64__)
> > > #define FN_PREFIX __x64_
> > > #elif defined(__s390x__)
> > > #define FN_PREFIX __s390x_
> > > #elif defined(__aarch64__)
> > > #define FN_PREFIX __arm64_
> > > -#else
> > > -/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER */
> > > -#define FN_PREFIX
> >
> > The patch does maintain the previous behavior, but I'm wondering if
> > the
> > original assertion about ARCH_HAS_SYSCALL_WRAPPER on Power was
> > correct:
> >
> > $ grep ARCH_HAS_SYSCALL_WRAPPER arch/powerpc/Kconfig
> > select ARCH_HAS_SYSCALL_WRAPPER if !SPU_BASE &&
> > !COMPAT
> > depends on PPC64 && ARCH_HAS_SYSCALL_WRAPPER
> >
> > Perhaps I just forgot what that additional piece of information
> > that
> > explains the comment (highly probable these days), and if so, might
> > be
> > nice to add to this commit since I don't see it in 6a71770442b5
> > ("selftests: livepatch: Test livepatching a heavily called
> > syscall").
>
> I would take a bit further. We would rely on
> CONFIG_ARCH_HAS_SYSCALL_WRAPPER being set/unset per listed
> architectures
> "correctly" for us. If it changes somehow (though I cannot imagine
> reasons
> for that but let's say we add new architecture. LoongArch also
> supports
> live patching.), the above might evaluate to something broken.
>
I agree. Given that nobody even complained about it, I would say that
people testing on ppc64le has this defined correctly. Whenever new
archs start supporting livepatching, we can always revisit.
> So I would perhaps prefer to stay with the logic that defines
> FN_PREFIX
> per architecture and has also #else branch for the rest. And more
> comments
> never hurt.
Agreed.
>
> Btw, see also
> https://sashiko.dev/#/patchset/20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253%40suse.com
>
> for the Sashiko AI review. It also commented on this patch. Marcos, I
> guess that you will look there and I will just omit what Sashiko
> found in
> my review if I spot the same thing.
I already checked there. Maybe adding more context to the patch and
code will avoid further confusion about it. Let me add it in the v2.
Thanks for the reviews Miroslav and Joe!
>
> Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0
2026-03-19 13:03 ` Miroslav Benes
@ 2026-03-19 14:16 ` Marcos Paulo de Souza
2026-03-20 11:18 ` Miroslav Benes
0 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-19 14:16 UTC (permalink / raw)
To: Miroslav Benes
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Thu, 2026-03-19 at 14:03 +0100, Miroslav Benes wrote:
> A nit but I think that "test-kprobe: " is unnecessary noise in the
> subject
> and can be dropped. It applies to all patches in the series.
Ok, I'll drop it in the v2.
>
> On Fri, 13 Mar 2026, Marcos Paulo de Souza wrote:
>
> > Older kernels don't support true/false for boolean module
> > parameters
> > because they lack commit 0d6ea3ac94ca
> > ("lib/kstrtox.c: add "false"/"true" support to kstrtobool()").
> > Replace
> > true/false by 1/0 so the test module can be loaded on older
> > kernels.
> >
> > No functional changes.
>
> We also define a bool module parameter in
> test_modules/test_klp_callbacks_busy.c. Does it have a similar
> problem?
No, because n/N was accepted as false already on 4.12 (SLE12-SP5). I'm
not sure about older versions tough.
>
> Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches
2026-03-16 20:38 ` Joe Lawrence
@ 2026-03-19 14:35 ` Marcos Paulo de Souza
2026-03-20 11:33 ` Petr Mladek
0 siblings, 1 reply; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-19 14:35 UTC (permalink / raw)
To: Joe Lawrence
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Mon, 2026-03-16 at 16:38 -0400, Joe Lawrence wrote:
> On Fri, Mar 13, 2026 at 05:58:34PM -0300, Marcos Paulo de Souza
> wrote:
> > Running the upstream selftests on older kernels can presente some
> > issues
> > regarding features being not present. One of such issues if the
> > missing
> > capability of having both kprobes and livepatches on the same
> > function.
> >
>
> nit picking, but slightly reworded for clarity and spelling:
>
> Running upstream selftests on older kernels can be problematic when
> features or fixes from newer versions are not present. For example,
> older kernels may lack the capability to support kprobes and
> livepatches
> on the same function simultaneously.
Much better, I'll pick your description for v2.
>
> > The support was introduced in commit 0bc11ed5ab60c
> > ("kprobes: Allow kprobes coexist with livepatch"), which means that
> > older
> > kernels may lack this change.
> >
> > The lack of this feature can be checked when a kprobe without a
> > post_handler is loaded and checking that the enabled_function's
> > file
> > shows the flag "I". A kernel with the proper support for kprobes
> > and
> > livepatches would presente the flag only when a post_handler is
>
> nit: s/presente/present
Ok.
>
> > registered.
> >
> > No functional changes.
> >
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > ---
> > tools/testing/selftests/livepatch/test-kprobe.sh | 52
> > ++++++++++++++----------
> > 1 file changed, 31 insertions(+), 21 deletions(-)
> >
> > diff --git a/tools/testing/selftests/livepatch/test-kprobe.sh
> > b/tools/testing/selftests/livepatch/test-kprobe.sh
> > index cdf31d0e51955..44cd16156dbd4 100755
> > --- a/tools/testing/selftests/livepatch/test-kprobe.sh
> > +++ b/tools/testing/selftests/livepatch/test-kprobe.sh
> > @@ -16,30 +16,19 @@ setup_config
> > # when it uses a post_handler since only one IPMODIFY maybe be
> > registered
> > # to any given function at a time.
> >
> > -start_test "livepatch interaction with kprobed function with
> > post_handler"
> > -
> > -echo 1 > "$SYSFS_KPROBES_DIR/enabled"
> > -
> > -load_mod $MOD_KPROBE has_post_handler=1
> > -load_failing_mod $MOD_LIVEPATCH
> > -unload_mod $MOD_KPROBE
> > -
> > -check_result "% insmod test_modules/test_klp_kprobe.ko
> > has_post_handler=1
> > -% insmod test_modules/$MOD_LIVEPATCH.ko
> > -livepatch: enabling patch '$MOD_LIVEPATCH'
> > -livepatch: '$MOD_LIVEPATCH': initializing patching transition
> > -livepatch: failed to register ftrace handler for function
> > 'cmdline_proc_show' (-16)
> > -livepatch: failed to patch object 'vmlinux'
> > -livepatch: failed to enable patch '$MOD_LIVEPATCH'
> > -livepatch: '$MOD_LIVEPATCH': canceling patching transition, going
> > to unpatch
> > -livepatch: '$MOD_LIVEPATCH': completing unpatching transition
> > -livepatch: '$MOD_LIVEPATCH': unpatching complete
> > -insmod: ERROR: could not insert module
> > test_modules/$MOD_LIVEPATCH.ko: Device or resource busy
> > -% rmmod test_klp_kprobe"
> > -
> > start_test "livepatch interaction with kprobed function without
> > post_handler"
> >
> > load_mod $MOD_KPROBE has_post_handler=0
> > +
> > +# Check if commit 0bc11ed5ab60c ("kprobes: Allow kprobes coexist
> > with livepatch")
> > +# is missing, meaning that livepatches and kprobes can't be used
> > together.
> > +# When the commit is missing, kprobes always set IPMODIFY (the I
> > flag), even
> > +# when the post handler is missing.
> > +if grep --quiet ") R I"
> > "$SYSFS_DEBUG_DIR/tracing/enabled_functions"; then
>
> Will flags R I always be in this order?
seq_printf(m, " (%ld)%s%s%s%s%s",
ftrace_rec_count(rec),
rec->flags & FTRACE_FL_REGS ? " R" : " ",
rec->flags & FTRACE_FL_IPMODIFY ? " I" : "
",
So this is safe. I'll add a comment in the patch to explain why this is
safe too. Thanks for the comment!
>
> --
> Joe
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-19 14:11 ` Marcos Paulo de Souza
@ 2026-03-20 10:45 ` Miroslav Benes
2026-03-27 13:24 ` Marcos Paulo de Souza
0 siblings, 1 reply; 29+ messages in thread
From: Miroslav Benes @ 2026-03-20 10:45 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Joe Lawrence, Josh Poimboeuf, Jiri Kosina, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
> > So I would perhaps prefer to stay with the logic that defines
> > FN_PREFIX
> > per architecture and has also #else branch for the rest. And more
> > comments
> > never hurt.
>
> Agreed.
Hm, so I thought about a bit more and I very likely misunderstood the
motivation behind the patch. I will speculate and correct me if I am
wrong, please. The idea behind the whole patch set is to make the
selftests run on older kernels which I think is something we should
support. The issue is that old kernels (like mentioned 4.12) do not have
syscall wrappers at all. getpid() syscall is just plain old sys_getpid
there and not the current __x64_sys_getpid on x86. The patch fixes it
by checking CONFIG_ARCH_HAS_SYSCALL_WRAPPER and defining FN_PREFIX
accordingly.
So, if this is correct, I think it should be done differently. We should
have something like syscall_wrapper.h which would define FN_PREFIX for
the supported architectures and different kernel versions since the
wrappers may have changed a couple of times during the history. In that
case there could then be an #else branch which might just error out with
the message to add proper syscall wrapper naming.
The changelog then should explain it because it is not in fact tight to
powerpc.
What do you think? Am I off again?
Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0
2026-03-19 14:16 ` Marcos Paulo de Souza
@ 2026-03-20 11:18 ` Miroslav Benes
0 siblings, 0 replies; 29+ messages in thread
From: Miroslav Benes @ 2026-03-20 11:18 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Thu, 19 Mar 2026, Marcos Paulo de Souza wrote:
> On Thu, 2026-03-19 at 14:03 +0100, Miroslav Benes wrote:
> > A nit but I think that "test-kprobe: " is unnecessary noise in the
> > subject
> > and can be dropped. It applies to all patches in the series.
>
> Ok, I'll drop it in the v2.
>
> >
> > On Fri, 13 Mar 2026, Marcos Paulo de Souza wrote:
> >
> > > Older kernels don't support true/false for boolean module
> > > parameters
> > > because they lack commit 0d6ea3ac94ca
> > > ("lib/kstrtox.c: add "false"/"true" support to kstrtobool()").
> > > Replace
> > > true/false by 1/0 so the test module can be loaded on older
> > > kernels.
> > >
> > > No functional changes.
> >
> > We also define a bool module parameter in
> > test_modules/test_klp_callbacks_busy.c. Does it have a similar
> > problem?
>
> No, because n/N was accepted as false already on 4.12 (SLE12-SP5). I'm
> not sure about older versions tough.
strtobool() (predecessor of kstrtobool()) has it from the beginning and
that is ~2010 which predates the kernel live patching itself so I think we
are good.
Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches
2026-03-19 14:35 ` Marcos Paulo de Souza
@ 2026-03-20 11:33 ` Petr Mladek
2026-03-27 13:43 ` Marcos Paulo de Souza
0 siblings, 1 reply; 29+ messages in thread
From: Petr Mladek @ 2026-03-20 11:33 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Joe Lawrence, Josh Poimboeuf, Jiri Kosina, Miroslav Benes,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Thu 2026-03-19 11:35:16, Marcos Paulo de Souza wrote:
> On Mon, 2026-03-16 at 16:38 -0400, Joe Lawrence wrote:
> > On Fri, Mar 13, 2026 at 05:58:34PM -0300, Marcos Paulo de Souza
> > wrote:
> > > Running the upstream selftests on older kernels can presente some
> > > issues
> > > regarding features being not present. One of such issues if the
> > > missing
> > > capability of having both kprobes and livepatches on the same
> > > function.
> > >
> >
> > nit picking, but slightly reworded for clarity and spelling:
> >
> > Running upstream selftests on older kernels can be problematic when
> > features or fixes from newer versions are not present. For example,
> > older kernels may lack the capability to support kprobes and
> > livepatches
> > on the same function simultaneously.
>
> Much better, I'll pick your description for v2.
>
> >
> > > The support was introduced in commit 0bc11ed5ab60c
> > > ("kprobes: Allow kprobes coexist with livepatch"), which means that
> > > older
> > > kernels may lack this change.
> > >
> > > The lack of this feature can be checked when a kprobe without a
> > > post_handler is loaded and checking that the enabled_function's
> > > file
> > > shows the flag "I". A kernel with the proper support for kprobes
> > > and
> > > livepatches would presente the flag only when a post_handler is
> >
> > nit: s/presente/present
>
> > > --- a/tools/testing/selftests/livepatch/test-kprobe.sh
> > > +++ b/tools/testing/selftests/livepatch/test-kprobe.sh
> > > @@ -16,30 +16,19 @@ setup_config
> > > # when it uses a post_handler since only one IPMODIFY maybe be
> > > registered
> > > # to any given function at a time.
> > >
> > > -start_test "livepatch interaction with kprobed function with
> > > post_handler"
> > > -
> > > -echo 1 > "$SYSFS_KPROBES_DIR/enabled"
> > > -
> > > -load_mod $MOD_KPROBE has_post_handler=1
> > > -load_failing_mod $MOD_LIVEPATCH
> > > -unload_mod $MOD_KPROBE
> > > -
> > > -check_result "% insmod test_modules/test_klp_kprobe.ko
> > > has_post_handler=1
> > > -% insmod test_modules/$MOD_LIVEPATCH.ko
> > > -livepatch: enabling patch '$MOD_LIVEPATCH'
> > > -livepatch: '$MOD_LIVEPATCH': initializing patching transition
> > > -livepatch: failed to register ftrace handler for function
> > > 'cmdline_proc_show' (-16)
> > > -livepatch: failed to patch object 'vmlinux'
> > > -livepatch: failed to enable patch '$MOD_LIVEPATCH'
> > > -livepatch: '$MOD_LIVEPATCH': canceling patching transition, going
> > > to unpatch
> > > -livepatch: '$MOD_LIVEPATCH': completing unpatching transition
> > > -livepatch: '$MOD_LIVEPATCH': unpatching complete
> > > -insmod: ERROR: could not insert module
> > > test_modules/$MOD_LIVEPATCH.ko: Device or resource busy
> > > -% rmmod test_klp_kprobe"
> > > -
> > > start_test "livepatch interaction with kprobed function without
> > > post_handler"
> > >
> > > load_mod $MOD_KPROBE has_post_handler=0
> > > +
> > > +# Check if commit 0bc11ed5ab60c ("kprobes: Allow kprobes coexist
> > > with livepatch")
> > > +# is missing, meaning that livepatches and kprobes can't be used
> > > together.
> > > +# When the commit is missing, kprobes always set IPMODIFY (the I
> > > flag), even
> > > +# when the post handler is missing.
> > > +if grep --quiet ") R I"
> > > "$SYSFS_DEBUG_DIR/tracing/enabled_functions"; then
> >
> > Will flags R I always be in this order?
>
> seq_printf(m, " (%ld)%s%s%s%s%s",
> ftrace_rec_count(rec),
> rec->flags & FTRACE_FL_REGS ? " R" : " ",
> rec->flags & FTRACE_FL_IPMODIFY ? " I" : "
> ",
>
> So this is safe. I'll add a comment in the patch to explain why this is
> safe too. Thanks for the comment!
I would personally check also "cmdline_proc_show" to make sure that
the line is about this function. Something like:
grep --quiet ") "cmdline_proc_show.*([0-9]\+) R"
But I am afraid that this approach is not good. It breaks the test.
It won't longer be able to catch regressions when the kprobe
sets "FTRACE_FL_IPMODIFY" by mistake again.
We could add a version check. But it would break users who backport
the fix into older kernels.
IMHO, the best solution would be to keep the test as is.
Whoever is running the test with older kernels should mark it
as "failure-expected". The test is pointing out an existing problem
in the old kernel. IMHO, it should not hide it.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute
2026-03-13 20:58 ` [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute Marcos Paulo de Souza
@ 2026-03-20 13:03 ` Miroslav Benes
2026-03-20 13:12 ` Petr Mladek
1 sibling, 0 replies; 29+ messages in thread
From: Miroslav Benes @ 2026-03-20 13:03 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, 13 Mar 2026, Marcos Paulo de Souza wrote:
> In order to run the selftests on older kernels, split the sysfs tests to
> another file, making it able to skip the tests when the attributes
> don't exists.
>
> No functional changes.
The functional change is that the test does not run older kernels now so I
would remove the line.
Anyway, I am not entirely happy with carving all three tests out of
test-sysfs.sh to be honest. Wouldn't it be better to just hide them under
"if check_sysfs_exists" condition and keep them here? You could make it
more compact if you check for the sysfs attribute just before checking
both permissions and values the first time it is accessed.
Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message
2026-03-13 20:58 ` [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message Marcos Paulo de Souza
@ 2026-03-20 13:04 ` Miroslav Benes
2026-03-20 13:26 ` Petr Mladek
1 sibling, 0 replies; 29+ messages in thread
From: Miroslav Benes @ 2026-03-20 13:04 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, 13 Mar 2026, Marcos Paulo de Souza wrote:
> On SLE kernels there is a warning when a livepatch is disabled:
> livepatch: attempt to disable live patch test_klp_livepatch, setting
> NO_SUPPORT taint flag
>
> Extend lightly the detection of messages when a livepatch is disabled
> to cover this case as well.
s/lightly/slightly/ ?
Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute
2026-03-13 20:58 ` [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute Marcos Paulo de Souza
2026-03-20 13:03 ` Miroslav Benes
@ 2026-03-20 13:12 ` Petr Mladek
1 sibling, 0 replies; 29+ messages in thread
From: Petr Mladek @ 2026-03-20 13:12 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri 2026-03-13 17:58:36, Marcos Paulo de Souza wrote:
> In order to run the selftests on older kernels, split the sysfs tests to
> another file, making it able to skip the tests when the attributes
> don't exists.
>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> tools/testing/selftests/livepatch/Makefile | 1 +
> .../selftests/livepatch/test-sysfs-replace-attr.sh | 75 ++++++++++++++++++++++
> tools/testing/selftests/livepatch/test-sysfs.sh | 48 --------------
> 3 files changed, 76 insertions(+), 48 deletions(-)
>
> diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
> index a080eb54a215d..b95aa6e78a273 100644
> --- a/tools/testing/selftests/livepatch/Makefile
> +++ b/tools/testing/selftests/livepatch/Makefile
> @@ -10,6 +10,7 @@ TEST_PROGS := \
> test-state.sh \
> test-ftrace.sh \
> test-sysfs.sh \
> + test-sysfs-replace-attr.sh \
> test-syscall.sh \
> test-kprobe.sh
>
> diff --git a/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh b/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh
> new file mode 100755
> index 0000000000000..d1051211fe320
> --- /dev/null
> +++ b/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh
> @@ -0,0 +1,75 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2022 Song Liu <song@kernel.org>
> +
> +. $(dirname $0)/functions.sh
> +
> +MOD_LIVEPATCH=test_klp_livepatch
> +
> +setup_config
> +
> +# - load a livepatch and verifies the sysfs replace attribute exists
> +
> +start_test "check sysfs replace attribute"
> +
> +load_lp $MOD_LIVEPATCH
> +
> +check_sysfs_exists "$MOD_LIVEPATCH" "replace"
> +file_exists=$?
> +
> +disable_lp $MOD_LIVEPATCH
> +
> +unload_lp $MOD_LIVEPATCH
> +
> +if [[ "$file_exists" == "0" ]]; then
> + skip "sysfs attribute doesn't exists."
Nit: I would write "is not supported by this kernel version"
instead of "doesn't exist".
I think that it better describes the situation.
"doesn't exist" sounds more like an error description.
> +fi
This extra code is repeated in 6th and 7th patch as well.
It would be nice to hide it into some helper function
so that we could use here something like:
check_sysfs_attr_or_skip "replace"
or
if has_klp_sysfs_attr "replace" ; then
skip "sysfs \"replace\" attribute is not supported"
fi
Best Regards,
Petr
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message
2026-03-13 20:58 ` [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message Marcos Paulo de Souza
2026-03-20 13:04 ` Miroslav Benes
@ 2026-03-20 13:26 ` Petr Mladek
2026-03-20 13:41 ` Marcos Paulo de Souza
1 sibling, 1 reply; 29+ messages in thread
From: Petr Mladek @ 2026-03-20 13:26 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri 2026-03-13 17:58:39, Marcos Paulo de Souza wrote:
> On SLE kernels there is a warning when a livepatch is disabled:
> livepatch: attempt to disable live patch test_klp_livepatch, setting
> NO_SUPPORT taint flag
>
> Extend lightly the detection of messages when a livepatch is disabled
> to cover this case as well.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> tools/testing/selftests/livepatch/functions.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
> index 781346d6e94e0..73a1d4e6acaeb 100644
> --- a/tools/testing/selftests/livepatch/functions.sh
> +++ b/tools/testing/selftests/livepatch/functions.sh
> @@ -324,7 +324,7 @@ function check_result {
> # - filter out dmesg timestamp prefixes
> result=$(dmesg | awk -v last_dmesg="$LAST_DMESG" 'p; $0 == last_dmesg { p=1 }' | \
> grep -e 'livepatch:' -e 'test_klp' | \
> - grep -v '\(tainting\|taints\) kernel' | \
> + grep -v '\(tainting\|taints\|taint\) \(kernel\|flag\)' | \
> sed 's/^\[[ 0-9.]*\] //' | \
> sed 's/^\[[ ]*[CT][0-9]*\] //')
With the upstream maintainer hat on:
I am afraid that we could not take this. It is needed only because
of another out-of-tree patch. It does not describe the upstream
behavior. It might even hide problems.
We should maintain a SUSE-specific patch against the selftests
as a counter-part for the patch adding the tainting.
Or we could try to upstream the patch which adds the tainting.
Well, we might want to limit the tainting only to livepatches
with callbacks or shadow variables. IMHO, only these features
are source of potential problems.
Best Rerards,
Petr
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (7 preceding siblings ...)
2026-03-13 20:58 ` [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message Marcos Paulo de Souza
@ 2026-03-20 13:31 ` Petr Mladek
8 siblings, 0 replies; 29+ messages in thread
From: Petr Mladek @ 2026-03-20 13:31 UTC (permalink / raw)
To: Marcos Paulo de Souza
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri 2026-03-13 17:58:31, Marcos Paulo de Souza wrote:
> These patches don't really change how the patches are run, just skip
> some tests on kernels that don't support a feature (like kprobe and
> livepatched living together) or when a livepatch sysfs attribute is
> missing.
>
> The last patch slightly adjusts check_result function to skip dmesg
> messages on SLE kernels when a livepatch is removed.
>
> These patches are based on printk/for-next branch.
>
> Please review! Thanks!
JFYI, I am suprised how good was the review made by the Sashiko AI, see
https://sashiko.dev/#/patchset/20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253%40suse.com
It pointed out many problems mentioned in the human review.
IMHO, it was also able to explain them very well.
Well, it missed some higher level views.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message
2026-03-20 13:26 ` Petr Mladek
@ 2026-03-20 13:41 ` Marcos Paulo de Souza
0 siblings, 0 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-20 13:41 UTC (permalink / raw)
To: Petr Mladek
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, 2026-03-20 at 14:26 +0100, Petr Mladek wrote:
> On Fri 2026-03-13 17:58:39, Marcos Paulo de Souza wrote:
> > On SLE kernels there is a warning when a livepatch is disabled:
> > livepatch: attempt to disable live patch test_klp_livepatch,
> > setting
> > NO_SUPPORT taint flag
> >
> > Extend lightly the detection of messages when a livepatch is
> > disabled
> > to cover this case as well.
> >
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > ---
> > tools/testing/selftests/livepatch/functions.sh | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/livepatch/functions.sh
> > b/tools/testing/selftests/livepatch/functions.sh
> > index 781346d6e94e0..73a1d4e6acaeb 100644
> > --- a/tools/testing/selftests/livepatch/functions.sh
> > +++ b/tools/testing/selftests/livepatch/functions.sh
> > @@ -324,7 +324,7 @@ function check_result {
> > # - filter out dmesg timestamp prefixes
> > result=$(dmesg | awk -v last_dmesg="$LAST_DMESG" 'p; $0 ==
> > last_dmesg { p=1 }' | \
> > grep -e 'livepatch:' -e 'test_klp' | \
> > - grep -v '\(tainting\|taints\) kernel' | \
> > + grep -v '\(tainting\|taints\|taint\)
> > \(kernel\|flag\)' | \
> > sed 's/^\[[ 0-9.]*\] //' | \
> > sed 's/^\[[ ]*[CT][0-9]*\] //')
>
> With the upstream maintainer hat on:
>
> I am afraid that we could not take this. It is needed only because
> of another out-of-tree patch. It does not describe the upstream
> behavior. It might even hide problems.
>
> We should maintain a SUSE-specific patch against the selftests
> as a counter-part for the patch adding the tainting.
>
> Or we could try to upstream the patch which adds the tainting.
> Well, we might want to limit the tainting only to livepatches
> with callbacks or shadow variables. IMHO, only these features
> are source of potential problems.
TBH I wasn't expecting this patch to be merged, but I send it anyway
since the change wasn't big. But I agree, we can drop this one from the
patchset.
>
> Best Rerards,
> Petr
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-16 20:12 ` Joe Lawrence
2026-03-19 12:54 ` Miroslav Benes
@ 2026-03-27 13:16 ` Marcos Paulo de Souza
1 sibling, 0 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-27 13:16 UTC (permalink / raw)
To: Joe Lawrence
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Mon, 2026-03-16 at 16:12 -0400, Joe Lawrence wrote:
> On Fri, Mar 13, 2026 at 05:58:32PM -0300, Marcos Paulo de Souza
> wrote:
> > Instead of checking if the architecture running the test was
> > powerpc,
> > check if CONF_ARCH_HAS_SYSCALL_WRAPPER is defined or not.
> >
> > No functional changes.
> >
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > ---
> > tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git
> > a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > index dd802783ea849..c01a586866304 100644
> > ---
> > a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > +++
> > b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > @@ -12,15 +12,14 @@
> > #include <linux/slab.h>
> > #include <linux/livepatch.h>
> >
> > -#if defined(__x86_64__)
> > +#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
> > +#define FN_PREFIX
> > +#elif defined(__x86_64__)
> > #define FN_PREFIX __x64_
> > #elif defined(__s390x__)
> > #define FN_PREFIX __s390x_
> > #elif defined(__aarch64__)
> > #define FN_PREFIX __arm64_
> > -#else
> > -/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER */
> > -#define FN_PREFIX
>
> The patch does maintain the previous behavior, but I'm wondering if
> the
> original assertion about ARCH_HAS_SYSCALL_WRAPPER on Power was
> correct:
>
> $ grep ARCH_HAS_SYSCALL_WRAPPER arch/powerpc/Kconfig
> select ARCH_HAS_SYSCALL_WRAPPER if !SPU_BASE &&
> !COMPAT
> depends on PPC64 && ARCH_HAS_SYSCALL_WRAPPER
>
> Perhaps I just forgot what that additional piece of information that
> explains the comment (highly probable these days), and if so, might
> be
> nice to add to this commit since I don't see it in 6a71770442b5
> ("selftests: livepatch: Test livepatching a heavily called syscall").
Sorry for the late reply...
Well, so far the test always run fine for us, so I never looked why ppc
didn't have ARCH_HAS_SYSCALL_WRAPPER TBH... I can add some information
about it, sure.
>
> Thanks,
> --
> Joe
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER
2026-03-20 10:45 ` Miroslav Benes
@ 2026-03-27 13:24 ` Marcos Paulo de Souza
0 siblings, 0 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-27 13:24 UTC (permalink / raw)
To: Miroslav Benes
Cc: Joe Lawrence, Josh Poimboeuf, Jiri Kosina, Petr Mladek,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, 2026-03-20 at 11:45 +0100, Miroslav Benes wrote:
> > > So I would perhaps prefer to stay with the logic that defines
> > > FN_PREFIX
> > > per architecture and has also #else branch for the rest. And more
> > > comments
> > > never hurt.
> >
> > Agreed.
>
> Hm, so I thought about a bit more and I very likely misunderstood the
> motivation behind the patch. I will speculate and correct me if I am
> wrong, please. The idea behind the whole patch set is to make the
> selftests run on older kernels which I think is something we should
> support. The issue is that old kernels (like mentioned 4.12) do not
> have
> syscall wrappers at all. getpid() syscall is just plain old
> sys_getpid
> there and not the current __x64_sys_getpid on x86. The patch fixes it
> by checking CONFIG_ARCH_HAS_SYSCALL_WRAPPER and defining FN_PREFIX
> accordingly.
Exactly. The definition was added on
commit 1bd21c6c21e848996339508d3ffb106d505256a8
Author: Dominik Brodowski <linux@dominikbrodowski.net>
Date: Thu Apr 5 11:53:01 2018 +0200
syscalls/core: Introduce CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y
>
> So, if this is correct, I think it should be done differently. We
> should
> have something like syscall_wrapper.h which would define FN_PREFIX
> for
> the supported architectures and different kernel versions since the
> wrappers may have changed a couple of times during the history. In
> that
> case there could then be an #else branch which might just error out
> with
> the message to add proper syscall wrapper naming.
Well, it seems too much for a simple test to me, but I can do that, no
problem.
>
> The changelog then should explain it because it is not in fact tight
> to
> powerpc.
Makes sense, I'll change it.
>
> What do you think? Am I off again?
I agree with everything, but adding another header file seems a little
too much work for a simple test case, but it's doable. Let me work on
it.
>
> Miroslav
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches
2026-03-20 11:33 ` Petr Mladek
@ 2026-03-27 13:43 ` Marcos Paulo de Souza
0 siblings, 0 replies; 29+ messages in thread
From: Marcos Paulo de Souza @ 2026-03-27 13:43 UTC (permalink / raw)
To: Petr Mladek
Cc: Joe Lawrence, Josh Poimboeuf, Jiri Kosina, Miroslav Benes,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Fri, 2026-03-20 at 12:33 +0100, Petr Mladek wrote:
> On Thu 2026-03-19 11:35:16, Marcos Paulo de Souza wrote:
> > On Mon, 2026-03-16 at 16:38 -0400, Joe Lawrence wrote:
> > > On Fri, Mar 13, 2026 at 05:58:34PM -0300, Marcos Paulo de Souza
> > > wrote:
> > > > Running the upstream selftests on older kernels can presente
> > > > some
> > > > issues
> > > > regarding features being not present. One of such issues if the
> > > > missing
> > > > capability of having both kprobes and livepatches on the same
> > > > function.
> > > >
> > >
> > > nit picking, but slightly reworded for clarity and spelling:
> > >
> > > Running upstream selftests on older kernels can be problematic
> > > when
> > > features or fixes from newer versions are not present. For
> > > example,
> > > older kernels may lack the capability to support kprobes and
> > > livepatches
> > > on the same function simultaneously.
> >
> > Much better, I'll pick your description for v2.
> >
> > >
> > > > The support was introduced in commit 0bc11ed5ab60c
> > > > ("kprobes: Allow kprobes coexist with livepatch"), which means
> > > > that
> > > > older
> > > > kernels may lack this change.
> > > >
> > > > The lack of this feature can be checked when a kprobe without a
> > > > post_handler is loaded and checking that the enabled_function's
> > > > file
> > > > shows the flag "I". A kernel with the proper support for
> > > > kprobes
> > > > and
> > > > livepatches would presente the flag only when a post_handler is
> > >
> > > nit: s/presente/present
> >
> > > > --- a/tools/testing/selftests/livepatch/test-kprobe.sh
> > > > +++ b/tools/testing/selftests/livepatch/test-kprobe.sh
> > > > @@ -16,30 +16,19 @@ setup_config
> > > > # when it uses a post_handler since only one IPMODIFY maybe be
> > > > registered
> > > > # to any given function at a time.
> > > >
> > > > -start_test "livepatch interaction with kprobed function with
> > > > post_handler"
> > > > -
> > > > -echo 1 > "$SYSFS_KPROBES_DIR/enabled"
> > > > -
> > > > -load_mod $MOD_KPROBE has_post_handler=1
> > > > -load_failing_mod $MOD_LIVEPATCH
> > > > -unload_mod $MOD_KPROBE
> > > > -
> > > > -check_result "% insmod test_modules/test_klp_kprobe.ko
> > > > has_post_handler=1
> > > > -% insmod test_modules/$MOD_LIVEPATCH.ko
> > > > -livepatch: enabling patch '$MOD_LIVEPATCH'
> > > > -livepatch: '$MOD_LIVEPATCH': initializing patching transition
> > > > -livepatch: failed to register ftrace handler for function
> > > > 'cmdline_proc_show' (-16)
> > > > -livepatch: failed to patch object 'vmlinux'
> > > > -livepatch: failed to enable patch '$MOD_LIVEPATCH'
> > > > -livepatch: '$MOD_LIVEPATCH': canceling patching transition,
> > > > going
> > > > to unpatch
> > > > -livepatch: '$MOD_LIVEPATCH': completing unpatching transition
> > > > -livepatch: '$MOD_LIVEPATCH': unpatching complete
> > > > -insmod: ERROR: could not insert module
> > > > test_modules/$MOD_LIVEPATCH.ko: Device or resource busy
> > > > -% rmmod test_klp_kprobe"
> > > > -
> > > > start_test "livepatch interaction with kprobed function
> > > > without
> > > > post_handler"
> > > >
> > > > load_mod $MOD_KPROBE has_post_handler=0
> > > > +
> > > > +# Check if commit 0bc11ed5ab60c ("kprobes: Allow kprobes
> > > > coexist
> > > > with livepatch")
> > > > +# is missing, meaning that livepatches and kprobes can't be
> > > > used
> > > > together.
> > > > +# When the commit is missing, kprobes always set IPMODIFY (the
> > > > I
> > > > flag), even
> > > > +# when the post handler is missing.
> > > > +if grep --quiet ") R I"
> > > > "$SYSFS_DEBUG_DIR/tracing/enabled_functions"; then
> > >
> > > Will flags R I always be in this order?
> >
> > seq_printf(m, " (%ld)%s%s%s%s%s",
> > ftrace_rec_count(rec),
> > rec->flags & FTRACE_FL_REGS ? " R" : "
> > ",
> > rec->flags & FTRACE_FL_IPMODIFY ? " I"
> > : "
> > ",
> >
> > So this is safe. I'll add a comment in the patch to explain why
> > this is
> > safe too. Thanks for the comment!
>
> I would personally check also "cmdline_proc_show" to make sure that
> the line is about this function. Something like:
>
> grep --quiet ") "cmdline_proc_show.*([0-9]\+) R"
>
>
> But I am afraid that this approach is not good. It breaks the test.
> It won't longer be able to catch regressions when the kprobe
> sets "FTRACE_FL_IPMODIFY" by mistake again.
>
> We could add a version check. But it would break users who backport
> the fix into older kernels.
>
> IMHO, the best solution would be to keep the test as is.
> Whoever is running the test with older kernels should mark it
> as "failure-expected". The test is pointing out an existing problem
> in the old kernel. IMHO, it should not hide it.
Makes sense, thanks for your review Petr. I'll drop this patch from v2.
>
> Best Regards,
> Petr
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2026-03-27 13:43 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER Marcos Paulo de Souza
2026-03-16 20:12 ` Joe Lawrence
2026-03-19 12:54 ` Miroslav Benes
2026-03-19 14:11 ` Marcos Paulo de Souza
2026-03-20 10:45 ` Miroslav Benes
2026-03-27 13:24 ` Marcos Paulo de Souza
2026-03-27 13:16 ` Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0 Marcos Paulo de Souza
2026-03-19 13:03 ` Miroslav Benes
2026-03-19 14:16 ` Marcos Paulo de Souza
2026-03-20 11:18 ` Miroslav Benes
2026-03-13 20:58 ` [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches Marcos Paulo de Souza
2026-03-16 20:38 ` Joe Lawrence
2026-03-19 14:35 ` Marcos Paulo de Souza
2026-03-20 11:33 ` Petr Mladek
2026-03-27 13:43 ` Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists Marcos Paulo de Souza
2026-03-16 20:47 ` Joe Lawrence
2026-03-13 20:58 ` [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute Marcos Paulo de Souza
2026-03-20 13:03 ` Miroslav Benes
2026-03-20 13:12 ` Petr Mladek
2026-03-13 20:58 ` [PATCH 6/8] selftests: livepatch: sysfs: Split tests of stack_order attribute Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 7/8] selftests: livepatch: sysfs: Split tests of patched attribute Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message Marcos Paulo de Souza
2026-03-20 13:04 ` Miroslav Benes
2026-03-20 13:26 ` Petr Mladek
2026-03-20 13:41 ` Marcos Paulo de Souza
2026-03-20 13:31 ` [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox