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 25*6e0b7975SChristophe Leroy /* 26*6e0b7975SChristophe Leroy * These are our native regset flavors. 27*6e0b7975SChristophe Leroy */ 28*6e0b7975SChristophe Leroy enum powerpc_regset { 29*6e0b7975SChristophe Leroy REGSET_GPR, 30*6e0b7975SChristophe Leroy REGSET_FPR, 31*6e0b7975SChristophe Leroy #ifdef CONFIG_ALTIVEC 32*6e0b7975SChristophe Leroy REGSET_VMX, 33*6e0b7975SChristophe Leroy #endif 34*6e0b7975SChristophe Leroy #ifdef CONFIG_VSX 35*6e0b7975SChristophe Leroy REGSET_VSX, 36*6e0b7975SChristophe Leroy #endif 37*6e0b7975SChristophe Leroy #ifdef CONFIG_SPE 38*6e0b7975SChristophe Leroy REGSET_SPE, 39*6e0b7975SChristophe Leroy #endif 40*6e0b7975SChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 41*6e0b7975SChristophe Leroy REGSET_TM_CGPR, /* TM checkpointed GPR registers */ 42*6e0b7975SChristophe Leroy REGSET_TM_CFPR, /* TM checkpointed FPR registers */ 43*6e0b7975SChristophe Leroy REGSET_TM_CVMX, /* TM checkpointed VMX registers */ 44*6e0b7975SChristophe Leroy REGSET_TM_CVSX, /* TM checkpointed VSX registers */ 45*6e0b7975SChristophe Leroy REGSET_TM_SPR, /* TM specific SPR registers */ 46*6e0b7975SChristophe Leroy REGSET_TM_CTAR, /* TM checkpointed TAR register */ 47*6e0b7975SChristophe Leroy REGSET_TM_CPPR, /* TM checkpointed PPR register */ 48*6e0b7975SChristophe Leroy REGSET_TM_CDSCR, /* TM checkpointed DSCR register */ 49*6e0b7975SChristophe Leroy #endif 50*6e0b7975SChristophe Leroy #ifdef CONFIG_PPC64 51*6e0b7975SChristophe Leroy REGSET_PPR, /* PPR register */ 52*6e0b7975SChristophe Leroy REGSET_DSCR, /* DSCR register */ 53*6e0b7975SChristophe Leroy #endif 54*6e0b7975SChristophe Leroy #ifdef CONFIG_PPC_BOOK3S_64 55*6e0b7975SChristophe Leroy REGSET_TAR, /* TAR register */ 56*6e0b7975SChristophe Leroy REGSET_EBB, /* EBB registers */ 57*6e0b7975SChristophe Leroy REGSET_PMR, /* Performance Monitor Registers */ 58*6e0b7975SChristophe Leroy #endif 59*6e0b7975SChristophe Leroy #ifdef CONFIG_PPC_MEM_KEYS 60*6e0b7975SChristophe Leroy REGSET_PKEY, /* AMR register */ 61*6e0b7975SChristophe Leroy #endif 62*6e0b7975SChristophe Leroy }; 63*6e0b7975SChristophe 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); 173*6e0b7975SChristophe Leroy 174*6e0b7975SChristophe Leroy /* ptrace-view */ 175*6e0b7975SChristophe Leroy 176*6e0b7975SChristophe Leroy extern const struct user_regset_view user_ppc_native_view; 177