1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <generated/compile.h>
22
23#include <linux/kernel.h>
24#include <linux/sched.h>
25#include <linux/mm.h>
26#include <linux/smp.h>
27#include <linux/errno.h>
28#include <linux/ptrace.h>
29#include <linux/regset.h>
30#include <linux/user.h>
31#include <linux/elf.h>
32
33#include <asm/user.h>
34
35static int genregs_get(struct task_struct *target,
36 const struct user_regset *regset,
37 unsigned int pos, unsigned int count,
38 void *kbuf, void __user *ubuf)
39{
40 int ret;
41 unsigned int dummy;
42 struct pt_regs *regs = task_pt_regs(target);
43
44
45 if (!regs)
46 return -EIO;
47
48
49
50
51
52
53
54 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
55 ®s->r00, 0, 32*sizeof(unsigned long));
56
57#define ONEXT(KPT_REG, USR_REG) \
58 if (!ret) \
59 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, \
60 KPT_REG, offsetof(struct user_regs_struct, USR_REG), \
61 offsetof(struct user_regs_struct, USR_REG) + \
62 sizeof(unsigned long));
63
64
65 ONEXT(®s->sa0, sa0);
66 ONEXT(®s->lc0, lc0);
67 ONEXT(®s->sa1, sa1);
68 ONEXT(®s->lc1, lc1);
69 ONEXT(®s->m0, m0);
70 ONEXT(®s->m1, m1);
71 ONEXT(®s->usr, usr);
72 ONEXT(®s->preds, p3_0);
73 ONEXT(®s->gp, gp);
74 ONEXT(®s->ugp, ugp);
75 ONEXT(&pt_elr(regs), pc);
76 dummy = pt_cause(regs);
77 ONEXT(&dummy, cause);
78 ONEXT(&pt_badva(regs), badva);
79
80
81 if (!ret)
82 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
83 offsetof(struct user_regs_struct, pad1), -1);
84 return ret;
85}
86
87static int genregs_set(struct task_struct *target,
88 const struct user_regset *regset,
89 unsigned int pos, unsigned int count,
90 const void *kbuf, const void __user *ubuf)
91{
92 int ret;
93 unsigned long bucket;
94 struct pt_regs *regs = task_pt_regs(target);
95
96 if (!regs)
97 return -EIO;
98
99 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
100 ®s->r00, 0, 32*sizeof(unsigned long));
101
102#define INEXT(KPT_REG, USR_REG) \
103 if (!ret) \
104 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, \
105 KPT_REG, offsetof(struct user_regs_struct, USR_REG), \
106 offsetof(struct user_regs_struct, USR_REG) + \
107 sizeof(unsigned long));
108
109
110 INEXT(®s->sa0, sa0);
111 INEXT(®s->lc0, lc0);
112 INEXT(®s->sa1, sa1);
113 INEXT(®s->lc1, lc1);
114 INEXT(®s->m0, m0);
115 INEXT(®s->m1, m1);
116 INEXT(®s->usr, usr);
117 INEXT(®s->preds, p3_0);
118 INEXT(®s->gp, gp);
119 INEXT(®s->ugp, ugp);
120 INEXT(&pt_elr(regs), pc);
121
122
123 INEXT(&bucket, cause);
124 INEXT(&bucket, badva);
125
126
127 if (!ret)
128 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
129 offsetof(struct user_regs_struct, pad1), -1);
130
131 if (ret)
132 return ret;
133
134
135
136
137
138 regs->hvmer.vmpsp = regs->r29;
139 return 0;
140}
141
142enum hexagon_regset {
143 REGSET_GENERAL,
144};
145
146static const struct user_regset hexagon_regsets[] = {
147 [REGSET_GENERAL] = {
148 .core_note_type = NT_PRSTATUS,
149 .n = ELF_NGREG,
150 .size = sizeof(unsigned long),
151 .align = sizeof(unsigned long),
152 .get = genregs_get,
153 .set = genregs_set,
154 },
155};
156
157static const struct user_regset_view hexagon_user_view = {
158 .name = UTS_MACHINE,
159 .e_machine = ELF_ARCH,
160 .ei_osabi = ELF_OSABI,
161 .regsets = hexagon_regsets,
162 .n = ARRAY_SIZE(hexagon_regsets)
163};
164
165const struct user_regset_view *task_user_regset_view(struct task_struct *task)
166{
167 return &hexagon_user_view;
168}
169
170void ptrace_disable(struct task_struct *child)
171{
172
173 user_disable_single_step(child);
174}
175
176long arch_ptrace(struct task_struct *child, long request,
177 unsigned long addr, unsigned long data)
178{
179 return ptrace_request(child, request, addr, data);
180}
181