selftests/powerpc: Add ptrace tests for ppc registers
v14 cover selftests/powerpc: Add ptrace tests for ppc registers
From: Simon Guo <[email protected]>
This selftest suite is for PPC register ptrace functionality. It is also useful for Transaction Memory functionality verification.
Test Result (All tests pass on both BE and LE)
----------------------------------------------
ptrace-ebb PASS
ptrace-gpr PASS
ptrace-tm-gpr PASS
ptrace-tm-spd-gpr PASS
ptrace-tar PASS
ptrace-tm-tar PASS
ptrace-tm-spd-tar PASS
ptrace-vsx PASS
ptrace-tm-vsx PASS
ptrace-tm-spd-vsx PASS
ptrace-tm-spr PASS
Previous versions:
==================
RFC: https://lkml.org/lkml/2014/4/1/292 V1: https://lkml.org/lkml/2014/4/2/43 V2: https://lkml.org/lkml/2014/5/5/88 V3: https://lkml.org/lkml/2014/5/23/486 V4: https://lkml.org/lkml/2014/11/11/6 V5: https://lkml.org/lkml/2014/11/25/134 V6: https://lkml.org/lkml/2014/12/2/98 V7: https://lkml.org/lkml/2015/1/14/19 V8: https://lkml.org/lkml/2015/5/19/700 V9: https://lkml.org/lkml/2015/10/8/522 V10: https://lkml.org/lkml/2016/2/16/219 V11: https://lkml.org/lkml/2016/7/16/231 V12: https://lkml.org/lkml/2016/7/27/134 V13: https://lkml.org/lkml/2016/7/27/656
Changes in V14:
---------------
- Remove duplicated NT_PPC_xxx register macro intools/testing/selftests/powerpc/ptrace/ptrace.h
- Clean some coding style warning
Changes in V13:
---------------
- Remove Cc lines from changelog
- Add more Signed-off-by lines of Simon Guo
Changes in V12:
---------------
- Revert change which is trying to incoporate following patch:
[PATCH 3/5] powerpc: tm: Always use fp_state and vr_state to store live registers
- Release share memory resource in all self test cases
- Optimize tfhar usage in ptrace-tm-spr.c
Changes in V11:
---------------
- Rework based on following patch:
[PATCH 3/5] powerpc: tm: Always use fp_state and vr_state to store live registers
- Split EBB/PMU register ptrace implementation.
- Clean some coding style warning
- Added more shared memory based sync between parent and child during TM tests
- Re worded some of the commit messages and cleaned them up
- selftests/powerpc/ebb/reg.h has already moved as selftests/powerpc/reg.h Dropped the previous patch doing the same thing
- Combined the definitions of SPRN_DSCR from dscr/ test cases
- Fixed dscr/ test cases for new SPRN_DSCR_PRIV definition available
Changes in V10:
---------------
- Rebased against the latest mainline
- Fixed couple of build failures in the test cases related to aux vector
Changes in V9:
--------------
- Fixed static build check failure after tm_orig_msr got dropped
- Fixed asm volatile construct for used registers set
- Fixed EBB, VSX, VMX tests for LE
- Fixed TAR test which was failing because of system calls
- Added checks for PPC_FEATURE2_HTM aux feature in the tests
- Fixed copyright statements
Changes in V8:
--------------
- Split the misc register set into individual ELF core notes
- Implemented support for VSX register set (on and off TM)
- Implemented support for EBB register set
- Implemented review comments on previous versions
- Some code re-arrangements, re-writes and documentation
- Added comprehensive list of test cases into selftests
Changes in V7:
--------------
- Fixed a config directive in the MISC code
- Merged the two gitignore patches into a single one
Changes in V6:
--------------
- Added two git ignore patches for powerpc selftests
- Re-formatted all in-code function definitions in kernel-doc format
Changes in V5:
--------------
- Changed flush_tmregs_to_thread, so not to take into account self tracing
- Dropped the 3rd patch in the series which had merged two functions
- Fixed one build problem for the misc debug register patch
- Accommodated almost all the review comments from Suka on the 6th patch
- Minor changes to the self test program
- Changed commit messages for some of the patches
Changes in V4:
--------------
- Added one test program into the powerpc selftest bucket in this regard
- Split the 2nd patch in the previous series into four different patches
- Accommodated most of the review comments on the previous patch series
- Added a patch to merge functions __switch_to_tm and tm_reclaim_task
Changes in V3:
--------------
- Added two new error paths in every TM related get/set functions when regset support is not present on the system (ENODEV) or when the process does not have any transaction active (ENODATA) in the context
- Installed the active hooks for all the newly added regset core note types
Changes in V2:
--------------
- Removed all the power specific ptrace requests corresponding to new NT_PPC_*
elf core note types. Now all the register sets can be accessed from ptrace
through PTRACE_GETREGSET/PTRACE_SETREGSET using the individual NT_PPC* core
note type instead
- Fixed couple of attribute values for REGSET_TM_CGPR register set
- Renamed flush_tmreg_to_thread as flush_tmregs_to_thread
- Fixed 32 bit checkpointed GPR support
- Changed commit messages accordingly
-------------
Anshuman Khandual (15):
selftests/powerpc: Add more SPR numbers, TM & VMX instructions to
'reg.h'
selftests/powerpc: Use the new SPRN_DSCR_PRIV definiton selftests/powerpc: Add ptrace tests for EBB selftests/powerpc: Add ptrace tests for GPR/FPR registers selftests/powerpc: Add ptrace tests for GPR/FPR registers in TM selftests/powerpc: Add ptrace tests for GPR/FPR registers in suspended
TM
selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR registers selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR in TM selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR in suspended TM selftests/powerpc: Add ptrace tests for VSX, VMX registers selftests/powerpc: Add ptrace tests for VSX, VMX registers in TM selftests/powerpc: Add ptrace tests for VSX, VMX registers in
suspended TM
selftests/powerpc: Add ptrace tests for TM SPR registers selftests/powerpc: Add .gitignore file for ptrace executables selftests/powerpc: Fix a build issue
tools/testing/selftests/powerpc/Makefile | 3 +- .../selftests/powerpc/context_switch/cp_abort.c | 6 +- tools/testing/selftests/powerpc/dscr/dscr.h | 10 +- tools/testing/selftests/powerpc/ptrace/.gitignore | 11 + tools/testing/selftests/powerpc/ptrace/Makefile | 13 + .../testing/selftests/powerpc/ptrace/ptrace-ebb.c | 188 +++++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 99 +++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 196 ++++++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 74 ++ .../testing/selftests/powerpc/ptrace/ptrace-tar.c | 159 +++++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 ++ .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 296 ++++++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 324 +++++++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-tar.c | 195 ++++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c | 219 ++++++ .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 186 +++++ .../selftests/powerpc/ptrace/ptrace-tm-tar.c | 182 +++++ .../selftests/powerpc/ptrace/ptrace-tm-vsx.c | 206 ++++++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.c | 140 ++++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.h | 127 ++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 396 +++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 771 +++++++++++++++++++++ tools/testing/selftests/powerpc/reg.h | 42 +- 23 files changed, 3880 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/.gitignore create mode 100644 tools/testing/selftests/powerpc/ptrace/Makefile create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-ebb.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-ebb.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-gpr.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tar.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tar.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-vsx.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace.S create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace.h
Signature · 1 line
1.8.3.1
PATCH v14 1/15 selftests/powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h'
From: Anshuman Khandual <[email protected]>
This patch adds SPR number for TAR, PPR, DSCR special purpose registers. It also adds TM, VSX, VMX related instructions which will then be used by patches later in the series.
--- tools/testing/selftests/powerpc/reg.h | 42 ++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-)
tools/testing/selftests/powerpc/reg.h +39 -3
@@ -18,6 +18,19 @@#define mb () asm volatile("sync" : : : "memory"); +/* Vector Instructions */ +#define VSX_XX1 (xs, ra, rb) (((xs) & 0x1f) << 21 | ((ra) << 16) | \ + ((rb) << 11) | (((xs) >> 5))) +#define STXVD2X (xs, ra, rb) .long (0x7c000798 | VSX_XX1((xs), (ra), (rb))) +#define LXVD2X (xs, ra, rb) .long (0x7c000698 | VSX_XX1((xs), (ra), (rb))) + +/* TM instructions */ +#define TBEGIN ".long 0x7C00051D;" +#define TABORT ".long 0x7C00071D;" +#define TEND ".long 0x7C00055D;" +#define TSUSPEND ".long 0x7C0005DD;" +#define TRESUME ".long 0x7C2005DD;" +#define SPRN_MMCR2 769#define SPRN_MMCRA 770#define SPRN_MMCR0 779
@@ -51,10 +64,33 @@#define SPRN_SDAR 781#define SPRN_SIER 768 -#define SPRN_TEXASR 0x82 +#define SPRN_TEXASR 0x82/* Transaction Exception and Status Register */ #define SPRN_TFIAR 0x81/* Transaction Failure Inst Addr */ #define SPRN_TFHAR 0x80/* Transaction Failure Handler Addr */ -#define TEXASR_FS 0x08000000 -#define SPRN_TAR 0x32f +#define SPRN_TAR 0x32f/* Target Address Register */ + +#define SPRN_DSCR_PRIV 0x11/* Privilege State DSCR */ +#define SPRN_DSCR 0x03/* Data Stream Control Register */ +#define SPRN_PPR 896/* Program Priority Register */ + +/* TEXASR register bits */ +#define TEXASR_FC 0xFE00000000000000 +#define TEXASR_FP 0x0100000000000000 +#define TEXASR_DA 0x0080000000000000 +#define TEXASR_NO 0x0040000000000000 +#define TEXASR_FO 0x0020000000000000 +#define TEXASR_SIC 0x0010000000000000 +#define TEXASR_NTC 0x0008000000000000 +#define TEXASR_TC 0x0004000000000000 +#define TEXASR_TIC 0x0002000000000000 +#define TEXASR_IC 0x0001000000000000 +#define TEXASR_IFC 0x0000800000000000 +#define TEXASR_ABT 0x0000000100000000 +#define TEXASR_SPD 0x0000000080000000 +#define TEXASR_HV 0x0000000020000000 +#define TEXASR_PR 0x0000000010000000 +#define TEXASR_FS 0x0000000008000000 +#define TEXASR_TE 0x0000000004000000 +#define TEXASR_ROT 0x0000000002000000#endif /* _SELFTESTS_POWERPC_REG_H */
Signature · 1 line
1.8.3.1
PATCH v14 2/15 selftests/powerpc: Use the new SPRN_DSCR_PRIV definiton
In reply to [email protected]From: Anshuman Khandual <[email protected]>
Now that the new DSCR register definitions (SPRN_DSCR_PRIV and SPRN_DSCR) are defined outside this directory, use them instead.
--- tools/testing/selftests/powerpc/dscr/dscr.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tools/testing/selftests/powerpc/dscr/dscr.h +4 -6
@@ -28,8 +28,6 @@#include "utils.h" -#define SPRN_DSCR 0x11/* Privilege state SPR */ -#define SPRN_DSCR_USR 0x03/* Problem state SPR */ #define THREADS 100/* Max threads */ #define COUNT 100/* Max iterations */ #define DSCR_MAX 16/* Max DSCR value */
@@ -48,14 +46,14 @@ inline unsigned long get_dscr(void) {unsigned long ret; - asmvolatile ("mfspr %0,%1" :"=r" (ret):"i" (SPRN_DSCR )); + asmvolatile ("mfspr %0,%1" :"=r" (ret) :"i" (SPRN_DSCR_PRIV ));return ret; }inline void set_dscr (unsigned long val) { - asmvolatile ("mtspr %1,%0" : :"r" (val),"i" (SPRN_DSCR )); + asmvolatile ("mtspr %1,%0" : :"r" (val),"i" (SPRN_DSCR_PRIV )); }/* Problem state DSCR access */
@@ -63,14 +61,14 @@ inline unsigned long get_dscr_usr(void) {unsigned long ret; - asmvolatile ("mfspr %0,%1" :"=r" (ret):"i" (SPRN_DSCR_USR )); + asmvolatile ("mfspr %0,%1" :"=r" (ret) :"i" (SPRN_DSCR ));return ret; }inline void set_dscr_usr (unsigned long val) { - asmvolatile ("mtspr %1,%0" : :"r" (val),"i" (SPRN_DSCR_USR )); + asmvolatile ("mtspr %1,%0" : :"r" (val),"i" (SPRN_DSCR )); }/* Default DSCR access */
Signature · 1 line
1.8.3.1
PATCH v14 3/15 selftests/powerpc: Add ptrace tests for EBB
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for EBB/PMU specific registers. This also adds some generic ptrace interface based helper functions to be used by other patches later on in the series.
--- tools/testing/selftests/powerpc/Makefile | 3 +- tools/testing/selftests/powerpc/ptrace/Makefile | 7 + .../testing/selftests/powerpc/ptrace/ptrace-ebb.c | 188 +++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 99 +++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 225 +++++++++++++++++++++ 5 files changed, 521 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/Makefile create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-ebb.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-ebb.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace.h
tools/testing/selftests/powerpc/Makefile +2 -1
@@ -25,7 +25,8 @@ SUB_DIRS = alignment \ syscalls \ tm \ vphn \ - math + math \ + ptrace endif
tools/testing/selftests/powerpc/ptrace/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +TEST_PROGS := ptrace-ebb +all: $(TEST_PROGS) +CFLAGS += -m64 +$(TEST_PROGS): ../harness.c ptrace.S ../utils.c ptrace.h +ptrace-ebb: ../pmu/event.c ../pmu/lib.c ../pmu/ebb/ebb_handler.S ../pmu/ebb/busy_loop.S +clean: + rm -f $(TEST_PROGS) *.o
tools/testing/selftests/powerpc/ptrace/ptrace-ebb.c new file +188 -0
188 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-ebb.h new file +99 -0
99 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h new file +225 -0
225 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 4/15 selftests/powerpc: Add ptrace tests for GPR/FPR registers
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for GPR/FPR registers. This adds ptrace interface based helper functions related to GPR/FPR access and some assembly helper functions related to GPR/FPR registers.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 196 +++++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 74 ++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 131 +++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 211 +++++++++++++++++++++ 5 files changed, 614 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-gpr.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace.S
tools/testing/selftests/powerpc/ptrace/Makefile +2 -1
@@ -1,4 +1,5 @@ -TEST_PROGS := ptrace-ebb +TEST_PROGS := ptrace-ebb ptrace-gpr + all: $(TEST_PROGS) CFLAGS += -m64 $(TEST_PROGS): ../harness.c ptrace.S ../utils.c ptrace.h
tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c new file +196 -0
196 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-gpr.h new file +74 -0
74 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.S new file +131 -0
131 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +211 -0
220 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 5/15 selftests/powerpc: Add ptrace tests for GPR/FPR registers in TM
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for GPR/FPR registers inside TM context. This adds ptrace interface based helper functions related to checkpointed GPR/FPR access.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 296 +++++++++++++++++++++ 2 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c
tools/testing/selftests/powerpc/ptrace/Makefile +2 -1
@@ -1,8 +1,9 @@ -TEST_PROGS := ptrace-ebb ptrace-gpr +TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr all: $(TEST_PROGS) CFLAGS += -m64 $(TEST_PROGS): ../harness.c ptrace.S ../utils.c ptrace.h ptrace-ebb: ../pmu/event.c ../pmu/lib.c ../pmu/ebb/ebb_handler.S ../pmu/ebb/busy_loop.S + clean: rm -f $(TEST_PROGS) *.o
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +296 -0
296 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 6/15 selftests/powerpc: Add ptrace tests for GPR/FPR registers in suspended TM
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for GPR/FPR registers inside suspended TM context.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 2 +- .../selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 324 +++++++++++++++++++++ 2 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
@@ -1,4 +1,4 @@ -TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr +TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c new file +324 -0
324 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 7/15 selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR registers
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TAR, PPR, DSCR registers. This also adds ptrace interface based helper functions related to TAR, PPR, DSCR register access.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../testing/selftests/powerpc/ptrace/ptrace-tar.c | 159 ++++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 ++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 181 +++++++++++++++++++++ 4 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tar.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tar.h
tools/testing/selftests/powerpc/ptrace/Makefile +2 -1
@@ -1,4 +1,5 @@ -TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr +TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ +ptrace-tar all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +159 -0
159 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-tar.h new file +50 -0
50 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +181 -0
187 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 8/15 selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR in TM
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TAR, PPR, DSCR registers inside TM context. This also adds ptrace interface based helper functions related to checkpointed TAR, PPR, DSCR register access.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 2 +- .../selftests/powerpc/ptrace/ptrace-tm-tar.c | 182 +++++++++++++++++++++ 2 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
@@ -1,5 +1,5 @@ TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ -ptrace-tar +ptrace-tar ptrace-tm-tar all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 9/15 selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR in suspended TM
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TAR, PPR, DSCR registers inside suspended TM context.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 2 +- .../selftests/powerpc/ptrace/ptrace-tm-spd-tar.c | 195 +++++++++++++++++++++ 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
@@ -1,5 +1,5 @@ TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ -ptrace-tar ptrace-tm-tar +ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c new file +195 -0
195 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 10/15 selftests/powerpc: Add ptrace tests for VSX, VMX registers
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for VSX, VMX registers. This also adds ptrace interface based helper functions related to VSX, VMX registers access. This also adds some assembly helper functions related to VSX and VMX registers.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 2 +- .../testing/selftests/powerpc/ptrace/ptrace-vsx.c | 140 +++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.h | 127 ++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 265 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 119 +++++++++ 5 files changed, 652 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-vsx.h
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
@@ -1,5 +1,5 @@ TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ -ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar +ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c new file +140 -0
140 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-vsx.h new file +127 -0
127 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.S +265 -0
268 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +119 -0
125 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 11/15 selftests/powerpc: Add ptrace tests for VSX, VMX registers in TM
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for VSX, VMX registers inside TM context. This also adds ptrace interface based helper functions related to chckpointed VSX, VMX registers access.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-vsx.c | 206 +++++++++++++++++++++ 2 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c
tools/testing/selftests/powerpc/ptrace/Makefile +2 -1
@@ -1,5 +1,6 @@ TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ -ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx +ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx + all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c new file +206 -0
206 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 12/15 selftests/powerpc: Add ptrace tests for VSX, VMX registers in suspended TM
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for VSX, VMX registers inside suspended TM context.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c | 219 +++++++++++++++++++++ 2 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c
tools/testing/selftests/powerpc/ptrace/Makefile +2 -1
@@ -1,5 +1,6 @@ TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ -ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx +ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \ +ptrace-tm-spd-vsx all: $(TEST_PROGS)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v14 13/15 selftests/powerpc: Add ptrace tests for TM SPR registers
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TM SPR registers. This also adds ptrace interface based helper functions related to TM SPR registers access.
--- tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 186 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 35 ++++ 3 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
tools/testing/selftests/powerpc/ptrace/Makefile +2 -1
@@ -1,7 +1,8 @@ TEST_PROGS := ptrace-ebb 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-spd-vsx ptrace-tm-spr +include ../../lib.mk all: $(TEST_PROGS) CFLAGS += -m64
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +186 -0
186 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +35 -0
@@ -52,6 +52,11 @@ struct fpr_regs {unsigned long fpscr; }; +struct tm_spr_regs { +unsigned long tm_tfhar; +unsigned long tm_texasr; +unsigned long tm_tfiar; +};/* Basic ptrace operations */ int start_trace (pid_t child)
@@ -665,6 +670,36 @@ int write_vsx_ckpt(pid_t child, unsigned long *vsx)return TEST_PASS ; } +/* TM SPR */ +int show_tm_spr (pid_t child,struct tm_spr_regs *out) +{ +struct tm_spr_regs *regs; +struct iovec iov; +int ret; + + regs = (struct tm_spr_regs *)malloc (sizeof (struct tm_spr_regs )); +if (!regs) { +perror ("malloc() failed" ); +return TEST_FAIL ; + } + + iov.iov_base = (u64 *) regs; + iov.iov_len =sizeof (struct tm_spr_regs ); + + ret =ptrace (PTRACE_GETREGSET , child,NT_PPC_TM_SPR , &iov); +if (ret) { +perror ("ptrace(PTRACE_GETREGSET) failed" ); +return TEST_FAIL ; + } + +if (out) +memcpy (out, regs,sizeof (struct tm_spr_regs )); + +return TEST_PASS ; +} + + +/* Analyse TEXASR after TM failure */ inline unsigned long get_tfiar (void ) {
Signature · 1 line
1.8.3.1
PATCH v14 14/15 selftests/powerpc: Add .gitignore file for ptrace executables
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch adds a .gitignore file for all the executables in the ptrace test directory thus making invisible with git status query.
--- tools/testing/selftests/powerpc/ptrace/.gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tools/testing/selftests/powerpc/ptrace/.gitignore
tools/testing/selftests/powerpc/ptrace/.gitignore new file +11 -0
@@ -0,0 +1,11 @@ +ptrace-ebb +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
Signature · 1 line
1.8.3.1
PATCH v14 15/15 selftests/powerpc: Fix a build issue
In reply to [email protected]From: Anshuman Khandual <[email protected]>
Fixes the following build failure -
cp_abort.c:90:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < NUM_LOOPS; i++) {
^
cp_abort.c:90:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
cp_abort.c:97:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < NUM_LOOPS; i++) {
--- tools/testing/selftests/powerpc/context_switch/cp_abort.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/powerpc/context_switch/cp_abort.c +3 -3
@@ -67,7 +67,7 @@ int test_cp_abort(void)/* 128 bytes for a full cache line */ char buf[128] __cacheline_aligned;cpu_set_t cpuset; -int fd1[2 ], fd2[2 ], pid; +int fd1[2 ], fd2[2 ], pid, i;char c;/* only run this test on a P9 or later */
@@ -87,14 +87,14 @@ int test_cp_abort(void)FAIL_IF (pid <0 );if (!pid) { -for (int i =0 ; i <NUM_LOOPS ; i++) { +for (i =0 ; i <NUM_LOOPS ; i++) {FAIL_IF ((write (fd1[WRITE_FD ], &c,1 )) !=1 );FAIL_IF ((read (fd2[READ_FD ], &c,1 )) !=1 );/* A paste succeeds if CR0 EQ bit is set */ FAIL_IF (paste (buf) &0x20000000 ); } }else { -for (int i =0 ; i <NUM_LOOPS ; i++) { +for (i =0 ; i <NUM_LOOPS ; i++) {FAIL_IF ((read (fd1[READ_FD ], &c,1 )) !=1 );copy (buf);FAIL_IF ((write (fd2[WRITE_FD ], &c,1 ) !=1 ));
Signature · 1 line
1.8.3.1
Quoted 8 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Simon Guo <[email protected]>
This selftest suite is for PPC register ptrace functionality. It is also useful for Transaction Memory functionality verification.
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>
Hi Simon,
Thanks for putting the effort in to get these merged! I have a few remarks that apply to more than one patch which I'll say here.
I'm not sure #defining the TM instructions as .long for the selftests is useful. Compilers these days know about the instructions 'tbegin.' 'tsuspend.' and the like, I would question anyone using a compiler old enough not to know about these...
There are a few assembly fpu register load functions that could be consolidated into those in math/ and even some in tm/
Doing while(ptr); to wait for another thread should be
while(ptr)
asm volatile("" : : : "memory");
Documentation/volatile-considered-harmful.txt for reasons why. Even knowing this I did it your way without thinking in a selftest I wrote doing similar things and it turns out that it didn't work [the way we both expect it would].
Having said all that, I'm aware that these are selftests and this series could be nicer but I won't lose any sleep if they were merged almost as is. Thanks for your work!
Finally, they didn't compile for me, I did a git rebase --exec with my build scripts and:
selftests/powerpc: Add ptrace tests for EBB
[snip] *** No rule to make target 'ptrace.S', needed by 'ptrace-ebb'.
(that appears fixed by subsequent patch)
selftests/powerpc: Add ptrace tests for GPR/FPR registers
Seems to have failed horribly and those problems continue...
I applied these to powerpc-next at:
commit c6935931c1894ff857616ff8549b61236a19148f
Author: Linus Torvalds <[email protected]> Date: Sun Sep 4 14:31:46 2016 -0700
Linux 4.8-rc5
Should I have based on something else?
Quoted 229 lines
Test Result (All tests pass on both BE and LE)
----------------------------------------------
ptrace-ebb PASS
ptrace-gpr PASS
ptrace-tm-gpr PASS
ptrace-tm-spd-gpr PASS
ptrace-tar PASS
ptrace-tm-tar PASS
ptrace-tm-spd-tar PASS
ptrace-vsx PASS
ptrace-tm-vsx PASS
ptrace-tm-spd-vsx PASS
ptrace-tm-spr PASSPrevious versions:
==================
RFC: https://lkml.org/lkml/2014/4/1/292
V1: https://lkml.org/lkml/2014/4/2/43
V2: https://lkml.org/lkml/2014/5/5/88
V3: https://lkml.org/lkml/2014/5/23/486
V4: https://lkml.org/lkml/2014/11/11/6
V5: https://lkml.org/lkml/2014/11/25/134
V6: https://lkml.org/lkml/2014/12/2/98
V7: https://lkml.org/lkml/2015/1/14/19
V8: https://lkml.org/lkml/2015/5/19/700
V9: https://lkml.org/lkml/2015/10/8/522
V10: https://lkml.org/lkml/2016/2/16/219
V11: https://lkml.org/lkml/2016/7/16/231
V12: https://lkml.org/lkml/2016/7/27/134
V13: https://lkml.org/lkml/2016/7/27/656Changes in V14:
---------------
- Remove duplicatedNT_PPC_xxxregister macro intools/testing/selftests/powerpc/ptrace/ptrace.h
- Clean some coding style warningChanges in V13:
---------------
- Remove Cc lines from changelog
- Add more Signed-off-by lines of Simon GuoChanges in V12:
---------------
- Revert change which is trying to incoporate following patch:
[PATCH 3/5] powerpc: tm: Always usefp_stateandvr_stateto store live registers
- Release share memory resource in all self test cases
- Optimize tfhar usage inptrace-tm-spr.cChanges in V11:
---------------
- Rework based on following patch:
[PATCH 3/5] powerpc: tm: Always usefp_stateandvr_stateto store live registers
- Split EBB/PMU register ptrace implementation.
- Clean some coding style warning
- Added more shared memory based sync between parent and child during TM tests
- Re worded some of the commit messages and cleaned them up
-selftests/powerpc/ebb/reg.hhas already moved asselftests/powerpc/reg.h
Dropped the previous patch doing the same thing
- Combined the definitions ofSPRN_DSCRfrom dscr/ test cases
- Fixed dscr/ test cases for newSPRN_DSCR_PRIVdefinition availableChanges in V10:
---------------
- Rebased against the latest mainline
- Fixed couple of build failures in the test cases related to aux vectorChanges in V9:
--------------
- Fixed static build check failure aftertm_orig_msrgot dropped
- Fixed asm volatile construct for used registers set
- Fixed EBB, VSX, VMX tests for LE
- Fixed TAR test which was failing because of system calls
- Added checks forPPC_FEATURE2_HTMaux feature in the tests
- Fixed copyright statementsChanges in V8:
--------------
- Split the misc register set into individual ELF core notes
- Implemented support for VSX register set (on and off TM)
- Implemented support for EBB register set
- Implemented review comments on previous versions
- Some code re-arrangements, re-writes and documentation
- Added comprehensive list of test cases into selftestsChanges in V7:
--------------
- Fixed a config directive in the MISC code
- Merged the two gitignore patches into a single oneChanges in V6:
--------------
- Added two git ignore patches for powerpc selftests
- Re-formatted all in-code function definitions in kernel-doc formatChanges in V5:
--------------
- Changedflush_tmregs_to_thread, so not to take into account self tracing
- Dropped the 3rd patch in the series which had merged two functions
- Fixed one build problem for the misc debug register patch
- Accommodated almost all the review comments from Suka on the 6th patch
- Minor changes to the self test program
- Changed commit messages for some of the patchesChanges in V4:
--------------
- Added one test program into the powerpc selftest bucket in this regard
- Split the 2nd patch in the previous series into four different patches
- Accommodated most of the review comments on the previous patch series
- Added a patch to merge functions__switch_to_tmandtm_reclaim_taskChanges in V3:
--------------
- Added two new error paths in every TM related get/set functions when regset
support is not present on the system (ENODEV) or when the process does not
have any transaction active (ENODATA) in the context
- Installed the active hooks for all the newly added regset core note typesChanges in V2:
--------------
- Removed all the power specific ptrace requests corresponding to new NT_PPC_*
elf core note types. Now all the register sets can be accessed from ptrace
through PTRACE_GETREGSET/PTRACE_SETREGSET using the individual NT_PPC* core
note type instead
- Fixed couple of attribute values forREGSET_TM_CGPRregister set
- Renamedflush_tmreg_to_threadasflush_tmregs_to_thread
- Fixed 32 bit checkpointed GPR support
- Changed commit messages accordingly
-------------Anshuman Khandual (15):
selftests/powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h'
selftests/powerpc: Use the newSPRN_DSCR_PRIVdefiniton selftests/powerpc: Add ptrace tests for EBB selftests/powerpc: Add ptrace tests for GPR/FPR registers selftests/powerpc: Add ptrace tests for GPR/FPR registers in TM selftests/powerpc: Add ptrace tests for GPR/FPR registers in suspended
TM
selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR registers selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR in TM selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR in suspended TM
selftests/powerpc: Add ptrace tests for VSX, VMX registers selftests/powerpc: Add ptrace tests for VSX, VMX registers in TM selftests/powerpc: Add ptrace tests for VSX, VMX registers in suspended TM
selftests/powerpc: Add ptrace tests for TM SPR registers selftests/powerpc: Add .gitignore file for ptrace executables selftests/powerpc: Fix a build issuetools/testing/selftests/powerpc/Makefile | 3 +- .../selftests/powerpc/context_switch/cp_abort.c | 6 +- tools/testing/selftests/powerpc/dscr/dscr.h | 10 +- tools/testing/selftests/powerpc/ptrace/.gitignore | 11 + tools/testing/selftests/powerpc/ptrace/Makefile | 13 +
.../testing/selftests/powerpc/ptrace/ptrace-ebb.c | 188 +++++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 99 +++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 196 ++++++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 74 ++ .../testing/selftests/powerpc/ptrace/ptrace-tar.c | 159 +++++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 ++ .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 296 ++++++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 324 +++++++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-tar.c | 195 ++++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c | 219 ++++++ .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 186 +++++ .../selftests/powerpc/ptrace/ptrace-tm-tar.c | 182 +++++ .../selftests/powerpc/ptrace/ptrace-tm-vsx.c | 206 ++++++.../testing/selftests/powerpc/ptrace/ptrace-vsx.c | 140 ++++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.h | 127 ++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 396 +++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 771
+++++++++++++++++++++
tools/testing/selftests/powerpc/reg.h | 42 +-23 files changed, 3880 insertions(+), 13 deletions(-)create mode 100644
tools/testing/selftests/powerpc/ptrace/.gitignorecreate mode 100644tools/testing/selftests/powerpc/ptrace/Makefilecreate mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-ebb.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-ebb.h
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-gpr.h
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tar.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tar.h
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-vsx.h
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace.Screate mode 100644tools/testing/selftests/powerpc/ptrace/ptrace.h
Hi Cyril,
Quoted 7 lines · Cyril Bur
Thanks for putting the effort in to get these merged! I have a few remarks that apply to more than one patch which I'll say here.
I'm not sure #defining the TM instructions as .long for the selftests is useful. Compilers these days know about the instructions 'tbegin.' 'tsuspend.' and the like, I would question anyone using a compiler old enough not to know about these...
I agree. But let me check with original author Anshuman firstly.
Quoted 3 lines
There are a few assembly fpu register load functions that could be consolidated into those in math/ and even some in tm/
Will rework that.
Quoted 10 lines
Doing while(ptr); to wait for another thread should be
while(ptr)
asmvolatile("" : : : "memory");
Documentation/volatile-considered-harmful.txtfor reasons why. Even knowing this I did it your way without thinking in a selftest I wrote doing similar things and it turns out that it didn't work [the way we both expect it would].
You are right.
Quoted 16 lines
Having said all that, I'm aware that these are selftests and this series could be nicer but I won't lose any sleep if they were merged almost as is. Thanks for your work!
Finally, they didn't compile for me, I did a git rebase --exec with my build scripts and:
selftests/powerpc: Add ptrace tests for EBB
[snip] *** No rule to make target 'ptrace.S', needed by 'ptrace-ebb'.(that appears fixed by subsequent patch)
selftests/powerpc: Add ptrace tests for GPR/FPR registers
Seems to have failed horribly and those problems continue...
Quoted 8 lines
I applied these to powerpc-next at:
commitc6935931c1894ff857616ff8549b61236a19148f
Author: Linus Torvalds <[email protected]> Date: Sun Sep 4 14:31:46 2016 -0700Linux 4.8-rc5
Should I have based on something else?
I didn't reproduce the latter error and I also applied on c69359. My build script is only one line:
make -C tools/testing/selftests TARGETS=powerpc 1>/dev/null
Did I miss anything with your build script?
Anyway I need to fix that.
Thanks for the sharing. Most are good comments and I will rework that.
BR,
- Simon
Quoted 6 lines · Simon Guo
Hi Cyril,
Quoted 4 lines · Cyril Bur
Thanks for putting the effort in to get these merged! I have a few remarks that apply to more than one patch which I'll say here.
Quoted 9 lines
Quoted 7 lines
I'm not sure #defining the TM instructions as .long for the selftests
is useful. Compilers these days know about the instructions 'tbegin.'
'tsuspend.' and the like, I would question anyone using a compiler old
enough not to know about these...I agree. But let me check with original author Anshuman firstly.
Great!
I'll send through my other emails that I actually wrote before this one, please ignore if I've repeated myself.
Quoted 6 lines
Quoted 4 lines
There are a few assembly fpu register load functions that could be consolidated into those in math/ and even some in tm/
Will rework that.
Thanks
Quoted 7 lines
Quoted 7 lines
Doing while(ptr); to wait for another thread should be
while(ptr)
asmvolatile("" : : : "memory");
Quoted 8 lines
Quoted 6 lines
Documentation/volatile-considered-harmful.txtfor reasons why. Even knowing this I did it your way without thinking in a selftest I
wrote doing similar things and it turns out that it didn't work [the
way we both expect it would].You are right.
Thanks
Quoted 24 lines
Quoted 24 lines
Having said all that, I'm aware that these are selftests and this series could be nicer but I won't lose any sleep if they were merged
almost as is. Thanks for your work!Finally, they didn't compile for me, I did a git rebase --exec with my
build scripts and:selftests/powerpc: Add ptrace tests for EBB
[snip] *** No rule to make target 'ptrace.S', needed by 'ptrace-ebb'.(that appears fixed by subsequent patch)
selftests/powerpc: Add ptrace tests for GPR/FPR registers
Seems to have failed horribly and those problems continue...I applied these to powerpc-next at:
commitc6935931c1894ff857616ff8549b61236a19148f
Author: Linus Torvalds <[email protected]> Date: Sun Sep 4 14:31:46 2016 -0700
Quoted 7 lines
Quoted 3 lines
Linux 4.8-rc5
Should I have based on something else?
I didn't reproduce the latter error and I also applied on c69359. My build script is only one line:
make -Ctools/testing/selftestsTARGETS=powerpc 1>/dev/null
I do the same except without TARGETS=powerpc (I test with all the selftests). The difference I suspect is that I'm cross compiling and the #include <linux/elf.h> in ptrace.h is the problem. On my x86 machine this includes an x86 version which has different defines.
Quoted 2 lines
Did I miss anything with your build script?
Anyway I need to fix that.
Its messy but I think the accepted solution for kselftests is to do:
#include "../../../../../usr/include/linux/elf.h"
which I believe will get the headers generated for the target by make headers_install and therefore should match that for which the kselftests are being compiled.
Quoted 6 lines
Thanks for the sharing. Most are good comments and I will rework that.
BR,
- Simon
Re: [PATCH v14 01/15] selftests/powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h'
In reply to [email protected]Quoted 28 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds SPR number for TAR, PPR, DSCR special purpose registers. It also adds TM, VSX, VMX related instructions which will then be used by patches later in the series.
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>---
tools/testing/selftests/powerpc/reg.h | 42
++++++++++++++++++++++++++++++++---1 file changed, 39 insertions(+), 3 deletions(-)tools/testing/selftests/powerpc/reg.h +0
-0@@ -18,6 +18,19 @@
#definemb()asmvolatile("sync" : : : "memory");tools/testing/selftests/powerpc/reg.h +2
-0+/* Vector Instructions */ +#define VSX_XX1 (xs, ra, rb) (((xs) & 0x1f) << 21 | ((ra) <<16) | \
tools/testing/selftests/powerpc/reg.h +2
-0+ ((rb) << 11) | (((xs) >> 5))) +#define STXVD2X (xs, ra, rb) .long (0x7c000798 | VSX_XX1((xs),
Quoted 3 lines
(ra), (rb)))
+#defineLXVD2X(xs, ra, rb).long (0x7c000698| VSX_XX1((xs),
(ra), (rb)))
Theres an instructions.h file in tools/testing/selftests/powerpc/ would these be better suited there?
tools/testing/selftests/powerpc/reg.h line 33
Quoted 8 lines
tools/testing/selftests/powerpc/reg.h +8
-0+ +/* TM instructions */ +#define TBEGIN ".long 0x7C00051D;" +#define TABORT ".long 0x7C00071D;" +#define TEND ".long 0x7C00055D;" +#define TSUSPEND ".long 0x7C0005DD;" +#define TRESUME ".long 0x7C2005DD;" +
These are only useful on old compilers that don't know about TM. For selftests I would discourage creating these and using the actual instructions, they are fairly well known today by most compilers.
Quoted 44 lines
#define SPRN_MMCR2 769
#define SPRN_MMCRA 770
#define SPRN_MMCR0 779tools/testing/selftests/powerpc/reg.h +0
-0@@ -51,10 +64,33 @@ #define SPRN_SDAR 781 #define SPRN_SIER 768tools/testing/selftests/powerpc/reg.h +1
-1-#define SPRN_TEXASR 0x82 +#define SPRN_TEXASR 0x82/* Transaction Exception and Status Register */
#define SPRN_TFIAR 0x81 /* Transaction Failure Inst Addr */
#define SPRN_TFHAR 0x80 /* Transaction Failure Handler Addr */tools/testing/selftests/powerpc/reg.h +4
-2-#define TEXASR_FS 0x08000000 -#define SPRN_TAR 0x32f +#define SPRN_TAR 0x32f/* Target Address Register */ + +#define SPRN_DSCR_PRIV 0x11/* Privilege State DSCR */ +#define SPRN_DSCR 0x03/* Data Stream Control Register */
tools/testing/selftests/powerpc/reg.h +21
-0+#define SPRN_PPR 896/* Program Priority Register */ + +/* TEXASR register bits */ +#define TEXASR_FC 0xFE00000000000000 +#define TEXASR_FP 0x0100000000000000 +#define TEXASR_DA 0x0080000000000000 +#define TEXASR_NO 0x0040000000000000 +#define TEXASR_FO 0x0020000000000000 +#define TEXASR_SIC 0x0010000000000000 +#define TEXASR_NTC 0x0008000000000000 +#define TEXASR_TC 0x0004000000000000 +#define TEXASR_TIC 0x0002000000000000 +#define TEXASR_IC 0x0001000000000000 +#define TEXASR_IFC 0x0000800000000000 +#define TEXASR_ABT 0x0000000100000000 +#define TEXASR_SPD 0x0000000080000000 +#define TEXASR_HV 0x0000000020000000 +#define TEXASR_PR 0x0000000010000000 +#define TEXASR_FS 0x0000000008000000 +#define TEXASR_TE 0x0000000004000000 +#define TEXASR_ROT 0x0000000002000000
#endif /*_SELFTESTS_POWERPC_REG_H*/
Re: [PATCH v14 04/15] selftests/powerpc: Add ptrace tests for GPR/FPR registers
In reply to [email protected]Quoted 25 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for GPR/FPR registers. This adds ptrace interface based helper functions related to GPR/FPR access and some assembly helper functions related to GPR/FPR registers.
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>---
tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 196
+++++++++++++++++++
.../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 74 ++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 131
+++++++++++++
tools/testing/selftests/powerpc/ptrace/ptrace.h | 211
+++++++++++++++++++++5 files changed, 614 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-gpr.h
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace.S
[snip]
Quoted 126 lines
new file mode 100644
index 0000000..193beeatools/testing/selftests/powerpc/ptrace/ptrace.S new file +121
-0@@ -0,0 +1,131 @@ +/* + * Ptrace interface test helper assembly functions + * + * Copyright (C) 2015 Anshuman Khandual, IBM Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include <ppc-asm.h> +#include "../reg.h" + + +/* Non volatile GPR - unsigned long buf[18] */ +FUNC_START(load_gpr) + ld 14, 0*8(3) + ld 15, 1*8(3) + ld 16, 2*8(3) + ld 17, 3*8(3) + ld 18, 4*8(3) + ld 19, 5*8(3) + ld 20, 6*8(3) + ld 21, 7*8(3) + ld 22, 8*8(3) + ld 23, 9*8(3) + ld 24, 10*8(3) + ld 25, 11*8(3) + ld 26, 12*8(3) + ld 27, 13*8(3) + ld 28, 14*8(3) + ld 29, 15*8(3) + ld 30, 16*8(3) + ld 31, 17*8(3) + blr +FUNC_END(load_gpr) + +FUNC_START(store_gpr) + std 14, 0*8(3) + std 15, 1*8(3) + std 16, 2*8(3) + std 17, 3*8(3) + std 18, 4*8(3) + std 19, 5*8(3) + std 20, 6*8(3) + std 21, 7*8(3) + std 22, 8*8(3) + std 23, 9*8(3) + std 24, 10*8(3) + std 25, 11*8(3) + std 26, 12*8(3) + std 27, 13*8(3) + std 28, 14*8(3) + std 29, 15*8(3) + std 30, 16*8(3) + std 31, 17*8(3) + blr +FUNC_END(store_gpr) + +/* Single Precision Float - float buf[32] */ +FUNC_START(load_fpr) + lfs 0, 0*4(3) + lfs 1, 1*4(3) + lfs 2, 2*4(3) + lfs 3, 3*4(3) + lfs 4, 4*4(3) + lfs 5, 5*4(3) + lfs 6, 6*4(3) + lfs 7, 7*4(3) + lfs 8, 8*4(3) + lfs 9, 9*4(3) + lfs 10, 10*4(3) + lfs 11, 11*4(3) + lfs 12, 12*4(3) + lfs 13, 13*4(3) + lfs 14, 14*4(3) + lfs 15, 15*4(3) + lfs 16, 16*4(3) + lfs 17, 17*4(3) + lfs 18, 18*4(3) + lfs 19, 19*4(3) + lfs 20, 20*4(3) + lfs 21, 21*4(3) + lfs 22, 22*4(3) + lfs 23, 23*4(3) + lfs 24, 24*4(3) + lfs 25, 25*4(3) + lfs 26, 26*4(3) + lfs 27, 27*4(3) + lfs 28, 28*4(3) + lfs 29, 29*4(3) + lfs 30, 30*4(3) + lfs 31, 31*4(3) + blr +FUNC_END(load_fpr) + +FUNC_START(store_fpr) + stfs 0, 0*4(3) + stfs 1, 1*4(3) + stfs 2, 2*4(3) + stfs 3, 3*4(3) + stfs 4, 4*4(3) + stfs 5, 5*4(3) + stfs 6, 6*4(3) + stfs 7, 7*4(3) + stfs 8, 8*4(3) + stfs 9, 9*4(3) + stfs 10, 10*4(3) + stfs 11, 11*4(3) + stfs 12, 12*4(3) + stfs 13, 13*4(3) + stfs 14, 14*4(3) + stfs 15, 15*4(3) + stfs 16, 16*4(3) + stfs 17, 17*4(3) + stfs 18, 18*4(3) + stfs 19, 19*4(3) + stfs 20, 20*4(3) + stfs 21, 21*4(3) + stfs 22, 22*4(3) + stfs 23, 23*4(3)
tools/testing/selftests/powerpc/ptrace/ptrace.S line 131
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace.S new file +10
-0+ stfs 24, 24*4(3) + stfs 25, 25*4(3) + stfs 26, 26*4(3) + stfs 27, 27*4(3) + stfs 28, 28*4(3) + stfs 29, 29*4(3) + stfs 30, 30*4(3) + stfs 31, 31*4(3) + blr +FUNC_END(store_fpr)
I wrote similar functions in math/fpu_asm.S perhaps it would be time consolidate those and these into an fpu_asm.S file at a higher level, TM related tests would benefit as well.
Quoted 9 lines
tools/testing/selftests/powerpc/ptrace/ptrace.h +0
-0@@ -157,6 +157,214 @@ fail: return TEST_FAIL; }
[snip]
Re: [PATCH v14 05/15] selftests/powerpc: Add ptrace tests for GPR/FPR registers in TM
In reply to [email protected]Quoted 116 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for GPR/FPR registers inside TM context. This adds ptrace interface based helper functions related to checkpointed GPR/FPR access.
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>---
tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 296
+++++++++++++++++++++2 files changed, 298 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.ctools/testing/selftests/powerpc/ptrace/Makefile +1
-1@@ -1,8 +1,9 @@ -TEST_PROGS := ptrace-ebb ptrace-gpr +TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr
all: $(TEST_PROGS)
CFLAGS += -m64
$(TEST_PROGS):../harness.cptrace.S../utils.cptrace.h
ptrace-ebb:../pmu/event.c../pmu/lib.c../pmu/ebb/ebb_handler.S../pmu/ebb/busy_loop.S
+
clean:
rm -f $(TEST_PROGS) *.otools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +76
-0@@ -0,0 +1,296 @@ +/* +* Ptrace test for GPR/FPR registers in TM context +* +* Copyright (C) 2015 Anshuman Khandual, IBM Corporation. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ +#include "ptrace.h" +#include "ptrace-gpr.h" + +/* Tracer and Tracee Shared Data */ +int shm_id; +volatile unsigned long *cptr, *pptr; + +float a =FPR_1 ; +float b =FPR_2 ; +float c =FPR_3 ; + +void tm_gpr (void ) +{ +unsigned long gpr_buf[18 ]; +unsigned long result, texasr; +float fpr_buf[32 ]; + +printf ("Starting the child\n" ); + cptr = (unsigned long *)shmat (shm_id,NULL ,0 ); + +trans: + cptr[1 ] =0 ; + asm __volatile__( + +"li 14, %[gpr_1];" +"li 15, %[gpr_1];" +"li 16, %[gpr_1];" +"li 17, %[gpr_1];" +"li 18, %[gpr_1];" +"li 19, %[gpr_1];" +"li 20, %[gpr_1];" +"li 21, %[gpr_1];" +"li 22, %[gpr_1];" +"li 23, %[gpr_1];" +"li 24, %[gpr_1];" +"li 25, %[gpr_1];" +"li 26, %[gpr_1];" +"li 27, %[gpr_1];" +"li 28, %[gpr_1];" +"li 29, %[gpr_1];" +"li 30, %[gpr_1];" +"li 31, %[gpr_1];" + +"lfs 0, 0(%[flt_1]);" +"lfs 1, 0(%[flt_1]);" +"lfs 2, 0(%[flt_1]);" +"lfs 3, 0(%[flt_1]);" +"lfs 4, 0(%[flt_1]);" +"lfs 5, 0(%[flt_1]);" +"lfs 6, 0(%[flt_1]);" +"lfs 7, 0(%[flt_1]);" +"lfs 8, 0(%[flt_1]);" +"lfs 9, 0(%[flt_1]);" +"lfs 10, 0(%[flt_1]);" +"lfs 11, 0(%[flt_1]);" +"lfs 12, 0(%[flt_1]);" +"lfs 13, 0(%[flt_1]);" +"lfs 14, 0(%[flt_1]);" +"lfs 15, 0(%[flt_1]);" +"lfs 16, 0(%[flt_1]);" +"lfs 17, 0(%[flt_1]);" +"lfs 18, 0(%[flt_1]);" +"lfs 19, 0(%[flt_1]);" +"lfs 20, 0(%[flt_1]);" +"lfs 21, 0(%[flt_1]);" + "lfs 22, 0(%[flt_1]);"
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 86
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +10
-0+"lfs 23, 0(%[flt_1]);" +"lfs 24, 0(%[flt_1]);" +"lfs 25, 0(%[flt_1]);" +"lfs 26, 0(%[flt_1]);" +"lfs 27, 0(%[flt_1]);" +"lfs 28, 0(%[flt_1]);" +"lfs 29, 0(%[flt_1]);" +"lfs 30, 0(%[flt_1]);" +"lfs 31, 0(%[flt_1]);" +
There was this in the previous patch? Can we consolidate?
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 88
Quoted 2 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +2
-0+"1: ;" +TBEGIN
tbegin. is probably fine
Quoted 45 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +45
-0+"beq 2f;" + +"li 14, %[gpr_2];" +"li 15, %[gpr_2];" +"li 16, %[gpr_2];" +"li 17, %[gpr_2];" +"li 18, %[gpr_2];" +"li 19, %[gpr_2];" +"li 20, %[gpr_2];" +"li 21, %[gpr_2];" +"li 22, %[gpr_2];" +"li 23, %[gpr_2];" +"li 24, %[gpr_2];" +"li 25, %[gpr_2];" +"li 26, %[gpr_2];" +"li 27, %[gpr_2];" +"li 28, %[gpr_2];" +"li 29, %[gpr_2];" +"li 30, %[gpr_2];" +"li 31, %[gpr_2];" + + +"lfs 0, 0(%[flt_2]);" +"lfs 1, 0(%[flt_2]);" +"lfs 2, 0(%[flt_2]);" +"lfs 3, 0(%[flt_2]);" +"lfs 4, 0(%[flt_2]);" +"lfs 5, 0(%[flt_2]);" +"lfs 6, 0(%[flt_2]);" +"lfs 7, 0(%[flt_2]);" +"lfs 8, 0(%[flt_2]);" +"lfs 9, 0(%[flt_2]);" +"lfs 10, 0(%[flt_2]);" +"lfs 11, 0(%[flt_2]);" +"lfs 12, 0(%[flt_2]);" +"lfs 13, 0(%[flt_2]);" +"lfs 14, 0(%[flt_2]);" +"lfs 15, 0(%[flt_2]);" +"lfs 16, 0(%[flt_2]);" +"lfs 17, 0(%[flt_2]);" +"lfs 18, 0(%[flt_2]);" +"lfs 19, 0(%[flt_2]);" +"lfs 20, 0(%[flt_2]);" +"lfs 21, 0(%[flt_2]);" +"lfs 22, 0(%[flt_2]);"
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 143
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +10
-0+"lfs 23, 0(%[flt_2]);" +"lfs 24, 0(%[flt_2]);" +"lfs 25, 0(%[flt_2]);" +"lfs 26, 0(%[flt_2]);" +"lfs 27, 0(%[flt_2]);" +"lfs 28, 0(%[flt_2]);" +"lfs 29, 0(%[flt_2]);" +"lfs 30, 0(%[flt_2]);" +"lfs 31, 0(%[flt_2]);" +TSUSPEND
tsuspend.
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 146
Quoted 3 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +3
-0+"li 7, 1;" +"stw 7, 0(%[cptr1]);" +TRESUME
tresume.
Quoted 3 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +3
-0+"b .;" + +TEND
...
Quoted 4 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +4
-0+"li 0, 0;" +"ori %[res], 0, 0;" +"b 3f;" +
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 163
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +10
-0+/* Transaction abort handler */ +"2: ;" +"li 0, 1;" +"ori %[res], 0, 0;" +"mfspr %[texasr], %[sprn_texasr];" + +"3: ;" + : [res] "=r" (result), [texasr] "=r" (texasr) + : [gpr_1]"i"(GPR_1), [gpr_2]"i"(GPR_2), + [sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "r" (&a),
Thanks for actually passing through texasr like this (as opposed to simply hardcoding it), made this easier to read.
Quoted 74 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +74
-0+ [flt_2] "r" (&b), [cptr1] "r" (&cptr[1]) + : "memory", "r7", "r8", "r9", "r10", +" r11", " r12", " r13", " r14", " r15", " r16", +" r17", " r18", " r19", " r20", " r21", " r22", +" r23", " r24", " r25", " r26", " r27", " r28", + "r29", "r30", "r31" + ); + +if (result) { +if (!cptr[0 ]) + goto trans; + +shmdt ((void *)cptr); +store_gpr (gpr_buf); +store_fpr (fpr_buf); + +if (validate_gpr (gpr_buf,GPR_3 )) +exit (1 ); + +if (validate_fpr_float (fpr_buf, c)) +exit (1 ); + +exit (0 ); + } +shmdt ((void *)cptr); +exit (1 ); +} + +int trace_tm_gpr (pid_t child) +{ +unsigned long gpr[18 ]; +unsigned long fpr[32 ]; +int ret; + + ret =start_trace (child); +if (ret) +return TEST_FAIL ; + + ret =show_gpr (child, gpr); +if (ret) +return TEST_FAIL ; + + ret =validate_gpr (gpr,GPR_2 ); +if (ret) +return TEST_FAIL ; + + ret =show_fpr (child, fpr); +if (ret) +return TEST_FAIL ; + + ret =validate_fpr (fpr,FPR_2_REP ); +if (ret) +return TEST_FAIL ; + + ret =show_ckpt_fpr (child, fpr); +if (ret) +return TEST_FAIL ; + + ret =validate_fpr (fpr,FPR_1_REP ); +if (ret) +return TEST_FAIL ; + + ret =show_ckpt_gpr (child, gpr); +if (ret) +return TEST_FAIL ; + + ret =validate_gpr (gpr,GPR_1 ); +if (ret) +return TEST_FAIL ; + + ret =write_ckpt_gpr (child,GPR_3 ); +if (ret) +return TEST_FAIL ; +
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 247
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +10
-0+ ret =write_ckpt_fpr (child,FPR_3_REP ); +if (ret) +return TEST_FAIL ; + + pptr[0 ] =1 ; + ret =stop_trace (child); +if (ret) +return TEST_FAIL ; + +return TEST_PASS ;
I'll repeat this somewhere else perhaps as it seems to be a theme, it might be wise to use the TEST_FAIL(x) macro from utils.h as it will give information to more quickly narrow down where the test failed.
Quoted 9 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +8
-0+} + +int ptrace_tm_gpr (void ) +{ +pid_t pid; +int ret, status; + + SKIP_IF(!((long)get_auxv_entry(AT_HWCAP2) &
PPC_FEATURE2_HTM));
Theres a function (have_htm()) in tm/tm.h that might be nice to move more generally which does this...
Quoted 4 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +1
-0+ shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2,0777|IPC_CREAT);
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +2
-0+ pid =fork (); +if (pid <0 ) {
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 268
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +10
-0+perror ("fork() failed" ); +return TEST_FAIL ; + } +if (pid ==0 ) +tm_gpr (); + +if (pid) { + pptr = (unsigned long *)shmat (shm_id,NULL ,0 ); + +while (!pptr[1 ]);
asm volatile("" : : : "memory");
See: Documentation/volatile-considered-harmful.txt also in some selftests I wrote I had exactly what you had and just declaring volatile didn't *work* [do that I thought it would which it seems is what you want here too]!
Quoted 11 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +10
-0+kill (pid,SIGTERM ); +return TEST_FAIL ; + } + +shmdt ((void *)pptr); + + ret =wait (&status); +shmctl (shm_id,IPC_RMID ,NULL ); +if (ret != pid) { + printf("Child's exit status notcaptured\n");
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c line 288
Quoted 8 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +8
-0+return TEST_FAIL ; + } + +if (WIFEXITED (status)) { +if (WEXITSTATUS (status)) +return TEST_FAIL ; + } +return TEST_PASS ;
return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :TEST_PASS;
Quoted 8 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c new file +8
-0+ } +return TEST_PASS ; +} + +int main (int argc,char *argv[]) +{ +return test_harness (ptrace_tm_gpr,"ptrace_tm_gpr" ); +}
Re: [PATCH v14 07/15] selftests/powerpc: Add ptrace tests for TAR, PPR, DSCR registers
In reply to [email protected]Quoted 21 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TAR, PPR, DSCR registers. This also adds ptrace interface based helper functions related to TAR, PPR, DSCR register access.
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>---
tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../testing/selftests/powerpc/ptrace/ptrace-tar.c | 159
++++++++++++++++++
.../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 ++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 181
+++++++++++++++++++++4 files changed, 392 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c
create mode 100644tools/testing/selftests/powerpc/ptrace/ptrace-tar.h
[snip]
Quoted 8 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +8
-0+ +void tar (void ) +{ +unsigned long reg[3 ]; +int ret; + + cptr = (int *)shmat (shm_id,NULL ,0 ); + printf("%-30s TAR: %u PPR: %lx DSCR: %u\n",
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c line 35
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +10
-0+ user_write, TAR_1, PPR_1, DSCR_1); + +mtspr (SPRN_TAR ,TAR_1 ); +mtspr (SPRN_PPR ,PPR_1 ); +mtspr (SPRN_DSCR ,DSCR_1 ); + + cptr[2 ] =1 ; + +/* Wait on parent */ +while (!cptr[0 ]);
asm volatile("" ::: "memory");Quoted 57 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +33
-0+ + reg[0 ] =mfspr (SPRN_TAR ); + reg[1 ] =mfspr (SPRN_PPR ); + reg[2 ] =mfspr (SPRN_DSCR ); + +printf ("%-30s TAR: %lu PPR: %lx DSCR: %lu\n" , + user_read, reg[0 ], reg[1 ], reg[2 ]); + +/* Unblock the parent now */ + cptr[1 ] =1 ; +shmdt ((int *)cptr); + + ret =validate_tar_registers (reg,TAR_2 ,PPR_2 ,DSCR_2 ); +if (ret) +exit (1 ); +exit (0 ); +} + +int trace_tar (pid_t child) +{ +unsigned long reg[3 ]; +int ret; + + ret =start_trace (child); +if (ret) +return TEST_FAIL ; + + ret =show_tar_registers (child, reg); +if (ret) +return TEST_FAIL ; + + printf("%-30s TAR: %lu PPR: %lx DSCR: %lu\n", + ptrace_read_running, reg[0], reg[1],reg[2]);
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +23
-0+ + ret =validate_tar_registers (reg,TAR_1 ,PPR_1 ,DSCR_1 ); +if (ret) +return TEST_FAIL ; + + ret =stop_trace (child); +if (ret) +return TEST_FAIL ; + +return TEST_PASS ; +} + +int trace_tar_write (pid_t child) +{ +int ret; + + ret =start_trace (child); +if (ret) +return TEST_FAIL ; + + ret =write_tar_registers (child,TAR_2 ,PPR_2 ,DSCR_2 ); +if (ret) +return TEST_FAIL ;
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c line 101
Quoted 10 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +10
-0+ +printf ("%-30s TAR: %u PPR: %lx DSCR: %u\n" , + ptrace_write_running,TAR_2 ,PPR_2 ,DSCR_2 ); + + ret =stop_trace (child); +if (ret) +return TEST_FAIL ; + +return TEST_PASS ; +}
More comments about calling TEST_FAIL(x)
Quoted 19 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +7
-0+ +int ptrace_tar (void ) +{ +pid_t pid; +int ret, status; + + shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3,0777|IPC_CREAT);
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +10
-0+ pid =fork (); +if (pid <0 ) { +perror ("fork() failed" ); +return TEST_FAIL ; + } + +if (pid ==0 ) +tar (); + +if (pid) {
[snip]
Re: [PATCH v14 15/15] selftests/powerpc: Fix a build issue
In reply to [email protected]Quoted 14 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
Fixes the following build failure -
cp_abort.c:90:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i <NUM_LOOPS; i++) {
^
cp_abort.c:90:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
cp_abort.c:97:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i <NUM_LOOPS; i++) {
Quoted 2 lines
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>
Quoted 36 lines
---
tools/testing/selftests/powerpc/context_switch/cp_abort.c | 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)diff --git
a/tools/testing/selftests/powerpc/context_switch/cp_abort.cb/tools/testing/selftests/powerpc/context_switch/cp_abort.cindex 5a5b55a..1ce7dce 100644tools/testing/selftests/powerpc/context_switch/cp_abort.c +1
-1@@ -67,7 +67,7 @@ int test_cp_abort(void) /* 128 bytes for a full cache line */ char buf[128] __cacheline_aligned; cpu_set_t cpuset; -int fd1[2 ], fd2[2 ], pid; +int fd1[2 ], fd2[2 ], pid, i; char c;
/* only run this test on a P9 or later */tools/testing/selftests/powerpc/context_switch/cp_abort.c +0
-0@@ -87,14 +87,14 @@ int test_cp_abort(void) FAIL_IF(pid < 0);
if (!pid) {tools/testing/selftests/powerpc/context_switch/cp_abort.c +1
-1-for (int i =0 ; i <NUM_LOOPS ; i++) { +for (i =0 ; i <NUM_LOOPS ; i++) {
FAIL_IF((write(fd1[WRITE_FD], &c, 1)) != 1);FAIL_IF((read(fd2[READ_FD], &c, 1)) != 1); /* A paste succeeds if CR0 EQ bit is set */FAIL_IF(paste(buf) & 0x20000000); }
} else {tools/testing/selftests/powerpc/context_switch/cp_abort.c +1
-1-for (int i =0 ; i <NUM_LOOPS ; i++) { +for (i =0 ; i <NUM_LOOPS ; i++) {
FAIL_IF((read(fd1[READ_FD], &c, 1)) != 1); copy(buf);FAIL_IF((write(fd2[WRITE_FD], &c, 1) != 1));
Re: [PATCH v14 13/15] selftests/powerpc: Add ptrace tests for TM SPR registers
In reply to [email protected]Quoted 6 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TM SPR registers. This also adds ptrace interface based helper functions related to TM SPR registers access.
I'm seeing this one fail a lot, it does occasionally succeed but fails a lot on my test setup.
I use qemu on a power8 for most of my testing:
qemu-system-ppc64 --enable-kvm -machine pseries,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 4,sockets=1,cores=2,threads=2 -nographic -vga none
Quoted 70 lines
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>---
tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 186
+++++++++++++++++++++
tools/testing/selftests/powerpc/ptrace/ptrace.h | 35 ++++3 files changed, 223 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.ctools/testing/selftests/powerpc/ptrace/Makefile +0
-0@@ -1,7 +1,8 @@TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \
ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \tools/testing/selftests/powerpc/ptrace/Makefile +1
-1-ptrace-tm-spd-vsx +ptrace-tm-spd-vsx ptrace-tm-spr
+include../../lib.mk
all: $(TEST_PROGS)
CFLAGS += -m64tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +34
-0@@ -0,0 +1,186 @@ +/* +* Ptrace test TM SPR registers +* +* Copyright (C) 2015 Anshuman Khandual, IBM Corporation. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ +#include "ptrace.h" + +/* Tracee and tracer shared data */ +struct shared { +int flag; +struct tm_spr_regs regs; +}; +unsigned long tfhar; + +int shm_id; +volatile struct shared *cptr, *pptr; + +int shm_id1; +volatile int *cptr1, *pptr1; + +#define TM_SCHED 0xde0000018c000001 +#define TM_KVM_SCHED 0xe0000001ac000001 + +int validate_tm_spr (struct tm_spr_regs *regs) +{ +if (regs->tm_tfhar != tfhar) +return TEST_FAIL ; + + if ((regs->tm_texasr != TM_SCHED) && (regs->tm_texasr !=
TM_KVM_SCHED))
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
Quoted 1 line
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +1
-0+return TEST_FAIL ;
The above condition fails, should this test try again if this condition is true, rather than fail?
Quoted 8 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +2
-0+ + if ((regs->tm_texasr == TM_KVM_SCHED) && (regs->tm_tfiar !=0))
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +5
-0+return TEST_FAIL ; + +return TEST_PASS ; +} +
[snip]
Michael Ellerman
reviewerQuoted 7 lines · Cyril Bur
Its messy but I think the accepted solution for kselftests is to do:
#include "
../../../../../usr/include/linux/elf.h"which I believe will get the headers generated for the target by
make headers_installand therefore should match that for which the kselftests are being compiled.
Don't put the path in the include line though, add it to CFLAGS.
See eg. tools/testing/selftests/powerpc/tm/Makefile:
tm-syscall: CFLAGS += -I../../../../../usr/include
cheers
Re: [PATCH v14 13/15] selftests/powerpc: Add ptrace tests for TM SPR registers
In reply to Cyril BurQuoted 8 lines · Cyril Bur
Quoted 6 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TM SPR registers. This also adds ptrace interface based helper functions related to TM SPR registers access.
Quoted 7 lines
I'm seeing this one fail a lot, it does occasionally succeed but fails a lot on my test setup.
I use qemu on a power8 for most of my testing:
qemu-system-ppc64 --enable-kvm -machine pseries,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 4,sockets=1,cores=2,threads=2 -nographic -vga none
Hi Cyril,
Sorry for the late response. I am just back from a vacation. Strangely the case always succeed in my machine. I will try to reproduce it with your configuration.
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +1
-0+ if ((regs->tm_texasr != TM_SCHED) && (regs->tm_texasr !=
TM_KVM_SCHED))(quoted diff) +1
-0+ return TEST_FAIL;The above condition fails, should this test try again if this condition is true, rather than fail?
If you have the value of "regs->tm_texasr" in hand, please let me know.
Thanks for the elaborated comment in other mails and I will work on that.
BR,
- Simon
Re: [PATCH v14 13/15] selftests/powerpc: Add ptrace tests for TM SPR registers
In reply to Cyril BurHi Cyril,
Quoted 83 lines · Cyril Bur
Quoted 6 lines · On Mon, 2016-09-12 at 15:33 +0800, [email protected] wrote:
From: Anshuman Khandual <[email protected]>
This patch adds ptrace interface test for TM SPR registers. This also adds ptrace interface based helper functions related to TM SPR registers access.
I'm seeing this one fail a lot, it does occasionally succeed but fails a lot on my test setup.
I use qemu on a power8 for most of my testing:
qemu-system-ppc64 --enable-kvm -machine pseries,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 4,sockets=1,cores=2,threads=2 -nographic -vga noneQuoted 66 lines
Signed-off-by Anshuman Khandual <[email protected]>Signed-off-by Simon Guo <[email protected]>---
tools/testing/selftests/powerpc/ptrace/Makefile | 3 +- .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 186
+++++++++++++++++++++
tools/testing/selftests/powerpc/ptrace/ptrace.h | 35 ++++3 files changed, 223 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.ctools/testing/selftests/powerpc/ptrace/Makefile +0
-0@@ -1,7 +1,8 @@TEST_PROGS := ptrace-ebb ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \
ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \tools/testing/selftests/powerpc/ptrace/Makefile +1
-1-ptrace-tm-spd-vsx +ptrace-tm-spd-vsx ptrace-tm-spr
+include../../lib.mk
all: $(TEST_PROGS)
CFLAGS += -m64tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +31
-0@@ -0,0 +1,186 @@ +/* +* Ptrace test TM SPR registers +* +* Copyright (C) 2015 Anshuman Khandual, IBM Corporation. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ +#include "ptrace.h" + +/* Tracee and tracer shared data */ +struct shared { +int flag; +struct tm_spr_regs regs; +}; +unsigned long tfhar; + +int shm_id; +volatile struct shared *cptr, *pptr; + +int shm_id1; +volatile int *cptr1, *pptr1; + +#define TM_SCHED 0xde0000018c000001 +#define TM_KVM_SCHED 0xe0000001ac000001 + +int validate_tm_spr (struct tm_spr_regs *regs) +{ +if (regs->tm_tfhar != tfhar)
Quoted 9 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
Quoted 5 lines
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +3
-0+return TEST_FAIL ; + + if ((regs->tm_texasr != TM_SCHED) && (regs->tm_texasr !=
TM_KVM_SCHED))tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +1
-0+return TEST_FAIL ;The above condition fails, should this test try again if this condition is true, rather than fail?
I reproduced the failure with your configuration. Besides treclaim, there are many other reasons that may lead to the transaction failure according to ISA. At least I observed following Texasr values:
1000018000001
1000088000001
10000a8000001I noticed some FIAR locates at IPI handling related code. My previous configuration is 4 sockets/each with only 1 core/1 thread. That is probably the reason I always passed the test in the old configuration.(per my understanding, IPI is limited within threads). So I removed the checking regarding specfied TEXASR value.
And I think I have reworked all your other comments.
I will send out v15 soon. Again thanks for your code inspection.
BR,
- Simon