Add new powerpc specific ELF core notes
Subsystems (4)
v11 cover Add new powerpc specific ELF core notes
From: Simon Guo <[email protected]>
This patch series adds twelve new ELF core note sections which can be used with existing ptrace request PTRACE_GETREG/SET-SETREGSET for accessing various transactional memory and other miscellaneous debug register sets on powerpc platform.
Note this patch series now depends on following patch:
[PATCH 3/5] powerpc: tm: Always use fp_state and vr_state to store live registers
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
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 (27):
elf: Add powerpc specific core note sections powerpc/process: Add the function flush_tmregs_to_thread 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 powerpc/ptrace: Enable support for Performance Monitor registers 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
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 | 1601 +++++++++++++++++--- include/uapi/linux/elf.h | 13 + 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 | 184 +++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 102 ++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.c | 195 +++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 74 + .../testing/selftests/powerpc/ptrace/ptrace-tar.c | 158 ++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 + .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 296 ++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 322 ++++ .../selftests/powerpc/ptrace/ptrace-tm-spd-tar.c | 192 +++ .../selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c | 218 +++ .../selftests/powerpc/ptrace/ptrace-tm-spr.c | 175 +++ .../selftests/powerpc/ptrace/ptrace-tm-tar.c | 179 +++ .../selftests/powerpc/ptrace/ptrace-tm-vsx.c | 205 +++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.c | 140 ++ .../testing/selftests/powerpc/ptrace/ptrace-vsx.h | 121 ++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 396 +++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 783 ++++++++++ tools/testing/selftests/powerpc/reg.h | 42 +- .../powerpc/tm/tm-signal-context-chk-fpu.c | 3 - .../powerpc/tm/tm-signal-context-chk-gpr.c | 3 - .../powerpc/tm/tm-signal-context-chk-vmx.c | 3 - .../powerpc/tm/tm-signal-context-chk-vsx.c | 3 - .../selftests/powerpc/tm/tm-signal-context-chk.c | 3 - 33 files changed, 5338 insertions(+), 199 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 v11 1/27 elf: Add powerpc specific core note sections
From: Anshuman Khandual <[email protected]>
This 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, performance monitor 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/uapi/linux/elf.h +13 -0
@@ -381,6 +381,19 @@ 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_PMU 0x107/* Performance Monitor Registers */ +#define NT_PPC_TM_CGPR 0x108/* TM checkpointed GPR Registers */ +#define NT_PPC_TM_CFPR 0x109/* TM checkpointed FPR Registers */ +#define NT_PPC_TM_CVMX 0x10a/* TM checkpointed VMX Registers */ +#define NT_PPC_TM_CVSX 0x10b/* TM checkpointed VSX Registers */ +#define NT_PPC_TM_SPR 0x10c/* TM Special Purpose Registers */ +#define NT_PPC_TM_CTAR 0x10d/* TM checkpointed Target Address Register */ +#define NT_PPC_TM_CPPR 0x10e/* TM checkpointed Program Priority Register */ +#define NT_PPC_TM_CDSCR 0x10f/* 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
1.8.3.1
PATCH v11 2/27 powerpc/process: Add the function flush_tmregs_to_thread
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
@@ -75,6 +75,14 @@ static inline void disable_kernel_spe(void)static inline void __giveup_spe (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
@@ -1027,6 +1027,26 @@ static inline void restore_sprs(struct thread_struct *old_thread,#endif } +#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
1.8.3.1
PATCH v11 4/27 powerpc/ptrace: Enable support for NT_PPC_CGPR
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
@@ -181,6 +181,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) {
@@ -614,6 +634,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.
@@ -630,6 +816,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[] = {
@@ -664,6 +853,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 = {
@@ -826,6 +1022,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,
@@ -870,6 +1084,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
1.8.3.1
PATCH v11 5/27 powerpc/ptrace: Enable support for NT_PPC_CFPR
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
@@ -799,6 +799,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 'ckfp_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_CKFPR (i); + buf[32 ] = target->thread.ckfp_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 'ckfp_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_CKFPR (i) = buf[i]; + target->thread.ckfp_state.fpscr = buf[32 ]; +return 0 ; +}#endif /*
@@ -818,6 +933,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 };
@@ -859,6 +975,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 };
@@ -1091,6 +1212,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
1.8.3.1
PATCH v11 6/27 powerpc/ptrace: Enable support for NT_PPC_CVMX
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
1.8.3.1
PATCH v11 7/27 powerpc/ptrace: Enable support for NT_PPC_CVSX
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
1.8.3.1
PATCH v11 8/27 powerpc/ptrace: Enable support for TM SPR state
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
1.8.3.1
PATCH v11 9/27 powerpc/ptrace: Enable NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
@@ -1309,6 +1309,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 */ /*
@@ -1332,6 +1477,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 };
@@ -1393,6 +1541,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 };
@@ -1645,6 +1808,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
1.8.3.1
PATCH v11 10/27 powerpc/ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
@@ -1456,6 +1456,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. */
@@ -1481,6 +1553,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[] = {
@@ -1557,6 +1636,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 = {
@@ -1824,6 +1922,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
1.8.3.1
PATCH v11 3/27 powerpc/ptrace: Adapt gpr32_get, gpr32_set functions for transaction
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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
@@ -674,24 +674,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);
@@ -731,20 +742,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);
@@ -804,6 +826,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
1.8.3.1
PATCH v11 11/27 powerpc/ptrace: Enable support for EBB registers
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This 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 | 1 + arch/powerpc/kernel/ptrace.c | 75 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)
arch/powerpc/include/uapi/asm/elf.h +1 -0
@@ -94,6 +94,7 @@#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 3/* includes ebbrr, ebbhr, bescr */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +75 -0
99 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 12/27 powerpc/ptrace: Enable support for Performance Monitor registers
In reply to [email protected]From: Anshuman Khandual <[email protected]>
This patch enables support for Performance monitor registers related ELF core note NT_PPC_PMU based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding one new register sets REGSET_PMU 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 | 3 +- arch/powerpc/kernel/ptrace.c | 75 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-)
arch/powerpc/include/uapi/asm/elf.h +2 -1
@@ -94,7 +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 3/* includes ebbrr, ebbhr, bescr */ +#define ELF_NEBB 3/* includes ebbrr, ebbhr, bescr */ +#define ELF_NPMU 5/* includes 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 +75 -0
93 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 13/27 selftests/powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h'
In reply to [email protected]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 ++++++++++++++++++++-- .../powerpc/tm/tm-signal-context-chk-fpu.c | 3 -- .../powerpc/tm/tm-signal-context-chk-gpr.c | 3 -- .../powerpc/tm/tm-signal-context-chk-vmx.c | 3 -- .../powerpc/tm/tm-signal-context-chk-vsx.c | 3 -- .../selftests/powerpc/tm/tm-signal-context-chk.c | 3 -- 6 files changed, 39 insertions(+), 18 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
@@ -46,10 +59,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 */
tools/testing/selftests/powerpc/tm/tm-signal-context-chk-fpu.c +0 -3
@@ -23,9 +23,6 @@#include "utils.h" #include "tm.h" -#define TBEGIN ".long 0x7C00051D ;" -#define TSUSPEND ".long 0x7C0005DD ;" -#define TRESUME ".long 0x7C2005DD ;"#define MAX_ATTEMPT 100#define NV_FPU_REGS 18
tools/testing/selftests/powerpc/tm/tm-signal-context-chk-gpr.c +0 -3
@@ -25,9 +25,6 @@#include "utils.h" #include "tm.h" -#define TBEGIN ".long 0x7C00051D ;" -#define TSUSPEND ".long 0x7C0005DD ;" -#define TRESUME ".long 0x7C2005DD ;"#define MAX_ATTEMPT 100#define NV_GPR_REGS 18
tools/testing/selftests/powerpc/tm/tm-signal-context-chk-vmx.c +0 -3
@@ -26,9 +26,6 @@#include "utils.h" #include "tm.h" -#define TBEGIN ".long 0x7C00051D ;" -#define TSUSPEND ".long 0x7C0005DD ;" -#define TRESUME ".long 0x7C2005DD ;"#define MAX_ATTEMPT 100 extern long tm_signal_self_context_load(pid_t pid, long *gps, double *fps, vector int *vms, vector int *vss);
tools/testing/selftests/powerpc/tm/tm-signal-context-chk-vsx.c +0 -3
@@ -26,9 +26,6 @@#include "utils.h" #include "tm.h" -#define TBEGIN ".long 0x7C00051D ;" -#define TSUSPEND ".long 0x7C0005DD ;" -#define TRESUME ".long 0x7C2005DD ;"#define MAX_ATTEMPT 100 extern long tm_signal_self_context_load(pid_t pid, long *gps, double *fps, vector int *vms, vector int *vss);
tools/testing/selftests/powerpc/tm/tm-signal-context-chk.c +0 -3
@@ -23,9 +23,6 @@#include "utils.h" #include "tm.h" -#define TBEGIN ".long 0x7C00051D ;" -#define TSUSPEND ".long 0x7C0005DD ;" -#define TRESUME ".long 0x7C2005DD ;"#define MAX_ATTEMPT 100static double fps[] = {1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,
Signature · 1 line
1.8.3.1
PATCH v11 14/27 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 v11 15/27 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 | 184 ++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-ebb.h | 102 +++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 240 +++++++++++++++++++++ 5 files changed, 535 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
@@ -24,7 +24,8 @@ SUB_DIRS = benchmarks \ 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 +184 -0
184 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace-ebb.h new file +102 -0
102 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 16/27 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 | 195 +++++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-gpr.h | 74 ++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 131 +++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 208 +++++++++++++++++++++ 5 files changed, 610 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 +195 -0
195 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 +208 -0
214 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 17/27 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 v11 18/27 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 | 322 +++++++++++++++++++++ 2 files changed, 323 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 +322 -0
322 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 19/27 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 | 158 ++++++++++++++++++ .../testing/selftests/powerpc/ptrace/ptrace-tar.h | 50 ++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 181 +++++++++++++++++++++ 4 files changed, 391 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 +158 -0
158 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 v11 20/27 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 | 179 +++++++++++++++++++++ 2 files changed, 180 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 +179 -0
179 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 22/27 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 | 121 ++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.S | 265 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 119 +++++++++ 5 files changed, 646 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 +121 -0
121 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 v11 23/27 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 | 205 +++++++++++++++++++++ 2 files changed, 207 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 +205 -0
205 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 24/27 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 | 218 +++++++++++++++++++++ 2 files changed, 220 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 +218 -0
218 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 25/27 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 | 175 +++++++++++++++++++++ tools/testing/selftests/powerpc/ptrace/ptrace.h | 35 +++++ 3 files changed, 212 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 +175 -0
175 lines not on this page · raw message
tools/testing/selftests/powerpc/ptrace/ptrace.h +35 -0
@@ -67,6 +67,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)
@@ -680,6 +685,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 v11 26/27 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 v11 21/27 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 | 192 +++++++++++++++++++++ 2 files changed, 193 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 +192 -0
192 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v11 27/27 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