Testcases for protection keys feature in powerpc/next
cover Testcases for protection keys feature in powerpc/next
Ram Pai submitted a separate series containing the rework of the x86 test and also the powerpc-specific tests:
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=24741
There's a bug in the powerpc tests where they expect the AMR, IAMR and UAMOR registers to be zeroed when a process starts. This is currently true on powernv but isn't on LPARs, where key 31 is reserved and its bits are set. This causes the tests to fail on that platform.
This series fixes the bug and now the tests pass on both powernv and LPAR machines running powerpc/next. I think it's worth submitting these tests separately from the one coming from x86 so here they are.
Thiago Jung Bauermann (2):
selftests/powerpc: Add ptrace tests for Protection Key registers selftests/powerpc: Add core file test for Protection Key registers
tools/testing/selftests/powerpc/include/reg.h | 1 + tools/testing/selftests/powerpc/ptrace/Makefile | 8 +- tools/testing/selftests/powerpc/ptrace/child.h | 130 ++++++ tools/testing/selftests/powerpc/ptrace/core-pkey.c | 460 +++++++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 326 +++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 37 ++ 6 files changed, 961 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/child.h create mode 100644 tools/testing/selftests/powerpc/ptrace/core-pkey.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 selftests/powerpc: Add ptrace tests for Protection Key registers
This test exercises read and write access to the AMR, IAMR and UAMOR.
--- tools/testing/selftests/powerpc/include/reg.h | 1 + tools/testing/selftests/powerpc/ptrace/Makefile | 5 +- tools/testing/selftests/powerpc/ptrace/child.h | 130 ++++++++ .../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 326 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 37 +++ 5 files changed, 498 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/child.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
tools/testing/selftests/powerpc/include/reg.h +1 -0
@@ -54,6 +54,7 @@#define SPRN_DSCR_PRIV 0x11/* Privilege State DSCR */ #define SPRN_DSCR 0x03/* Data Stream Control Register */ #define SPRN_PPR 896/* Program Priority Register */ +#define SPRN_AMR 13/* Authority Mask Register - problem state */ /* TEXASR register bits */ #define TEXASR_FC 0xFE00000000000000
tools/testing/selftests/powerpc/ptrace/Makefile +4 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \ - ptrace-tm-spd-vsx ptrace-tm-spr + ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey include ../../lib.mk
@@ -9,6 +9,9 @@ all: $(TEST_PROGS) CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie +ptrace-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h ptrace-pkey.c + $(LINK.c) $^ $(LDLIBS) -pthread -o $@ + $(TEST_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h clean:
tools/testing/selftests/powerpc/ptrace/child.h new file +130 -0
130 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c new file +326 -0
326 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +37 -0
@@ -102,6 +102,43 @@ int cont_trace(pid_t child)return TEST_PASS ; } +int ptrace_read_regs (pid_t child,unsigned long type,unsigned long regs[], +int n) +{ +struct iovec iov; +long ret; + +FAIL_IF (start_trace (child)); + + iov.iov_base = regs; + iov.iov_len = n *sizeof (unsigned long ); + + ret =ptrace (PTRACE_GETREGSET , child, type, &iov); +FAIL_IF (ret !=0 ); + +FAIL_IF (stop_trace (child)); + +return TEST_PASS ; +} + +long ptrace_write_regs (pid_t child,unsigned long type,unsigned long regs[], +int n) +{ +struct iovec iov; +long ret; + +FAIL_IF (start_trace (child)); + + iov.iov_base = regs; + iov.iov_len = n *sizeof (unsigned long ); + + ret =ptrace (PTRACE_SETREGSET , child, type, &iov); + +FAIL_IF (stop_trace (child)); + +return ret; +} +/* TAR, PPR, DSCR */ int show_tar_registers (pid_t child,unsigned long *out) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 selftests/powerpc: Add core file test for Protection Key registers
In reply to Thiago Jung BauermannThis test verifies that the AMR, IAMR and UAMOR are being written to a process' core file.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 5 +- tools/testing/selftests/powerpc/ptrace/core-pkey.c | 460 +++++++++++++++++++++ 2 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/core-pkey.c
tools/testing/selftests/powerpc/ptrace/Makefile +4 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \ - ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey + ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey core-pkey include ../../lib.mk
@@ -12,6 +12,9 @@ CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie ptrace-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h ptrace-pkey.c $(LINK.c) $^ $(LDLIBS) -pthread -o $@ +core-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h core-pkey.c + $(LINK.c) $^ $(LDLIBS) -pthread -o $@ + $(TEST_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h clean:
tools/testing/selftests/powerpc/ptrace/core-pkey.c new file +460 -0
460 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html