diff options
author | Cristian Marussi <cristian.marussi@arm.com> | 2019-10-25 18:57:07 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2019-11-08 11:10:33 +0000 |
commit | f96bf43403165e4478942b0998931b14621ec207 (patch) | |
tree | 49c7215339ac6585aeb48ff534bf6962e6a6ccde /tools/testing/selftests/arm64/signal/testcases/mangle_pstate_invalid_compat_toggle.c | |
parent | kselftest: arm64: extend toplevel skeleton Makefile (diff) | |
download | linux-dev-f96bf43403165e4478942b0998931b14621ec207.tar.xz linux-dev-f96bf43403165e4478942b0998931b14621ec207.zip |
kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils
Add some arm64/signal specific boilerplate and utility code to help
further testcases' development.
Introduce also one simple testcase mangle_pstate_invalid_compat_toggle
and some related helpers: it is a simple mangle testcase which messes
with the ucontext_t from within the signal handler, trying to toggle
PSTATE state bits to switch the system between 32bit/64bit execution
state. Expects SIGSEGV on test PASS.
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'tools/testing/selftests/arm64/signal/testcases/mangle_pstate_invalid_compat_toggle.c')
-rw-r--r-- | tools/testing/selftests/arm64/signal/testcases/mangle_pstate_invalid_compat_toggle.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/testing/selftests/arm64/signal/testcases/mangle_pstate_invalid_compat_toggle.c b/tools/testing/selftests/arm64/signal/testcases/mangle_pstate_invalid_compat_toggle.c new file mode 100644 index 000000000000..2cb118b0ba05 --- /dev/null +++ b/tools/testing/selftests/arm64/signal/testcases/mangle_pstate_invalid_compat_toggle.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 ARM Limited + * + * Try to mangle the ucontext from inside a signal handler, toggling + * the execution state bit: this attempt must be spotted by Kernel and + * the test case is expected to be terminated via SEGV. + */ + +#include "test_signals_utils.h" +#include "testcases.h" + +static int mangle_invalid_pstate_run(struct tdescr *td, siginfo_t *si, + ucontext_t *uc) +{ + ASSERT_GOOD_CONTEXT(uc); + + /* This config should trigger a SIGSEGV by Kernel */ + uc->uc_mcontext.pstate ^= PSR_MODE32_BIT; + + return 1; +} + +struct tdescr tde = { + .sanity_disabled = true, + .name = "MANGLE_PSTATE_INVALID_STATE_TOGGLE", + .descr = "Mangling uc_mcontext with INVALID STATE_TOGGLE", + .sig_trig = SIGUSR1, + .sig_ok = SIGSEGV, + .run = mangle_invalid_pstate_run, +}; |