Skip to content

Commit 65c02a5

Browse files
committed
ARCv2: ptrace: provide regset for accumulator/r30 regs
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent 991c7ed commit 65c02a5

3 files changed

Lines changed: 65 additions & 3 deletions

File tree

‎arch/arc/include/uapi/asm/elf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef unsigned long elf_greg_t;
2727
typedef unsigned long elf_fpregset_t;
2828

2929
#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))
3031

3132
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
3233

‎arch/arc/include/uapi/asm/ptrace.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ struct user_regs_struct {
4747
unsigned long efa; /* break pt addr, for break points in delay slots */
4848
unsigned long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */
4949
};
50+
51+
struct user_regs_arcv2 {
52+
unsigned long r30, r58, r59;
53+
};
54+
5055
#endif /* !__ASSEMBLY__ */
5156

5257
#endif /* _UAPI__ASM_ARC_PTRACE_H */

‎arch/arc/kernel/ptrace.c‎

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,75 @@ static int genregs_set(struct task_struct *target,
184184
return ret;
185185
}
186186

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+
187232
enum arc_getset {
188-
REGSET_GENERAL,
233+
REGSET_CMN,
234+
REGSET_ARCV2,
189235
};
190236

191237
static const struct user_regset arc_regsets[] = {
192-
[REGSET_GENERAL] = {
238+
[REGSET_CMN] = {
193239
.core_note_type = NT_PRSTATUS,
194240
.n = ELF_NGREG,
195241
.size = sizeof(unsigned long),
196242
.align = sizeof(unsigned long),
197243
.get = genregs_get,
198244
.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
200256
};
201257

202258
static const struct user_regset_view user_arc_view = {

0 commit comments

Comments
 (0)