Add new powerpc specific ELF core notes
Subsystems (4)
v6 cover Add new powerpc specific ELF core notes
This patch series adds five new ELF core note sections which can be
used with existing ptrace request PTRACE_GETREGSET-SETREGSET for accessing various transactional memory and 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
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
-----------
The patch series has been verified both in 32 bit and 64 bit compiled test program. Test result for the selftest test (64 bit compiled) can be found here.
test: tm_ptrace
tags: git_version:v3.18-rc6-8-ge2aa4ce
===Testing TM based PTRACE Interface===
Testing TM specific SPR:
TFHAR: 10001098
TEXASR: de0000018c000001
TFIAR: c000000000041858
TM ORIG_MSR: 800000050000f032
TM CH DSCR: a (PASSED)
TM CH TAR: 14 (PASSED)
TM CH PPR: 8000000000000 (PASSED)
Testing TM checkpointed GPR:
TM CH NIP: 10001098
TM CH LINK: 10000ea0
TM CH CCR: 24000422
TM CH GPR[0]: 0 (PASSED)
TM CH GPR[1]: 1 (PASSED)
TM CH GPR[2]: 2 (PASSED)
TM CH GPR[3]: 3 (PASSED)
TM CH GPR[4]: 4 (PASSED)
TM CH GPR[5]: 5 (PASSED)
TM CH GPR[6]: 6 (PASSED)
TM CH GPR[7]: 7 (PASSED)
TM CH GPR[8]: 8 (PASSED)
TM CH GPR[9]: 9 (PASSED)
TM CH GPR[10]: a (PASSED)
TM CH GPR[11]: b (PASSED)
TM CH GPR[12]: c (PASSED)
TM CH GPR[13]: d (PASSED)
TM CH GPR[14]: e (PASSED)
TM CH GPR[15]: f (PASSED)
TM CH GPR[16]: 0 (PASSED)
TM CH GPR[17]: 1 (PASSED)
TM CH GPR[18]: 2 (PASSED)
TM CH GPR[19]: 3 (PASSED)
TM CH GPR[20]: 4 (PASSED)
TM CH GPR[21]: 5 (PASSED)
TM CH GPR[22]: 6 (PASSED)
TM CH GPR[23]: 7 (PASSED)
TM CH GPR[24]: 8 (PASSED)
TM CH GPR[25]: 9 (PASSED)
TM CH GPR[26]: a (PASSED)
TM CH GPR[27]: b (PASSED)
TM CH GPR[28]: c (PASSED)
TM CH GPR[29]: d (PASSED)
TM CH GPR[30]: e (PASSED)
TM CH GPR[31]: f (PASSED)
Testing TM checkpointed FPR:
TM CH FPSCR: 0
TM CH FPR[0]: 0 (PASSED)
TM CH FPR[1]: 1 (PASSED)
TM CH FPR[2]: 2 (PASSED)
TM CH FPR[3]: 3 (PASSED)
TM CH FPR[4]: 4 (PASSED)
TM CH FPR[5]: 5 (PASSED)
TM CH FPR[6]: 6 (PASSED)
TM CH FPR[7]: 7 (PASSED)
TM CH FPR[8]: 8 (PASSED)
TM CH FPR[9]: 9 (PASSED)
TM CH FPR[10]: a (PASSED)
TM CH FPR[11]: b (PASSED)
TM CH FPR[12]: c (PASSED)
TM CH FPR[13]: d (PASSED)
TM CH FPR[14]: e (PASSED)
TM CH FPR[15]: f (PASSED)
TM CH FPR[16]: 0 (PASSED)
TM CH FPR[17]: 1 (PASSED)
TM CH FPR[18]: 2 (PASSED)
TM CH FPR[19]: 3 (PASSED)
TM CH FPR[20]: 4 (PASSED)
TM CH FPR[21]: 5 (PASSED)
TM CH FPR[22]: 6 (PASSED)
TM CH FPR[23]: 7 (PASSED)
TM CH FPR[24]: 8 (PASSED)
TM CH FPR[25]: 9 (PASSED)
TM CH FPR[26]: a (PASSED)
TM CH FPR[27]: b (PASSED)
TM CH FPR[28]: c (PASSED)
TM CH FPR[29]: d (PASSED)
TM CH FPR[30]: e (PASSED)
TM CH FPR[31]: f (PASSED)
Testing TM running GPR:
TM RN NIP: 100011b0
TM RN LINK: 10000ea0
TM RN CCR: 4000422
TM RN GPR[0]: f (PASSED)
TM RN GPR[1]: e (PASSED)
TM RN GPR[2]: d (PASSED)
TM RN GPR[3]: c (PASSED)
TM RN GPR[4]: b (PASSED)
TM RN GPR[5]: a (PASSED)
TM RN GPR[6]: 9 (PASSED)
TM RN GPR[7]: 8 (PASSED)
TM RN GPR[8]: 7 (PASSED)
TM RN GPR[9]: 6 (PASSED)
TM RN GPR[10]: 5 (PASSED)
TM RN GPR[11]: 4 (PASSED)
TM RN GPR[12]: 3 (PASSED)
TM RN GPR[13]: 2 (PASSED)
TM RN GPR[14]: 1 (PASSED)
TM RN GPR[15]: 0 (PASSED)
TM RN GPR[16]: f (PASSED)
TM RN GPR[17]: e (PASSED)
TM RN GPR[18]: d (PASSED)
TM RN GPR[19]: c (PASSED)
TM RN GPR[20]: b (PASSED)
TM RN GPR[21]: a (PASSED)
TM RN GPR[22]: 9 (PASSED)
TM RN GPR[23]: 8 (PASSED)
TM RN GPR[24]: 7 (PASSED)
TM RN GPR[25]: 6 (PASSED)
TM RN GPR[26]: 5 (PASSED)
TM RN GPR[27]: 4 (PASSED)
TM RN GPR[28]: 3 (PASSED)
TM RN GPR[29]: 2 (PASSED)
TM RN GPR[30]: 1 (PASSED)
TM RN GPR[31]: 0 (PASSED)
Testing TM running FPR:
TM RN FPSCR: 0
TM RN FPR[0]: f (PASSED)
TM RN FPR[1]: e (PASSED)
TM RN FPR[2]: d (PASSED)
TM RN FPR[3]: c (PASSED)
TM RN FPR[4]: b (PASSED)
TM RN FPR[5]: a (PASSED)
TM RN FPR[6]: 9 (PASSED)
TM RN FPR[7]: 8 (PASSED)
TM RN FPR[8]: 7 (PASSED)
TM RN FPR[9]: 6 (PASSED)
TM RN FPR[10]: 5 (PASSED)
TM RN FPR[11]: 4 (PASSED)
TM RN FPR[12]: 3 (PASSED)
TM RN FPR[13]: 2 (PASSED)
TM RN FPR[14]: 1 (PASSED)
TM RN FPR[15]: 0 (PASSED)
TM RN FPR[16]: f (PASSED)
TM RN FPR[17]: e (PASSED)
TM RN FPR[18]: d (PASSED)
TM RN FPR[19]: c (PASSED)
TM RN FPR[20]: b (PASSED)
TM RN FPR[21]: a (PASSED)
TM RN FPR[22]: 9 (PASSED)
TM RN FPR[23]: 8 (PASSED)
TM RN FPR[24]: 7 (PASSED)
TM RN FPR[25]: 6 (PASSED)
TM RN FPR[26]: 5 (PASSED)
TM RN FPR[27]: 4 (PASSED)
TM RN FPR[28]: 3 (PASSED)
TM RN FPR[29]: 2 (PASSED)
TM RN FPR[30]: 1 (PASSED)
TM RN FPR[31]: 0 (PASSED)
Testing TM running MISC debug registers:
TM RN DSCR: 32 (PASSED)
TM RN TAR: 3c (PASSED)
TM RN PPR: 4000000000000 (PASSED)
success: tm_ptrace
Anshuman Khandual (9):
elf: Add new powerpc specifc core note sections
powerpc, process: Add the function flush_tmregs_to_thread powerpc, ptrace: Enable fpr_(get/set) for transactional memory powerpc, ptrace: Enable vr_(get/set) for transactional memory powerpc, ptrace: Enable support for transactional memory register sets powerpc, ptrace: Enable support for miscellaneous debug registers selftests, powerpc: Add test case for TM related ptrace interface selftests, powerpc: Make GIT ignore all binaries related to TM
selftests: Make GIT ignore all binaries in powerpc test suite
arch/powerpc/include/asm/switch_to.h | 8 + arch/powerpc/include/uapi/asm/elf.h | 3 + arch/powerpc/kernel/process.c | 20 + arch/powerpc/kernel/ptrace.c | 1059 +++++++++++++++++++- include/uapi/linux/elf.h | 5 + .../testing/selftests/powerpc/copyloops/.gitignore | 4 + tools/testing/selftests/powerpc/mm/.gitignore | 1 + tools/testing/selftests/powerpc/pmu/.gitignore | 3 + tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 + .../selftests/powerpc/primitives/.gitignore | 1 + tools/testing/selftests/powerpc/tm/.gitignore | 2 + tools/testing/selftests/powerpc/tm/Makefile | 2 +- tools/testing/selftests/powerpc/tm/tm-ptrace.c | 542 ++++++++++ 13 files changed, 1647 insertions(+), 25 deletions(-) create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore create mode 100644 tools/testing/selftests/powerpc/tm/tm-ptrace.c
Signature · 1 line
1.9.3
PATCH v6 1/9 elf: Add new powerpc specifc core note sections
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)
include/uapi/linux/elf.h +5 -0
@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */ #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.9.3
PATCH v6 2/9 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
1.9.3
PATCH v6 3/9 powerpc, ptrace: Enable fpr_(get/set) for transactional memory
In reply to Anshuman KhandualThis patch enables the fpr_get which gets the running value of all the FPR registers and the fpr_set which sets the running value of of all the FPR registers to accommodate in transaction ptrace interface based requests.
--- arch/powerpc/kernel/ptrace.c | 110 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 6 deletions(-)
arch/powerpc/kernel/ptrace.c +104 -6
@@ -357,6 +357,36 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,return ret; } + +/** +* fpr_get - get FPR 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. +* +* 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. The userspace interface buffer layout is as follows. +* +* 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,22 +397,68 @@ 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])); -return user_regset_copyout (&pos, &count, &kbuf, &ubuf, &target->thread.fp_state,0 ,-1 );#endif } +/** +* fpr_set - set FPR 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. +* +* 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. The userspace interface buffer layout is as follows. +* +* 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 +469,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,12 +498,14 @@ 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])); -return user_regset_copyin (&pos, &count, &kbuf, &ubuf, &target->thread.fp_state,0 ,-1 ); +#endif }
Signature · 1 line
1.9.3
PATCH v6 4/9 powerpc, ptrace: Enable vr_(get/set) for transactional memory
In reply to Anshuman KhandualThis patch enables the vr_get which gets the running value of all the VMX registers and the vr_set which sets the running value of of all the VMX registers to accommodate in transaction ptrace interface based requests.
--- arch/powerpc/kernel/ptrace.c | 104 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 3 deletions(-)
arch/powerpc/kernel/ptrace.c +101 -3
@@ -530,10 +530,35 @@ static int vr_active(struct task_struct *target,return target->thread.used_vr ? regset->n :0 ; } +/** +* vr_get - get VR 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. +* +* 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. The userspace interface buffer +* layout is as follows. +* +* 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);
@@ -541,8 +566,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) {/*
@@ -553,7 +589,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 ); }
@@ -561,10 +606,35 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,return ret; } +/** +* vr_set - set VR 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. +* +* 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. The userspace interface buffer +* layout is as follows. +* +* 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);
@@ -572,8 +642,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 ) {/*
@@ -584,11 +665,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
1.9.3
PATCH v6 5/9 powerpc, ptrace: Enable support for transactional memory register sets
In reply to Anshuman KhandualThis patch enables get and set of transactional memory related register sets through PTRACE_GETREGSET-PTRACE_SETREGSET interface by implementing four new powerpc specific register sets i.e REGSET_TM_SPR, REGSET_TM_CGPR, REGSET_TM_CFPR, REGSET_CVMX support corresponding to these following new ELF core note types added previously in this regard.
(1) NT_PPC_TM_SPR (2) NT_PPC_TM_CGPR (3) NT_PPC_TM_CFPR (4) NT_PPC_TM_CVMX
--- arch/powerpc/include/uapi/asm/elf.h | 2 + arch/powerpc/kernel/ptrace.c | 714 +++++++++++++++++++++++++++++++++++- 2 files changed, 701 insertions(+), 15 deletions(-)
arch/powerpc/include/uapi/asm/elf.h +2 -0
@@ -91,6 +91,8 @@#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_NTMSPRREG 7/* includes TM sprs, org_msr, dscr, tar, ppr */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +699 -15
782 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH v6 6/9 powerpc, ptrace: Enable support for miscellaneous debug registers
In reply to Anshuman KhandualThis patch enables get and set of miscellaneous debug registers through ptrace PTRACE_GETREGSET-PTRACE_SETREGSET interface by implementing new powerpc specific register set REGSET_MISC support corresponding to the new ELF core note NT_PPC_MISC added previously in this regard.
--- arch/powerpc/include/uapi/asm/elf.h | 1 + arch/powerpc/kernel/ptrace.c | 131 ++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+)
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_NTMSPRREG 7/* includes TM sprs, org_msr, dscr, tar, ppr */ +#define ELF_NMISCREG 3/* includes dscr, tar, ppr */ typedef unsigned long elf_greg_t64 ;typedef elf_greg_t64 elf_gregset_t64 [ELF_NGREG ];
arch/powerpc/kernel/ptrace.c +131 -0
155 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH v6 7/9 selftests, powerpc: Add test case for TM related ptrace interface
In reply to Anshuman KhandualThis patch adds one more test case called 'tm-ptrace' targeting TM related ptrace interface. This test creates one child process to run some basic TM transactions and the parent process attaches the child to do some ptrace probing using the recently added regset interfaces. The parent process then compares the received values against the expected values to verify whether it has passed the given test or not.
--- tools/testing/selftests/powerpc/tm/Makefile | 2 +- tools/testing/selftests/powerpc/tm/tm-ptrace.c | 542 +++++++++++++++++++++++++ 2 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/tm/tm-ptrace.c
tools/testing/selftests/powerpc/tm/Makefile +1 -1
@@ -1,4 +1,4 @@ -PROGS := tm-resched-dscr +PROGS := tm-resched-dscr tm-ptrace all: $(PROGS)
tools/testing/selftests/powerpc/tm/tm-ptrace.c new file +542 -0
542 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH v6 8/9 selftests, powerpc: Make GIT ignore all binaries related to TM
In reply to Anshuman KhandualThis patch includes all the TM test binaries into the .gitignore file listing in the same directory. This will make sure that GIT ignores all of them while displaying status.
--- tools/testing/selftests/powerpc/tm/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore
tools/testing/selftests/powerpc/tm/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +tm-ptrace +tm-resched-dscr
Signature · 1 line
1.9.3
PATCH v6 9/9 selftests: Make GIT ignore all binaries in powerpc test suite
In reply to Anshuman KhandualThis patch includes all of the powerpc test binaries into the .gitignore file listing in their respective directories. This will make sure that GIT ignores all of these test binaries while displaying status.
--- .../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++ tools/testing/selftests/powerpc/mm/.gitignore | 1 + tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++ tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++ .../selftests/powerpc/primitives/.gitignore | 1 + 5 files changed, 31 insertions(+) create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
tools/testing/selftests/powerpc/copyloops/.gitignore new file +4 -0
@@ -0,0 +1,4 @@ +copyuser_64 +copyuser_power7 +memcpy_64 +memcpy_power7
tools/testing/selftests/powerpc/mm/.gitignore new file +1 -0
@@ -0,0 +1 @@ +hugetlb_vs_thp_test
tools/testing/selftests/powerpc/pmu/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +count_instructions +l3_bank_test +per_event_excludes
tools/testing/selftests/powerpc/pmu/ebb/.gitignore new file +22 -0
@@ -0,0 +1,22 @@ +reg_access_test +event_attributes_test +cycles_test +cycles_with_freeze_test +pmc56_overflow_test +ebb_vs_cpu_event_test +cpu_event_vs_ebb_test +cpu_event_pinned_vs_ebb_test +task_event_vs_ebb_test +task_event_pinned_vs_ebb_test +multi_ebb_procs_test +multi_counter_test +pmae_handling_test +close_clears_pmcc_test +instruction_count_test +fork_cleanup_test +ebb_on_child_test +ebb_on_willing_child_test +back_to_back_ebbs_test +lost_exception_test +no_handler_test +cycles_with_mmcr2_test
tools/testing/selftests/powerpc/primitives/.gitignore new file +1 -0
@@ -0,0 +1 @@ +load_unaligned_zeropad
Signature · 1 line
1.9.3
Re: [PATCH V6 9/9] selftests: Make GIT ignore all binaries in powerpc test suite
Quoted 6 lines · Anshuman Khandual
This patch includes all of the powerpc test binaries into the .gitignore file listing in their respective directories. This will make sure that GIT ignores all of these test binaries while displaying status.
Signed-off-by Anshuman Khandual <[email protected]>
Quoted 13 lines
--- .../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++ tools/testing/selftests/powerpc/mm/.gitignore | 1 + tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++ tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++ .../selftests/powerpc/primitives/.gitignore | 1 + 5 files changed, 31 insertions(+) create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
Creating a single .gitignore at tools/testing/selftests/powerpc will make this simpler without having to add one .gitignore for each directory underneath.
Thanks for taking on the task to add .gitignore for all powerpc binaries.
-- Shuah
Signature · 4 lines
Shuah Khan Sr. Linux Kernel Developer Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Michael Ellerman
reviewerRe: [V6,1/9] elf: Add new powerpc specifc core note sections
In reply to Anshuman KhandualQuoted 17 lines · Anshuman Khandual
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
Acked-by Andrew Morton <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)include/uapi/linux/elf.h +0
-0
include/uapi/linux/elf.h typedef struct elf64_shdr { · line 386
Quoted 8 lines
include/uapi/linux/elf.h +5
-0@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */
This is a really terrible name, "MISC".
Having said that, I guess it's accurate. We have a whole bunch of regs that have accrued over recent years that aren't accessible via ptrace.
It seems to me if we're adding a misc regset we should be adding everything we might want to it that is currenty architected.
But currently you only include the PPR, TAR & DSCR.
Looking at Power ISA v2.07, I see the following that could be included:
MMCR2
MMCRA
PMC1
PMC2
PMC3
PMC4
PMC5
PMC6
MMCR0
EBBHR
EBBRR
BESCR
SIAR
SDAR
CFAR?
Those are all new in 2.07 except for CFAR.
There might be more I missed, that was just a quick scan.
Some are only accessible when EBB is in use, maybe those could be a separate regset.
cheers
Re: [PATCH V6 9/9] selftests: Make GIT ignore all binaries in powerpc test suite
In reply to Shuah KhanQuoted 20 lines · Shuah Khan
Quoted 5 lines · Anshuman Khandual
Quoted 5 lines
This patch includes all of the powerpc test binaries into the .gitignore file listing in their respective directories. This will make sure that GIT ignores all of these test binaries while displaying status.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Anshuman Khandual <[email protected]>--- .../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++ tools/testing/selftests/powerpc/mm/.gitignore | 1 + tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++ tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++ .../selftests/powerpc/primitives/.gitignore | 1 + 5 files changed, 31 insertions(+) create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
Quoted 3 lines
Creating a single .gitignore at
tools/testing/selftests/powerpcwill make this simpler without having to add one .gitignore for each directory underneath.
Sure, will do.
Quoted 3 lines
Thanks for taking on the task to add .gitignore for all powerpc binaries.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
In reply to Michael EllermanQuoted 29 lines · Michael Ellerman
Quoted 17 lines · Anshuman Khandual
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
Acked-by Andrew Morton <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)include/uapi/linux/elf.h +0
-0include/uapi/linux/elf.h typedef struct elf64_shdr { · line 386
Quoted 8 lines
include/uapi/linux/elf.h +5
-0@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */ This is a really terrible name, "MISC".
Quoted 5 lines
Having said that, I guess it's accurate. We have a whole bunch of regs that have accrued over recent years that aren't accessible via ptrace.
It seems to me if we're adding a misc regset we should be adding everything we might want to it that is currenty architected.
But I believe they also need to be part of the thread_struct structure to be accessible from ptrace.
Quoted 2 lines
But currently you only include the PPR, TAR & DSCR.
Yeah, thats what we started with.
Quoted 18 lines
Looking at Power ISA v2.07, I see the following that could be included:
MMCR2
MMCRA
PMC1
PMC2
PMC3
PMC4
PMC5
PMC6
MMCR0
EBBHR
EBBRR
BESCR
SIAR
SDAR
CFAR?
MMCRA, PMC[1..6], EBBHR, BESCR, EBBRR, CFAR are not part of the thread struct.
Quoted 7 lines
Those are all new in 2.07 except for CFAR.
There might be more I missed, that was just a quick scan.
Some are only accessible when EBB is in use, maybe those could be a separate regset.
Yeah we can have one more regset for EBB specific registers.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 30 lines · Anshuman Khandual
Quoted 29 lines · Michael Ellerman
Quoted 17 lines · Anshuman Khandual
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
Acked-by Andrew Morton <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)include/uapi/linux/elf.h +0
-0include/uapi/linux/elf.h typedef struct elf64_shdr { · line 386
Quoted 8 lines
include/uapi/linux/elf.h +5
-0@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */ This is a really terrible name, "MISC".
Quoted 8 lines
Quoted 5 lines
Having said that, I guess it's accurate. We have a whole bunch of regs that have accrued over recent years that aren't accessible via ptrace.
It seems to me if we're adding a misc regset we should be adding everything we might want to it that is currenty architected.
But I believe they also need to be part of the
thread_structstructure to be accessible from ptrace.
Currently we dont context save/restore the PMC count registers (PMC1-PMC6) during the process context switch. So the values of PMC1..PMC6 are not thread specific in the structure. To be able to access them in ptrace when the tracee has stopped, we need to context save these counters in the thread struct. Shall we do that ? Then we can add them to the MISC regset bucket irrespective of whats the value we get in there when we probe through ptrace.
The same goes for MMCRA, CFAR registers as well.
Quoted 25 lines
Quoted 3 lines
But currently you only include the PPR, TAR & DSCR.
Yeah, thats what we started with.
Quoted 18 lines
Looking at Power ISA v2.07, I see the following that could be included:
MMCR2
MMCRA
PMC1
PMC2
PMC3
PMC4
PMC5
PMC6
MMCR0
EBBHR
EBBRR
BESCR
SIAR
SDAR
CFAR?
Quoted 1 line
MMCRA, PMC[1..6], EBBHR, BESCR, EBBRR, CFAR are not part of the thread struct.
Sorry. EBBRR, EBBHR, BESCR registers are part of the thread struct.
Quoted 10 lines
Quoted 8 lines
Those are all new in 2.07 except for CFAR.
There might be more I missed, that was just a quick scan.
Some are only accessible when EBB is in use, maybe those could be a separate regset.
Yeah we can have one more regset for EBB specific registers.
Should the new EBB specific regset include only EBBRR, EBBHR, BESCR registers or should it also include SIAR, SDAR, SIER, MMCR0, MMCR2 registers as well. I was thinking about putting these five registers into the MISC bucket instead. But from the perf code, it looks like these five registers are also related to the EBB context as well.
Some clarity on these points would really help.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 90 lines · Anshuman Khandual
Quoted 30 lines · Anshuman Khandual
Quoted 29 lines · Michael Ellerman
Quoted 17 lines · Anshuman Khandual
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
Acked-by Andrew Morton <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)include/uapi/linux/elf.h +0
-0include/uapi/linux/elf.h typedef struct elf64_shdr { · line 386
Quoted 8 lines
include/uapi/linux/elf.h +5
-0@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */ This is a really terrible name, "MISC".
Quoted 8 lines
Quoted 5 lines
Having said that, I guess it's accurate. We have a whole bunch of regs that have accrued over recent years that aren't accessible via ptrace.
It seems to me if we're adding a misc regset we should be adding everything we might want to it that is currenty architected.
But I believe they also need to be part of the
thread_structstructure to be accessible from ptrace.Currently we dont context save/restore the PMC count registers (PMC1-PMC6) during the process context switch. So the values of PMC1..PMC6 are not thread specific in the structure. To be able to access them in ptrace when the tracee has stopped, we need to context save these counters in the thread struct. Shall we do that ? Then we can add them to the MISC regset bucket irrespective of whats the value we get in there when we probe through ptrace.
The same goes for MMCRA, CFAR registers as well.
Quoted 25 lines
Quoted 3 lines
But currently you only include the PPR, TAR & DSCR.
Yeah, thats what we started with.
Quoted 18 lines
Looking at Power ISA v2.07, I see the following that could be included:
MMCR2
MMCRA
PMC1
PMC2
PMC3
PMC4
PMC5
PMC6
MMCR0
EBBHR
EBBRR
BESCR
SIAR
SDAR
CFAR?Quoted 1 line
MMCRA, PMC[1..6], EBBHR, BESCR, EBBRR, CFAR are not part of the thread struct.
Sorry. EBBRR, EBBHR, BESCR registers are part of the thread struct.
Quoted 10 lines
Quoted 8 lines
Those are all new in 2.07 except for CFAR.
There might be more I missed, that was just a quick scan.
Some are only accessible when EBB is in use, maybe those could be a separate regset.
Yeah we can have one more regset for EBB specific registers.
Quoted 7 lines
Should the new EBB specific regset include only EBBRR, EBBHR, BESCR registers or should it also include SIAR, SDAR, SIER, MMCR0, MMCR2 registers as well. I was thinking about putting these five registers into the MISC bucket instead. But from the perf code, it looks like these five registers are also related to the EBB context as well.
Some clarity on these points would really help.
Hi,
from the provided testcase using ptrace interface, reviewing with the help of Ulrich, it looks OK from GDB perspective, with the exception of a few concerns:
The patchset seems to change the "original" ptrace requests (i.e. PTRACE_GETREGS/GETFPREGS/GETVRREGS...) to return the "transactional" state, and adds new register sets to return the "checkpointed" state. Considering that whenever you get a debugger interception inside a transactional block, the transaction will abort, we're wondering if it wouldn't make more sense to display the 'checkpointed' state as the normal registers since this is where the execution will continue from.
Also, we've noticed that the 'misc' regset contains registers from different ISA versions (dscr and ppr appear in ISA 2.05, tar is from 2.07). I'm not sure if there is a way to detect presence/validity of such registers, but perhaps it might be a good idea to separate registers from different ISAs in different regsets.
Regarding the inclusion of other registers along with the EBB-related ones, I'm sorry but I'm not familiar with them.
Thanks and regards,
--
Edjunior
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 105 lines · Edjunior Barbosa Machado
Quoted 90 lines · Anshuman Khandual
Quoted 30 lines · Anshuman Khandual
Quoted 29 lines · Michael Ellerman
Quoted 17 lines · Anshuman Khandual
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
Acked-by Andrew Morton <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)include/uapi/linux/elf.h +0
-0include/uapi/linux/elf.h typedef struct elf64_shdr { · line 386
Quoted 8 lines
include/uapi/linux/elf.h +5
-0@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */ This is a really terrible name, "MISC".
Quoted 8 lines
Quoted 5 lines
Having said that, I guess it's accurate. We have a whole bunch of regs that have accrued over recent years that aren't accessible via ptrace.
It seems to me if we're adding a misc regset we should be adding everything we might want to it that is currenty architected.
But I believe they also need to be part of the
thread_structstructure to be accessible from ptrace.Currently we dont context save/restore the PMC count registers (PMC1-PMC6) during the process context switch. So the values of PMC1..PMC6 are not thread specific in the structure. To be able to access them in ptrace when the tracee has stopped, we need to context save these counters in the thread struct. Shall we do that ? Then we can add them to the MISC regset bucket irrespective of whats the value we get in there when we probe through ptrace.
The same goes for MMCRA, CFAR registers as well.
Quoted 25 lines
Quoted 3 lines
But currently you only include the PPR, TAR & DSCR.
Yeah, thats what we started with.
Quoted 18 lines
Looking at Power ISA v2.07, I see the following that could be included:
MMCR2
MMCRA
PMC1
PMC2
PMC3
PMC4
PMC5
PMC6
MMCR0
EBBHR
EBBRR
BESCR
SIAR
SDAR
CFAR?Quoted 1 line
MMCRA, PMC[1..6], EBBHR, BESCR, EBBRR, CFAR are not part of the thread struct.
Sorry. EBBRR, EBBHR, BESCR registers are part of the thread struct.
Quoted 10 lines
Quoted 8 lines
Those are all new in 2.07 except for CFAR.
There might be more I missed, that was just a quick scan.
Some are only accessible when EBB is in use, maybe those could be a separate regset.
Yeah we can have one more regset for EBB specific registers.
Quoted 7 lines
Should the new EBB specific regset include only EBBRR, EBBHR, BESCR registers or should it also include SIAR, SDAR, SIER, MMCR0, MMCR2 registers as well. I was thinking about putting these five registers into the MISC bucket instead. But from the perf code, it looks like these five registers are also related to the EBB context as well.
Some clarity on these points would really help.
Hi,
from the provided testcase using ptrace interface, reviewing with the help of Ulrich, it looks OK from GDB perspective, with the exception of a few concerns:
Quoted 7 lines
The patchset seems to change the "original" ptrace requests (i.e. PTRACE_GETREGS/GETFPREGS/GETVRREGS...) to return the "transactional" state, and adds new register sets to return the "checkpointed" state. Considering that whenever you get a debugger interception inside a transactional block, the transaction will abort, we're wondering if it wouldn't make more sense to display the 'checkpointed' state as the normal registers since this is where the execution will continue from.
Debugger interception (trace interrupt) in between any transaction block will abort it ? I doubt that. The tracee process will just stop, it's context gets saved in the kernel so that it can again start executing from the exact same point onward when it resumes. If this happens when inside any transaction block, the transaction's running context and check pointed context will get saved. The execution will again start from the running context values instead of check pointed when the process resumes. Check pointed values will be loaded back into the context when the transaction finishes. Inside transaction both running and check pointed values can be probed independently.
Quoted 6 lines
Also, we've noticed that the 'misc' regset contains registers from different ISA versions (dscr and ppr appear in ISA 2.05, tar is from 2.07). I'm not sure if there is a way to detect presence/validity of such registers, but perhaps it might be a good idea to separate registers from different ISAs in different regsets.
Thats right, will use feature CPU_FTR_ARCH_207S (which checks whether we are v2.07 compliant) to detect whether TAR register is available or not.
Quoted 3 lines
Regarding the inclusion of other registers along with the EBB-related ones, I'm sorry but I'm not familiar with them.
Michael Ellerman mentioned that we can look into them separately sometime later not in this patch series.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 8 lines · Anshuman Khandual
Quoted 5 lines
Quoted 5 lines
Also, we've noticed that the 'misc' regset contains registers from different ISA versions (dscr and ppr appear in ISA 2.05, tar is from 2.07). I'm not sure if there is a way to detect presence/validity of such registers, but perhaps it might be a good idea to separate registers from different ISAs in different regsets.
Thats right, will use feature
CPU_FTR_ARCH_207S(which checks whether we are v2.07 compliant) to detect whether TAR register is available or not.
Need to correct something here. Run time detection of the presence of TAR register through the feature bit CPU_FTR_ARCH_207S as I had mentioned before is not required. Right now we take care of the compile time availability of the individual registers the same way it is present on the thread struct. In the systems which do not have the TAR register, thread.tar is always going to be 0 which is exactly the same value we would get by excluding tar register copy after the run time detection of the feature.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
In reply to Anshuman KhandualQuoted 33 lines · Anshuman Khandual
Quoted 32 lines · Edjunior Barbosa Machado
Quoted 31 lines · Anshuman Khandual
Quoted 30 lines · Anshuman Khandual
Quoted 29 lines · Michael Ellerman
Quoted 17 lines · Anshuman Khandual
This patch adds four new ELF core note sections for powerpc transactional memory and one new ELF core note section for powerpc general miscellaneous debug registers. These addition of new ELF core note sections extends the existing ELF ABI without affecting it in any manner.
Acked-by Andrew Morton <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/uapi/linux/elf.h | 5 +++++ 1 file changed, 5 insertions(+)include/uapi/linux/elf.h +0
-0include/uapi/linux/elf.h typedef struct elf64_shdr { · line 386
Quoted 8 lines
include/uapi/linux/elf.h +5
-0@@ -379,6 +379,11 @@ 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_TM_SPR 0x103/* PowerPC TM special registers */ +#define NT_PPC_TM_CGPR 0x104/* PowerpC TM checkpointed GPR */ +#define NT_PPC_TM_CFPR 0x105/* PowerPC TM checkpointed FPR */ +#define NT_PPC_TM_CVMX 0x106/* PowerPC TM checkpointed VMX */ +#define NT_PPC_MISC 0x107/* PowerPC miscellaneous registers */ This is a really terrible name, "MISC".
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Having said that, I guess it's accurate. We have a whole bunch of re=
gs that
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
have accrued over recent years that aren't accessible via ptrace.
It seems to me if we're adding a misc regset we should be adding eve=
rything we
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
might want to it that is currenty architected.
But I believe they also need to be part of the
thread_structstructur=
e to be
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
accessible from ptrace.
Currently we dont context save/restore the PMC count registers (PMC1-P=
MC6)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
during the process context switch. So the values of PMC1..PMC6 are not thread specific in the structure. To be able to access them in ptrace when the tracee has stopped, we need to context save these counters in the thread struct. Shall we do that ? Then we can add them to the MISC regset bucket irrespective of whats the value we get in there whe=
n
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
we probe through ptrace.
The same goes for MMCRA, CFAR registers as well.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
=20
Quoted 2 lines
But currently you only include the PPR, TAR & DSCR.
Yeah, thats what we started with.
Quoted 2 lines
Looking at Power ISA v2.07, I see the following that could be includ=
ed:
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
MMCR2
MMCRA
PMC1
PMC2
PMC3
PMC4
PMC5
PMC6
MMCR0
EBBHR
EBBRR
BESCR
SIAR
SDAR
CFAR?
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
MMCRA, PMC[1..6], EBBHR, BESCR, EBBRR, CFAR are not part of the threa=
d struct.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Sorry. EBBRR, EBBHR, BESCR registers are part of the thread struct.
Quoted 7 lines
Quoted 7 lines
Those are all new in 2.07 except for CFAR.
There might be more I missed, that was just a quick scan.
Some are only accessible when EBB is in use, maybe those could be a =
separate
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
regset.
Yeah we can have one more regset for EBB specific registers.
Should the new EBB specific regset include only EBBRR, EBBHR, BESCR re=
gisters
Quoted 1 line
Quoted 1 line
Quoted 1 line
or should it also include SIAR, SDAR, SIER, MMCR0, MMCR2 registers as =
well. I
Quoted 1 line
Quoted 1 line
Quoted 1 line
was thinking about putting these five registers into the MISC bucket i=
nstead.
Quoted 1 line
Quoted 1 line
Quoted 1 line
But from the perf code, it looks like these five registers are also re=
lated to
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
the EBB context as well.
Some clarity on these points would really help.
=20
Hi,
=20
from the provided testcase using ptrace interface, reviewing with the h=
elp
Quoted 1 line
Quoted 1 line
of Ulrich, it looks OK from GDB perspective, with the exception of a fe=
w
Quoted 4 lines
Quoted 4 lines
concerns:
=20
The patchset seems to change the "original" ptrace requests (i.e. PTRACE_GETREGS/GETFPREGS/GETVRREGS...) to return the "transactional" st=
ate, and
Quoted 1 line
Quoted 1 line
adds new register sets to return the "checkpointed" state. Considering =
that
Quoted 1 line
Quoted 1 line
whenever you get a debugger interception inside a transactional block, =
the
Quoted 1 line
Quoted 1 line
transaction will abort, we're wondering if it wouldn't make more sense =
to=20
Quoted 1 line
Quoted 1 line
display the 'checkpointed' state as the normal registers since this is =
where the
Quoted 3 lines
Quoted 1 line
execution will continue from.
=20
Debugger interception (trace interrupt) in between any transaction block =
will abort
Quoted 1 line
it ? I doubt that.
The trace interrupt will not abort the transaction explicitly...
Quoted 2 lines
The tracee process will just stop, it's context gets saved in the kernel so that it can again start executing from the exact same point onw=
ard when it
Quoted 1 line
resumes.=20
... unfortunately, this save *will* doom the transaction. To save, a treclaim instruction is run which will always explicitly doom the transaction.
Quoted 1 line
If this happens when inside any transaction block, the transaction's runn=
ing
Quoted 1 line
context and check pointed context will get saved. The execution will agai=
n start from
Quoted 1 line
the running context values instead of check pointed when the process resu=
mes. Check
Quoted 1 line
pointed values will be loaded back into the context when the transaction =
finishes.
Although since the transaction has been explicitly doomed, the hardware will *always* abort at this point and start execution from the checkpointed values.
Quoted 1 line
Inside transaction both running and check pointed values can be probed in=
dependently.
Yep, that's the idea, although setting the running values won't change anything since the the translation is already doomed and will abort once the cpu starts executing it. =20
Mikey
Quoted 2 lines
Quoted 2 lines
=20
Also, we've noticed that the 'misc' regset contains registers from diff=
erent ISA
Quoted 1 line
Quoted 1 line
versions (dscr and ppr appear in ISA 2.05, tar is from 2.07). I'm not s=
ure if
Quoted 1 line
Quoted 1 line
there is a way to detect presence/validity of such registers, but perha=
ps it
Quoted 1 line
Quoted 1 line
might be a good idea to separate registers from different ISAs in diffe=
rent
Quoted 3 lines
Quoted 1 line
regsets.
=20
Thats right, will use featureCPU_FTR_ARCH_207S(which checks whether we =
are v2.07
Quoted 4 lines
compliant) to detect whether TAR register is available or not.=20 =20
Quoted 2 lines
=20
Regarding the inclusion of other registers along with the EBB-related o=
nes, I'm
Quoted 3 lines
Quoted 1 line
sorry but I'm not familiar with them.
=20
Michael Ellerman mentioned that we can look into them separately sometime=
later
Quoted 6 lines
not in this patch series.
=20
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Michael Neuling <[email protected]> wrote on 22.01.2015 00:39:57:
Quoted 16 lines · Anshuman Khandual
Quoted 10 lines · Edjunior Barbosa Machado
Quoted 8 lines
The patchset seems to change the "original" ptrace requests (i.e. PTRACE_GETREGS/GETFPREGS/GETVRREGS...) to return the "transactional" state, and adds new register sets to return the "checkpointed" state. Considering that whenever you get a debugger interception inside a transactional block, the transaction will abort, we're wondering if it wouldn't make more sense to display the 'checkpointed' state as the normal registers since this is where the execution will continue from.
Quoted 2 lines
Debugger interception (trace interrupt) in between any transaction block will abort it ? I doubt that.
The trace interrupt will not abort the transaction explicitly...
Quoted 9 lines
Quoted 3 lines
The tracee process will just stop, it's context gets saved in the kernel so that it can again start executing from the exact same point onward when it resumes.
... unfortunately, this save *will* doom the transaction. To save, a treclaim instruction is run which will always explicitly doom the transaction.
Quoted 1 line
If this happens when inside any transaction block, the transaction's
running
Quoted 9 lines
Quoted 4 lines
context and check pointed context will get saved. The execution will again start from the running context values instead of check pointed when the process resumes. Check pointed values will be loaded back into the context when the transaction finishes.
Although since the transaction has been explicitly doomed, the hardware will *always* abort at this point and start execution from the checkpointed values.
Quoted 6 lines
Quoted 2 lines
Inside transaction both running and check pointed values can be probed independently.
Yep, that's the idea, although setting the running values won't change anything since the the translation is already doomed and will abort once the cpu starts executing it.
So this looks to me like the overall effect on debugging transactional code should be the same on Power and z, even if some internal details are different (on z, the exception will automatically abort the transaction; on p, the exception itself will not abort, but *restarting* user space execution will).
Quoted 1 line
From a GDB perspective, it would therefore be preferable if the ptrace
interface were to behave in a similar fashion on p as on z: that is, if an exception interrupting a transaction results in a ptrace intercept, at this point:
- the "normal" ptrace register set commands should access the *checkpointed* registers (allowing both read and write access)
-- GDB will use this to display current position (already reflecting the fact that the transaction will abort), and use it when changing register values e.g. to effect an inferior function call
- a new ptrace register set should allow access (read-only) to the *running* register values
-- GDB can use this to display the position inside the transaction at the point it aborted, using new transaction-specific commands
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Inside transaction both running and check pointed values can be probed independently.
Yep, that's the idea, although setting the running values won't change anything since the the translation is already doomed and will abort onc=
e
Quoted 7 lines
Quoted 1 line
the cpu starts executing it.
=20
So this looks to me like the overall effect on debugging transactional code should be the same on Power and z, even if some internal details are different (on z, the exception will automatically abort the transaction; on p, the exception itself will not abort, but *restarting* user space execution will).
Yep
Quoted 4 lines
From a GDB perspective, it would therefore be preferable if the ptrace interface were to behave in a similar fashion on p as on z: that is, if an exception interrupting a transaction results in a ptrace intercept, at this point:
Agreed.
Quoted 2 lines
- the "normal" ptrace register set commands should access the *checkpointed* registers (allowing both read and write access)
OK, this is a change from what we've been proposing with Anshuman's patch set but I'm happy to change it to make it consistent with other architectures. It's relatively arbitrary which goes where, so I'm happy to change.
Quoted 3 lines
-- GDB will use this to display current position (already reflecting the fact that the transaction will abort), and use it when changing register values e.g. to effect an inferior function call
"Current position" depends on your perspective. Is it the last executed instruction or the next executed instruction? If it's the last executed instruction, then it's the running values. If it's the next, then it's the check pointed. =20
Anyway, I'm happy to make it the check pointed values for the sake of ptrace/gdb.
Quoted 2 lines
- a new ptrace register set should allow access (read-only) to the *running* register values
This is because changing them won't ever result in a side effect? =20
Quoted 2 lines
-- GDB can use this to display the position inside the transaction at the point it aborted, using new transaction-specific commands
Yep.
Mikey
PS in the subject s/specifc/specific/
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 4 lines · Michael Neuling
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Inside transaction both running and check pointed values can be probed independently.
Yep, that's the idea, although setting the running values won't chang=
e
Quoted 1 line
Quoted 1 line
Quoted 1 line
anything since the the translation is already doomed and will abort o=
nce
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
the cpu starts executing it.
=20
So this looks to me like the overall effect on debugging transactional code should be the same on Power and z, even if some internal details are different (on z, the exception will automatically abort the transaction; on p, the exception itself will not abort, but *restarting=
*
Quoted 7 lines
Quoted 1 line
user space execution will).
=20
Yep
=20Quoted 3 lines
From a GDB perspective, it would therefore be preferable if the ptrace interface were to behave in a similar fashion on p as on z: that is, if an exception interrupting a transaction results in a ptrace intercep=
t,
Quoted 15 lines
Quoted 1 line
at this point:
=20
Agreed.
=20Quoted 2 lines
- the "normal" ptrace register set commands should access the *checkpointed* registers (allowing both read and write access)
=20
OK, this is a change from what we've been proposing with Anshuman's patch set but I'm happy to change it to make it consistent with other architectures. It's relatively arbitrary which goes where, so I'm happy to change.
=20Quoted 3 lines
-- GDB will use this to display current position (already reflecting the fact that the transaction will abort), and use it when changing register values e.g. to effect an inferior function call
Quoted 8 lines
=20
"Current position" depends on your perspective. Is it the last executed instruction or the next executed instruction? If it's the last executed instruction, then it's the running values. If it's the next, then it's the check pointed. =20
=20
Anyway, I'm happy to make it the check pointed values for the sake of ptrace/gdb.
Uli,
Sorry, I'm rethinking this as we didn't consider user suspended transactions.
It makes sense for normal transactions but for user suspended transactions the running values are the ones you want to modify since that is where you'll end up restarting from. The hardware will only abort/rollback once a tresume is encountered.
*=20
So we could do what you're talking about for normal transactions and then switch them for suspended transactions. But this just seems to be making the kernel interface overly complicated. =20
So I'm keen on just keeping it the way Anshuman has now and GDB has to understand the program flow better to know which ones it wants to modify. The kernel always provides the "normal" set as running and the new set as check pointed. GDB then has to check the MSR to work out what it wants to modify.
Quoted 4 lines
Quoted 2 lines
- a new ptrace register set should allow access (read-only) to the *running* register values
=20
This is because changing them won't ever result in a side effect? =20
For the same reason as above, we need to be able to modify the running values when it's a user suspended transaction. So I don't agree with this any more in the case of user suspended transaction. We need to be able to modify both sets of registers.
Mikey
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Michael Neuling <[email protected]> wrote on 28.01.2015 05:28:09:
Quoted 7 lines
Sorry, I'm rethinking this as we didn't consider user suspended transactions.
It makes sense for normal transactions but for user suspended transactions the running values are the ones you want to modify since that is where you'll end up restarting from. The hardware will only abort/rollback once a tresume is encountered.
OK, I see. I hadn't really looked into suspended transactions before ...
Quoted 3 lines
So we could do what you're talking about for normal transactions and then switch them for suspended transactions. But this just seems to be making the kernel interface overly complicated.
Agreed. Given that there seems to be an inevitable difference in how transactions are seen by the debugger between Power and z (there are no suspended transactions on z), I guess it makes more sense to have the interface naturally model the hardware register sets on Power, and have GDB cope with the differences.
Quoted 5 lines
So I'm keen on just keeping it the way Anshuman has now and GDB has to understand the program flow better to know which ones it wants to modify. The kernel always provides the "normal" set as running and the new set as check pointed. GDB then has to check the MSR to work out what it wants to modify.
So I'm thinking how this all would work out for the case of GDB wanting to call an inferior function while the process is stopped within a transaction (in either transactional or suspended state).
(A) In suspended state, I guess GDB could modify the "normal" register set and ask the kernel to continue. The kernel would then transfer control to the inferior function entry point while still in suspended state, and the inferior function would execute in suspended state until it hits the GDB-placed breakpoint at the end. At this point, GDB would reload the original values to the "normal" register set, and ask the kernel to continue. The kernel would then transfer control to the originally-interrupted piece of code in suspended state, which would continue to execute until the tresume, at which point the transaction would abort (due to TDOOMED). Right?
(B) In transactional state, GDB could modify the "checkpointed" register set and ask the kernel to continue. The kernel would transfer control to the originally-interrupted code in transactional state. At this point, the transaction would immediately abort, and control would transfer to the state specified in the checkpointed register set, and the inferior function would now execute in non-transactional state, until it hits the breakpoint. At this point, GDB would now have to restore the original values of the *checkpointed* register set into the *normal* register set (a bit weird from a GDB internals perspective), and ask the kernel to continue. Execution would now resume at the abort handler of the originally interrupted transaction. (Hmm. Maybe GDB would also have to set cr0 or something?)
Is it possible for GDB to change the state (transactional vs. suspended) where the kernel ought to let the application continue in? I guess via modifying the appropriate MSR bits via ptrace?
If so, there would be other options to handle this:
(A') In the transactional state, GDB could set the MSR to suspended, and modify the "normal" register set. The inferior function would execute in the suspended state as in (A) above. Upon return, GDB would restore the normal register set (including restoring the MSR to transactional state). Once the kernel resumes the application, the transaction would abort at this point.
(B') In the suspended state, GDB could set the MSR to transactional, and modify the "checkpointed" register set. Once the kernel resumes the application, the transaction immediately aborts and control transfers to the inferior function, executing in nontransactional state as in (B). Upon return, GDB would again need to restore the original checkpointed register set into the normal register set, set cr0 to indicate transactional abort, and continue.
Using the combination of (A)+(A') would be easiest to implement in GDB without modifying a lot of common code, and would have the advantage that the inferior function always executes in the same state (suspended), while leaving information about the interrupted transaction visible.
Using the combination of (B)+(B') would be a bit more difficult to implement (but certainly feasible), and would have the advantage that the inferior function always executes in nontransactional state (which is what it would most likely expect, anyway). However, the disadvantage is that after the inferior call returns, GDB is unable to fully restore the visible inferior state as it was before (since we're now in nontransactional state, and there is probably no way to force us back into transactional/suspended state ...).
Am I missing something here? Any additional thoughts?
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
- a new ptrace register set should allow access (read-only) to the *running* register values
This is because changing them won't ever result in a side effect?
For the same reason as above, we need to be able to modify the running values when it's a user suspended transaction. So I don't agree with this any more in the case of user suspended transaction. We need to be able to modify both sets of registers.
So I guess the kernel, on resuming the application, first loads the checkpointed register set into normal registers, issues the trechkpt instruction to move them to the checkpointed register, and then loads the normal register set, before returning to user space? Then it does indeed appear that both sets *are* modifyable, and thus the kernel interface should export them as such.
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Uli,
Sorry for the slow response.
Quoted 27 lines
Michael Neuling <[email protected]> wrote on 28.01.2015 05:28:09:
=20Quoted 7 lines
Sorry, I'm rethinking this as we didn't consider user suspended transactions.
It makes sense for normal transactions but for user suspended transactions the running values are the ones you want to modify since that is where you'll end up restarting from. The hardware will only abort/rollback once a tresume is encountered.
=20
OK, I see. I hadn't really looked into suspended transactions before ...Quoted 3 lines
So we could do what you're talking about for normal transactions and then switch them for suspended transactions. But this just seems to be making the kernel interface overly complicated.
=20
Agreed. Given that there seems to be an inevitable difference in how transactions are seen by the debugger between Power and z (there are no suspended transactions on z), I guess it makes more sense to have the interface naturally model the hardware register sets on Power, and have GDB cope with the differences.Quoted 5 lines
So I'm keen on just keeping it the way Anshuman has now and GDB has to understand the program flow better to know which ones it wants to modify. The kernel always provides the "normal" set as running and the new set as check pointed. GDB then has to check the MSR to work out what it wants to modify.
Quoted 4 lines
=20
So I'm thinking how this all would work out for the case of GDB wanting to call an inferior function while the process is stopped within a transaction (in either transactional or suspended state).
Should this inferior function be run in the current mode of the processor? ie if the process is currently transactional and the transaction aborts, should we be able to see any global state change because of an inferior function being run in GDB? =20
Also, if you modify the stack in suspend mode, that'll be persistent. So it's possible that you could corrupt your stack if you abort. For example, if your tbegin is inside a function (one or more deep) that returns (one or more times while transactional), you need make sure you don't touch the stack non-transactionally if you want to be able to abort and not corrupt your stack.
I think what you're proposing with running the inferior function in suspend mode may end up corrupting the stack in this way. You'd need to be really careful to make sure the inferior function is run on the stack pointer of the checkpointed registers. =20
We do something like this in the kernel when laying out a signal frame on the user stack when the user is transactional. We lay it out on the checkpointed stack pointer/r1. (The best way for users to avoid this problem is to use sigaltstack() but we can't rely on that).
Quoted 10 lines
(A) In suspended state, I guess GDB could modify the "normal" register set and ask the kernel to continue. The kernel would then transfer control to the inferior function entry point while still in suspended state, and the inferior function would execute in suspended state until it hits the GDB-placed breakpoint at the end. At this point, GDB would reload the original values to the "normal" register set, and ask the kernel to continue. The kernel would then transfer control to the originally-interrupted piece of code in suspended state, which would continue to execute until the tresume, at which point the transaction would abort (due to TDOOMED). Right?
I think so.
Quoted 4 lines
(B) In transactional state, GDB could modify the "checkpointed" register set and ask the kernel to continue. The kernel would transfer control to the originally-interrupted code in transactional state. At this point, the transaction would immediately abort, and control would
Quoted 8 lines
transfer to the state specified in the checkpointed register set, and the inferior function would now execute in non-transactional state, until it hits the breakpoint. At this point, GDB would now have to restore the original values of the *checkpointed* register set into the *normal* register set (a bit weird from a GDB internals perspective), and ask the kernel to continue. Execution would now resume at the abort handler of the originally interrupted transaction. (Hmm. Maybe GDB would also have to set cr0 or something?)
OK, but do we want the inferior function to be run non-transactionally? Should it changes be seen after the transaction aborts? =20
Quoted 3 lines
Is it possible for GDB to change the state (transactional vs. suspended) where the kernel ought to let the application continue in? I guess via modifying the appropriate MSR bits via ptrace?
Yes, you can change the MSR to change the TM mode.
Quoted 8 lines
If so, there would be other options to handle this:
=20
(A') In the transactional state, GDB could set the MSR to suspended, and modify the "normal" register set. The inferior function would execute in the suspended state as in (A) above. Upon return, GDB would restore the normal register set (including restoring the MSR to transactional state). Once the kernel resumes the application, the transaction would abort at this point.
This seems ok, although again, the inferior function would have side effects even if the transaction aborts. Is that what we want? Can we say to users that the inferior function is actually be run after the transaction aborts?
Also, we need to be careful with the stack. =20
Quoted 7 lines
(B') In the suspended state, GDB could set the MSR to transactional, and modify the "checkpointed" register set. Once the kernel resumes the application, the transaction immediately aborts and control transfers to the inferior function, executing in nontransactional state as in (B). Upon return, GDB would again need to restore the original checkpointed register set into the normal register set, set cr0 to indicate transactional abort, and continue.
OK.
Quoted 6 lines
Using the combination of (A)+(A') would be easiest to implement in GDB without modifying a lot of common code, and would have the advantage that the inferior function always executes in the same state (suspended), while leaving information about the interrupted transaction visible.
=20
Quoted 8 lines
Using the combination of (B)+(B') would be a bit more difficult to implement (but certainly feasible), and would have the advantage that the inferior function always executes in nontransactional state (which is what it would most likely expect, anyway). However, the disadvantage is that after the inferior call returns, GDB is unable to fully restore the visible inferior state as it was before (since we're now in nontransactional state, and there is probably no way to force us back into transactional/suspended state ...).
Yep.
Quoted 11 lines
Am I missing something here? Any additional thoughts?
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
- a new ptrace register set should allow access (read-only) to the *running* register values
This is because changing them won't ever result in a side effect?
For the same reason as above, we need to be able to modify the running values when it's a user suspended transaction. So I don't agree with this any more in the case of user suspended transaction. We need to be able to modify both sets of registers.
Quoted 5 lines
=20
So I guess the kernel, on resuming the application, first loads the checkpointed register set into normal registers, issues the trechkpt instruction to move them to the checkpointed register, and then loads the normal register set, before returning to user space? =20
Correct.
Quoted 3 lines
Then it does
indeed appear that both sets *are* modifyable, and thus the kernel interface should export them as such.
Correct.
Getting back to the kernel interface, are you happy with what Anshuman has proposed in the current series?
Regards,
Mikey
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Michael Neuling <[email protected]> wrote on 23.02.2015 05:51:50:
Quoted 1 line
Sorry for the slow response.
Same here :-(
Quoted 4 lines
Should this inferior function be run in the current mode of the processor? ie if the process is currently transactional and the transaction aborts, should we be able to see any global state change because of an inferior function being run in GDB?
Inferior functions IMO should *not* run in transactional mode. A typical inferior call is to malloc to get some memory to be used by GDB to store data in the inferior ... you wouldn't want to call malloc inside a transaction.
Now, whether inferior functions can run in *suspended* mode (i.e. causing the transaction to abort after the inferior call has returned) or have to run in nontransactional mode (aborting the transaction befer the inferior call), I'm not sure. Unless there are some unexpected side effect, it seems cleaner to run in suspended mode, since this way we can restore the state we were in before the inferior call after the call (which is what user would tend to expect).
On the other hand, inferior function calls do not necessarily return. In fact, they could throw or longjmp to some routine higher up on the stack, in which case GDB will never get control back. The rest of program execution would then be done in suspended mode (and not nontransactional mode), at least until code attempts to start the next transaction. Not sure if this is an issue.
Quoted 6 lines
Also, if you modify the stack in suspend mode, that'll be persistent. So it's possible that you could corrupt your stack if you abort. For example, if your tbegin is inside a function (one or more deep) that returns (one or more times while transactional), you need make sure you don't touch the stack non-transactionally if you want to be able to abort and not corrupt your stack.
I see.
Quoted 4 lines
I think what you're proposing with running the inferior function in suspend mode may end up corrupting the stack in this way. You'd need to be really careful to make sure the inferior function is run on the stack pointer of the checkpointed registers.
On the other hand, if code called a subroutine after the tbegin, if we were using the checkpointed r1, this might corrupt the stack of the transactional code. (This code will never actually *run* again since the transaction is doomed, but we can still *inspect* it in GDB after the inferior call has returned, so the stack should remain unchanged. Well .. if the transaction is suspended, the code might in fact still run, so it should remain unchanged either way.)
I guess we could use the minimum of transactional and checkpointed r1 in that case, to be safe either way.
Quoted 11 lines
Quoted 10 lines
(A) In suspended state, I guess GDB could modify the "normal" register set and ask the kernel to continue. The kernel would then transfer control to the inferior function entry point while still in suspended state, and the inferior function would execute in suspended state until it hits the GDB-placed breakpoint at the end. At this point, GDB would reload the original values to the "normal" register set, and ask the kernel to continue. The kernel would then transfer control to the originally-interrupted piece of code in suspended state, which would continue to execute until the tresume, at which point the transaction would abort (due to TDOOMED). Right?
Quoted 1 line
I think so.
Good.
Quoted 1 line
Quoted 1 line
(B) In transactional state, GDB could modify the "checkpointed"
register
Quoted 12 lines
Quoted 11 lines
set and ask the kernel to continue. The kernel would transfer control to the originally-interrupted code in transactional state. At this point, the transaction would immediately abort, and control would transfer to the state specified in the checkpointed register set, and the inferior function would now execute in non-transactional state, until it hits the breakpoint. At this point, GDB would now have to restore the original values of the *checkpointed* register set into the *normal* register set (a bit weird from a GDB internals perspective), and ask the kernel to continue. Execution would now resume at the abort handler of the originally interrupted transaction. (Hmm. Maybe GDB would also have to set cr0 or something?)
Quoted 2 lines
OK, but do we want the inferior function to be run non-transactionally? Should it changes be seen after the transaction aborts?
Yes, see above.
Quoted 5 lines
Quoted 3 lines
Is it possible for GDB to change the state (transactional vs. suspended) where the kernel ought to let the application continue in? I guess via modifying the appropriate MSR bits via ptrace?
Yes, you can change the MSR to change the TM mode.
OK, that's good.
Quoted 9 lines
Quoted 8 lines
If so, there would be other options to handle this:
(A') In the transactional state, GDB could set the MSR to suspended, and modify the "normal" register set. The inferior function would execute in the suspended state as in (A) above. Upon return, GDB would restore the normal register set (including restoring the MSR to transactional state). Once the kernel resumes the application, the transaction would abort at this point.
Quoted 6 lines
This seems ok, although again, the inferior function would have side effects even if the transaction aborts. Is that what we want? Can we say to users that the inferior function is actually be run after the transaction aborts?
Also, we need to be careful with the stack.
See above.
Quoted 25 lines
Quoted 7 lines
(B') In the suspended state, GDB could set the MSR to transactional, and modify the "checkpointed" register set. Once the kernel resumes the application, the transaction immediately aborts and control transfers to the inferior function, executing in nontransactional state as in (B). Upon return, GDB would again need to restore the original checkpointed register set into the normal register set, set cr0 to indicate transactional abort, and continue.
OK.
Quoted 6 lines
Using the combination of (A)+(A') would be easiest to implement in GDB without modifying a lot of common code, and would have the advantage that the inferior function always executes in the same state (suspended), while leaving information about the interrupted transaction visible.
Quoted 8 lines
Using the combination of (B)+(B') would be a bit more difficult to implement (but certainly feasible), and would have the advantage that the inferior function always executes in nontransactional state (which is what it would most likely expect, anyway). However, the disadvantage is that after the inferior call returns, GDB is unable to fully restore the visible inferior state as it was before (since we're now in nontransactional state, and there is probably no way to force us back into transactional/suspended state ...).
Quoted 1 line
Yep.
So right now I'd tend to prefer (A)+(A'), but the important thing is that the kernel seems to provide all features required for GDB to implement any of the above, so we can still make that decision later.
Quoted 2 lines
Getting back to the kernel interface, are you happy with what Anshuman has proposed in the current series?
Given the discussion above, this seems fine to me now.
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 5 lines · Ulrich Weigand
Michael Neuling <[email protected]> wrote on 23.02.2015 05:51:50:
=20Quoted 1 line
Sorry for the slow response.
=20
Same here :-(
I'm going to break the cycle and respond in a few hours :-)
Quoted 2 lines
Quoted 2 lines
I think what you're proposing with running the inferior function in suspend mode may end up corrupting the stack in this way. You'd need t=
o
Quoted 1 line
Quoted 1 line
be really careful to make sure the inferior function is run on the stac=
k
Quoted 12 lines
Quoted 1 line
pointer of the checkpointed registers.
=20
On the other hand, if code called a subroutine after the tbegin, if we were using the checkpointed r1, this might corrupt the stack of the transactional code. (This code will never actually *run* again since the transaction is doomed, but we can still *inspect* it in GDB after the inferior call has returned, so the stack should remain unchanged. Well .. if the transaction is suspended, the code might in fact still run, so it should remain unchanged either way.)
=20
I guess we could use the minimum of transactional and checkpointed r1 in that case, to be safe either way.
Sounds good.
<snip>
Quoted 21 lines
Quoted 15 lines
Quoted 6 lines
Using the combination of (A)+(A') would be easiest to implement in GDB without modifying a lot of common code, and would have the advantage that the inferior function always executes in the same state (suspended), while leaving information about the interrupted transaction visible.
Quoted 8 lines
Using the combination of (B)+(B') would be a bit more difficult to implement (but certainly feasible), and would have the advantage that the inferior function always executes in nontransactional state (which is what it would most likely expect, anyway). However, the disadvantage is that after the inferior call returns, GDB is unable to fully restore the visible inferior state as it was before (since we're now in nontransactional state, and there is probably no way to force us back into transactional/suspended state ...).
Quoted 1 line
Yep.
=20
So right now I'd tend to prefer (A)+(A'), but the important thing is that the kernel seems to provide all features required for GDB to implement any of the above, so we can still make that decision later. =20
Quoted 4 lines
Quoted 2 lines
Getting back to the kernel interface, are you happy with what Anshuman has proposed in the current series?
=20
Given the discussion above, this seems fine to me now.
Great, we'll push through with this in mind.
Thanks!
Mikey
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 12 lines · Michael Neuling
Quoted 5 lines · Ulrich Weigand
Michael Neuling <[email protected]> wrote on 23.02.2015 05:51:50:
=20Quoted 1 line
Sorry for the slow response.
=20
Same here :-(=20
I'm going to break the cycle and respond in a few hours :-) =20
=20Quoted 2 lines
Quoted 2 lines
I think what you're proposing with running the inferior function in suspend mode may end up corrupting the stack in this way. You'd need=
to
Quoted 1 line
Quoted 1 line
Quoted 1 line
be really careful to make sure the inferior function is run on the st=
ack
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
pointer of the checkpointed registers.
=20
On the other hand, if code called a subroutine after the tbegin, if we were using the checkpointed r1, this might corrupt the stack of the transactional code. (This code will never actually *run* again since the transaction is doomed, but we can still *inspect* it in GDB after the inferior call has returned, so the stack should remain unchanged. Well .. if the transaction is suspended, the code might in fact still run, so it should remain unchanged either way.)
=20
I guess we could use the minimum of transactional and checkpointed r1 in that case, to be safe either way.
Quoted 14 lines
=20
Sounds good.
=20
<snip>
=20Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Using the combination of (A)+(A') would be easiest to implement in GDB without modifying a lot of common code, and would have the advantage that the inferior function always executes in the same state (suspended), while leaving information about the interrupted transaction visible.
Using the combination of (B)+(B') would be a bit more difficult to implement (but certainly feasible), and would have the advantage that the inferior function always executes in nontransactional stat=
e
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
(which is what it would most likely expect, anyway). However, the disadvantage is that after the inferior call returns, GDB is unable to fully restore the visible inferior state as it was before (since we're now in nontransactional state, and there is probably no way to force us back into transactional/suspended state ...).
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Yep.
=20
So right now I'd tend to prefer (A)+(A'), but the important thing is that the kernel seems to provide all features required for GDB to implement any of the above, so we can still make that decision later. =20Quoted 1 line
Getting back to the kernel interface, are you happy with what Anshuma=
n
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
has proposed in the current series?
=20
Given the discussion above, this seems fine to me now.=20
Great, we'll push through with this in mind.
Anshuman,
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set. =20
Mikey
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 57 lines · Michael Neuling
Quoted 56 lines · Michael Neuling
Quoted 5 lines · Ulrich Weigand
Michael Neuling <[email protected]> wrote on 23.02.2015 05:51:50:
Quoted 1 line
Sorry for the slow response.
Same here :-(
I'm going to break the cycle and respond in a few hours :-)
Quoted 13 lines
Quoted 4 lines
I think what you're proposing with running the inferior function in suspend mode may end up corrupting the stack in this way. You'd need to be really careful to make sure the inferior function is run on the stack pointer of the checkpointed registers.
On the other hand, if code called a subroutine after the tbegin, if we were using the checkpointed r1, this might corrupt the stack of the transactional code. (This code will never actually *run* again since the transaction is doomed, but we can still *inspect* it in GDB after the inferior call has returned, so the stack should remain unchanged. Well .. if the transaction is suspended, the code might in fact still run, so it should remain unchanged either way.)
Quoted 2 lines
I guess we could use the minimum of transactional and checkpointed r1 in that case, to be safe either way.
Sounds good.
<snip>
Quoted 25 lines
Quoted 15 lines
Quoted 6 lines
Using the combination of (A)+(A') would be easiest to implement in GDB without modifying a lot of common code, and would have the advantage that the inferior function always executes in the same state (suspended), while leaving information about the interrupted transaction visible.
Quoted 8 lines
Using the combination of (B)+(B') would be a bit more difficult to implement (but certainly feasible), and would have the advantage that the inferior function always executes in nontransactional state (which is what it would most likely expect, anyway). However, the disadvantage is that after the inferior call returns, GDB is unable to fully restore the visible inferior state as it was before (since we're now in nontransactional state, and there is probably no way to force us back into transactional/suspended state ...).
Quoted 1 line
Yep.
So right now I'd tend to prefer (A)+(A'), but the important thing is that the kernel seems to provide all features required for GDB to implement any of the above, so we can still make that decision later.
Quoted 2 lines
Getting back to the kernel interface, are you happy with what Anshuman has proposed in the current series?
Given the discussion above, this seems fine to me now.
Quoted 7 lines
Quoted 1 line
Great, we'll push through with this in mind.
Anshuman,
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set.
No, we dont have that yet. When ptracing in 32-bit mode the MSR value which can be viewed or set from the user space through PTRACE_GETREGS PTRACE_SETREGS call is it's lower 32 bits only. Either we can club the upper 32 bits of MSR as part of one of the ELF core notes we are adding in the patch series or we can create one more separate ELF core note for that purpose. Let me know your opinion on this.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Anshuman Khandual <[email protected]> wrote on 23.03.2015 11:34:30:
Quoted 10 lines
Quoted 3 lines
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set.
No, we dont have that yet. When ptracing in 32-bit mode the MSR value which can be viewed or set from the user space through
PTRACE_GETREGSPTRACE_SETREGScall is it's lower 32 bits only. Either we can club the upper 32 bits of MSR as part of one of the ELF core notes we are adding in the patch series or we can create one more separate ELF core note for that purpose. Let me know your opinion on this.
I'm not sure I understand this. I thought we had the following:
- If the process calling ptrace is itself 64-bit (which is how GDB is built on all current Linux distributions), then PTRACE_GETREGS etc. will *always* operate on 64-bit register sets, even if the target process is 32-bit.
- If the process calling ptrace is 32-bit, then PTRACE_GETREGS will
operate on 32-bit register sets. However, there is a separate
PTRACE_GETREGS64 / PTRACE_SETREGS64 call that will also provide the opportunity to operate on the full 64-bit register set. Both apply independently of whether the target process is 32-bit or 64-bit.
Is this not correct?
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 13 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 23.03.2015 11:34:30:
=20Quoted 10 lines
Quoted 3 lines
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set.
No, we dont have that yet. When ptracing in 32-bit mode the MSR value which can be viewed or set from the user space through
PTRACE_GETREGSPTRACE_SETREGScall is it's lower 32 bits only. Either we can club the upper 32 bits of MSR as part of one of the ELF core notes we are adding in the patch series or we can create one more separate ELF core note for that purpose. Let me know your opinion on this.
Quoted 16 lines
=20
I'm not sure I understand this. I thought we had the following:
=20
- If the process calling ptrace is itself 64-bit (which is how GDB is built on all current Linux distributions), thenPTRACE_GETREGSetc. will *always* operate on 64-bit register sets, even if the target process is 32-bit.
=20
- If the process calling ptrace is 32-bit, thenPTRACE_GETREGSwill
operate on 32-bit register sets. However, there is a separate
PTRACE_GETREGS64/PTRACE_SETREGS64call that will also provide the opportunity to operate on the full 64-bit register set. Both apply independently of whether the target process is 32-bit or 64-bit.
=20
Is this not correct?
I think you're correct. We should be right. I'd forgotten about the GET/SETREGS64 interfaces.
Mikey
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 29 lines · Michael Neuling
Quoted 28 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 23.03.2015 11:34:30:
Quoted 10 lines
Quoted 3 lines
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set.
No, we dont have that yet. When ptracing in 32-bit mode the MSR value which can be viewed or set from the user space through
PTRACE_GETREGSPTRACE_SETREGScall is it's lower 32 bits only. Either we can club the upper 32 bits of MSR as part of one of the ELF core notes we are adding in the patch series or we can create one more separate ELF core note for that purpose. Let me know your opinion on this.I'm not sure I understand this. I thought we had the following:
- If the process calling ptrace is itself 64-bit (which is how GDB is built on all current Linux distributions), then
PTRACE_GETREGSetc. will *always* operate on 64-bit register sets, even if the target process is 32-bit.- If the process calling ptrace is 32-bit, then
PTRACE_GETREGSwill
operate on 32-bit register sets. However, there is a separate
PTRACE_GETREGS64/PTRACE_SETREGS64call that will also provide the opportunity to operate on the full 64-bit register set. Both apply independently of whether the target process is 32-bit or 64-bit.
Quoted 4 lines
Quoted 1 line
Is this not correct?
I think you're correct. We should be right. I'd forgotten about the GET/SETREGS64 interfaces.
In that case, is the patch series complete and okay ? Is there any thing else we need to verify other than waiting for the GDB test results which Edjunior has been working on. But I am not aware of the status on the GDB test development front.
Edjunior,
Do you have any updates ?
Regards
Anshuman
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 9 lines · Anshuman Khandual
Quoted 8 lines · Michael Neuling
Quoted 7 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 23.03.2015 11:34:30:
Quoted 4 lines
Quoted 3 lines
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
No, we dont have that yet. When ptracing in 32-bit mode the MSR value which can be viewed or set from the user space through
PTRACE_GETREGSPTRACE_SETREGScall is it's lower 32 bits only. Either we can club the upper 32 bits of MSR as part of one of the ELF core notes we are adding in the patch series or we can create one more separate ELF cor=
e
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 1 line
note for that purpose. Let me know your opinion on this.
I'm not sure I understand this. I thought we had the following:
- If the process calling ptrace is itself 64-bit (which is how GDB is built on all current Linux distributions), then
PTRACE_GETREGSetc. will *always* operate on 64-bit register sets, even if the target process is 32-bit.- If the process calling ptrace is 32-bit, then
PTRACE_GETREGSwill
operate on 32-bit register sets. However, there is a separate
PTRACE_GETREGS64/PTRACE_SETREGS64call that will also provide the opportunity to operate on the full 64-bit register set. Both apply independently of whether the target process is 32-bit or 64-bit.Is this not correct?
Quoted 8 lines
Quoted 3 lines
=20
I think you're correct. We should be right. I'd forgotten about the GET/SETREGS64 interfaces.=20
In that case, is the patch series complete and okay ? Is there any thing else we need to verify other than waiting for the GDB test results which Edjunior has been working on. But I am not aware of the status on the GDB test development front.
I think we are good.
Mikey
Quoted 9 lines
=20
Edjunior,
=20
Do you have any updates ?
=20
Regards
Anshuman
=20
=20
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 36 lines · Michael Neuling
Quoted 35 lines · Anshuman Khandual
Quoted 33 lines · Michael Neuling
Quoted 21 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 23.03.2015 11:34:30:
Quoted 10 lines
Quoted 3 lines
With that in mind, do we have a way to set the top 32bits of the MSR (which contain the TM bits) when ptracing 32 bit processes? I can't find anything like that in this patch set.
No, we dont have that yet. When ptracing in 32-bit mode the MSR value which can be viewed or set from the user space through
PTRACE_GETREGSPTRACE_SETREGScall is it's lower 32 bits only. Either we can club the upper 32 bits of MSR as part of one of the ELF core notes we are adding in the patch series or we can create one more separate ELF core note for that purpose. Let me know your opinion on this.I'm not sure I understand this. I thought we had the following:
- If the process calling ptrace is itself 64-bit (which is how GDB is built on all current Linux distributions), then
PTRACE_GETREGSetc. will *always* operate on 64-bit register sets, even if the target process is 32-bit.Quoted 8 lines
- If the process calling ptrace is 32-bit, then
PTRACE_GETREGSwill
operate on 32-bit register sets. However, there is a separate
PTRACE_GETREGS64/PTRACE_SETREGS64call that will also provide the opportunity to operate on the full 64-bit register set. Both apply independently of whether the target process is 32-bit or 64-bit.Is this not correct?
I think you're correct. We should be right. I'd forgotten about the GET/SETREGS64 interfaces.
Quoted 6 lines
Quoted 4 lines
In that case, is the patch series complete and okay ? Is there any thing else we need to verify other than waiting for the GDB test results which Edjunior has been working on. But I am not aware of the status on the GDB test development front.
I think we are good.
I had posted a newer version [V7] of this patch series couple of months back which got ignored while the discussion continued in this version.
V7: https://lkml.org/lkml/2015/1/14/19
Apart from the last gitignore related patch which already got merged into mainline separately, all other patches should be as good even today. I will try rebasing the series, running the base tests again and re post it in some time.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Anshuman Khandual <[email protected]> wrote on 10.04.2015 11:10:35:
Quoted 1 line
I had posted a newer version [V7] of this patch series couple of months
back
Quoted 3 lines
which got ignored while the discussion continued in this version.
Ah, with all the back-and-forth on the checkpointed state, I never looked at this. Unfortunately, there's still a number of issues with this, I think:
- You provide checkpointed FPR and VMX registers, but there doesn't seem to be any way to get at the checkpointed *VSX* registers (i.e. the part that is neither covered by FPR or VMX, corresponding to NT_PPC_VSX).
- We may have had this discussion in the past, but I still do not like the notion of a "misc" register set, in particular since the three registers in it are available at different architecture levels and categories.
I would much prefer three separate regsets (e.g. NT_PPC_DSCR, NT_PPC_PPR, and NT_PPC_TAR), each of which is available and valid if and only if the current processor actually has the register in question.
If we do have a single regset, at the very least a "get" operation should set registers unvailable on the machine to a defined state (zero?) instead of simply leaving memory uninitialized.
- Similarly, the NT_PPC_TM_SPR regset as currently defined mixes and matches
registers with different "lifetimes". The transactional memory registers (TFHAR, TEXASR, TFIAR) are available *always* on machines that support transactions. But the other registers in that regset are checkpointed versions that are only available/valid within a transaction. I think a better way to faithfully represent this would be to have theNT_PPC_TM_SPR
regset only contain the transcational memory registers, and use separate regsets for the checkpointed registers -- those should parallel the non- checkpointed register regset.
For example, if we have NT_PPC_DSCR, there should be a NT_PPC_CDSCR for the checkpointed version etc. (If we do stay with MISC, there should
then
be a CMISC).
- Particularly confusing to me is the "checkpointed original MSR" which currently also resides in NT_PPC_TM_SPR. What exactly is this? How does that differ from the MSR slot in the NT_PPC_TM_CGPR regset?
I may be misreading kernel code, but it seems the kernel does not
actually
use the ckpt_regs.msr slot at all, and therefore the corresponding slot
of
the NT_PPC_TM_CGPR regset is likewise undefined/unused. Would it not be more consistent to use that slot to pass the checkpointed MSR?
In any case, it seems the ptrace set-register case currently allows user space to restore *any* arbitrary value into the checkpointed MSR, which would presumably get restored into the real MSR at some point, unless I'm missing something here. Do we not need a check that only safe bits are modified, just like with ptrace access to the real MSR?
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 9 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 10.04.2015 11:10:35:
Quoted 1 line
I had posted a newer version [V7] of this patch series couple of months
back
Quoted 3 lines
which got ignored while the discussion continued in this version.
Quoted 7 lines
Ah, with all the back-and-forth on the checkpointed state, I never looked at this. Unfortunately, there's still a number of issues with this, I think:
- You provide checkpointed FPR and VMX registers, but there doesn't seem to be any way to get at the checkpointed *VSX* registers (i.e. the part that is neither covered by FPR or VMX, corresponding to
NT_PPC_VSX).
Will change vsr_get, vsr_set functions as we have done for fpr_get and fpr_set functions. Also will add one more ELF core note NT_PPC_TM_CVSX to fetch the check pointed state of VSX register while inside the transaction.
Quoted 4 lines
- We may have had this discussion in the past, but I still do not like the notion of a "misc" register set, in particular since the three registers in it are available at different architecture levels and categories.
Misc category as always stands for registers which can not be easily classified into any meaningful categories.
Quoted 4 lines
I would much prefer three separate regsets (e.g.
NT_PPC_DSCR,NT_PPC_PPR, andNT_PPC_TAR), each of which is available and valid if and only if the current processor actually has the register in question.
Thats like adding one ELF core note for every single register because we cannot put them in any category. Then as Michael Ellerman had pointed out to include a lot more registers in this MISC category (which we are not doing right now in the interest of having minimum support available before we look at the full possible list of MISC registers), we should add one ELF core note section for each of those individual registers ? I am not sure.
Quoted 4 lines
If we do have a single regset, at the very least a "get" operation should set registers unvailable on the machine to a defined state (zero?) instead of simply leaving memory uninitialized.
Yeah sure, we can do that.
Quoted 12 lines
- Similarly, the
NT_PPC_TM_SPRregset as currently defined mixes and matches
registers with different "lifetimes". The transactional memory registers (TFHAR, TEXASR, TFIAR) are available *always* on machines that support transactions. But the other registers in that regset are checkpointed versions that are only available/valid within a transaction. I think a better way to faithfully represent this would be to have theNT_PPC_TM_SPR
regset only contain the transcational memory registers, and use separate regsets for the checkpointed registers -- those should parallel the non- checkpointed register regset.
Right now, we support NT_PPC_TM_SPR only inside the transaction, so we dont have the problem with different "lifetimes" registers accessed together. But yes, I get your point.
Quoted 5 lines
For example, if we have
NT_PPC_DSCR, there should be aNT_PPC_CDSCRfor the checkpointed version etc. (If we do stay with MISC, there should
then
be a CMISC).
But then NT_PPC_MISC and NT_PPC_CMISC can contain different set of registers. NT_PPC_CMISC will contain the orig_msr for now which the other elf core note does not have and NT_PPC_MISC will grow to have lot more registers in the future leaving behind NT_PPC_CMISC as it is. Need to take care of these.
Quoted 4 lines
- Particularly confusing to me is the "checkpointed original MSR" which currently also resides in
NT_PPC_TM_SPR. What exactly is this? How does that differ from the MSR slot in theNT_PPC_TM_CGPRregset?
I believed it stores the check pointed MSR value which was in the register before the transaction started. But then how it is different from the ckpt_regs.msr, I am not sure. Mikey or Michael should be able to clarify more on this. I can see "orig_msr" getting used in many places to hold the check pointed value of MSR.
Quoted 7 lines
I may be misreading kernel code, but it seems the kernel does not
actually
use the ckpt_regs.msr slot at all, and therefore the corresponding slot
of
theNT_PPC_TM_CGPRregset is likewise undefined/unused. Would it not be more consistent to use that slot to pass the checkpointed MSR?
Hmm. Its a valid point. Would like to get some more clarity on this from Mikey whether that slot can be used for check pointed MSR value or not. Then why did we have these two slots to hold the same check pointed MSR value in the first place at all. Getting confused a bit.
Quoted 6 lines
In any case, it seems the ptrace set-register case currently allows user space to restore *any* arbitrary value into the checkpointed MSR, which would presumably get restored into the real MSR at some point, unless I'm missing something here. Do we not need a check that only safe bits are modified, just like with ptrace access to the real MSR?
Where and which safe bits do we check before writing any value into the MSR register from ptrace interface ? May be I am missing something here.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 9 lines · Anshuman Khandual
Quoted 2 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 10.04.2015 11:10:35:
I believed it stores the check pointed MSR value which was in the register before the transaction started. But then how it is different from the ckpt_regs.msr, I am not sure. Mikey or Michael should be able to clarify more on this. I can see "
orig_msr" getting used in many places to hold the check pointed value of MSR.
tm_orig_msr is used during process context switch only. ckpt_regs gets used in the signal context where we save all userspace context. So ptrace would look into the saved MSR value correctly inside ckpt_regs.msr slot. I believe thats the check pointed MSR value we are interested in from the ptrace perspective not the tm_orig_msr which just gets used during process context switch.
Quoted 11 lines
Quoted 6 lines
I may be misreading kernel code, but it seems the kernel does not
actually
use the ckpt_regs.msr slot at all, and therefore the corresponding slot
of
theNT_PPC_TM_CGPRregset is likewise undefined/unused. Would it not be more consistent to use that slot to pass the checkpointed MSR?Hmm. Its a valid point. Would like to get some more clarity on this from Mikey whether that slot can be used for check pointed MSR value or not. Then why did we have these two slots to hold the same check pointed MSR value in the first place at all. Getting confused a bit.
Using ckpt_regs.msr during process context switch instead of tm_orig_msr seems to be working fine and all the basic TM tests pass, in which case we can drop tm_orig_msr from thread_struct. Will post a patch on this and see whats the response from others.
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
In reply to Anshuman KhandualAnshuman Khandual <[email protected]> wrote on 13.04.2015 10:48:57:
Quoted 2 lines · Ulrich Weigand
Quoted 1 line
- You provide checkpointed FPR and VMX registers, but there doesn't
seem
Quoted 1 line
Quoted 1 line
to be any way to get at the checkpointed *VSX* registers (i.e. the
part
Quoted 3 lines
Quoted 1 line
that is neither covered by FPR or VMX, corresponding to
NT_PPC_VSX).Will change
vsr_get,vsr_setfunctions as we have done forfpr_getand
fpr_set
Quoted 1 line
functions. Also will add one more ELF core note
NT_PPC_TM_CVSXto fetch
the
Quoted 1 line
check pointed state of VSX register while inside the transaction.
OK.
Quoted 1 line
Quoted 1 line
I would much prefer three separate regsets (e.g.
NT_PPC_DSCR,
NT_PPC_PPR,
Quoted 1 line
Quoted 1 line
and
NT_PPC_TAR), each of which is available and valid if and only if
the
Quoted 5 lines
Quoted 1 line
current processor actually has the register in question.
Thats like adding one ELF core note for every single register because we cannot
put them in any category. Then as Michael Ellerman had pointed out to
include
Quoted 1 line
a lot more registers in this MISC category (which we are not doing right
now
Quoted 1 line
in the interest of having minimum support available before we look at the
full
Quoted 1 line
possible list of MISC registers), we should add one ELF core note section
for
Quoted 1 line
each of those individual registers ? I am not sure.
This confuses me a bit. My understanding was that ptrace regsets, once defined, should never change in the future. (GDB will only check whether or not a regset is supported; if it is, it will expect the contents to be as it expects them to be.) "Including a lot more registers" would therefore
seem to require adding new regsets anyway, which is one of the reasons why I disagree a "MISC" regset is particularly useful.
Quoted 3 lines
Quoted 3 lines
- Similarly, the
NT_PPC_TM_SPRregset as currently defined mixes and matches
registers with different "lifetimes". The transactional memory
registers
Quoted 1 line
Quoted 1 line
(TFHAR, TEXASR, TFIAR) are available *always* on machines that
support
Quoted 1 line
Quoted 1 line
transactions. But the other registers in that regset are
checkpointed
Quoted 1 line
Quoted 1 line
versions that are only available/valid within a transaction. I think
a
Quoted 3 lines
Quoted 3 lines
better way to faithfully represent this would be to have the
NT_PPC_TM_SPR
regset only contain the transcational memory registers, and use
separate
Quoted 1 line
Quoted 1 line
regsets for the checkpointed registers -- those should parallel the
non-
Quoted 3 lines
Quoted 1 line
checkpointed register regset.
Right now, we support
NT_PPC_TM_SPRonly inside the transaction, so we
dont
Quoted 1 line
have the problem with different "lifetimes" registers accessed together.
But
Quoted 1 line
yes, I get your point.
Since the transactional SPRs are accessible from user space outside of a transaction, it would make sense for them to accessible from ptrace as well.
If the current patch set doesn't do that, I guess it would be better to change that.
Quoted 5 lines
Quoted 3 lines
- Particularly confusing to me is the "checkpointed original MSR" which currently also resides in
NT_PPC_TM_SPR. What exactly is this? How does that differ from the MSR slot in theNT_PPC_TM_CGPRregset?I believed it stores the check pointed MSR value which was in the
register
Quoted 3 lines
before the transaction started. But then how it is different from the ckpt_regs.msr, I am not sure. Mikey or Michael should be able to clarify more on this. I can see "
orig_msr" getting used in many places to hold
the
Quoted 1 line
check pointed value of MSR.
Your other mail states that the orig_mst may be irrelevant for ptrace anyway ... that would be OK with me as well.
Quoted 1 line
Quoted 1 line
In any case, it seems the ptrace set-register case currently allows
user
Quoted 1 line
Quoted 1 line
space to restore *any* arbitrary value into the checkpointed MSR,
which
Quoted 1 line
Quoted 1 line
would presumably get restored into the real MSR at some point, unless
I'm
Quoted 1 line
Quoted 1 line
missing something here. Do we not need a check that only safe bits
are
Quoted 3 lines
Quoted 1 line
modified, just like with ptrace access to the real MSR?
Where and which safe bits do we check before writing any value into the
MSR
Quoted 1 line
register from ptrace interface ? May be I am missing something here.
All ptrace accesses to *set* the regular msr go via this routine:
static int set_user_msr(struct task_struct *task, unsigned long msr)
{
task->thread.regs->msr &= ~MSR_DEBUGCHANGE;
task->thread.regs->msr |= msr & MSR_DEBUGCHANGE;
return 0;
}I think we'd need to do the equivalent whenever changing the checkpointed MSR.
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 35 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 13.04.2015 10:48:57:
Quoted 2 lines · Ulrich Weigand
Quoted 1 line
- You provide checkpointed FPR and VMX registers, but there doesn't
seem
Quoted 1 line
Quoted 1 line
to be any way to get at the checkpointed *VSX* registers (i.e. the
part
Quoted 3 lines
Quoted 1 line
that is neither covered by FPR or VMX, corresponding to
NT_PPC_VSX).Will change
vsr_get,vsr_setfunctions as we have done forfpr_getand
fpr_setQuoted 1 line
functions. Also will add one more ELF core note
NT_PPC_TM_CVSXto fetchthe
Quoted 1 line
check pointed state of VSX register while inside the transaction.
OK.
Quoted 1 line
Quoted 1 line
I would much prefer three separate regsets (e.g.
NT_PPC_DSCR,
NT_PPC_PPR,Quoted 1 line
Quoted 1 line
and
NT_PPC_TAR), each of which is available and valid if and only ifthe
Quoted 5 lines
Quoted 1 line
current processor actually has the register in question.
Thats like adding one ELF core note for every single register because we cannot
put them in any category. Then as Michael Ellerman had pointed out toinclude
Quoted 1 line
a lot more registers in this MISC category (which we are not doing right
now
Quoted 1 line
in the interest of having minimum support available before we look at the
full
Quoted 1 line
possible list of MISC registers), we should add one ELF core note section
for
Quoted 1 line
each of those individual registers ? I am not sure.
Quoted 7 lines
This confuses me a bit. My understanding was that ptrace regsets, once defined, should never change in the future. (GDB will only check whether or not a regset is supported; if it is, it will expect the contents to be as it expects them to be.) "Including a lot more registers" would therefore
seem to require adding new regsets anyway, which is one of the reasons why I disagree a "MISC" regset is particularly useful.
Yeah right. Started thinking that (NT_PPC_TAR, NT_PPC_CTAR), (NT_PPC_PPR, NT_PPC_CPPR), (NT_PPC_DSCR, NT_PPC_CDSCR) kind of combinations make more sense !
Quoted 22 lines
Quoted 4 lines
Quoted 4 lines
- Similarly, the
NT_PPC_TM_SPRregset as currently defined mixes and matches
registers with different "lifetimes". The transactional memoryregisters
Quoted 1 line
Quoted 1 line
(TFHAR, TEXASR, TFIAR) are available *always* on machines that
support
Quoted 1 line
Quoted 1 line
transactions. But the other registers in that regset are
checkpointed
Quoted 1 line
Quoted 1 line
versions that are only available/valid within a transaction. I think
a
Quoted 3 lines
Quoted 3 lines
better way to faithfully represent this would be to have the
NT_PPC_TM_SPR
regset only contain the transcational memory registers, and useseparate
Quoted 1 line
Quoted 1 line
regsets for the checkpointed registers -- those should parallel the
non-
Quoted 3 lines
Quoted 1 line
checkpointed register regset.
Right now, we support
NT_PPC_TM_SPRonly inside the transaction, so wedont
Quoted 1 line
have the problem with different "lifetimes" registers accessed together.
Quoted 8 lines
But
Quoted 1 line
yes, I get your point.
Since the transactional SPRs are accessible from user space outside of a transaction, it would make sense for them to accessible from ptrace as well.
If the current patch set doesn't do that, I guess it would be better to change that.
Yeah I agree. Will change it.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
- Particularly confusing to me is the "checkpointed original MSR" which currently also resides in
NT_PPC_TM_SPR. What exactly is this? How does that differ from the MSR slot in theNT_PPC_TM_CGPRregset?I believed it stores the check pointed MSR value which was in the
register
Quoted 8 lines
Quoted 3 lines
before the transaction started. But then how it is different from the ckpt_regs.msr, I am not sure. Mikey or Michael should be able to clarify more on this. I can see "
orig_msr" getting used in many places to holdthe
Quoted 1 line
check pointed value of MSR.
Your other mail states that the
orig_mstmay be irrelevant for ptrace anyway ... that would be OK with me as well.
Yeah. The variable tm_orig_msr is used to compute MSR state inside the kernel or what would be passed to the user space while returning at various stages of the transaction, where as ckpt_regs.msr contains the latest check pointed MSR value to be fetched by ptrace. Thats my understanding as of now.
Quoted 18 lines
Quoted 2 lines
Quoted 2 lines
In any case, it seems the ptrace set-register case currently allows
user
Quoted 1 line
Quoted 1 line
space to restore *any* arbitrary value into the checkpointed MSR,
which
Quoted 1 line
Quoted 1 line
would presumably get restored into the real MSR at some point, unless
I'm
Quoted 1 line
Quoted 1 line
missing something here. Do we not need a check that only safe bits
are
Quoted 3 lines
Quoted 1 line
modified, just like with ptrace access to the real MSR?
Where and which safe bits do we check before writing any value into the
MSR
Quoted 1 line
register from ptrace interface ? May be I am missing something here.
All ptrace accesses to *set* the regular msr go via this routine:
static int
set_user_msr(struct task_struct *task, unsigned long msr)
Quoted 8 lines
{ task->thread.regs->msr &= ~MSR_DEBUGCHANGE; task->thread.regs->msr |= msr & MSR_DEBUGCHANGE; return 0; }I think we'd need to do the equivalent whenever changing the checkpointed MSR.
Agree, will incorporate this change.
In summary, after putting together all the issues that we have discussed till now regarding the number and scope of all new ELF core note sections being added, the probable elements there in can be listed as below.
Changed ELF core note sections
------------------------------
These core note sections need to be changed to accommodate the in transaction ptrace requests when the running/current value of these registers will reside some where else instead of the original places of thread_struct.
/* Running register state */
(1) NT_PRFPREG (Accessible always)
(2) NT_PPC_VMX (Accessible always)
(3) NT_PPC_VSX (Accessible always)
New ELF core note sections
--------------------------
/* TM check pointed register set */
(1) NT_PPC_TM_CGPR --> NT_PRSTATUS (Accessible inside TM)
(2) NT_PPC_TM_CFPR --> NT_PRFPREG (Accessible inside TM)
(3) NT_PPC_TM_CVMX --> NT_PPC_VMX (Accessible inside TM)
(4) NT_PPC_TM_CVSX --> NT_PPC_VSX (Accessible inside TM)
NOTE: The register set data structure for these ELF core not sections would exactly match with that of the corresponding running value register sets indicated above.
/* TM SPR set */ (Accessible always)
(5) NT_PPC_TM_SPR thread->tm_tfhar
thread->tm_tfiar thread->ttm_exasr
/* TM check pointed misc register set */
(6) NT_PPC_TM_TAR thread->tm_tar (Accessible inside TM)
(7) NT_PPC_TM_PPR thread->tm_ppr (Accessible inside TM)
(8) NT_PPC_TM_DSCR thread->tm_dscr (Accessible inside TM)
NOTE: Application can have a different set of TAR, PPR and DSCR registers inside the transaction compared that of the outside. Also seems like they are *not* the check pointed ones, will double check on this. Changed the core note section name from NT_PPC_TM_CTAR to just NT_PPC_TM_TAR and for all the others.
/* Running misc register set */
(9) NT_PPC_TAR thread->tar (Accessible always)
(10) NT_PPC_PPR thread->ppr (Accessible always)
(11) NT_PPC_DSCR thread->dscr (Accessible always)
NOTE: They are like any other special purpose register which can be changed from the user space. So the elf core note section name can be generic. Here are some optional ELF core note sections which we can also add like the above ones.
(12) NT_PPC_EBBRR thread->ebbrr (Accessible inside EBB)
(13) NT_PPC_EBBHR thread->ebbhr (Accessible inside EBB)
(14) NT_PPC_BESCR thread->bescr (Accessible inside EBB)
(15) NT_PPC_SIAR thread->siar (Accessible inside EBB)
(16) NT_PPC_SDAR thread->sdar (Accessible inside EBB)
(17) NT_PPC_SIER thread->sier (Accessible inside EBB)
(18) NT_PPC_MMCR2 thread->mmcr2 (Accessible inside EBB)
(19) NT_PPC_MMCR0 thread->mmcr0 (Accessible inside EBB)
Ulrich, Mikey, MPE,
Please do let me know your thoughts on this.
Regards
Anshuman
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Anshuman Khandual <[email protected]> wrote on 21.04.2015 06:55:24:
Quoted 15 lines
Changed ELF core note sections
------------------------------
These core note sections need to be changed to accommodate the in transaction ptrace requests when the running/current value of these registers will reside some where else instead of the original places ofthread_struct./* Running register state */
(1) NT_PRFPREG (Accessible always) (2) NT_PPC_VMX (Accessible always) (3) NT_PPC_VSX (Accessible always)New ELF core note sections
--------------------------
/* TM check pointed register set */
Quoted 8 lines
(1) NT_PPC_TM_CGPR --> NT_PRSTATUS (Accessible inside TM) (2) NT_PPC_TM_CFPR --> NT_PRFPREG (Accessible inside TM) (3) NT_PPC_TM_CVMX --> NT_PPC_VMX (Accessible inside TM) (4) NT_PPC_TM_CVSX --> NT_PPC_VSX (Accessible inside TM)NOTE: The register set data structure for these ELF core not sections would exactly match with that of the corresponding running value register sets indicated above.
OK.
Quoted 4 lines
/* TM SPR set */ (Accessible always)
(5)NT_PPC_TM_SPRthread->tm_tfharthread->tm_tfiar thread->ttm_exasr
OK.
Quoted 10 lines
/* TM check pointed misc register set */
(6) NT_PPC_TM_TAR thread->tm_tar (Accessible inside TM) (7) NT_PPC_TM_PPR thread->tm_ppr (Accessible inside TM)(8)
NT_PPC_TM_DSCRthread->tm_dscr(Accessible inside TM)NOTE: Application can have a different set of TAR, PPR and DSCR registers inside the transaction compared that of the outside. Also seems like they are *not* the check pointed ones, will double check on this. Changed the core note section name from
NT_PPC_TM_CTARto justNT_PPC_TM_TARand for all the others.
Huh? How is this not the checkpointed set? I would have expected that NT_PPC_TAR contains the current tar (which is the one in the transaction if we're within one), while NT_PPC_TM_CTAR contains the checkpointed value that will be restored once the transaction aborts. Why is this not the case?
Quoted 5 lines
NOTE: They are like any other special purpose register which can be changed from the user space. So the elf core note section name can be generic. Here are some optional ELF core note sections which we can also add like the above ones.
Quoted 8 lines
(12) NT_PPC_EBBRR thread->ebbrr (Accessible inside EBB) (13) NT_PPC_EBBHR thread->ebbhr (Accessible inside EBB) (14) NT_PPC_BESCR thread->bescr (Accessible inside EBB) (15) NT_PPC_SIAR thread->siar (Accessible inside EBB) (16) NT_PPC_SDAR thread->sdar (Accessible inside EBB) (17) NT_PPC_SIER thread->sier (Accessible inside EBB) (18) NT_PPC_MMCR2 thread->mmcr2 (Accessible inside EBB) (19) NT_PPC_MMCR0 thread->mmcr0 (Accessible inside EBB)
So I'm not really familiar with the EBB stuff. But just as a general note, if those are in fact related (i.e. on every machine that has EBB, all those registers will be available), it might indeed make more sense to collect them into a single note section (NT_PPC_EBB?) after all.
Bye,
Ulrich
Re: [V6,1/9] elf: Add new powerpc specifc core note sections
Quoted 47 lines · Ulrich Weigand
Anshuman Khandual <[email protected]> wrote on 21.04.2015 06:55:24:
Quoted 15 lines
Changed ELF core note sections
------------------------------
These core note sections need to be changed to accommodate the in transaction ptrace requests when the running/current value of these registers will reside some where else instead of the original places ofthread_struct./* Running register state */
(1) NT_PRFPREG (Accessible always) (2) NT_PPC_VMX (Accessible always) (3) NT_PPC_VSX (Accessible always)New ELF core note sections
--------------------------
/* TM check pointed register set */Quoted 8 lines
(1) NT_PPC_TM_CGPR --> NT_PRSTATUS (Accessible inside TM) (2) NT_PPC_TM_CFPR --> NT_PRFPREG (Accessible inside TM) (3) NT_PPC_TM_CVMX --> NT_PPC_VMX (Accessible inside TM) (4) NT_PPC_TM_CVSX --> NT_PPC_VSX (Accessible inside TM)NOTE: The register set data structure for these ELF core not sections would exactly match with that of the corresponding running value register sets indicated above.
OK.
Quoted 4 lines
/* TM SPR set */ (Accessible always)
(5)NT_PPC_TM_SPRthread->tm_tfharthread->tm_tfiar thread->ttm_exasrOK.
Quoted 10 lines
/* TM check pointed misc register set */
(6) NT_PPC_TM_TAR thread->tm_tar (Accessible inside TM) (7) NT_PPC_TM_PPR thread->tm_ppr (Accessible inside TM)(8)
NT_PPC_TM_DSCRthread->tm_dscr(Accessible inside TM)NOTE: Application can have a different set of TAR, PPR and DSCR registers inside the transaction compared that of the outside. Also seems like they are *not* the check pointed ones, will double check on this. Changed the core note section name from
NT_PPC_TM_CTARto justNT_PPC_TM_TARand for all the others.
Quoted 6 lines
Huh? How is this not the checkpointed set? I would have expected that
NT_PPC_TARcontains the current tar (which is the one in the transaction if we're within one), whileNT_PPC_TM_CTARcontains the checkpointed value that will be restored once the transaction aborts. Why is this not the case?
Yeah you are right. There is one running value always which is 'thread->tm_tar' when TM is active and it is 'thread->tar' when TM is not active. This can be accessed *always* with NT_PPC_TAR. The check pointed TAR is 'thread->tar' only when *TM is active* which can be accessed via NT_PPC_TM_CTAR. Will update the ELF core note list with lifetimes.
Quoted 15 lines
Quoted 6 lines
NOTE: They are like any other special purpose register which can be changed from the user space. So the elf core note section name can be generic. Here are some optional ELF core note sections which we can also add like the above ones.
Quoted 8 lines
(12) NT_PPC_EBBRR thread->ebbrr (Accessible inside EBB) (13) NT_PPC_EBBHR thread->ebbhr (Accessible inside EBB) (14) NT_PPC_BESCR thread->bescr (Accessible inside EBB) (15) NT_PPC_SIAR thread->siar (Accessible inside EBB) (16) NT_PPC_SDAR thread->sdar (Accessible inside EBB) (17) NT_PPC_SIER thread->sier (Accessible inside EBB) (18) NT_PPC_MMCR2 thread->mmcr2 (Accessible inside EBB) (19) NT_PPC_MMCR0 thread->mmcr0 (Accessible inside EBB)
Quoted 5 lines
So I'm not really familiar with the EBB stuff. But just as a general note, if those are in fact related (i.e. on every machine that has EBB, all those registers will be available), it might indeed make more sense to collect them into a single note section (
NT_PPC_EBB?) after all.
I agree that would save us precious ELF core note section entry slots which are 256 in total ever for powerpc arch. Right now all these register states in thread_struct are getting used for EBB only. But again these are PMU related registers, in future we may need to access them for purposes other than EBB. Yes, that will be a problem for us to solve later on. Right now it makes more sense to group them together under EBB heading and pass them as a group which saves ELF core note entries for powerpc. Hopefully Mikey and Michael will agree on this.