xref: /openbmc/linux/arch/powerpc/kernel/ptrace/ptrace-decl.h (revision 81e30a5412e4bcdc9d338ffa0cf1f4b90bc63abc)
17b99ed4eSChristophe Leroy /* SPDX-License-Identifier: GPL-2.0-or-later */
27b99ed4eSChristophe Leroy 
3*81e30a54SBenjamin Gray #include <linux/regset.h>
4*81e30a54SBenjamin Gray 
57c1f8db0SChristophe Leroy /*
67c1f8db0SChristophe Leroy  * Set of msr bits that gdb can change on behalf of a process.
77c1f8db0SChristophe Leroy  */
87c1f8db0SChristophe Leroy #ifdef CONFIG_PPC_ADV_DEBUG_REGS
97c1f8db0SChristophe Leroy #define MSR_DEBUGCHANGE	0
107c1f8db0SChristophe Leroy #else
117c1f8db0SChristophe Leroy #define MSR_DEBUGCHANGE	(MSR_SE | MSR_BE)
127c1f8db0SChristophe Leroy #endif
137c1f8db0SChristophe Leroy 
147c1f8db0SChristophe Leroy /*
157c1f8db0SChristophe Leroy  * Max register writeable via put_reg
167c1f8db0SChristophe Leroy  */
177c1f8db0SChristophe Leroy #ifdef CONFIG_PPC32
187c1f8db0SChristophe Leroy #define PT_MAX_PUT_REG	PT_MQ
197c1f8db0SChristophe Leroy #else
207c1f8db0SChristophe Leroy #define PT_MAX_PUT_REG	PT_CCR
217c1f8db0SChristophe Leroy #endif
227c1f8db0SChristophe Leroy 
237c1f8db0SChristophe Leroy #define TVSO(f)	(offsetof(struct thread_vr_state, f))
247c1f8db0SChristophe Leroy #define TFSO(f)	(offsetof(struct thread_fp_state, f))
257c1f8db0SChristophe Leroy #define TSO(f)	(offsetof(struct thread_struct, f))
267c1f8db0SChristophe Leroy 
276e0b7975SChristophe Leroy /*
286e0b7975SChristophe Leroy  * These are our native regset flavors.
296e0b7975SChristophe Leroy  */
306e0b7975SChristophe Leroy enum powerpc_regset {
316e0b7975SChristophe Leroy 	REGSET_GPR,
326e0b7975SChristophe Leroy 	REGSET_FPR,
336e0b7975SChristophe Leroy #ifdef CONFIG_ALTIVEC
346e0b7975SChristophe Leroy 	REGSET_VMX,
356e0b7975SChristophe Leroy #endif
366e0b7975SChristophe Leroy #ifdef CONFIG_VSX
376e0b7975SChristophe Leroy 	REGSET_VSX,
386e0b7975SChristophe Leroy #endif
396e0b7975SChristophe Leroy #ifdef CONFIG_SPE
406e0b7975SChristophe Leroy 	REGSET_SPE,
416e0b7975SChristophe Leroy #endif
426e0b7975SChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
436e0b7975SChristophe Leroy 	REGSET_TM_CGPR,		/* TM checkpointed GPR registers */
446e0b7975SChristophe Leroy 	REGSET_TM_CFPR,		/* TM checkpointed FPR registers */
456e0b7975SChristophe Leroy 	REGSET_TM_CVMX,		/* TM checkpointed VMX registers */
466e0b7975SChristophe Leroy 	REGSET_TM_CVSX,		/* TM checkpointed VSX registers */
476e0b7975SChristophe Leroy 	REGSET_TM_SPR,		/* TM specific SPR registers */
486e0b7975SChristophe Leroy 	REGSET_TM_CTAR,		/* TM checkpointed TAR register */
496e0b7975SChristophe Leroy 	REGSET_TM_CPPR,		/* TM checkpointed PPR register */
506e0b7975SChristophe Leroy 	REGSET_TM_CDSCR,	/* TM checkpointed DSCR register */
516e0b7975SChristophe Leroy #endif
526e0b7975SChristophe Leroy #ifdef CONFIG_PPC64
536e0b7975SChristophe Leroy 	REGSET_PPR,		/* PPR register */
546e0b7975SChristophe Leroy 	REGSET_DSCR,		/* DSCR register */
556e0b7975SChristophe Leroy #endif
566e0b7975SChristophe Leroy #ifdef CONFIG_PPC_BOOK3S_64
576e0b7975SChristophe Leroy 	REGSET_TAR,		/* TAR register */
586e0b7975SChristophe Leroy 	REGSET_EBB,		/* EBB registers */
596e0b7975SChristophe Leroy 	REGSET_PMR,		/* Performance Monitor Registers */
606e0b7975SChristophe Leroy #endif
616e0b7975SChristophe Leroy #ifdef CONFIG_PPC_MEM_KEYS
626e0b7975SChristophe Leroy 	REGSET_PKEY,		/* AMR register */
636e0b7975SChristophe Leroy #endif
646e0b7975SChristophe Leroy };
656e0b7975SChristophe Leroy 
667b99ed4eSChristophe Leroy /* ptrace-(no)vsx */
677b99ed4eSChristophe Leroy 
6847e12855SAl Viro user_regset_get2_fn fpr_get;
697b99ed4eSChristophe Leroy int fpr_set(struct task_struct *target, const struct user_regset *regset,
707b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count,
717b99ed4eSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
727b99ed4eSChristophe Leroy 
737b99ed4eSChristophe Leroy /* ptrace-vsx */
747b99ed4eSChristophe Leroy 
757b99ed4eSChristophe Leroy int vsr_active(struct task_struct *target, const struct user_regset *regset);
7647e12855SAl Viro user_regset_get2_fn vsr_get;
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);
8447e12855SAl Viro user_regset_get2_fn vr_get;
851b20773bSChristophe Leroy int vr_set(struct task_struct *target, const struct user_regset *regset,
861b20773bSChristophe Leroy 	   unsigned int pos, unsigned int count,
871b20773bSChristophe Leroy 	   const void *kbuf, const void __user *ubuf);
881b20773bSChristophe Leroy 
8960ef9dbdSChristophe Leroy /* ptrace-spe */
9060ef9dbdSChristophe Leroy 
9160ef9dbdSChristophe Leroy int evr_active(struct task_struct *target, const struct user_regset *regset);
9247e12855SAl Viro user_regset_get2_fn evr_get;
9360ef9dbdSChristophe Leroy int evr_set(struct task_struct *target, const struct user_regset *regset,
9460ef9dbdSChristophe Leroy 	    unsigned int pos, unsigned int count,
9560ef9dbdSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
9660ef9dbdSChristophe Leroy 
977b99ed4eSChristophe Leroy /* ptrace */
987b99ed4eSChristophe Leroy 
997c1f8db0SChristophe Leroy int gpr32_get_common(struct task_struct *target,
1007c1f8db0SChristophe Leroy 		     const struct user_regset *regset,
10147e12855SAl Viro 		     struct membuf to,
1027c1f8db0SChristophe Leroy 		     unsigned long *regs);
1037c1f8db0SChristophe Leroy int gpr32_set_common(struct task_struct *target,
1047c1f8db0SChristophe Leroy 		     const struct user_regset *regset,
1057c1f8db0SChristophe Leroy 		     unsigned int pos, unsigned int count,
1067c1f8db0SChristophe Leroy 		     const void *kbuf, const void __user *ubuf,
1077c1f8db0SChristophe Leroy 		     unsigned long *regs);
1087c1f8db0SChristophe Leroy 
1097c1f8db0SChristophe Leroy /* ptrace-tm */
1107c1f8db0SChristophe Leroy 
1117b99ed4eSChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1127b99ed4eSChristophe Leroy void flush_tmregs_to_thread(struct task_struct *tsk);
1137b99ed4eSChristophe Leroy #else
1147b99ed4eSChristophe Leroy static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
1157b99ed4eSChristophe Leroy #endif
1167c1f8db0SChristophe Leroy 
1177c1f8db0SChristophe Leroy int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
11847e12855SAl Viro user_regset_get2_fn tm_cgpr_get;
1197c1f8db0SChristophe Leroy int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
1207c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1217c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1227c1f8db0SChristophe Leroy int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
12347e12855SAl Viro user_regset_get2_fn tm_cfpr_get;
1247c1f8db0SChristophe Leroy int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
1257c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1267c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1277c1f8db0SChristophe Leroy int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
12847e12855SAl Viro user_regset_get2_fn tm_cvmx_get;
1297c1f8db0SChristophe Leroy int tm_cvmx_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_cvsx_active(struct task_struct *target, const struct user_regset *regset);
13347e12855SAl Viro user_regset_get2_fn tm_cvsx_get;
1347c1f8db0SChristophe Leroy int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
1357c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1367c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1377c1f8db0SChristophe Leroy int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
13847e12855SAl Viro user_regset_get2_fn tm_spr_get;
1397c1f8db0SChristophe Leroy int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
1407c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1417c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1427c1f8db0SChristophe Leroy int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
14347e12855SAl Viro user_regset_get2_fn tm_tar_get;
1447c1f8db0SChristophe Leroy int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
1457c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1467c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1477c1f8db0SChristophe Leroy int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
14847e12855SAl Viro user_regset_get2_fn tm_ppr_get;
1497c1f8db0SChristophe Leroy int tm_ppr_set(struct task_struct *target, const struct user_regset *regset,
1507c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1517c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1527c1f8db0SChristophe Leroy int tm_dscr_active(struct task_struct *target, const struct user_regset *regset);
15347e12855SAl Viro user_regset_get2_fn tm_dscr_get;
1547c1f8db0SChristophe Leroy int tm_dscr_set(struct task_struct *target, const struct user_regset *regset,
1557c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1567c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
15747e12855SAl Viro user_regset_get2_fn tm_cgpr32_get;
1587c1f8db0SChristophe Leroy int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
1597c1f8db0SChristophe Leroy 		  unsigned int pos, unsigned int count,
1607c1f8db0SChristophe Leroy 		  const void *kbuf, const void __user *ubuf);
1616e0b7975SChristophe Leroy 
1626e0b7975SChristophe Leroy /* ptrace-view */
1636e0b7975SChristophe Leroy 
16467e364b3SChristophe Leroy int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data);
16567e364b3SChristophe Leroy int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data);
16667e364b3SChristophe Leroy 
1676e0b7975SChristophe Leroy extern const struct user_regset_view user_ppc_native_view;
168323a780cSChristophe Leroy 
1694d90eb97SChristophe Leroy /* ptrace-fpu */
1704d90eb97SChristophe Leroy int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data);
1714d90eb97SChristophe Leroy int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data);
1724d90eb97SChristophe Leroy 
173323a780cSChristophe Leroy /* ptrace-(no)adv */
174da529d47SChristophe Leroy void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
175e08227d2SChristophe Leroy int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
176e08227d2SChristophe Leroy 			unsigned long __user *datalp);
177323a780cSChristophe Leroy int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);
178323a780cSChristophe Leroy long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info);
179323a780cSChristophe Leroy long ppc_del_hwdebug(struct task_struct *child, long data);
180