selftests/rseq: add rseq syscall errors test
Subsystems (2)
PATCH 1/1 selftests/rseq: add rseq syscall errors test
This test adds coverage of expected errors during rseq registration and unregistration, it disables glibc integration and will thus always exercise the rseq syscall explictly.
Signed-off-by Michael Jeanson <[email protected]>
Reviewed-by Mathieu Desnoyers <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Shuah Khan <[email protected]>
--- tools/testing/selftests/rseq/.gitignore | 1 + tools/testing/selftests/rseq/Makefile | 9 +- tools/testing/selftests/rseq/rseq.c | 6 +- tools/testing/selftests/rseq/rseq.h | 5 + .../selftests/rseq/run_syscall_errors_test.sh | 5 + .../selftests/rseq/syscall_errors_test.c | 124 ++++++++++++++++++ 6 files changed, 145 insertions(+), 5 deletions(-) create mode 100755 tools/testing/selftests/rseq/run_syscall_errors_test.sh create mode 100644 tools/testing/selftests/rseq/syscall_errors_test.c
tools/testing/selftests/rseq/.gitignore +1 -0
@@ -9,3 +9,4 @@ param_test_compare_twice param_test_mm_cid param_test_mm_cid_benchmark param_test_mm_cid_compare_twice +syscall_errors_test
tools/testing/selftests/rseq/Makefile +7 -2
@@ -16,11 +16,12 @@ OVERRIDE_TARGETS = 1 TEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \ param_test_benchmark param_test_compare_twice param_test_mm_cid \ - param_test_mm_cid_benchmark param_test_mm_cid_compare_twice + param_test_mm_cid_benchmark param_test_mm_cid_compare_twice \ + syscall_errors_test TEST_GEN_PROGS_EXTENDED = librseq.so -TEST_PROGS = run_param_test.sh +TEST_PROGS = run_param_test.sh run_syscall_errors_test.sh TEST_FILES := settings
@@ -54,3 +55,7 @@ $(OUTPUT)/param_test_mm_cid_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ $(OUTPUT)/param_test_mm_cid_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ rseq.h rseq-*.h $(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@ + +$(OUTPUT)/syscall_errors_test: syscall_errors_test.c $(TEST_GEN_PROGS_EXTENDED) \ + rseq.h rseq-*.h + $(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
tools/testing/selftests/rseq/rseq.c +3 -3
@@ -88,7 +88,7 @@ static int sys_getcpu(unsigned *cpu, unsigned *node)return syscall (__NR_getcpu, cpu, node,NULL ); } -int rseq_available (void ) +bool rseq_available (void ) {int rc;
@@ -97,9 +97,9 @@ int rseq_available(void)abort ();switch (errno) {case ENOSYS : -return 0 ; +return false;case EINVAL : -return 1 ; +return true;default :abort (); }
tools/testing/selftests/rseq/rseq.h +5 -0
@@ -150,6 +150,11 @@ int32_t rseq_fallback_current_cpu(void);*/ int32_t rseq_fallback_current_node (void ); +/* +* Returns true if rseq is supported. +*/ +bool rseq_available (void ); +/* * Values returned can be either the current CPU number, -1 (rseq is * uninitialized), or -2 (rseq initialization has failed).
tools/testing/selftests/rseq/run_syscall_errors_test.sh new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2024 Michael Jeanson <[email protected]> + +GLIBC_TUNABLES="${GLIBC_TUNABLES:-}:glibc.pthread.rseq=0" ./syscall_errors_test
tools/testing/selftests/rseq/syscall_errors_test.c new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
2.43.0
[tip: sched/core] selftests/rseq: Add rseq syscall errors test
The following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 3c27b40830cad0917c92fecf0c9cb1ec41de17cc Gitweb: https://git.kernel.org/tip/3c27b40830cad0917c92fecf0c9cb1ec41de17cc Author: Michael Jeanson <[email protected]> AuthorDate: Tue, 21 Jan 2025 16:33:52 -05:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 22 Feb 2025 14:13:45 +01:00
selftests/rseq: Add rseq syscall errors test
This test adds coverage of expected errors during rseq registration and unregistration, it disables glibc integration and will thus always exercise the rseq syscall explictly.
Signed-off-by Michael Jeanson <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
Reviewed-by Mathieu Desnoyers <[email protected]>
Cc Shuah Khan <[email protected]>
--- tools/testing/selftests/rseq/.gitignore | 1 +- tools/testing/selftests/rseq/Makefile | 9 +- tools/testing/selftests/rseq/rseq.c | 6 +- tools/testing/selftests/rseq/rseq.h | 5 +- tools/testing/selftests/rseq/run_syscall_errors_test.sh | 5 +- tools/testing/selftests/rseq/syscall_errors_test.c | 124 +++++++- 6 files changed, 145 insertions(+), 5 deletions(-) create mode 100755 tools/testing/selftests/rseq/run_syscall_errors_test.sh create mode 100644 tools/testing/selftests/rseq/syscall_errors_test.c
tools/testing/selftests/rseq/.gitignore +1 -0
@@ -9,3 +9,4 @@ param_test_compare_twice param_test_mm_cid param_test_mm_cid_benchmark param_test_mm_cid_compare_twice +syscall_errors_test
tools/testing/selftests/rseq/Makefile +7 -2
@@ -16,11 +16,12 @@ OVERRIDE_TARGETS = 1 TEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \ param_test_benchmark param_test_compare_twice param_test_mm_cid \ - param_test_mm_cid_benchmark param_test_mm_cid_compare_twice + param_test_mm_cid_benchmark param_test_mm_cid_compare_twice \ + syscall_errors_test TEST_GEN_PROGS_EXTENDED = librseq.so -TEST_PROGS = run_param_test.sh +TEST_PROGS = run_param_test.sh run_syscall_errors_test.sh TEST_FILES := settings
@@ -54,3 +55,7 @@ $(OUTPUT)/param_test_mm_cid_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ $(OUTPUT)/param_test_mm_cid_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ rseq.h rseq-*.h $(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@ + +$(OUTPUT)/syscall_errors_test: syscall_errors_test.c $(TEST_GEN_PROGS_EXTENDED) \ + rseq.h rseq-*.h + $(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
tools/testing/selftests/rseq/rseq.c +3 -3
@@ -87,7 +87,7 @@ static int sys_getcpu(unsigned *cpu, unsigned *node)return syscall (__NR_getcpu, cpu, node,NULL ); } -int rseq_available (void ) +bool rseq_available (void ) {int rc;
@@ -96,9 +96,9 @@ int rseq_available(void)abort ();switch (errno) {case ENOSYS : -return 0 ; +return false;case EINVAL : -return 1 ; +return true;default :abort (); }
tools/testing/selftests/rseq/rseq.h +5 -0
@@ -160,6 +160,11 @@ int32_t rseq_fallback_current_cpu(void);int32_t rseq_fallback_current_node (void );/* +* Returns true if rseq is supported. +*/ +bool rseq_available (void ); + +/* * Values returned can be either the current CPU number, -1 (rseq is * uninitialized), or -2 (rseq initialization has failed). */
tools/testing/selftests/rseq/run_syscall_errors_test.sh new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2024 Michael Jeanson <[email protected]> + +GLIBC_TUNABLES="${GLIBC_TUNABLES:-}:glibc.pthread.rseq=0" ./syscall_errors_test
tools/testing/selftests/rseq/syscall_errors_test.c new file +124 -0
124 lines not on this page · raw message