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 */ 60*884ad5c5SBenjamin Gray REGSET_DEXCR, /* DEXCR registers */ 616e0b7975SChristophe Leroy #endif 626e0b7975SChristophe Leroy #ifdef CONFIG_PPC_MEM_KEYS 636e0b7975SChristophe Leroy REGSET_PKEY, /* AMR register */ 646e0b7975SChristophe Leroy #endif 656e0b7975SChristophe Leroy }; 666e0b7975SChristophe Leroy 677b99ed4eSChristophe Leroy /* ptrace-(no)vsx */ 687b99ed4eSChristophe Leroy 6947e12855SAl Viro user_regset_get2_fn fpr_get; 707b99ed4eSChristophe Leroy int fpr_set(struct task_struct *target, const struct user_regset *regset, 717b99ed4eSChristophe Leroy unsigned int pos, unsigned int count, 727b99ed4eSChristophe Leroy const void *kbuf, const void __user *ubuf); 737b99ed4eSChristophe Leroy 747b99ed4eSChristophe Leroy /* ptrace-vsx */ 757b99ed4eSChristophe Leroy 767b99ed4eSChristophe Leroy int vsr_active(struct task_struct *target, const struct user_regset *regset); 7747e12855SAl Viro user_regset_get2_fn vsr_get; 787b99ed4eSChristophe Leroy int vsr_set(struct task_struct *target, const struct user_regset *regset, 797b99ed4eSChristophe Leroy unsigned int pos, unsigned int count, 807b99ed4eSChristophe Leroy const void *kbuf, const void __user *ubuf); 817b99ed4eSChristophe Leroy 821b20773bSChristophe Leroy /* ptrace-altivec */ 831b20773bSChristophe Leroy 841b20773bSChristophe Leroy int vr_active(struct task_struct *target, const struct user_regset *regset); 8547e12855SAl Viro user_regset_get2_fn vr_get; 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); 9347e12855SAl Viro user_regset_get2_fn evr_get; 9460ef9dbdSChristophe Leroy int evr_set(struct task_struct *target, const struct user_regset *regset, 9560ef9dbdSChristophe Leroy unsigned int pos, unsigned int count, 9660ef9dbdSChristophe Leroy const void *kbuf, const void __user *ubuf); 9760ef9dbdSChristophe Leroy 987b99ed4eSChristophe Leroy /* ptrace */ 997b99ed4eSChristophe Leroy 1007c1f8db0SChristophe Leroy int gpr32_get_common(struct task_struct *target, 1017c1f8db0SChristophe Leroy const struct user_regset *regset, 10247e12855SAl Viro struct membuf to, 1037c1f8db0SChristophe Leroy unsigned long *regs); 1047c1f8db0SChristophe Leroy int gpr32_set_common(struct task_struct *target, 1057c1f8db0SChristophe Leroy const struct user_regset *regset, 1067c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1077c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf, 1087c1f8db0SChristophe Leroy unsigned long *regs); 1097c1f8db0SChristophe Leroy 1107c1f8db0SChristophe Leroy /* ptrace-tm */ 1117c1f8db0SChristophe Leroy 1127b99ed4eSChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1137b99ed4eSChristophe Leroy void flush_tmregs_to_thread(struct task_struct *tsk); 1147b99ed4eSChristophe Leroy #else 1157b99ed4eSChristophe Leroy static inline void flush_tmregs_to_thread(struct task_struct *tsk) { } 1167b99ed4eSChristophe Leroy #endif 1177c1f8db0SChristophe Leroy 1187c1f8db0SChristophe Leroy int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset); 11947e12855SAl Viro user_regset_get2_fn tm_cgpr_get; 1207c1f8db0SChristophe Leroy int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset, 1217c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1227c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 1237c1f8db0SChristophe Leroy int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset); 12447e12855SAl Viro user_regset_get2_fn tm_cfpr_get; 1257c1f8db0SChristophe Leroy int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset, 1267c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1277c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 1287c1f8db0SChristophe Leroy int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset); 12947e12855SAl Viro user_regset_get2_fn tm_cvmx_get; 1307c1f8db0SChristophe Leroy int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset, 1317c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1327c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 1337c1f8db0SChristophe Leroy int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset); 13447e12855SAl Viro user_regset_get2_fn tm_cvsx_get; 1357c1f8db0SChristophe Leroy int tm_cvsx_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_spr_active(struct task_struct *target, const struct user_regset *regset); 13947e12855SAl Viro user_regset_get2_fn tm_spr_get; 1407c1f8db0SChristophe Leroy int tm_spr_set(struct task_struct *target, const struct user_regset *regset, 1417c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1427c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 1437c1f8db0SChristophe Leroy int tm_tar_active(struct task_struct *target, const struct user_regset *regset); 14447e12855SAl Viro user_regset_get2_fn tm_tar_get; 1457c1f8db0SChristophe Leroy int tm_tar_set(struct task_struct *target, const struct user_regset *regset, 1467c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1477c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 1487c1f8db0SChristophe Leroy int tm_ppr_active(struct task_struct *target, const struct user_regset *regset); 14947e12855SAl Viro user_regset_get2_fn tm_ppr_get; 1507c1f8db0SChristophe Leroy int tm_ppr_set(struct task_struct *target, const struct user_regset *regset, 1517c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1527c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 1537c1f8db0SChristophe Leroy int tm_dscr_active(struct task_struct *target, const struct user_regset *regset); 15447e12855SAl Viro user_regset_get2_fn tm_dscr_get; 1557c1f8db0SChristophe Leroy int tm_dscr_set(struct task_struct *target, const struct user_regset *regset, 1567c1f8db0SChristophe Leroy unsigned int pos, unsigned int count, 1577c1f8db0SChristophe Leroy const void *kbuf, const void __user *ubuf); 15847e12855SAl Viro user_regset_get2_fn tm_cgpr32_get; 1597c1f8db0SChristophe Leroy int tm_cgpr32_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); 1626e0b7975SChristophe Leroy 1636e0b7975SChristophe Leroy /* ptrace-view */ 1646e0b7975SChristophe Leroy 16567e364b3SChristophe Leroy int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data); 16667e364b3SChristophe Leroy int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data); 16767e364b3SChristophe Leroy 1686e0b7975SChristophe Leroy extern const struct user_regset_view user_ppc_native_view; 169323a780cSChristophe Leroy 1704d90eb97SChristophe Leroy /* ptrace-fpu */ 1714d90eb97SChristophe Leroy int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data); 1724d90eb97SChristophe Leroy int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data); 1734d90eb97SChristophe Leroy 174323a780cSChristophe Leroy /* ptrace-(no)adv */ 175da529d47SChristophe Leroy void ppc_gethwdinfo(struct ppc_debug_info *dbginfo); 176e08227d2SChristophe Leroy int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, 177e08227d2SChristophe Leroy unsigned long __user *datalp); 178323a780cSChristophe Leroy int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data); 179323a780cSChristophe Leroy long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info); 180323a780cSChristophe Leroy long ppc_del_hwdebug(struct task_struct *child, long data); 181