Add new powerpc specific ELF core notes
Subsystems (4)
PATCH v8 1/28 elf: Add powerpc specific core note sections
In reply to Anshuman KhandualThis patch adds twelve ELF core note sections for powerpc architecture for various registers and register sets which need to be accessed from ptrace interface and then gdb. These additions include special purpose registers like TAR, PPR, DSCR, TM running and checkpointed state for various register sets, EBB related register set etc. Addition of these new ELF core note sections extends the existing ELF ABI on powerpc arch without affecting it in any manner.
--- include/uapi/linux/elf.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/uapi/linux/elf.h +12 -0
@@ -379,6 +379,18 @@ typedef struct elf64_shdr {#define NT_PPC_VMX 0x100/* PowerPC Altivec/VMX registers */ #define NT_PPC_SPE 0x101/* PowerPC SPE/EVR registers */ #define NT_PPC_VSX 0x102/* PowerPC VSX registers */ +#define NT_PPC_TAR 0x103/* Target Address Register */ +#define NT_PPC_PPR 0x104/* Program Priority Register */ +#define NT_PPC_DSCR 0x105/* Data Stream Control Register */ +#define NT_PPC_EBB 0x106/* Event Based Branch Registers */ +#define NT_PPC_TM_CGPR 0x107/* TM checkpointed GPR Registers */ +#define NT_PPC_TM_CFPR 0x108/* TM checkpointed FPR Registers */ +#define NT_PPC_TM_CVMX 0x109/* TM checkpointed VMX Registers */ +#define NT_PPC_TM_CVSX 0x10a/* TM checkpointed VSX Registers */ +#define NT_PPC_TM_SPR 0x10b/* TM Special Purpose Registers */ +#define NT_PPC_TM_CTAR 0x10c/* TM checkpointed Target Address Register */ +#define NT_PPC_TM_CPPR 0x10d/* TM checkpointed Program Priority Register */ +#define NT_PPC_TM_CDSCR 0x10e/* TM checkpointed Data Stream Control Register */ #define NT_386_TLS 0x200/* i386 TLS slots (struct user_desc) */ #define NT_386_IOPERM 0x201/* x86 io permission bitmap (1=deny) */ #define NT_X86_XSTATE 0x202/* x86 extended state using xsave */
Signature · 1 line
2.1.0
PATCH v8 5/28 powerpc, ptrace: Enable in transaction NT_PPC_VSX ptrace requests
In reply to Anshuman KhandualThis patch enables in transaction NT_PPC_VSX ptrace requests. The function vsr_get which gets the running value of all VSX registers and the function vsr_set which sets the running value of of all VSX registers work on the running set of VMX registers whose location will be different if transaction is active. This patch makes these functions adapt to situations when the transaction is active.
--- arch/powerpc/kernel/ptrace.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
arch/powerpc/kernel/ptrace.c +64 -0
@@ -680,6 +680,21 @@ static int vsr_active(struct task_struct *target,return target->thread.used_vsr ? regset->n :0 ; } +/* +* When the transaction is active, 'transact_fp' holds the current running +* value of all FPR registers and 'fp_state' holds the last checkpointed +* value of all FPR registers for the current transaction. When transaction +* is not active 'fp_state' holds the current running state of all the FPR +* registers. So this function which returns the current running values of +* all the FPR registers, needs to know whether any transaction is active +* or not. +* +* Userspace interface buffer layout: +* +* struct data { +* u64 vsx[32]; +* }; +*/ static int vsr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf)
@@ -687,16 +702,47 @@ static int vsr_get(struct task_struct *target, const struct user_regset *regset,u64 buf[32 ];int ret, i; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +flush_fp_to_thread (target); +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); +#endif flush_vsx_to_thread (target); +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) { +for (i =0 ; i <32 ; i++) + buf[i] = target->thread. + transact_fp.fpr[i][TS_VSRLOWOFFSET ]; + }else { +for (i =0 ; i <32 ; i++) + buf[i] = target->thread. + fp_state.fpr[i][TS_VSRLOWOFFSET ]; + } +#else for (i =0 ; i <32 ; i++) buf[i] = target->thread.fp_state.fpr[i][TS_VSRLOWOFFSET ]; +#endif ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, buf,0 ,32 *sizeof (double ));return ret; } +/* +* When the transaction is active, 'transact_fp' holds the current running +* value of all FPR registers and 'fp_state' holds the last checkpointed +* value of all FPR registers for the current transaction. When transaction +* is not active 'fp_state' holds the current running state of all the FPR +* registers. So this function which sets the current running values of all +* the FPR registers, needs to know whether any transaction is active or not. +* +* Userspace interface buffer layout: +* +* struct data { +* u64 vsx[32]; +* }; +*/ static int vsr_set (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,const void *kbuf,const void __user *ubuf)
@@ -704,12 +750,30 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,u64 buf[32 ];int ret,i; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +flush_fp_to_thread (target); +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); +#endif flush_vsx_to_thread (target); ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, buf,0 ,32 *sizeof (double )); + +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) { +for (i =0 ; i <32 ; i++) + target->thread.transact_fp. + fpr[i][TS_VSRLOWOFFSET ] = buf[i]; + }else { +for (i =0 ; i <32 ; i++) + target->thread.fp_state. + fpr[i][TS_VSRLOWOFFSET ] = buf[i]; + } +#else for (i =0 ; i <32 ; i++) target->thread.fp_state.fpr[i][TS_VSRLOWOFFSET ] = buf[i]; +#endif return ret;
Signature · 1 line
2.1.0
v8 cover Add new powerpc specific ELF core notes
From: Anshuman Khandual <[email protected]>
This patch series adds twelve new ELF core note sections which can
be used with existing ptrace request PTRACE_GETREGSET-SETREGSET for accessing various transactional memory and other miscellaneous debug register sets on powerpc platform.
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
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
Test Result
-----------
ptrace-ebb PASS
ptrace-gpr PASS
ptrace-tm-gpr PASS
ptrace-tm-spd-gpr PASS
ptrace-tar FAIL
ptrace-tm-tar FAIL
ptrace-tm-spd-tar FAIL
ptrace-vsx PASS
ptrace-tm-vsx PASS
ptrace-tm-spd-vsx PASS
ptrace-tm-spr PASS
NOTE: The above three test case failures are due to PPR context save/restore in various paths. Still continue to debug the issue.
Anshuman Khandual (28):
elf: Add powerpc specific core note sections
powerpc, process: Add the function flush_tmregs_to_thread powerpc, ptrace: Enable in transaction NT_PRFPREG ptrace requests powerpc, ptrace: Enable in transaction NT_PPC_VMX ptrace requests powerpc, ptrace: Enable in transaction NT_PPC_VSX ptrace requests powerpc, ptrace: Adapt gpr32_get, gpr32_set functions for transaction powerpc, ptrace: Enable support for NT_PPC_CGPR
powerpc, ptrace: Enable support for NT_PPC_CFPR
powerpc, ptrace: Enable support for NT_PPC_CVMX
powerpc, ptrace: Enable support for NT_PPC_CVSX
powerpc, ptrace: Enable support for TM SPR state
powerpc, ptrace: Enable NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR powerpc, ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR powerpc, ptrace: Enable support for EBB registers
selftests, powerpc: Move 'reg.h' file outside of 'ebb' sub directory selftests, powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h' 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
arch/powerpc/include/asm/switch_to.h | 8 + arch/powerpc/include/uapi/asm/elf.h | 5 + arch/powerpc/kernel/process.c | 20 + arch/powerpc/kernel/ptrace.c | 1737 ++++++++++++++++++-- include/uapi/linux/elf.h | 12 + tools/testing/selftests/powerpc/Makefile | 2 +- tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 2 +- tools/testing/selftests/powerpc/pmu/ebb/ebb.h | 2 +- .../selftests/powerpc/pmu/ebb/ebb_handler.S | 2 +- tools/testing/selftests/powerpc/pmu/ebb/reg.h | 49 - .../selftests/powerpc/pmu/ebb/reg_access_test.c | 2 +- tools/testing/selftests/powerpc/ptrace/.gitignore | 11 + tools/testing/selftests/powerpc/ptrace/Makefile | 12 + .../testing/selftests/powerpc/ptrace/ptrace-ebb.c | 144 ++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 98 ++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 191 +++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 73 + .../testing/selftests/powerpc/ptrace/ptrace-tar.c | 151 ++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 + .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 287 ++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 318 ++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-tar.c | 184 +++ .../selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c | 211 +++ .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 156 ++ .../selftests/powerpc/ptrace/ptrace-tm-tar.c | 169 ++ .../selftests/powerpc/ptrace/ptrace-tm-vsx.c | 195 +++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.c | 138 ++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.h | 83 + tools/testing/selftests/powerpc/ptrace/ptrace.S | 403 +++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 765 +++++++++ tools/testing/selftests/powerpc/reg.h | 70 + 31 files changed, 5372 insertions(+), 178 deletions(-) delete mode 100644 tools/testing/selftests/powerpc/pmu/ebb/reg.h 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 create mode 100644 tools/testing/selftests/powerpc/reg.h
Signature · 1 line
2.1.0
PATCH v8 4/28 powerpc, ptrace: Enable in transaction NT_PPC_VMX ptrace requests
This patch enables in transaction NT_PPC_VMX ptrace requests. The function vr_get which gets the running value of all VMX registers and the function vr_set which sets the running value of of all VMX registers work on the running set of VMX registers whose location will be different if transaction is active. This patch makes these functions adapt to situations when the transaction is active.
--- arch/powerpc/kernel/ptrace.c | 90 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 3 deletions(-)
arch/powerpc/kernel/ptrace.c +87 -3
@@ -517,10 +517,28 @@ static int vr_active(struct task_struct *target,return target->thread.used_vr ? regset->n :0 ; } +/* +* When the transaction is active, 'transact_vr' holds the current running +* value of all the VMX registers and 'vr_state' holds the last checkpointed +* value of all the VMX registers for the current transaction to fall back +* on in case it aborts. When transaction is not active 'vr_state' holds +* the current running state of all the VMX registers. So this function which +* gets the current running values of all the VMX registers, needs to know +* whether any transaction is active or not. +* +* Userspace interface buffer layout: +* +* struct data { +* vector128 vr[32]; +* vector128 vscr; +* vector128 vrsave; +* }; +*/ static int vr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf) { +struct thread_vr_state *addr;int ret;flush_altivec_to_thread (target);
@@ -528,8 +546,19 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,BUILD_BUG_ON (offsetof(struct thread_vr_state , vscr) != offsetof(struct thread_vr_state, vr[32])); +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) { +flush_fp_to_thread (target); +flush_tmregs_to_thread (target); + addr = &target->thread.transact_vr; + }else { + addr = &target->thread.vr_state; + } +#else + addr = &target->thread.vr_state; +#endif ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, - &target->thread.vr_state,0 , + addr,0 ,33 *sizeof (vector128));if (!ret) {/*
@@ -540,7 +569,16 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,u32 word; } vrsave;memset (&vrsave,0 ,sizeof (vrsave)); + +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) + vrsave.word = target->thread.transact_vrsave; +else + vrsave.word = target->thread.vrsave; +#else vrsave.word = target->thread.vrsave; +#endif + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, &vrsave,33 *sizeof (vector128),-1 ); }
@@ -548,10 +586,28 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,return ret; } +/* +* When the transaction is active, 'transact_vr' holds the current running +* value of all the VMX registers and 'vr_state' holds the last checkpointed +* value of all the VMX registers for the current transaction to fall back +* on in case it aborts. When transaction is not active 'vr_state' holds +* the current running state of all the VMX registers. So this function which +* sets the current running values of all the VMX registers, needs to know +* whether any transaction is active or not. +* +* Userspace interface buffer layout: +* +* struct data { +* vector128 vr[32]; +* vector128 vscr; +* vector128 vrsave; +* }; +*/ static int vr_set (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,const void *kbuf,const void __user *ubuf) { +struct thread_vr_state *addr;int ret;flush_altivec_to_thread (target);
@@ -559,8 +615,19 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,BUILD_BUG_ON (offsetof(struct thread_vr_state , vscr) != offsetof(struct thread_vr_state, vr[32])); +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) { +flush_fp_to_thread (target); +flush_tmregs_to_thread (target); + addr = &target->thread.transact_vr; + }else { + addr = &target->thread.vr_state; + } +#else + addr = &target->thread.vr_state; +#endif ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - &target->thread.vr_state,0 , + addr,0 ,33 *sizeof (vector128));if (!ret && count >0 ) {/*
@@ -571,11 +638,28 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,u32 word; } vrsave;memset (&vrsave,0 ,sizeof (vrsave)); + +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) + vrsave.word = target->thread.transact_vrsave; +else + vrsave.word = target->thread.vrsave; +#else vrsave.word = target->thread.vrsave; +#endif ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &vrsave,33 *sizeof (vector128),-1 ); -if (!ret) +if (!ret) { + +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +if (MSR_TM_ACTIVE (target->thread.regs->msr)) + target->thread.transact_vrsave = vrsave.word; +else + target->thread.vrsave = vrsave.word; +#else target->thread.vrsave = vrsave.word; +#endif + } }return ret;
Signature · 1 line
2.1.0
PATCH v8 14/28 powerpc, ptrace: Enable support for EBB registers
In reply to Anshuman KhandualThis patch enables support for EBB state registers related ELF core note NT_PPC_EBB based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding one new register sets REGSET_EBB in powerpc corresponding to the ELF core note sections added in this regard. It also implements the get, set and active functions for this new register sets added.
--- arch/powerpc/include/uapi/asm/elf.h | 2 + arch/powerpc/kernel/ptrace.c | 147 ++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+)
arch/powerpc/include/uapi/asm/elf.h +2 -0
@@ -94,6 +94,8 @@#define ELF_NVMX 34/* includes all vector registers */ #define ELF_NVSX 32/* includes all VSX registers */ #define ELF_NTMSPRREG 3/* include tfhar, tfiar, texasr */ +#define ELF_NEBB 8/* includes ebbrr, ebbhr, bescr, siar, +sdar, sier, mmcr2, mmcr0 */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +147 -0
171 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 18/28 selftests, powerpc: Add ptrace tests for GPR/FPR registers
In reply to Anshuman KhandualThis 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 | 5 +- .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 191 +++++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 73 ++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 140 ++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 208 +++++++++++++++++++++ 5 files changed, 615 insertions(+), 2 deletions(-) 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 +3 -2
@@ -1,7 +1,8 @@ -TEST_PROGS := ptrace-ebb +TEST_PROGS := ptrace-ebb ptrace-gpr + all: $(TEST_PROGS) -$(TEST_PROGS): ../harness.c +$(TEST_PROGS): ../harness.c ptrace.S 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-gpr.c new file +191 -0
191 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-gpr.h new file +73 -0
73 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.S new file +140 -0
140 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +208 -0
214 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 27/28 selftests, powerpc: Add ptrace tests for TM SPR registers
In reply to Anshuman KhandualThis 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 | 2 +- .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 156 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 35 +++++ 3 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
@@ -1,6 +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-tm-spd-vsx +ptrace-tm-spd-vsx ptrace-tm-spr all: $(TEST_PROGS)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c new file +156 -0
156 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +35 -0
@@ -82,6 +82,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)
@@ -662,6 +667,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
2.1.0
PATCH v8 15/28 selftests, powerpc: Move 'reg.h' file outside of 'ebb' sub directory
In reply to Anshuman KhandualThis patch moves 'reg.h' file from pmu 'ebb' sub directory to the powerpc root directory to make all the register definitions and instructions available for tests present in other subsystems.
--- tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 2 +- tools/testing/selftests/powerpc/pmu/ebb/ebb.h | 2 +- .../selftests/powerpc/pmu/ebb/ebb_handler.S | 2 +- tools/testing/selftests/powerpc/pmu/ebb/reg.h | 49 ---------------------- .../selftests/powerpc/pmu/ebb/reg_access_test.c | 2 +- tools/testing/selftests/powerpc/reg.h | 49 ++++++++++++++++++++++ 6 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 tools/testing/selftests/powerpc/pmu/ebb/reg.h create mode 100644 tools/testing/selftests/powerpc/reg.h
tools/testing/selftests/powerpc/pmu/ebb/ebb.c +1 -1
@@ -15,7 +15,7 @@#include <sys/ioctl.h> #include "trace.h" -#include "reg.h" +#include "../../reg.h" #include "ebb.h"
tools/testing/selftests/powerpc/pmu/ebb/ebb.h +1 -1
@@ -9,7 +9,7 @@#include "../event.h" #include "../lib.h" #include "trace.h" -#include "reg.h" +#include "../../reg.h" #define PMC_INDEX (pmc) ((pmc)-1)
tools/testing/selftests/powerpc/pmu/ebb/ebb_handler.S +1 -1
@@ -4,7 +4,7 @@ */ #include <ppc-asm.h> -#include "reg.h" +#include "../../reg.h" /* ppc-asm.h defines most of the reg aliases, but not r1/r2. */
tools/testing/selftests/powerpc/pmu/ebb/reg.h deleted +0 -49
49 lines not on this page · raw message
tools/testing/selftests/powerpc/pmu/ebb/reg_access_test.c +1 -1
@@ -7,7 +7,7 @@#include <stdlib.h> #include "ebb.h" -#include "reg.h" +#include "../../reg.h" /*
tools/testing/selftests/powerpc/reg.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 7/28 powerpc, ptrace: Enable support for NT_PPC_CGPR
In reply to Anshuman KhandualThis patch enables support for TM checkpointed GPR register set ELF core note NT_PPC_CGPR based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding a register set REGSET_CGPR in powerpc corresponding to the ELF core note section added. It implements the get, set and active functions for this new register set added.
--- arch/powerpc/kernel/ptrace.c | 222 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+)
arch/powerpc/kernel/ptrace.c +222 -0
@@ -180,6 +180,26 @@ static int set_user_msr(struct task_struct *task, unsigned long msr)return 0 ; } +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +static unsigned long get_user_ckpt_msr (struct task_struct *task) +{ +return task->thread.ckpt_regs.msr | task->thread.fpexc_mode; +} + +static int set_user_ckpt_msr (struct task_struct *task,unsigned long msr) +{ + task->thread.ckpt_regs.msr &= ~MSR_DEBUGCHANGE ; + task->thread.ckpt_regs.msr |= msr &MSR_DEBUGCHANGE ; +return 0 ; +} + +static int set_user_ckpt_trap (struct task_struct *task,unsigned long trap) +{ + task->thread.ckpt_regs.trap = trap &0xfff0 ; +return 0 ; +} +#endif +#ifdef CONFIG_PPC64 static int get_user_dscr (struct task_struct *task,unsigned long *data) {
@@ -846,6 +866,172 @@ static int evr_set(struct task_struct *target, const struct user_regset *regset, }#endif /* CONFIG_SPE */ +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +/** +* tm_cgpr_active - get active number of registers in CGPR +* @target: The target task. +* @regset: The user regset structure. +* +* This function checks for the active number of available +* regisers in transaction checkpointed GPR category. +*/ +static int tm_cgpr_active (struct task_struct *target, +const struct user_regset *regset) +{ +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return 0 ; + +return regset->n; +} + +/** +* tm_cgpr_get - get CGPR registers +* @target: The target task. +* @regset: The user regset structure. +* @pos: The buffer position. +* @count: Number of bytes to copy. +* @kbuf: Kernel buffer to copy from. +* @ubuf: User buffer to copy into. +* +* This function gets transaction checkpointed GPR registers. +* +* When the transaction is active, 'ckpt_regs' holds all the checkpointed +* GPR register values for the current transaction to fall back on if it +* aborts in between. This function gets those checkpointed GPR registers. +* The userspace interface buffer layout is as follows. +* +* struct data { +* struct pt_regs ckpt_regs; +* }; +*/ +static int tm_cgpr_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + +flush_fp_to_thread (target); +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.ckpt_regs, +0 , offsetof(struct pt_regs , msr)); +if (!ret) { +unsigned long msr =get_user_ckpt_msr (target); + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, &msr, + offsetof(struct pt_regs , msr), + offsetof(struct pt_regs , msr) + +sizeof (msr)); + } + +BUILD_BUG_ON (offsetof(struct pt_regs , orig_gpr3) != + offsetof(struct pt_regs , msr) +sizeof (long )); + +if (!ret) + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.ckpt_regs.orig_gpr3, + offsetof(struct pt_regs , orig_gpr3), +sizeof (struct pt_regs )); +if (!ret) + ret =user_regset_copyout_zero (&pos, &count, &kbuf, &ubuf, +sizeof (struct pt_regs ),-1 ); + +return ret; +} + +/* +* tm_cgpr_set - set the CGPR registers +* @target: The target task. +* @regset: The user regset structure. +* @pos: The buffer position. +* @count: Number of bytes to copy. +* @kbuf: Kernel buffer to copy into. +* @ubuf: User buffer to copy from. +* +* This function sets in transaction checkpointed GPR registers. +* +* When the transaction is active, 'ckpt_regs' holds the checkpointed +* GPR register values for the current transaction to fall back on if it +* aborts in between. This function sets those checkpointed GPR registers. +* The userspace interface buffer layout is as follows. +* +* struct data { +* struct pt_regs ckpt_regs; +* }; +*/ +static int tm_cgpr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +unsigned long reg; +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + +flush_fp_to_thread (target); +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.ckpt_regs, +0 ,PT_MSR *sizeof (reg)); + +if (!ret && count >0 ) { + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, ®, +PT_MSR *sizeof (reg), + (PT_MSR +1 ) *sizeof (reg)); +if (!ret) + ret =set_user_ckpt_msr (target, reg); + } + +BUILD_BUG_ON (offsetof(struct pt_regs , orig_gpr3) != + offsetof(struct pt_regs , msr) +sizeof (long )); + +if (!ret) + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.ckpt_regs.orig_gpr3, +PT_ORIG_R3 *sizeof (reg), + (PT_MAX_PUT_REG +1 ) *sizeof (reg)); + +if (PT_MAX_PUT_REG +1 <PT_TRAP && !ret) + ret =user_regset_copyin_ignore ( + &pos, &count, &kbuf, &ubuf, + (PT_MAX_PUT_REG +1 ) *sizeof (reg), +PT_TRAP *sizeof (reg)); + +if (!ret && count >0 ) { + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, ®, +PT_TRAP *sizeof (reg), + (PT_TRAP +1 ) *sizeof (reg)); +if (!ret) + ret =set_user_ckpt_trap (target, reg); + } + +if (!ret) + ret =user_regset_copyin_ignore ( + &pos, &count, &kbuf, &ubuf, + (PT_TRAP +1 ) *sizeof (reg),-1 ); + +return ret; +} +#endif /* * These are our native regset flavors.
@@ -862,6 +1048,9 @@ enum powerpc_regset {#ifdef CONFIG_SPE REGSET_SPE,#endif +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + REGSET_TM_CGPR, /* TM checkpointed GPR registers */ +#endif };static const struct user_regset native_regsets[] = {
@@ -896,6 +1085,13 @@ static const struct user_regset native_regsets[] = { .active = evr_active, .get = evr_get, .set = evr_set },#endif +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + [REGSET_TM_CGPR] = { + .core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG, + .size = sizeof(long), .align = sizeof(long), + .active = tm_cgpr_active, .get = tm_cgpr_get, .set = tm_cgpr_set + }, +#endif }; static const struct user_regset_view user_ppc_native_view = {
@@ -1058,6 +1254,24 @@ static int gpr32_set_common(struct task_struct *target, (PT_TRAP + 1) * sizeof(reg), -1); } +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +static int tm_cgpr32_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +return gpr32_get_common (target, regset, pos, count, kbuf, ubuf,1 ); +} + +static int tm_cgpr32_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +return gpr32_set_common (target, regset, pos, count, kbuf, ubuf,1 ); +} +#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ + static int gpr32_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count,
@@ -1102,6 +1316,14 @@ static const struct user_regset compat_regsets[] = { .active = evr_active, .get = evr_get, .set = evr_set },#endif +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + [REGSET_TM_CGPR] = { + .core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG, + .size = sizeof(long), .align = sizeof(long), + .active = tm_cgpr_active, + .get = tm_cgpr32_get, .set = tm_cgpr32_set + }, +#endif }; static const struct user_regset_view user_ppc_compat_view = {
Signature · 1 line
2.1.0
PATCH v8 3/28 powerpc, ptrace: Enable in transaction NT_PRFPREG ptrace requests
In reply to Anshuman KhandualThis patch enables in transaction NT_PRFPREG ptrace requests. The function fpr_get which gets the running value of all FPR registers and the function fpr_set which sets the running value of of all FPR registers work on the running set of FPR registers whose location will be different if transaction is active. This patch makes these functions adapt to situations when the transaction is active.
--- arch/powerpc/kernel/ptrace.c | 93 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-)
arch/powerpc/kernel/ptrace.c +89 -4
@@ -357,6 +357,29 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,return ret; } +/* +* When the transaction is active, 'transact_fp' holds the current running +* value of all FPR registers and 'fp_state' holds the last checkpointed +* value of all FPR registers for the current transaction. When transaction +* is not active 'fp_state' holds the current running state of all the FPR +* registers. So this function which returns the current running values of +* all the FPR registers, needs to know whether any transaction is active +* or not. +* +* Userspace interface buffer layout: +* +* struct data { +* u64 fpr[32]; +* u64 fpscr; +* }; +* +* There are two config options CONFIG_VSX and CONFIG_PPC_TRANSACTIONAL_MEM +* which determines the final code in this function. All the combinations of +* these two config options are possible except the one below as transactional +* memory config pulls in CONFIG_VSX automatically. +* +* !defined(CONFIG_VSX) && defined(CONFIG_PPC_TRANSACTIONAL_MEM) +*/ static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf)
@@ -367,14 +390,31 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,#endif flush_fp_to_thread (target); -#ifdef CONFIG_VSX +#if defined(CONFIG_VSX ) && defined(CONFIG_PPC_TRANSACTIONAL_MEM ) +/* copy to local buffer then write that out */ +if (MSR_TM_ACTIVE (target->thread.regs->msr)) { +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); +for (i =0 ; i <32 ; i++) + buf[i] = target->thread.TS_TRANS_FPR (i); + buf[32 ] = target->thread.transact_fp.fpscr; + }else { +for (i =0 ; i <32 ; i++) + buf[i] = target->thread.TS_FPR (i); + buf[32 ] = target->thread.fp_state.fpscr; + } +return user_regset_copyout (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 ); +#endif + +#if defined(CONFIG_VSX ) && !defined(CONFIG_PPC_TRANSACTIONAL_MEM )/* copy to local buffer then write that out */ for (i =0 ; i <32 ; i++) buf[i] = target->thread.TS_FPR (i); buf[32 ] = target->thread.fp_state.fpscr;return user_regset_copyout (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 ); +#endif -#else +#if !defined(CONFIG_VSX ) && !defined(CONFIG_PPC_TRANSACTIONAL_MEM )BUILD_BUG_ON (offsetof(struct thread_fp_state , fpscr) != offsetof(struct thread_fp_state, fpr[32][0]));
@@ -383,6 +423,29 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,#endif } +/* +* When the transaction is active, 'transact_fp' holds the current running +* value of all FPR registers and 'fp_state' holds the last checkpointed +* value of all FPR registers for the current transaction. When transaction +* is not active 'fp_state' holds the current running state of all the FPR +* registers. So this function which setss the current running values of +* all the FPR registers, needs to know whether any transaction is active +* or not. +* +* Userspace interface buffer layout: +* +* struct data { +* u64 fpr[32]; +* u64 fpscr; +* }; +* +* There are two config options CONFIG_VSX and CONFIG_PPC_TRANSACTIONAL_MEM +* which determines the final code in this function. All the combinations of +* these two config options are possible except the one below as transactional +* memory config pulls in CONFIG_VSX automatically. +* +* !defined(CONFIG_VSX) && defined(CONFIG_PPC_TRANSACTIONAL_MEM) +*/ static int fpr_set (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,const void *kbuf,const void __user *ubuf)
@@ -393,7 +456,27 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,#endif flush_fp_to_thread (target); -#ifdef CONFIG_VSX +#if defined(CONFIG_VSX ) && defined(CONFIG_PPC_TRANSACTIONAL_MEM ) +/* copy to local buffer then write that out */ + i =user_regset_copyin (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 ); +if (i) +return i; + +if (MSR_TM_ACTIVE (target->thread.regs->msr)) { +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); +for (i =0 ; i <32 ; i++) + target->thread.TS_TRANS_FPR (i) = buf[i]; + target->thread.transact_fp.fpscr = buf[32 ]; + }else { +for (i =0 ; i <32 ; i++) + target->thread.TS_FPR (i) = buf[i]; + target->thread.fp_state.fpscr = buf[32 ]; + } +return 0 ; +#endif + +#if defined(CONFIG_VSX ) && !defined(CONFIG_PPC_TRANSACTIONAL_MEM )/* copy to local buffer then write that out */ i =user_regset_copyin (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 );if (i)
@@ -402,7 +485,9 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset, target->thread.TS_FPR (i) = buf[i]; target->thread.fp_state.fpscr = buf[32 ];return 0 ; -#else +#endif + +#if !defined(CONFIG_VSX ) && !defined(CONFIG_PPC_TRANSACTIONAL_MEM )BUILD_BUG_ON (offsetof(struct thread_fp_state , fpscr) != offsetof(struct thread_fp_state, fpr[32][0]));
Signature · 1 line
2.1.0
PATCH v8 17/28 selftests, powerpc: Add ptrace tests for EBB
In reply to Anshuman KhandualThis patch adds ptrace interface test for EBB 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 | 2 +- tools/testing/selftests/powerpc/ptrace/Makefile | 7 + .../testing/selftests/powerpc/ptrace/ptrace-ebb.c | 144 +++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 98 +++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 224 +++++++++++++++++++++ 5 files changed, 474 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 +1 -1
@@ -12,7 +12,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR export CFLAGS -SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian +SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian ptrace endif
tools/testing/selftests/powerpc/ptrace/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +TEST_PROGS := ptrace-ebb +all: $(TEST_PROGS) + +$(TEST_PROGS): ../harness.c +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 +144 -0
144 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-ebb.h new file +98 -0
98 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h new file +224 -0
224 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 21/28 selftests, powerpc: Add ptrace tests for TAR, PPR, DSCR registers
In reply to Anshuman KhandualThis 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 | 151 +++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 ++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 179 +++++++++++++++++++++ 4 files changed, 382 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)
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c new file +151 -0
151 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 +179 -0
185 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 26/28 selftests, powerpc: Add ptrace tests for VSX, VMX registers in suspended TM
In reply to Anshuman KhandualThis 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 | 211 +++++++++++++++++++++ 2 files changed, 213 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 +211 -0
211 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 23/28 selftests, powerpc: Add ptrace tests for TAR, PPR, DSCR in suspended TM
In reply to Anshuman KhandualThis 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 | 184 +++++++++++++++++++++ 2 files changed, 185 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)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c new file +184 -0
184 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 25/28 selftests, powerpc: Add ptrace tests for VSX, VMX registers in TM
In reply to Anshuman KhandualThis 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 | 195 +++++++++++++++++++++ 2 files changed, 197 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)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c new file +195 -0
195 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 16/28 selftests, powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h'
In reply to Anshuman KhandualThis 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tools/testing/selftests/powerpc/reg.h +21 -0
@@ -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
@@ -46,4 +59,12 @@#define SPRN_SDAR 781#define SPRN_SIER 768 +#define SPRN_DSCR 3/* Data Stream Control Register */ +#define SPRN_TAR 815/* Target Address Register */ +#define SPRN_PPR 896/* Program Priority Register */ + +#define SPRN_TFHAR 0x80/* TM Failure Handle Register */ +#define SPRN_TFIAR 0x81/* TM Failure Instruction Address Register */ +#define SPRN_TEXASR 0x82/* TM Exception and Status Register */ +#endif /* _SELFTESTS_POWERPC_REG_H */
Signature · 1 line
2.1.0
PATCH v8 28/28 selftests, powerpc: Add .gitignore file for ptrace executables
In reply to Anshuman KhandualThis 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
2.1.0
PATCH v8 12/28 powerpc, ptrace: Enable NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR
In reply to Anshuman KhandualThis patch enables support for all three TM checkpointed SPR states related ELF core note NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding three new register sets REGSET_TM_CTAR, REGSET_TM_CPPR and REGSET_TM_CDSCR in powerpc corresponding to the ELF core note sections added. It implements the get, set and active functions for all these new register sets added.
--- arch/powerpc/kernel/ptrace.c | 178 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+)
arch/powerpc/kernel/ptrace.c +178 -0
@@ -1541,6 +1541,151 @@ static int tm_spr_set(struct task_struct *target, 2 * sizeof(u64), 3 * sizeof(u64));return ret; } + +static int tm_tar_active (struct task_struct *target, +const struct user_regset *regset) +{ +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (MSR_TM_ACTIVE (target->thread.regs->msr)) +return regset->n; + +return 0 ; +} + +static int tm_tar_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.tm_tar,0 ,sizeof (u64)); +return ret; +} + +static int tm_tar_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.tm_tar,0 ,sizeof (u64)); +return ret; +} + +static int tm_ppr_active (struct task_struct *target, +const struct user_regset *regset) +{ +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (MSR_TM_ACTIVE (target->thread.regs->msr)) +return regset->n; + +return 0 ; +} + + +static int tm_ppr_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.tm_ppr,0 ,sizeof (u64)); +return ret; +} + +static int tm_ppr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.tm_ppr,0 ,sizeof (u64)); +return ret; +} + +static int tm_dscr_active (struct task_struct *target, +const struct user_regset *regset) +{ +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (MSR_TM_ACTIVE (target->thread.regs->msr)) +return regset->n; + +return 0 ; +} + +static int tm_dscr_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.tm_dscr,0 ,sizeof (u64)); +return ret; +} + +static int tm_dscr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int ret; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.tm_dscr,0 ,sizeof (u64)); +return ret; +}#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ /*
@@ -1564,6 +1709,9 @@ enum powerpc_regset {REGSET_TM_CVMX ,/* TM checkpointed VMX registers */ REGSET_TM_CVSX ,/* TM checkpointed VSX registers */ REGSET_TM_SPR ,/* TM specific SPR registers */ +REGSET_TM_CTAR ,/* TM checkpointed TAR register */ +REGSET_TM_CPPR ,/* TM checkpointed PPR register */ + REGSET_TM_CDSCR, /* TM checkpointed DSCR register */ #endif };
@@ -1625,6 +1773,21 @@ static const struct user_regset native_regsets[] = { .size = sizeof(u64), .align = sizeof(u64), .active = tm_spr_active, .get = tm_spr_get, .set = tm_spr_set }, + [REGSET_TM_CTAR] = { + .core_note_type = NT_PPC_TM_CTAR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .active = tm_tar_active, .get = tm_tar_get, .set = tm_tar_set + }, + [REGSET_TM_CPPR] = { + .core_note_type = NT_PPC_TM_CPPR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .active = tm_ppr_active, .get = tm_ppr_get, .set = tm_ppr_set + }, + [REGSET_TM_CDSCR] = { + .core_note_type = NT_PPC_TM_CDSCR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set + }, #endif };
@@ -1877,6 +2040,21 @@ static const struct user_regset compat_regsets[] = { .size = sizeof(u64), .align = sizeof(u64), .active = tm_spr_active, .get = tm_spr_get, .set = tm_spr_set }, + [REGSET_TM_CTAR] = { + .core_note_type = NT_PPC_TM_CTAR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .active = tm_tar_active, .get = tm_tar_get, .set = tm_tar_set + }, + [REGSET_TM_CPPR] = { + .core_note_type = NT_PPC_TM_CPPR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .active = tm_ppr_active, .get = tm_ppr_get, .set = tm_ppr_set + }, + [REGSET_TM_CDSCR] = { + .core_note_type = NT_PPC_TM_CDSCR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set + }, #endif };
Signature · 1 line
2.1.0
PATCH v8 8/28 powerpc, ptrace: Enable support for NT_PPC_CFPR
In reply to Anshuman KhandualThis patch enables support for TM checkpointed FPR register set ELF core note NT_PPC_CFPR based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding a register set REGSET_CFPR in powerpc corresponding to the ELF core note section added. It implements the get, set and active functions for this new register set added.
--- arch/powerpc/kernel/ptrace.c | 126 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+)
arch/powerpc/kernel/ptrace.c +126 -0
@@ -1031,6 +1031,121 @@ static int tm_cgpr_set(struct task_struct *target, return ret; } + +/** +* tm_cfpr_active - get active number of registers in CFPR +* @target: The target task. +* @regset: The user regset structure. +* +* This function checks for the active number of available +* regisers in transaction checkpointed FPR category. +*/ +static int tm_cfpr_active (struct task_struct *target, +const struct user_regset *regset) +{ +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return 0 ; + +return regset->n; +} + +/** +* tm_cfpr_get - get CFPR registers +* @target: The target task. +* @regset: The user regset structure. +* @pos: The buffer position. +* @count: Number of bytes to copy. +* @kbuf: Kernel buffer to copy from. +* @ubuf: User buffer to copy into. +* +* This function gets in transaction checkpointed FPR registers. +* +* When the transaction is active 'fp_state' holds the checkpointed +* values for the current transaction to fall back on if it aborts +* in between. This function gets those checkpointed FPR registers. +* The userspace interface buffer layout is as follows. +* +* struct data { +* u64 fpr[32]; +* u64 fpscr; +*}; +*/ +static int tm_cfpr_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +u64 buf[33 ]; +int i; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + +flush_fp_to_thread (target); +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); + +/* copy to local buffer then write that out */ +for (i =0 ; i <32 ; i++) + buf[i] = target->thread.TS_FPR (i); + buf[32 ] = target->thread.fp_state.fpscr; +return user_regset_copyout (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 ); +} + +/** +* tm_cfpr_set - set CFPR registers +* @target: The target task. +* @regset: The user regset structure. +* @pos: The buffer position. +* @count: Number of bytes to copy. +* @kbuf: Kernel buffer to copy into. +* @ubuf: User buffer to copy from. +* +* This function sets in transaction checkpointed FPR registers. +* +* When the transaction is active 'fp_state' holds the checkpointed +* FPR register values for the current transaction to fall back on +* if it aborts in between. This function sets these checkpointed +* FPR registers. The userspace interface buffer layout is as follows. +* +* struct data { +* u64 fpr[32]; +* u64 fpscr; +*}; +*/ +static int tm_cfpr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +u64 buf[33 ]; +int i; + +if (!cpu_has_feature (CPU_FTR_TM )) +return -ENODEV ; + +if (!MSR_TM_ACTIVE (target->thread.regs->msr)) +return -ENODATA ; + +flush_fp_to_thread (target); +flush_altivec_to_thread (target); +flush_tmregs_to_thread (target); + +/* copy to local buffer then write that out */ + i =user_regset_copyin (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 ); +if (i) +return i; +for (i =0 ; i <32 ; i++) + target->thread.TS_FPR (i) = buf[i]; + target->thread.fp_state.fpscr = buf[32 ]; +return 0 ; +}#endif /*
@@ -1050,6 +1165,7 @@ enum powerpc_regset {#endif #ifdef CONFIG_PPC_TRANSACTIONAL_MEM REGSET_TM_CGPR, /* TM checkpointed GPR registers */ + REGSET_TM_CFPR, /* TM checkpointed FPR registers */#endif };
@@ -1091,6 +1207,11 @@ static const struct user_regset native_regsets[] = { .size = sizeof(long), .align = sizeof(long), .active = tm_cgpr_active, .get = tm_cgpr_get, .set = tm_cgpr_set }, + [REGSET_TM_CFPR] = { + .core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG, + .size = sizeof(double), .align = sizeof(double), + .active = tm_cfpr_active, .get = tm_cfpr_get, .set = tm_cfpr_set + },#endif };
@@ -1323,6 +1444,11 @@ static const struct user_regset compat_regsets[] = { .active = tm_cgpr_active, .get = tm_cgpr32_get, .set = tm_cgpr32_set }, + [REGSET_TM_CFPR] = { + .core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG, + .size = sizeof(double), .align = sizeof(double), + .active = tm_cfpr_active, .get = tm_cfpr_get, .set = tm_cfpr_set + },#endif };
Signature · 1 line
2.1.0
PATCH v8 2/28 powerpc, process: Add the function flush_tmregs_to_thread
In reply to Anshuman KhandualThis patch creates a function flush_tmregs_to_thread which will then be used by subsequent patches in this series. The function checks for self tracing ptrace interface attempts while in the TM context and logs appropriate warning message.
--- arch/powerpc/include/asm/switch_to.h | 8 ++++++++ arch/powerpc/kernel/process.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+)
arch/powerpc/include/asm/switch_to.h +8 -0
@@ -82,6 +82,14 @@ static inline void flush_spe_to_thread(struct task_struct *t) }#endif +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +extern void flush_tmregs_to_thread (struct task_struct *); +#else +static inline void flush_tmregs_to_thread (struct task_struct *t) +{ +} +#endif +static inline void clear_task_ebb (struct task_struct *t) {#ifdef CONFIG_PPC_BOOK3S_64
arch/powerpc/kernel/process.c +20 -0
@@ -745,6 +745,26 @@ void restore_tm_state(struct pt_regs *regs)#define __switch_to_tm (prev)#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +void flush_tmregs_to_thread (struct task_struct *tsk) +{ +/* +* Process self tracing is not yet supported through +* ptrace interface. Ptrace generic code should have +* prevented this from happening in the first place. +* Warn once here with the message, if some how it +* is attempted. +*/ +WARN_ONCE (tsk == current, +"Not expecting ptrace on self: TM regs may be incorrect\n" ); + +/* +* If task is not current, it should have been flushed +* already to it's thread_struct during __switch_to(). +*/ +} +#endif +struct task_struct *__switch_to (struct task_struct *prev,struct task_struct *new) {
Signature · 1 line
2.1.0
PATCH v8 6/28 powerpc, ptrace: Adapt gpr32_get, gpr32_set functions for transaction
In reply to Anshuman KhandualThis patch splits gpr32_get, gpr32_set functions to accommodate in transaction ptrace requests implemented in patches later in the series.
--- arch/powerpc/kernel/ptrace.c | 64 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 13 deletions(-)
arch/powerpc/kernel/ptrace.c +51 -13
@@ -906,24 +906,35 @@ static const struct user_regset_view user_ppc_native_view = {#ifdef CONFIG_PPC64 #include <linux/compat.h> -static int gpr32_get (struct task_struct *target, +static int gpr32_get_common (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count, -void *kbuf,void __user *ubuf) +void *kbuf,void __user *ubuf,bool tm_active) {const unsigned long *regs = &target->thread.regs->gpr[0 ]; +const unsigned long *ckpt_regs;compat_ulong_t *k = kbuf;compat_ulong_t __user *u = ubuf;compat_ulong_t reg;int i; -if (target->thread.regs ==NULL ) -return -EIO ; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + ckpt_regs = &target->thread.ckpt_regs.gpr[0 ]; +#endif +if (tm_active) { + regs = ckpt_regs; + }else { +if (target->thread.regs ==NULL ) +return -EIO ; -if (!FULL_REGS (target->thread.regs)) { -/* We have a partial register set. Fill 14-31 with bogus values */ -for (i =14 ; i <32 ; i++) - target->thread.regs->gpr[i] =NV_REG_POISON ; +if (!FULL_REGS (target->thread.regs)) { +/* +* We have a partial register set. +* Fill 14-31 with bogus values. +*/ +for (i =14 ; i <32 ; i++) + target->thread.regs->gpr[i] =NV_REG_POISON ; + } } pos /=sizeof (reg);
@@ -963,20 +974,31 @@ static int gpr32_get(struct task_struct *target, PT_REGS_COUNT * sizeof(reg), -1); } -static int gpr32_set (struct task_struct *target, +static int gpr32_set_common (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count, -const void *kbuf,const void __user *ubuf) +const void *kbuf,const void __user *ubuf,bool tm_active) {unsigned long *regs = &target->thread.regs->gpr[0 ]; +unsigned long *ckpt_regs;const compat_ulong_t *k = kbuf;const compat_ulong_t __user *u = ubuf;compat_ulong_t reg; -if (target->thread.regs ==NULL ) -return -EIO ; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + ckpt_regs = &target->thread.ckpt_regs.gpr[0 ]; +#endif -CHECK_FULL_REGS (target->thread.regs); +if (tm_active) { + regs = ckpt_regs; + }else { + regs = &target->thread.regs->gpr[0 ]; + +if (target->thread.regs ==NULL ) +return -EIO ; + +CHECK_FULL_REGS (target->thread.regs); + } pos /=sizeof (reg); count /=sizeof (reg);
@@ -1036,6 +1058,22 @@ static int gpr32_set(struct task_struct *target, (PT_TRAP + 1) * sizeof(reg), -1); } +static int gpr32_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +return gpr32_get_common (target, regset, pos, count, kbuf, ubuf,0 ); +} + +static int gpr32_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +return gpr32_set_common (target, regset, pos, count, kbuf, ubuf,0 ); +} +/* * These are the regset flavors matching the CONFIG_PPC32 native set. */
Signature · 1 line
2.1.0
PATCH v8 22/28 selftests, powerpc: Add ptrace tests for TAR, PPR, DSCR in TM
In reply to Anshuman KhandualThis 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 | 169 +++++++++++++++++++++ 2 files changed, 170 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)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c new file +169 -0
169 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 24/28 selftests, powerpc: Add ptrace tests for VSX, VMX registers
In reply to Anshuman KhandualThis 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 | 138 +++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.h | 83 +++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 263 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 119 ++++++++++ 5 files changed, 604 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)
tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c new file +138 -0
138 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-vsx.h new file +83 -0
83 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.S +263 -0
266 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
2.1.0
PATCH v8 20/28 selftests, powerpc: Add ptrace tests for GPR/FPR registers in suspended TM
In reply to Anshuman KhandualThis 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 | 318 +++++++++++++++++++++ 2 files changed, 319 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)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c new file +318 -0
318 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 19/28 selftests, powerpc: Add ptrace tests for GPR/FPR registers in TM
In reply to Anshuman KhandualThis 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 | 287 +++++++++++++++++++++ 2 files changed, 289 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) $(TEST_PROGS): ../harness.c ptrace.S 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 +287 -0
287 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 9/28 powerpc, ptrace: Enable support for NT_PPC_CVMX
In reply to Anshuman KhandualThis patch enables support for TM checkpointed VMX register set ELF core note NT_PPC_CVMX based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding a register set REGSET_CVMX in powerpc corresponding to the ELF core note section added. It implements the get, set and active functions for this new register set added.
--- arch/powerpc/include/uapi/asm/elf.h | 1 + arch/powerpc/kernel/ptrace.c | 158 ++++++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+)
arch/powerpc/include/uapi/asm/elf.h +1 -0
@@ -91,6 +91,7 @@#define ELF_NGREG 48/* includes nip, msr, lr, etc. */ #define ELF_NFPREG 33/* includes fpscr */ +#define ELF_NVMX 34/* includes all vector registers */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +158 -0
188 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 10/28 powerpc, ptrace: Enable support for NT_PPC_CVSX
In reply to Anshuman KhandualThis patch enables support for TM checkpointed VSX register set ELF core note NT_PPC_CVSX based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding a register set REGSET_CVSX in powerpc corresponding to the ELF core note section added. It implements the get, set and active functions for this new register set added.
--- arch/powerpc/include/uapi/asm/elf.h | 1 + arch/powerpc/kernel/ptrace.c | 129 ++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+)
arch/powerpc/include/uapi/asm/elf.h +1 -0
@@ -92,6 +92,7 @@#define ELF_NGREG 48/* includes nip, msr, lr, etc. */ #define ELF_NFPREG 33/* includes fpscr */ #define ELF_NVMX 34/* includes all vector registers */ +#define ELF_NVSX 32/* includes all VSX registers */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +129 -0
159 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 11/28 powerpc, ptrace: Enable support for TM SPR state
In reply to Anshuman KhandualThis patch enables support for TM SPR state related ELF core note NT_PPC_TM_SPR based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding a register set REGSET_TM_SPR in powerpc corresponding to the ELF core note section added. It implements the get, set and active functions for this new register set added.
--- arch/powerpc/include/uapi/asm/elf.h | 1 + arch/powerpc/kernel/ptrace.c | 143 +++++++++++++++++++++++++++++++++++- 2 files changed, 143 insertions(+), 1 deletion(-)
arch/powerpc/include/uapi/asm/elf.h +1 -0
@@ -93,6 +93,7 @@#define ELF_NFPREG 33/* includes fpscr */ #define ELF_NVMX 34/* includes all vector registers */ #define ELF_NVSX 32/* includes all VSX registers */ +#define ELF_NTMSPRREG 3/* include tfhar, tfiar, texasr */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +142 -1
173 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v8 13/28 powerpc, ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR
In reply to Anshuman KhandualThis patch enables support for running TAR, PPR, DSCR registers related ELF core notes NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding three new register sets REGSET_TAR, REGSET_PPR, REGSET_DSCR in powerpc corresponding to the ELF core note sections added in this regad. It implements the get, set and active functions for all these new register sets added.
--- arch/powerpc/kernel/ptrace.c | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+)
arch/powerpc/kernel/ptrace.c +117 -0
@@ -1688,6 +1688,78 @@ static int tm_dscr_set(struct task_struct *target, }#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ +#ifdef CONFIG_PPC64 +static int ppr_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.ppr,0 ,sizeof (u64)); +return ret; +} + +static int ppr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int ret; + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.ppr,0 ,sizeof (u64)); +return ret; +} + +static int dscr_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.dscr,0 ,sizeof (u64)); +return ret; +} +static int dscr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int ret; + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.dscr,0 ,sizeof (u64)); +return ret; +} +#endif +#ifdef CONFIG_PPC_BOOK3S_64 +static int tar_get (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +void *kbuf,void __user *ubuf) +{ +int ret; + + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.tar,0 ,sizeof (u64)); +return ret; +} +static int tar_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int ret; + + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &target->thread.tar,0 ,sizeof (u64)); +return ret; +} +#endif /* * These are our native regset flavors. */
@@ -1713,6 +1785,13 @@ enum powerpc_regset { REGSET_TM_CPPR, /* TM checkpointed PPR register */ REGSET_TM_CDSCR, /* TM checkpointed DSCR register */#endif +#ifdef CONFIG_PPC64 + REGSET_PPR, /* PPR register */ + REGSET_DSCR, /* DSCR register */ +#endif +#ifdef CONFIG_PPC_BOOK3S_64 + REGSET_TAR, /* TAR register */ +#endif };static const struct user_regset native_regsets[] = {
@@ -1789,6 +1868,25 @@ static const struct user_regset native_regsets[] = { .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set },#endif +#ifdef CONFIG_PPC64 + [REGSET_PPR] = { + .core_note_type = NT_PPC_PPR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .get = ppr_get, .set = ppr_set + }, + [REGSET_DSCR] = { + .core_note_type = NT_PPC_DSCR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .get = dscr_get, .set = dscr_set + }, +#endif +#ifdef CONFIG_PPC_BOOK3S_64 + [REGSET_TAR] = { + .core_note_type = NT_PPC_TAR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .get = tar_get, .set = tar_set + }, +#endif }; static const struct user_regset_view user_ppc_native_view = {
@@ -2056,6 +2154,25 @@ static const struct user_regset compat_regsets[] = { .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set },#endif +#ifdef CONFIG_PPC64 + [REGSET_PPR] = { + .core_note_type = NT_PPC_PPR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .get = ppr_get, .set = ppr_set + }, + [REGSET_DSCR] = { + .core_note_type = NT_PPC_DSCR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .get = dscr_get, .set = dscr_set + }, +#endif +#ifdef CONFIG_PPC_BOOK3S_64 + [REGSET_TAR] = { + .core_note_type = NT_PPC_TAR, .n = 1, + .size = sizeof(u64), .align = sizeof(u64), + .get = tar_get, .set = tar_set + }, +#endif }; static const struct user_regset_view user_ppc_compat_view = {
Signature · 1 line
2.1.0
Quoted 18 lines · Anshuman Khandual
From: Anshuman Khandual <[email protected]>
This patch series adds twelve new ELF core note sections which can
be used with existing ptrace request PTRACE_GETREGSET-SETREGSET for accessing various transactional memory and other miscellaneous debug register sets on powerpc platform.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
Quoted 8 lines
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
These patches are available for pull from this location mentioned below.
https://github.com/akhandual/linux.git ptrace_powerpc_v8
Anshuman Khandual <[email protected]> wrote on 19.05.2015 17:07:56:
Quoted 2 lines
This patch series adds twelve new ELF core note sections which can
be used with existing ptrace request PTRACE_GETREGSET-SETREGSET for
accessing
Quoted 1 line
various transactional memory and other miscellaneous debug register sets
on
Quoted 13 lines
powerpc platform.
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
Quoted 8 lines
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
This addresses all the issues I raised in my comments on V7. The register set layout looks good to me now.
Thanks,
Ulrich
Quoted 14 lines · Anshuman Khandual
Test Result
-----------
ptrace-ebb PASS
ptrace-gpr PASS
ptrace-tm-gpr PASS
ptrace-tm-spd-gpr PASS
ptrace-tar FAIL
ptrace-tm-tar FAIL
ptrace-tm-spd-tar FAIL
ptrace-vsx PASS
ptrace-tm-vsx PASS
ptrace-tm-spd-vsx PASS
ptrace-tm-spr PASS
Quoted 2 lines
NOTE: The above three test case failures are due to PPR context save/restore in various paths. Still continue to debug the issue.
This was an false alarm. The tracee process executed system calls with shmdt() and printf() after writing the new PPR value.