Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARCv2: ptrace: provide regset for accumulator/r30 regs

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+65 -3
+1
arch/arc/include/uapi/asm/elf.h
··· 27 27 typedef unsigned long elf_fpregset_t; 28 28 29 29 #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t)) 30 + #define ELF_ARCV2REG (sizeof(struct user_regs_arcv2) / sizeof(elf_greg_t)) 30 31 31 32 typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 32 33
+5
arch/arc/include/uapi/asm/ptrace.h
··· 47 47 unsigned long efa; /* break pt addr, for break points in delay slots */ 48 48 unsigned long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */ 49 49 }; 50 + 51 + struct user_regs_arcv2 { 52 + unsigned long r30, r58, r59; 53 + }; 54 + 50 55 #endif /* !__ASSEMBLY__ */ 51 56 52 57 #endif /* _UAPI__ASM_ARC_PTRACE_H */
+59 -3
arch/arc/kernel/ptrace.c
··· 184 184 return ret; 185 185 } 186 186 187 + #ifdef CONFIG_ISA_ARCV2 188 + static int arcv2regs_get(struct task_struct *target, 189 + const struct user_regset *regset, 190 + unsigned int pos, unsigned int count, 191 + void *kbuf, void __user *ubuf) 192 + { 193 + const struct pt_regs *regs = task_pt_regs(target); 194 + int ret, copy_sz; 195 + 196 + if (IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS)) 197 + copy_sz = sizeof(struct user_regs_arcv2); 198 + else 199 + copy_sz = 4; /* r30 only */ 200 + 201 + /* 202 + * itemized copy not needed like above as layout of regs (r30,r58,r59) 203 + * is exactly same in kernel (pt_regs) and userspace (user_regs_arcv2) 204 + */ 205 + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &regs->r30, 206 + 0, copy_sz); 207 + 208 + return ret; 209 + } 210 + 211 + static int arcv2regs_set(struct task_struct *target, 212 + const struct user_regset *regset, 213 + unsigned int pos, unsigned int count, 214 + const void *kbuf, const void __user *ubuf) 215 + { 216 + const struct pt_regs *regs = task_pt_regs(target); 217 + int ret, copy_sz; 218 + 219 + if (IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS)) 220 + copy_sz = sizeof(struct user_regs_arcv2); 221 + else 222 + copy_sz = 4; /* r30 only */ 223 + 224 + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, (void *)&regs->r30, 225 + 0, copy_sz); 226 + 227 + return ret; 228 + } 229 + 230 + #endif 231 + 187 232 enum arc_getset { 188 - REGSET_GENERAL, 233 + REGSET_CMN, 234 + REGSET_ARCV2, 189 235 }; 190 236 191 237 static const struct user_regset arc_regsets[] = { 192 - [REGSET_GENERAL] = { 238 + [REGSET_CMN] = { 193 239 .core_note_type = NT_PRSTATUS, 194 240 .n = ELF_NGREG, 195 241 .size = sizeof(unsigned long), 196 242 .align = sizeof(unsigned long), 197 243 .get = genregs_get, 198 244 .set = genregs_set, 199 - } 245 + }, 246 + #ifdef CONFIG_ISA_ARCV2 247 + [REGSET_ARCV2] = { 248 + .core_note_type = NT_ARC_V2, 249 + .n = ELF_ARCV2REG, 250 + .size = sizeof(unsigned long), 251 + .align = sizeof(unsigned long), 252 + .get = arcv2regs_get, 253 + .set = arcv2regs_set, 254 + }, 255 + #endif 200 256 }; 201 257 202 258 static const struct user_regset_view user_arc_view = {