1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3 #include <linux/regset.h> 4 5 /* 6 * Set of msr bits that gdb can change on behalf of a process. 7 */ 8 #ifdef CONFIG_PPC_ADV_DEBUG_REGS 9 #define MSR_DEBUGCHANGE 0 10 #else 11 #define MSR_DEBUGCHANGE (MSR_SE | MSR_BE) 12 #endif 13 14 /* 15 * Max register writeable via put_reg 16 */ 17 #ifdef CONFIG_PPC32 18 #define PT_MAX_PUT_REG PT_MQ 19 #else 20 #define PT_MAX_PUT_REG PT_CCR 21 #endif 22 23 #define TVSO(f) (offsetof(struct thread_vr_state, f)) 24 #define TFSO(f) (offsetof(struct thread_fp_state, f)) 25 #define TSO(f) (offsetof(struct thread_struct, f)) 26 27 /* 28 * These are our native regset flavors. 29 */ 30 enum powerpc_regset { 31 REGSET_GPR, 32 REGSET_FPR, 33 #ifdef CONFIG_ALTIVEC 34 REGSET_VMX, 35 #endif 36 #ifdef CONFIG_VSX 37 REGSET_VSX, 38 #endif 39 #ifdef CONFIG_SPE 40 REGSET_SPE, 41 #endif 42 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 43 REGSET_TM_CGPR, /* TM checkpointed GPR registers */ 44 REGSET_TM_CFPR, /* TM checkpointed FPR registers */ 45 REGSET_TM_CVMX, /* TM checkpointed VMX registers */ 46 REGSET_TM_CVSX, /* TM checkpointed VSX registers */ 47 REGSET_TM_SPR, /* TM specific SPR registers */ 48 REGSET_TM_CTAR, /* TM checkpointed TAR register */ 49 REGSET_TM_CPPR, /* TM checkpointed PPR register */ 50 REGSET_TM_CDSCR, /* TM checkpointed DSCR register */ 51 #endif 52 #ifdef CONFIG_PPC64 53 REGSET_PPR, /* PPR register */ 54 REGSET_DSCR, /* DSCR register */ 55 #endif 56 #ifdef CONFIG_PPC_BOOK3S_64 57 REGSET_TAR, /* TAR register */ 58 REGSET_EBB, /* EBB registers */ 59 REGSET_PMR, /* Performance Monitor Registers */ 60 #endif 61 #ifdef CONFIG_PPC_MEM_KEYS 62 REGSET_PKEY, /* AMR register */ 63 #endif 64 }; 65 66 /* ptrace-(no)vsx */ 67 68 user_regset_get2_fn fpr_get; 69 int fpr_set(struct task_struct *target, const struct user_regset *regset, 70 unsigned int pos, unsigned int count, 71 const void *kbuf, const void __user *ubuf); 72 73 /* ptrace-vsx */ 74 75 int vsr_active(struct task_struct *target, const struct user_regset *regset); 76 user_regset_get2_fn vsr_get; 77 int vsr_set(struct task_struct *target, const struct user_regset *regset, 78 unsigned int pos, unsigned int count, 79 const void *kbuf, const void __user *ubuf); 80 81 /* ptrace-altivec */ 82 83 int vr_active(struct task_struct *target, const struct user_regset *regset); 84 user_regset_get2_fn vr_get; 85 int vr_set(struct task_struct *target, const struct user_regset *regset, 86 unsigned int pos, unsigned int count, 87 const void *kbuf, const void __user *ubuf); 88 89 /* ptrace-spe */ 90 91 int evr_active(struct task_struct *target, const struct user_regset *regset); 92 user_regset_get2_fn evr_get; 93 int evr_set(struct task_struct *target, const struct user_regset *regset, 94 unsigned int pos, unsigned int count, 95 const void *kbuf, const void __user *ubuf); 96 97 /* ptrace */ 98 99 int gpr32_get_common(struct task_struct *target, 100 const struct user_regset *regset, 101 struct membuf to, 102 unsigned long *regs); 103 int gpr32_set_common(struct task_struct *target, 104 const struct user_regset *regset, 105 unsigned int pos, unsigned int count, 106 const void *kbuf, const void __user *ubuf, 107 unsigned long *regs); 108 109 /* ptrace-tm */ 110 111 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 112 void flush_tmregs_to_thread(struct task_struct *tsk); 113 #else 114 static inline void flush_tmregs_to_thread(struct task_struct *tsk) { } 115 #endif 116 117 int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset); 118 user_regset_get2_fn tm_cgpr_get; 119 int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset, 120 unsigned int pos, unsigned int count, 121 const void *kbuf, const void __user *ubuf); 122 int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset); 123 user_regset_get2_fn tm_cfpr_get; 124 int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset, 125 unsigned int pos, unsigned int count, 126 const void *kbuf, const void __user *ubuf); 127 int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset); 128 user_regset_get2_fn tm_cvmx_get; 129 int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset, 130 unsigned int pos, unsigned int count, 131 const void *kbuf, const void __user *ubuf); 132 int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset); 133 user_regset_get2_fn tm_cvsx_get; 134 int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset, 135 unsigned int pos, unsigned int count, 136 const void *kbuf, const void __user *ubuf); 137 int tm_spr_active(struct task_struct *target, const struct user_regset *regset); 138 user_regset_get2_fn tm_spr_get; 139 int tm_spr_set(struct task_struct *target, const struct user_regset *regset, 140 unsigned int pos, unsigned int count, 141 const void *kbuf, const void __user *ubuf); 142 int tm_tar_active(struct task_struct *target, const struct user_regset *regset); 143 user_regset_get2_fn tm_tar_get; 144 int tm_tar_set(struct task_struct *target, const struct user_regset *regset, 145 unsigned int pos, unsigned int count, 146 const void *kbuf, const void __user *ubuf); 147 int tm_ppr_active(struct task_struct *target, const struct user_regset *regset); 148 user_regset_get2_fn tm_ppr_get; 149 int tm_ppr_set(struct task_struct *target, const struct user_regset *regset, 150 unsigned int pos, unsigned int count, 151 const void *kbuf, const void __user *ubuf); 152 int tm_dscr_active(struct task_struct *target, const struct user_regset *regset); 153 user_regset_get2_fn tm_dscr_get; 154 int tm_dscr_set(struct task_struct *target, const struct user_regset *regset, 155 unsigned int pos, unsigned int count, 156 const void *kbuf, const void __user *ubuf); 157 user_regset_get2_fn tm_cgpr32_get; 158 int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset, 159 unsigned int pos, unsigned int count, 160 const void *kbuf, const void __user *ubuf); 161 162 /* ptrace-view */ 163 164 int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data); 165 int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data); 166 167 extern const struct user_regset_view user_ppc_native_view; 168 169 /* ptrace-fpu */ 170 int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data); 171 int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data); 172 173 /* ptrace-(no)adv */ 174 void ppc_gethwdinfo(struct ppc_debug_info *dbginfo); 175 int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, 176 unsigned long __user *datalp); 177 int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data); 178 long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info); 179 long ppc_del_hwdebug(struct task_struct *child, long data); 180