17b99ed4eSChristophe Leroy /* SPDX-License-Identifier: GPL-2.0-or-later */
27b99ed4eSChristophe Leroy
381e30a54SBenjamin Gray #include <linux/regset.h>
481e30a54SBenjamin 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 */
60884ad5c5SBenjamin Gray REGSET_DEXCR, /* DEXCR registers */
61*97228ca3SBenjamin Gray #ifdef CONFIG_CHECKPOINT_RESTORE
62*97228ca3SBenjamin Gray REGSET_HASHKEYR, /* HASHKEYR register */
63*97228ca3SBenjamin Gray #endif
646e0b7975SChristophe Leroy #endif
656e0b7975SChristophe Leroy #ifdef CONFIG_PPC_MEM_KEYS
666e0b7975SChristophe Leroy REGSET_PKEY, /* AMR register */
676e0b7975SChristophe Leroy #endif
686e0b7975SChristophe Leroy };
696e0b7975SChristophe Leroy
707b99ed4eSChristophe Leroy /* ptrace-(no)vsx */
717b99ed4eSChristophe Leroy
7247e12855SAl Viro user_regset_get2_fn fpr_get;
737b99ed4eSChristophe Leroy int fpr_set(struct task_struct *target, const struct user_regset *regset,
747b99ed4eSChristophe Leroy unsigned int pos, unsigned int count,
757b99ed4eSChristophe Leroy const void *kbuf, const void __user *ubuf);
767b99ed4eSChristophe Leroy
777b99ed4eSChristophe Leroy /* ptrace-vsx */
787b99ed4eSChristophe Leroy
797b99ed4eSChristophe Leroy int vsr_active(struct task_struct *target, const struct user_regset *regset);
8047e12855SAl Viro user_regset_get2_fn vsr_get;
817b99ed4eSChristophe Leroy int vsr_set(struct task_struct *target, const struct user_regset *regset,
827b99ed4eSChristophe Leroy unsigned int pos, unsigned int count,
837b99ed4eSChristophe Leroy const void *kbuf, const void __user *ubuf);
847b99ed4eSChristophe Leroy
851b20773bSChristophe Leroy /* ptrace-altivec */
861b20773bSChristophe Leroy
871b20773bSChristophe Leroy int vr_active(struct task_struct *target, const struct user_regset *regset);
8847e12855SAl Viro user_regset_get2_fn vr_get;
891b20773bSChristophe Leroy int vr_set(struct task_struct *target, const struct user_regset *regset,
901b20773bSChristophe Leroy unsigned int pos, unsigned int count,
911b20773bSChristophe Leroy const void *kbuf, const void __user *ubuf);
921b20773bSChristophe Leroy
9360ef9dbdSChristophe Leroy /* ptrace-spe */
9460ef9dbdSChristophe Leroy
9560ef9dbdSChristophe Leroy int evr_active(struct task_struct *target, const struct user_regset *regset);
9647e12855SAl Viro user_regset_get2_fn evr_get;
9760ef9dbdSChristophe Leroy int evr_set(struct task_struct *target, const struct user_regset *regset,
9860ef9dbdSChristophe Leroy unsigned int pos, unsigned int count,
9960ef9dbdSChristophe Leroy const void *kbuf, const void __user *ubuf);
10060ef9dbdSChristophe Leroy
1017b99ed4eSChristophe Leroy /* ptrace */
1027b99ed4eSChristophe Leroy
1037c1f8db0SChristophe Leroy int gpr32_get_common(struct task_struct *target,
1047c1f8db0SChristophe Leroy const struct user_regset *regset,
10547e12855SAl Viro struct membuf to,
1067c1f8db0SChristophe Leroy unsigned long *regs);
1077c1f8db0SChristophe Leroy int gpr32_set_common(struct task_struct *target,
1087c1f8db0SChristophe Leroy const struct user_regset *regset,
1097c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1107c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf,
1117c1f8db0SChristophe Leroy unsigned long *regs);
1127c1f8db0SChristophe Leroy
1137c1f8db0SChristophe Leroy /* ptrace-tm */
1147c1f8db0SChristophe Leroy
1157b99ed4eSChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1167b99ed4eSChristophe Leroy void flush_tmregs_to_thread(struct task_struct *tsk);
1177b99ed4eSChristophe Leroy #else
flush_tmregs_to_thread(struct task_struct * tsk)1187b99ed4eSChristophe Leroy static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
1197b99ed4eSChristophe Leroy #endif
1207c1f8db0SChristophe Leroy
1217c1f8db0SChristophe Leroy int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
12247e12855SAl Viro user_regset_get2_fn tm_cgpr_get;
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);
12747e12855SAl Viro user_regset_get2_fn tm_cfpr_get;
1287c1f8db0SChristophe Leroy int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
1297c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1307c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf);
1317c1f8db0SChristophe Leroy int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
13247e12855SAl Viro user_regset_get2_fn tm_cvmx_get;
1337c1f8db0SChristophe Leroy int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
1347c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1357c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf);
1367c1f8db0SChristophe Leroy int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
13747e12855SAl Viro user_regset_get2_fn tm_cvsx_get;
1387c1f8db0SChristophe Leroy int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
1397c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1407c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf);
1417c1f8db0SChristophe Leroy int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
14247e12855SAl Viro user_regset_get2_fn tm_spr_get;
1437c1f8db0SChristophe Leroy int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
1447c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1457c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf);
1467c1f8db0SChristophe Leroy int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
14747e12855SAl Viro user_regset_get2_fn tm_tar_get;
1487c1f8db0SChristophe Leroy int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
1497c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1507c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf);
1517c1f8db0SChristophe Leroy int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
15247e12855SAl Viro user_regset_get2_fn tm_ppr_get;
1537c1f8db0SChristophe Leroy int tm_ppr_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_dscr_active(struct task_struct *target, const struct user_regset *regset);
15747e12855SAl Viro user_regset_get2_fn tm_dscr_get;
1587c1f8db0SChristophe Leroy int tm_dscr_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);
16147e12855SAl Viro user_regset_get2_fn tm_cgpr32_get;
1627c1f8db0SChristophe Leroy int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
1637c1f8db0SChristophe Leroy unsigned int pos, unsigned int count,
1647c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf);
1656e0b7975SChristophe Leroy
1666e0b7975SChristophe Leroy /* ptrace-view */
1676e0b7975SChristophe Leroy
16867e364b3SChristophe Leroy int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data);
16967e364b3SChristophe Leroy int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data);
17067e364b3SChristophe Leroy
1716e0b7975SChristophe Leroy extern const struct user_regset_view user_ppc_native_view;
172323a780cSChristophe Leroy
1734d90eb97SChristophe Leroy /* ptrace-fpu */
1744d90eb97SChristophe Leroy int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data);
1754d90eb97SChristophe Leroy int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data);
1764d90eb97SChristophe Leroy
177323a780cSChristophe Leroy /* ptrace-(no)adv */
178da529d47SChristophe Leroy void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
179e08227d2SChristophe Leroy int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
180e08227d2SChristophe 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