selftests/powerpc: Add ptrace tests for Protection Key registers
PATCH v2 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 | 139 +++++++++ .../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 327 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 38 +++ 5 files changed, 509 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/child.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
Changes in v2:
- Added PARENT_SKIP_IF_UNSUPPORTED macro in child.h and use it in first call to ptrace_read_regs(NT_PPC_PKEY). (Suggested by Michael Ellerman)
- Changed ptrace_read_regs() to simply return the ptrace error value in case of error and avoid calling fprintf() so that errno is preserved.
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 +139 -0
139 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c new file +327 -0
327 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +38 -0
@@ -102,6 +102,44 @@ 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); +if (ret) +return ret; + +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 v2 2/2 selftests/powerpc: Add core file test for Protection Key registers
This 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 | 461 +++++++++++++++++++++ 2 files changed, 465 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/core-pkey.c
Changes in v2:
- Use PARENT_SKIP_IF_UNSUPPORTED macro in first call to ptrace_read_regs(NT_PPC_PKEY). (Suggested by Michael Ellerman)
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 +461 -0
461 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
Michael Ellerman
AppliedRe: [v2, 2/2] selftests/powerpc: Add core file test for Protection Key registers
Quoted 4 lines · Thiago Jung Bauermann
This test verifies that the AMR, IAMR and UAMOR are being written to a process' core file.
Signed-off-by Thiago Jung Bauermann <bauerman at linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/39b91dd625f15438859204a489ab62
cheers
--
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
Michael Ellerman
AppliedQuoted 3 lines · Thiago Jung Bauermann
This test exercises read and write access to the AMR, IAMR and UAMOR.
Signed-off-by Thiago Jung Bauermann <bauerman at linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/1f7256e7dddef49acf9f6c9fe3f935
cheers
--
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