xref: /openbmc/linux/arch/powerpc/kernel/ptrace/ptrace-decl.h (revision e08227d25a26901d13c6b597e60dffba40e2659d)
17b99ed4eSChristophe Leroy /* SPDX-License-Identifier: GPL-2.0-or-later */
27b99ed4eSChristophe Leroy 
37c1f8db0SChristophe Leroy /*
47c1f8db0SChristophe Leroy  * Set of msr bits that gdb can change on behalf of a process.
57c1f8db0SChristophe Leroy  */
67c1f8db0SChristophe Leroy #ifdef CONFIG_PPC_ADV_DEBUG_REGS
77c1f8db0SChristophe Leroy #define MSR_DEBUGCHANGE	0
87c1f8db0SChristophe Leroy #else
97c1f8db0SChristophe Leroy #define MSR_DEBUGCHANGE	(MSR_SE | MSR_BE)
107c1f8db0SChristophe Leroy #endif
117c1f8db0SChristophe Leroy 
127c1f8db0SChristophe Leroy /*
137c1f8db0SChristophe Leroy  * Max register writeable via put_reg
147c1f8db0SChristophe Leroy  */
157c1f8db0SChristophe Leroy #ifdef CONFIG_PPC32
167c1f8db0SChristophe Leroy #define PT_MAX_PUT_REG	PT_MQ
177c1f8db0SChristophe Leroy #else
187c1f8db0SChristophe Leroy #define PT_MAX_PUT_REG	PT_CCR
197c1f8db0SChristophe Leroy #endif
207c1f8db0SChristophe Leroy 
217c1f8db0SChristophe Leroy #define TVSO(f)	(offsetof(struct thread_vr_state, f))
227c1f8db0SChristophe Leroy #define TFSO(f)	(offsetof(struct thread_fp_state, f))
237c1f8db0SChristophe Leroy #define TSO(f)	(offsetof(struct thread_struct, f))
247c1f8db0SChristophe Leroy 
256e0b7975SChristophe Leroy /*
266e0b7975SChristophe Leroy  * These are our native regset flavors.
276e0b7975SChristophe Leroy  */
286e0b7975SChristophe Leroy enum powerpc_regset {
296e0b7975SChristophe Leroy 	REGSET_GPR,
306e0b7975SChristophe Leroy 	REGSET_FPR,
316e0b7975SChristophe Leroy #ifdef CONFIG_ALTIVEC
326e0b7975SChristophe Leroy 	REGSET_VMX,
336e0b7975SChristophe Leroy #endif
346e0b7975SChristophe Leroy #ifdef CONFIG_VSX
356e0b7975SChristophe Leroy 	REGSET_VSX,
366e0b7975SChristophe Leroy #endif
376e0b7975SChristophe Leroy #ifdef CONFIG_SPE
386e0b7975SChristophe Leroy 	REGSET_SPE,
396e0b7975SChristophe Leroy #endif
406e0b7975SChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
416e0b7975SChristophe Leroy 	REGSET_TM_CGPR,		/* TM checkpointed GPR registers */
426e0b7975SChristophe Leroy 	REGSET_TM_CFPR,		/* TM checkpointed FPR registers */
436e0b7975SChristophe Leroy 	REGSET_TM_CVMX,		/* TM checkpointed VMX registers */
446e0b7975SChristophe Leroy 	REGSET_TM_CVSX,		/* TM checkpointed VSX registers */
456e0b7975SChristophe Leroy 	REGSET_TM_SPR,		/* TM specific SPR registers */
466e0b7975SChristophe Leroy 	REGSET_TM_CTAR,		/* TM checkpointed TAR register */
476e0b7975SChristophe Leroy 	REGSET_TM_CPPR,		/* TM checkpointed PPR register */
486e0b7975SChristophe Leroy 	REGSET_TM_CDSCR,	/* TM checkpointed DSCR register */
496e0b7975SChristophe Leroy #endif
506e0b7975SChristophe Leroy #ifdef CONFIG_PPC64
516e0b7975SChristophe Leroy 	REGSET_PPR,		/* PPR register */
526e0b7975SChristophe Leroy 	REGSET_DSCR,		/* DSCR register */
536e0b7975SChristophe Leroy #endif
546e0b7975SChristophe Leroy #ifdef CONFIG_PPC_BOOK3S_64
556e0b7975SChristophe Leroy 	REGSET_TAR,		/* TAR register */
566e0b7975SChristophe Leroy 	REGSET_EBB,		/* EBB registers */
576e0b7975SChristophe Leroy 	REGSET_PMR,		/* Performance Monitor Registers */
586e0b7975SChristophe Leroy #endif
596e0b7975SChristophe Leroy #ifdef CONFIG_PPC_MEM_KEYS
606e0b7975SChristophe Leroy 	REGSET_PKEY,		/* AMR register */
616e0b7975SChristophe Leroy #endif
626e0b7975SChristophe Leroy };
636e0b7975SChristophe Leroy 
647b99ed4eSChristophe Leroy /* ptrace-(no)vsx */
657b99ed4eSChristophe Leroy 
667b99ed4eSChristophe Leroy int fpr_get(struct task_struct *target, const struct user_regset *regset,
677b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
687b99ed4eSChristophe Leroy int fpr_set(struct task_struct *target, const struct user_regset *regset,
697b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count,
707b99ed4eSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
717b99ed4eSChristophe Leroy 
727b99ed4eSChristophe Leroy /* ptrace-vsx */
737b99ed4eSChristophe Leroy 
747b99ed4eSChristophe Leroy int vsr_active(struct task_struct *target, const struct user_regset *regset);
757b99ed4eSChristophe Leroy int vsr_get(struct task_struct *target, const struct user_regset *regset,
767b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
777b99ed4eSChristophe Leroy int vsr_set(struct task_struct *target, const struct user_regset *regset,
787b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count,
797b99ed4eSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
807b99ed4eSChristophe Leroy 
811b20773bSChristophe Leroy /* ptrace-altivec */
821b20773bSChristophe Leroy 
831b20773bSChristophe Leroy int vr_active(struct task_struct *target, const struct user_regset *regset);
841b20773bSChristophe Leroy int vr_get(struct task_struct *target, const struct user_regset *regset,
851b20773bSChristophe Leroy 	   unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
861b20773bSChristophe Leroy int vr_set(struct task_struct *target, const struct user_regset *regset,
871b20773bSChristophe Leroy 	   unsigned int pos, unsigned int count,
881b20773bSChristophe Leroy 	   const void *kbuf, const void __user *ubuf);
891b20773bSChristophe Leroy 
9060ef9dbdSChristophe Leroy /* ptrace-spe */
9160ef9dbdSChristophe Leroy 
9260ef9dbdSChristophe Leroy int evr_active(struct task_struct *target, const struct user_regset *regset);
9360ef9dbdSChristophe Leroy int evr_get(struct task_struct *target, const struct user_regset *regset,
9460ef9dbdSChristophe Leroy 	    unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
9560ef9dbdSChristophe Leroy int evr_set(struct task_struct *target, const struct user_regset *regset,
9660ef9dbdSChristophe Leroy 	    unsigned int pos, unsigned int count,
9760ef9dbdSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
9860ef9dbdSChristophe Leroy 
997b99ed4eSChristophe Leroy /* ptrace */
1007b99ed4eSChristophe Leroy 
1017c1f8db0SChristophe Leroy int gpr32_get_common(struct task_struct *target,
1027c1f8db0SChristophe Leroy 		     const struct user_regset *regset,
1037c1f8db0SChristophe Leroy 		     unsigned int pos, unsigned int count,
1047c1f8db0SChristophe Leroy 			    void *kbuf, void __user *ubuf,
1057c1f8db0SChristophe Leroy 			    unsigned long *regs);
1067c1f8db0SChristophe Leroy int gpr32_set_common(struct task_struct *target,
1077c1f8db0SChristophe Leroy 		     const struct user_regset *regset,
1087c1f8db0SChristophe Leroy 		     unsigned int pos, unsigned int count,
1097c1f8db0SChristophe Leroy 		     const void *kbuf, const void __user *ubuf,
1107c1f8db0SChristophe Leroy 		     unsigned long *regs);
1117c1f8db0SChristophe Leroy 
1127c1f8db0SChristophe Leroy /* ptrace-tm */
1137c1f8db0SChristophe Leroy 
1147b99ed4eSChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1157b99ed4eSChristophe Leroy void flush_tmregs_to_thread(struct task_struct *tsk);
1167b99ed4eSChristophe Leroy #else
1177b99ed4eSChristophe Leroy static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
1187b99ed4eSChristophe Leroy #endif
1197c1f8db0SChristophe Leroy 
1207c1f8db0SChristophe Leroy int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
1217c1f8db0SChristophe Leroy int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
1227c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1237c1f8db0SChristophe Leroy int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
1247c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1257c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1267c1f8db0SChristophe Leroy int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
1277c1f8db0SChristophe Leroy int tm_cfpr_get(struct task_struct *target, const struct user_regset *regset,
1287c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1297c1f8db0SChristophe Leroy int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
1307c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1317c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1327c1f8db0SChristophe Leroy int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
1337c1f8db0SChristophe Leroy int tm_cvmx_get(struct task_struct *target, const struct user_regset *regset,
1347c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1357c1f8db0SChristophe Leroy int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
1367c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1377c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1387c1f8db0SChristophe Leroy int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
1397c1f8db0SChristophe Leroy int tm_cvsx_get(struct task_struct *target, const struct user_regset *regset,
1407c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1417c1f8db0SChristophe Leroy int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
1427c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1437c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1447c1f8db0SChristophe Leroy int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
1457c1f8db0SChristophe Leroy int tm_spr_get(struct task_struct *target, const struct user_regset *regset,
1467c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1477c1f8db0SChristophe Leroy int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
1487c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1497c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1507c1f8db0SChristophe Leroy int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
1517c1f8db0SChristophe Leroy int tm_tar_get(struct task_struct *target, const struct user_regset *regset,
1527c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1537c1f8db0SChristophe Leroy int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
1547c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1557c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1567c1f8db0SChristophe Leroy int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
1577c1f8db0SChristophe Leroy int tm_ppr_get(struct task_struct *target, const struct user_regset *regset,
1587c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1597c1f8db0SChristophe Leroy int tm_ppr_set(struct task_struct *target, const struct user_regset *regset,
1607c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1617c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1627c1f8db0SChristophe Leroy int tm_dscr_active(struct task_struct *target, const struct user_regset *regset);
1637c1f8db0SChristophe Leroy int tm_dscr_get(struct task_struct *target, const struct user_regset *regset,
1647c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1657c1f8db0SChristophe Leroy int tm_dscr_set(struct task_struct *target, const struct user_regset *regset,
1667c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1677c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1687c1f8db0SChristophe Leroy int tm_cgpr32_get(struct task_struct *target, const struct user_regset *regset,
1697c1f8db0SChristophe Leroy 		  unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
1707c1f8db0SChristophe Leroy int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
1717c1f8db0SChristophe Leroy 		  unsigned int pos, unsigned int count,
1727c1f8db0SChristophe Leroy 		  const void *kbuf, const void __user *ubuf);
1736e0b7975SChristophe Leroy 
1746e0b7975SChristophe Leroy /* ptrace-view */
1756e0b7975SChristophe Leroy 
1766e0b7975SChristophe Leroy extern const struct user_regset_view user_ppc_native_view;
177323a780cSChristophe Leroy 
178323a780cSChristophe Leroy /* ptrace-(no)adv */
179*e08227d2SChristophe Leroy int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
180*e08227d2SChristophe Leroy 			unsigned long __user *datalp);
181323a780cSChristophe Leroy int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);
182323a780cSChristophe Leroy long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info);
183323a780cSChristophe Leroy long ppc_del_hwdebug(struct task_struct *child, long data);
184