selftests/powerpc: Add tm-signal-pagefault test
authorGustavo Luiz Duarte <gustavold@linux.ibm.com>
Tue, 11 Feb 2020 03:38:30 +0000 (00:38 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 20 Mar 2020 02:10:23 +0000 (13:10 +1100)
commit915b7f6f9a5e232c138bb36743a1fdb0fcf2c432
tree65b8ecdd53bfe3b45e85be24de2d511a1cd59210
parent61da50b76b62fd815aa82d853bf82bf4f69568f5
selftests/powerpc: Add tm-signal-pagefault test

This test triggers a TM Bad Thing by raising a signal in transactional state
and forcing a pagefault to happen in kernelspace when the kernel signal
handling code first touches the user signal stack.

This is inspired by the test tm-signal-context-force-tm but uses userfaultfd to
make the test deterministic. While this test always triggers the bug in one
run, I had to execute tm-signal-context-force-tm several times (the test runs
5000 times each execution) to trigger the same bug.

tm-signal-context-force-tm is kept instead of replaced because, while this test
is more reliable and triggers the same bug, tm-signal-context-force-tm has a
better coverage, in the sense that by running the test several times it might
trigger the pagefault and/or be preempted at different places.

v3: skip test if userfaultfd is unavailable.

Signed-off-by: Gustavo Luiz Duarte <gustavold@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200211033831.11165-2-gustavold@linux.ibm.com
tools/testing/selftests/powerpc/tm/.gitignore
tools/testing/selftests/powerpc/tm/Makefile
tools/testing/selftests/powerpc/tm/tm-signal-pagefault.c [new file with mode: 0644]