* [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
@ 2026-04-13 17:26 ` Marcos Paulo de Souza
2026-04-15 9:58 ` Miroslav Benes
2026-04-13 17:26 ` [PATCH v2 2/6] selftests: livepatch: Replace true/false module parameter by y/n Marcos Paulo de Souza
` (6 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-13 17:26 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 that lack CONFIG_ARCH_HAS_SYSCALL_WRAPPER config don't
have any prefixes for their syscalls. The same applies to current
powerpc and loongarch, covering all currently supported architectures
that support livepatch.
The other supported architectures have specific prefixes, so error out
when a new architecture adds livepatch support with wrappes but didn't
update the test to include it.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
.../selftests/livepatch/test_modules/test_klp_syscall.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 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 dd802783ea84..b5527a288a7c 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,26 @@
#include <linux/slab.h>
#include <linux/livepatch.h>
-#if defined(__x86_64__)
+/*
+ * Before CONFIG_ARCH_HAS_SYSCALL_WRAPPER was introduced there were no
+ * prefixes for system calls.
+ * Both ppc and loongarch does not set prefixes for their system calls either.
+ */
+#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER) || defined(__powerpc__) || \
+ defined(__loongarch__)
+#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 */
+#elif defined(__powerpc__)
+#define FN_PREFIX
+#elif defined(__loongarch__)
#define FN_PREFIX
+#else
+#error "Missing syscall wrapper for the given architecture."
#endif
/* Protects klp_pids */
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config
2026-04-13 17:26 ` [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config Marcos Paulo de Souza
@ 2026-04-15 9:58 ` Miroslav Benes
0 siblings, 0 replies; 11+ messages in thread
From: Miroslav Benes @ 2026-04-15 9:58 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 Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:
> Older kernels that lack CONFIG_ARCH_HAS_SYSCALL_WRAPPER config don't
> have any prefixes for their syscalls. The same applies to current
> powerpc and loongarch, covering all currently supported architectures
> that support livepatch.
>
> The other supported architectures have specific prefixes, so error out
> when a new architecture adds livepatch support with wrappes but didn't
> update the test to include it.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> .../selftests/livepatch/test_modules/test_klp_syscall.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 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 dd802783ea84..b5527a288a7c 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,26 @@
> #include <linux/slab.h>
> #include <linux/livepatch.h>
>
> -#if defined(__x86_64__)
> +/*
> + * Before CONFIG_ARCH_HAS_SYSCALL_WRAPPER was introduced there were no
> + * prefixes for system calls.
> + * Both ppc and loongarch does not set prefixes for their system calls either.
> + */
> +#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER) || defined(__powerpc__) || \
> + defined(__loongarch__)
> +#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 */
> +#elif defined(__powerpc__)
> +#define FN_PREFIX
> +#elif defined(__loongarch__)
> #define FN_PREFIX
> +#else
> +#error "Missing syscall wrapper for the given architecture."
> #endif
I know that Sashiko commented on that already but even with that I wonder
if it was cleaner to structure it differently...
#if defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
#if define(__x86_64__)
...
#elif define(__powerpc__)
#define FN_PREFIX
#else
#error
#endif
#elif
#define FN_PREFIX
#endif
?
I still hope that it will be sufficient and we do not have to introduce
KERNEL_VERSION checks since wrappers changed/will change.
Miroslav
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/6] selftests: livepatch: Replace true/false module parameter by y/n
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config Marcos Paulo de Souza
@ 2026-04-13 17:26 ` Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 3/6] selftests: livepatch: Introduce does_sysfs_exists function Marcos Paulo de Souza
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-13 17:26 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 y/n 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 b67dfad03d97..7ced4082cff3 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=y
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=y
% 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=n
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=n
% 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] 11+ messages in thread* [PATCH v2 3/6] selftests: livepatch: Introduce does_sysfs_exists function
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 2/6] selftests: livepatch: Replace true/false module parameter by y/n Marcos Paulo de Souza
@ 2026-04-13 17:26 ` Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 4/6] selftests: livepatch: Check if patched sysfs attribute exists Marcos Paulo de Souza
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-13 17:26 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 1 if the livepatch sysfs attribute exists, and 0 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 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 8ec0cb64ad94..382596eaaf01 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -339,6 +339,16 @@ function check_result {
fi
}
+# does_sysfs_exists(modname, attr) - check sysfs attribute existence
+# modname - livepatch module creating the sysfs interface
+# attr - attribute name to be checked
+function does_sysfs_exists() {
+ local mod="$1"; shift
+ local attr="$1"; shift
+
+ [[ -f "$SYSFS_KLP_DIR/$mod/$attr" ]]
+}
+
# 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] 11+ messages in thread* [PATCH v2 4/6] selftests: livepatch: Check if patched sysfs attribute exists
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (2 preceding siblings ...)
2026-04-13 17:26 ` [PATCH v2 3/6] selftests: livepatch: Introduce does_sysfs_exists function Marcos Paulo de Souza
@ 2026-04-13 17:26 ` Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 5/6] selftests: livepatch: Check if replace " Marcos Paulo de Souza
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-13 17:26 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, check if given kernel
has support for the attribute. If the attribute is not supported, skip
the checks.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/test-sysfs.sh | 38 +++++++++++++++----------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
index 58fe1d96997c..a2d649404a63 100755
--- a/tools/testing/selftests/livepatch/test-sysfs.sh
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -8,6 +8,8 @@ MOD_LIVEPATCH=test_klp_livepatch
MOD_LIVEPATCH2=test_klp_callbacks_demo
MOD_LIVEPATCH3=test_klp_syscall
+HAS_PATCH_ATTR=0
+
setup_config
# - load a livepatch and verifies the sysfs entries work as expected
@@ -25,8 +27,12 @@ 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--"
-check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
+
+if does_sysfs_exists "$MOD_LIVEPATCH/vmlinux" "patched"; then
+ check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
+ check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
+ HAS_PATCH_ATTR=1
+fi
disable_lp $MOD_LIVEPATCH
@@ -45,23 +51,24 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
-start_test "sysfs test object/patched"
+if [[ "$HAS_PATCH_ATTR" == "1" ]]; then
+ start_test "sysfs test object/patched"
-MOD_LIVEPATCH=test_klp_callbacks_demo
-MOD_TARGET=test_klp_callbacks_mod
-load_lp $MOD_LIVEPATCH
+ 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"
+ # 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
+ disable_lp $MOD_LIVEPATCH
+ unload_lp $MOD_LIVEPATCH
-check_result "% insmod test_modules/test_klp_callbacks_demo.ko
+ 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
@@ -87,6 +94,7 @@ 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"
+fi
start_test "sysfs test replace enabled"
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v2 5/6] selftests: livepatch: Check if replace sysfs attribute exists
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (3 preceding siblings ...)
2026-04-13 17:26 ` [PATCH v2 4/6] selftests: livepatch: Check if patched sysfs attribute exists Marcos Paulo de Souza
@ 2026-04-13 17:26 ` Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 6/6] selftests: livepatch: Check if stack_order " Marcos Paulo de Souza
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-13 17:26 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, check if given kernel
has support for the attribute. If the attribute is not supported, skip
the checks.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/test-sysfs.sh | 39 +++++++++++++++----------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
index a2d649404a63..0cdaeef00983 100755
--- a/tools/testing/selftests/livepatch/test-sysfs.sh
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -9,6 +9,7 @@ MOD_LIVEPATCH2=test_klp_callbacks_demo
MOD_LIVEPATCH3=test_klp_syscall
HAS_PATCH_ATTR=0
+HAS_REPLACE_ATTR=0
setup_config
@@ -22,7 +23,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--"
@@ -34,6 +34,11 @@ if does_sysfs_exists "$MOD_LIVEPATCH/vmlinux" "patched"; then
HAS_PATCH_ATTR=1
fi
+if does_sysfs_exists "$MOD_LIVEPATCH" "replace"; then
+ check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
+ HAS_REPLACE_ATTR=1
+fi
+
disable_lp $MOD_LIVEPATCH
unload_lp $MOD_LIVEPATCH
@@ -96,18 +101,19 @@ livepatch: 'test_klp_callbacks_demo': unpatching complete
% rmmod test_klp_callbacks_demo"
fi
-start_test "sysfs test replace enabled"
+if [[ "$HAS_REPLACE_ATTR" == "1" ]]; then
+ start_test "sysfs test replace enabled"
-MOD_LIVEPATCH=test_klp_atomic_replace
-load_lp $MOD_LIVEPATCH replace=1
+ 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"
+ check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
+ check_sysfs_value "$MOD_LIVEPATCH" "replace" "1"
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
+ disable_lp $MOD_LIVEPATCH
+ unload_lp $MOD_LIVEPATCH
-check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=1
+ 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
@@ -120,17 +126,17 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
-start_test "sysfs test replace disabled"
+ start_test "sysfs test replace disabled"
-load_lp $MOD_LIVEPATCH replace=0
+ load_lp $MOD_LIVEPATCH replace=0
-check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
-check_sysfs_value "$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
+ disable_lp $MOD_LIVEPATCH
+ unload_lp $MOD_LIVEPATCH
-check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=0
+ 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
@@ -142,6 +148,7 @@ livepatch: '$MOD_LIVEPATCH': starting unpatching transition
livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
+fi
start_test "sysfs test stack_order value"
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v2 6/6] selftests: livepatch: Check if stack_order sysfs attribute exists
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (4 preceding siblings ...)
2026-04-13 17:26 ` [PATCH v2 5/6] selftests: livepatch: Check if replace " Marcos Paulo de Souza
@ 2026-04-13 17:26 ` Marcos Paulo de Souza
2026-04-14 12:12 ` [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-04-15 12:01 ` Miroslav Benes
7 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-13 17:26 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, check if given kernel
has support for the attribute. If the attribute is not supported, skip
the checks.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
tools/testing/selftests/livepatch/test-sysfs.sh | 43 ++++++++++++++-----------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
index 0cdaeef00983..77f515529646 100755
--- a/tools/testing/selftests/livepatch/test-sysfs.sh
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -10,6 +10,7 @@ MOD_LIVEPATCH3=test_klp_syscall
HAS_PATCH_ATTR=0
HAS_REPLACE_ATTR=0
+HAS_STACK_ORDER_ATTR=0
setup_config
@@ -23,8 +24,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"
@@ -39,6 +38,12 @@ if does_sysfs_exists "$MOD_LIVEPATCH" "replace"; then
HAS_REPLACE_ATTR=1
fi
+if does_sysfs_exists "$MOD_LIVEPATCH" "stack_order"; then
+ check_sysfs_rights "$MOD_LIVEPATCH" "stack_order" "-r--r--r--"
+ check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
+ HAS_STACK_ORDER_ATTR=1
+fi
+
disable_lp $MOD_LIVEPATCH
unload_lp $MOD_LIVEPATCH
@@ -150,33 +155,34 @@ livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
fi
-start_test "sysfs test stack_order value"
+if [[ "$HAS_STACK_ORDER_ATTR" == "1" ]]; then
+ start_test "sysfs test stack_order value"
-load_lp $MOD_LIVEPATCH
+ load_lp $MOD_LIVEPATCH
-check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
+ check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
-load_lp $MOD_LIVEPATCH2
+ load_lp $MOD_LIVEPATCH2
-check_sysfs_value "$MOD_LIVEPATCH2" "stack_order" "2"
+ check_sysfs_value "$MOD_LIVEPATCH2" "stack_order" "2"
-load_lp $MOD_LIVEPATCH3
+ load_lp $MOD_LIVEPATCH3
-check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "3"
+ check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "3"
-disable_lp $MOD_LIVEPATCH2
-unload_lp $MOD_LIVEPATCH2
+ disable_lp $MOD_LIVEPATCH2
+ unload_lp $MOD_LIVEPATCH2
-check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
-check_sysfs_value "$MOD_LIVEPATCH3" "stack_order" "2"
+ 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_LIVEPATCH3
+ unload_lp $MOD_LIVEPATCH3
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
+ disable_lp $MOD_LIVEPATCH
+ unload_lp $MOD_LIVEPATCH
-check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
+ 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
@@ -216,5 +222,6 @@ livepatch: '$MOD_LIVEPATCH': starting unpatching transition
livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
+fi
exit 0
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (5 preceding siblings ...)
2026-04-13 17:26 ` [PATCH v2 6/6] selftests: livepatch: Check if stack_order " Marcos Paulo de Souza
@ 2026-04-14 12:12 ` Marcos Paulo de Souza
2026-04-15 12:01 ` Miroslav Benes
7 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-14 12:12 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan
Cc: live-patching, linux-kselftest, linux-kernel
On Mon, 2026-04-13 at 14:26 -0300, Marcos Paulo de Souza wrote:
> A new version of the patchset, with fewer patches now. Please take a
> look!
>
> Original cover-letter:
> 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>
I saw some checks made by sashiko, and besides they not being so
horrible, I believe that I should fix me an send a v3 to address them.
But still, feel free to take a look :)
https://sashiko.dev/#/patchset/20260413-lp-tests-old-fixes-v2-0-367c7cb5006f%40suse.com
> ---
> Changes in v2:
> - Patch descriptions were changed to remove "test-X", since it was
> polluting the commit subjects (Miroslav Benes)
> - Patch 8 was dropped since it was checking for a message from an
> out-of-tree patch. (Petr Mladek)
> - Patch 3 was dropped as should be treated as expected failure for
> older kernels. (Petr Mladek)
> - Patch 2 was changed to use y/n instead of 1/0, since it's more
> natural to use it.
> - Patch 1 was changed to handle ppc and loongson, and error out if
> dealing with a different architecture that sets
> CONFIG_ARCH_HAS_SYSCALL_WRAPPER and haven't changed the test to
> include the proper wrapper prefix.
> - Patch 4 was changed to invert the return of the bash function to
> return 1 in failure, like
> a normal bash function (Joe Lawrence)
> - Patches 5, 6 an 7 were changed to not split the tests, but to only
> run the tests
> when the attribute were present (Miroslav Benes)
> - Link to v1:
> https://patch.msgid.link/20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253@suse.com
>
> ---
> Marcos Paulo de Souza (6):
> selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config
> selftests: livepatch: Replace true/false module parameter by
> y/n
> selftests: livepatch: Introduce does_sysfs_exists function
> selftests: livepatch: Check if patched sysfs attribute exists
> selftests: livepatch: Check if replace sysfs attribute exists
> selftests: livepatch: Check if stack_order sysfs attribute
> exists
>
> tools/testing/selftests/livepatch/functions.sh | 10 ++
> tools/testing/selftests/livepatch/test-kprobe.sh | 8 +-
> tools/testing/selftests/livepatch/test-sysfs.sh | 120
> ++++++++++++---------
> .../livepatch/test_modules/test_klp_syscall.c | 17 ++-
> 4 files changed, 99 insertions(+), 56 deletions(-)
> ---
> base-commit: 712c0756828becbfc629ff8d8b82deff5d1115e4
> change-id: 20260309-lp-tests-old-fixes-f955abc8ec27
>
> Best regards,
> --
> Marcos Paulo de Souza <mpdesouza@suse.com>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
` (6 preceding siblings ...)
2026-04-14 12:12 ` [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
@ 2026-04-15 12:01 ` Miroslav Benes
2026-04-15 12:37 ` Marcos Paulo de Souza
7 siblings, 1 reply; 11+ messages in thread
From: Miroslav Benes @ 2026-04-15 12:01 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 Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:
> A new version of the patchset, with fewer patches now. Please take a look!
>
> Original cover-letter:
> 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>
Besides my comment for 1/6 and what Sashiko discovered, it looks good to
me.
However, please also take a look at brand new
test_modules/test_klp_mod_target.c. It does not build on old kernels since
they lack proc_create_single(). I think it should be covered in this patch
set too.
Regards
Miroslav
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
2026-04-15 12:01 ` Miroslav Benes
@ 2026-04-15 12:37 ` Marcos Paulo de Souza
0 siblings, 0 replies; 11+ messages in thread
From: Marcos Paulo de Souza @ 2026-04-15 12:37 UTC (permalink / raw)
To: Miroslav Benes
Cc: Josh Poimboeuf, Jiri Kosina, Petr Mladek, Joe Lawrence,
Shuah Khan, live-patching, linux-kselftest, linux-kernel
On Wed, 2026-04-15 at 14:01 +0200, Miroslav Benes wrote:
> On Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:
>
> > A new version of the patchset, with fewer patches now. Please take
> > a look!
> >
> > Original cover-letter:
> > 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>
>
> Besides my comment for 1/6 and what Sashiko discovered, it looks good
> to
> me.
>
> However, please also take a look at brand new
> test_modules/test_klp_mod_target.c. It does not build on old kernels
> since
> they lack proc_create_single(). I think it should be covered in this
> patch
> set too.
I saw that yesterday as well, but I wanted to merge this series first.
I have plans to create a way to unregister the livepatches if something
fails, so we can continue to run the other tests. I was planning to fix
the test_klp_mod_target.c in the same patchset.
>
> Regards
> Miroslav
^ permalink raw reply [flat|nested] 11+ messages in thread