mbox series

[v3,0/9] A new selftests/ directory for arm compatibility testing

Message ID 20240625122408.1439097-1-dev.jain@arm.com (mailing list archive)
Headers show
Series A new selftests/ directory for arm compatibility testing | expand

Message

Dev Jain June 25, 2024, 12:23 p.m. UTC
This series introduces the selftests/arm directory, which tests 32 and
64-bit kernel compatibility with 32-bit ELFs running on the Aarch platform.
The need for this bucket of tests is that 32 bit applications built on
legacy ARM architecture must not break on the new Aarch64 platforms and
the 64-bit kernel. The kernel must emulate the data structures, system
calls and the registers according to Aarch32, when running a 32-bit
process; this directory fills that testing requirement.

One may find similarity between this directory and selftests/arm64; it is
advisable to refer to that since a lot has been pulled from there itself.

The mm directory includes a test for checking 4GB limit of the virtual
address space of a process.

The signal directory contains two tests, following a common theme: mangle
with arm_cpsr, dumped by the kernel to user space while invoking the signal
handler; kernel must spot this illegal attempt and terminate the program by
SEGV.

The elf directory includes a test for checking the 32-bit status of the ELF.

The abi directory includes two ptrace tests, in the first, a 32-bit parent
debugs a 32-bit child, and in the second, a 64-bit parent debugs a 32-bit
child. The second test will be skipped when running on a 32-bit kernel.

Credits to Mark Brown for suggesting this work.

Testing:
The series has been tested on the Aarch64 kernel. For the Aarch32 kernel,
I used qemu-system-arm with machine 'vexpress-a15', along with a buildroot
rootfs; the individual statically built tests pass on that, but building
the entire test suite on that remains untested, due to my lack of
experience with qemu and rootfses.
Since I have done some changes in selftests/arm64, I have tested that
those tests do not break.

v2->v3:
 - mm, elf: Split into multiple testcases
 - Eliminate copying in signal/ using ifdeffery and pulling from selftests/arm64
 - Delete config file, since it does not make sense for testing a 32-bit kernel
 - Split ptrace in selftests/arm64, and pull some stuff from there
 - Add abi tests containing ptrace and ptrace_64
 - Fix build warnings in selftests/arm64 (can be applied independent of this series)

v1->v2:
 - Formatting changes
 - Add .gitignore files and config file

v1:
 - https://lore.kernel.org/all/20240405084410.256788-1-dev.jain@arm.com/

Dev Jain (9):
  selftests/arm: Add mm test
  selftests/arm: Add elf test
  selftests: arm, arm64: Use ifdeffery to pull signal infrastructure
  selftests/arm: Add signal tests
  selftests/arm64: Fix build warnings for ptrace
  selftests/arm64: Split ptrace, use ifdeffery
  selftests/arm: Add ptrace test
  selftests/arm: Add ptrace_64 test
  selftests: Add build infrastructure along with README

 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/arm/Makefile          |  56 ++++++++
 tools/testing/selftests/arm/README            |  32 +++++
 tools/testing/selftests/arm/abi/.gitignore    |   4 +
 tools/testing/selftests/arm/abi/Makefile      |  26 ++++
 tools/testing/selftests/arm/abi/ptrace.c      |  82 +++++++++++
 tools/testing/selftests/arm/abi/ptrace.h      |  57 ++++++++
 tools/testing/selftests/arm/abi/ptrace_64.c   |  91 ++++++++++++
 .../selftests/arm/abi/trivial_32bit_program.c |  14 ++
 tools/testing/selftests/arm/elf/.gitignore    |   2 +
 tools/testing/selftests/arm/elf/Makefile      |   6 +
 tools/testing/selftests/arm/elf/parse_elf.c   |  77 ++++++++++
 tools/testing/selftests/arm/mm/.gitignore     |   2 +
 tools/testing/selftests/arm/mm/Makefile       |   6 +
 tools/testing/selftests/arm/mm/compat_va.c    |  89 ++++++++++++
 tools/testing/selftests/arm/signal/.gitignore |   3 +
 tools/testing/selftests/arm/signal/Makefile   |  30 ++++
 .../selftests/arm/signal/test_signals.c       |   2 +
 .../selftests/arm/signal/test_signals.h       |   2 +
 .../selftests/arm/signal/test_signals_utils.c |   2 +
 .../selftests/arm/signal/test_signals_utils.h |   2 +
 .../testcases/mangle_cpsr_invalid_aif_bits.c  |  33 +++++
 .../mangle_cpsr_invalid_compat_toggle.c       |  29 ++++
 tools/testing/selftests/arm64/abi/ptrace.c    | 121 ++--------------
 tools/testing/selftests/arm64/abi/ptrace.h    | 135 ++++++++++++++++++
 .../selftests/arm64/signal/test_signals.h     |  12 ++
 .../arm64/signal/test_signals_utils.c         |  51 +++++--
 .../arm64/signal/test_signals_utils.h         |   3 +
 28 files changed, 850 insertions(+), 120 deletions(-)
 create mode 100644 tools/testing/selftests/arm/Makefile
 create mode 100644 tools/testing/selftests/arm/README
 create mode 100644 tools/testing/selftests/arm/abi/.gitignore
 create mode 100644 tools/testing/selftests/arm/abi/Makefile
 create mode 100644 tools/testing/selftests/arm/abi/ptrace.c
 create mode 100644 tools/testing/selftests/arm/abi/ptrace.h
 create mode 100644 tools/testing/selftests/arm/abi/ptrace_64.c
 create mode 100644 tools/testing/selftests/arm/abi/trivial_32bit_program.c
 create mode 100644 tools/testing/selftests/arm/elf/.gitignore
 create mode 100644 tools/testing/selftests/arm/elf/Makefile
 create mode 100644 tools/testing/selftests/arm/elf/parse_elf.c
 create mode 100644 tools/testing/selftests/arm/mm/.gitignore
 create mode 100644 tools/testing/selftests/arm/mm/Makefile
 create mode 100644 tools/testing/selftests/arm/mm/compat_va.c
 create mode 100644 tools/testing/selftests/arm/signal/.gitignore
 create mode 100644 tools/testing/selftests/arm/signal/Makefile
 create mode 100644 tools/testing/selftests/arm/signal/test_signals.c
 create mode 100644 tools/testing/selftests/arm/signal/test_signals.h
 create mode 100644 tools/testing/selftests/arm/signal/test_signals_utils.c
 create mode 100644 tools/testing/selftests/arm/signal/test_signals_utils.h
 create mode 100644 tools/testing/selftests/arm/signal/testcases/mangle_cpsr_invalid_aif_bits.c
 create mode 100644 tools/testing/selftests/arm/signal/testcases/mangle_cpsr_invalid_compat_toggle.c
 create mode 100644 tools/testing/selftests/arm64/abi/ptrace.h