aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVineet Gupta2017-05-03 13:21:31 -0500
committerVineet Gupta2017-05-03 13:21:31 -0500
commit65c02a556bc4f374e9002ded1ea11a0263da7b63 (patch)
treee1fc9fb0759116f84380260fd73e74183f9673f8
parent991c7ed6acca506983c42d51965da8b8f3677682 (diff)
downloadkernel-65c02a556bc4f374e9002ded1ea11a0263da7b63.tar.gz
kernel-65c02a556bc4f374e9002ded1ea11a0263da7b63.tar.xz
kernel-65c02a556bc4f374e9002ded1ea11a0263da7b63.zip
ARCv2: ptrace: provide regset for accumulator/r30 regs
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r--arch/arc/include/uapi/asm/elf.h1
-rw-r--r--arch/arc/include/uapi/asm/ptrace.h5
-rw-r--r--arch/arc/kernel/ptrace.c62
3 files changed, 65 insertions, 3 deletions
diff --git a/arch/arc/include/uapi/asm/elf.h b/arch/arc/include/uapi/asm/elf.h
index 0037a587320d..06d95e611616 100644
--- a/arch/arc/include/uapi/asm/elf.h
+++ b/arch/arc/include/uapi/asm/elf.h
@@ -27,6 +27,7 @@ typedef unsigned long elf_greg_t;
27typedef unsigned long elf_fpregset_t; 27typedef unsigned long elf_fpregset_t;
28 28
29#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t)) 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
31typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 32typedef elf_greg_t elf_gregset_t[ELF_NGREG];
32 33
diff --git a/arch/arc/include/uapi/asm/ptrace.h b/arch/arc/include/uapi/asm/ptrace.h
index 0b3ef63d4a03..dd206e6b482c 100644
--- a/arch/arc/include/uapi/asm/ptrace.h
+++ b/arch/arc/include/uapi/asm/ptrace.h
@@ -47,6 +47,11 @@ struct user_regs_struct {
47 unsigned long efa; /* break pt addr, for break points in delay slots */ 47 unsigned long efa; /* break pt addr, for break points in delay slots */
48 unsigned long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */ 48 unsigned long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */
49}; 49};
50
51struct user_regs_arcv2 {
52 unsigned long r30, r58, r59;
53};
54
50#endif /* !__ASSEMBLY__ */ 55#endif /* !__ASSEMBLY__ */
51 56
52#endif /* _UAPI__ASM_ARC_PTRACE_H */ 57#endif /* _UAPI__ASM_ARC_PTRACE_H */
diff --git a/arch/arc/kernel/ptrace.c b/arch/arc/kernel/ptrace.c
index 31150060d38b..5ee4676f135d 100644
--- a/arch/arc/kernel/ptrace.c
+++ b/arch/arc/kernel/ptrace.c
@@ -184,19 +184,75 @@ static int genregs_set(struct task_struct *target,
184 return ret; 184 return ret;
185} 185}
186 186
187#ifdef CONFIG_ISA_ARCV2
188static 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
211static 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
187enum arc_getset { 232enum arc_getset {
188 REGSET_GENERAL, 233 REGSET_CMN,
234 REGSET_ARCV2,
189}; 235};
190 236
191static const struct user_regset arc_regsets[] = { 237static const struct user_regset arc_regsets[] = {
192 [REGSET_GENERAL] = { 238 [REGSET_CMN] = {
193 .core_note_type = NT_PRSTATUS, 239 .core_note_type = NT_PRSTATUS,
194 .n = ELF_NGREG, 240 .n = ELF_NGREG,
195 .size = sizeof(unsigned long), 241 .size = sizeof(unsigned long),
196 .align = sizeof(unsigned long), 242 .align = sizeof(unsigned long),
197 .get = genregs_get, 243 .get = genregs_get,
198 .set = genregs_set, 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
202static const struct user_regset_view user_arc_view = { 258static const struct user_regset_view user_arc_view = {