Skip to content

selftests/x86: Improve signal test code

Chang S. Bae linux-kselftest lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4selftests/x86: Fix the altstack freetools/testing/selftests/x86/mov_ss_trap.c tools/testing/selftests/x86/single_step_syscall.c+20 -140 replies
2/4selftests/x86/mov_ss_trap: Include processor-flags.htools/testing/selftests/x86/mov_ss_trap.c+1 -20 replies
3/4selftests/x86: Consolidate signal handler helperstools/testing/selftests/x86/Makefile tools/testing/selftests/x86/amx.c tools/testing/selftests/x86/corrupt_xstate_header.c +17 more+72 -3310 replies
4/4selftests/x86: Refactor altstack setup codetools/testing/selftests/x86/amx.c tools/testing/selftests/x86/helpers.c tools/testing/selftests/x86/helpers.h +5 more+130 -800 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/4] selftests/x86: Improve signal test code

Hi all,

This is a cleanup series to consolidate a common signal setup code. Right now quite a bit of duplicated code is there in an unorganized way. Here is a rework of that signal-related code:

(1) Consolidate the signal handler helpers

They have been exactly copied everywhere. Place them in the shared code. Then, remove those duplicates.

(2) Simplify altstack code

Most cases require just a usable alternate stack. So, there is a chance to simplify them all. Abstract the entire setup code to one setup call. Then, it can reduce the amount of code there.

For testing sigaltstack() specifically, another helper is provided that excludes the syscall part.

The series also includes some preparatory changes for them:

* Along with the rework, some existing problem was uncovered. A couple of tests look to free the altstack memory even before the signal delivery. Adjust the memory cleanup to resolve this issue.

* Also resolve a define conflict separately before including the refactored header.

Then, there is another selftest fix that I posted:
https://lore.kernel.org/lkml/[email protected]/
which has a conflict with this. As the fix should go first, this cleanup series is based on it.

FWIW, at the moment, the new x86 selftest cases -- lam and test_shadow_stack do not conflict with this.

Here is the repository where this series can be found:
git://github.com/intel/amx-linux.git selftest-signal

Thanks,
Chang

Chang S. Bae (4):
selftests/x86: Fix the altstack free selftests/x86/mov_ss_trap: Include processor-flags.h selftests/x86: Consolidate signal handler helpers selftests/x86: Refactor altstack setup code

 tools/testing/selftests/x86/Makefile          |  16 ++-
 tools/testing/selftests/x86/amx.c             |  67 +++--------
 .../selftests/x86/corrupt_xstate_header.c     |  15 +--
 tools/testing/selftests/x86/entry_from_vm86.c |  25 +---
 tools/testing/selftests/x86/fsgsbase.c        |  25 +---
 tools/testing/selftests/x86/helpers.c         | 110 ++++++++++++++++++
 tools/testing/selftests/x86/helpers.h         |  10 ++
 tools/testing/selftests/x86/ioperm.c          |  26 +----
 tools/testing/selftests/x86/iopl.c            |  26 +----
 tools/testing/selftests/x86/ldt_gdt.c         |  19 +--
 tools/testing/selftests/x86/mov_ss_trap.c     |  26 +----
 tools/testing/selftests/x86/ptrace_syscall.c  |  24 +---
 tools/testing/selftests/x86/sigaltstack.c     |  67 +++--------
 tools/testing/selftests/x86/sigreturn.c       |  35 +-----
 .../selftests/x86/single_step_syscall.c       |  36 +-----
 .../testing/selftests/x86/syscall_arg_fault.c |  24 +---
 tools/testing/selftests/x86/syscall_nt.c      |  13 ---
 tools/testing/selftests/x86/sysret_rip.c      |  24 +---
 tools/testing/selftests/x86/test_vsyscall.c   |  13 ---
 tools/testing/selftests/x86/unwind_vdso.c     |  13 ---
 20 files changed, 205 insertions(+), 409 deletions(-)
 create mode 100644 tools/testing/selftests/x86/helpers.c
Signature · 1 line
2.17.1