Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
5e9a2692 | 2 | * Ptrace user space interface. |
1da177e4 | 3 | * |
a53c8fab | 4 | * Copyright IBM Corp. 1999, 2010 |
5e9a2692 | 5 | * Author(s): Denis Joseph Barrow |
1da177e4 | 6 | * Martin Schwidefsky (schwidefsky@de.ibm.com) |
1da177e4 LT |
7 | */ |
8 | ||
9 | #include <linux/kernel.h> | |
10 | #include <linux/sched.h> | |
11 | #include <linux/mm.h> | |
12 | #include <linux/smp.h> | |
1da177e4 LT |
13 | #include <linux/errno.h> |
14 | #include <linux/ptrace.h> | |
15 | #include <linux/user.h> | |
16 | #include <linux/security.h> | |
17 | #include <linux/audit.h> | |
7ed20e1a | 18 | #include <linux/signal.h> |
63506c41 MS |
19 | #include <linux/elf.h> |
20 | #include <linux/regset.h> | |
753c4dd6 | 21 | #include <linux/tracehook.h> |
bcf5cef7 | 22 | #include <linux/seccomp.h> |
048cd4e5 | 23 | #include <linux/compat.h> |
9bf1226b | 24 | #include <trace/syscall.h> |
1da177e4 LT |
25 | #include <asm/segment.h> |
26 | #include <asm/page.h> | |
27 | #include <asm/pgtable.h> | |
28 | #include <asm/pgalloc.h> | |
1da177e4 | 29 | #include <asm/uaccess.h> |
778959db | 30 | #include <asm/unistd.h> |
a0616cde | 31 | #include <asm/switch_to.h> |
a806170e | 32 | #include "entry.h" |
1da177e4 | 33 | |
347a8dc3 | 34 | #ifdef CONFIG_COMPAT |
1da177e4 LT |
35 | #include "compat_ptrace.h" |
36 | #endif | |
37 | ||
1c569f02 JS |
38 | #define CREATE_TRACE_POINTS |
39 | #include <trace/events/syscalls.h> | |
5e9ad7df | 40 | |
64597f9d | 41 | void update_cr_regs(struct task_struct *task) |
1da177e4 | 42 | { |
5e9a2692 MS |
43 | struct pt_regs *regs = task_pt_regs(task); |
44 | struct thread_struct *thread = &task->thread; | |
a45aff52 | 45 | struct per_regs old, new; |
5e9a2692 | 46 | |
66389e85 | 47 | #ifdef CONFIG_64BIT |
d35339a4 | 48 | /* Take care of the enable/disable of transactional execution. */ |
80703617 | 49 | if (MACHINE_HAS_TE || MACHINE_HAS_VX) { |
c63badeb | 50 | unsigned long cr, cr_new; |
d35339a4 | 51 | |
c63badeb | 52 | __ctl_store(cr, 0, 0); |
80703617 MS |
53 | cr_new = cr; |
54 | if (MACHINE_HAS_TE) { | |
55 | /* Set or clear transaction execution TXC bit 8. */ | |
56 | cr_new |= (1UL << 55); | |
57 | if (task->thread.per_flags & PER_FLAG_NO_TE) | |
58 | cr_new &= ~(1UL << 55); | |
59 | } | |
60 | if (MACHINE_HAS_VX) { | |
61 | /* Enable/disable of vector extension */ | |
62 | cr_new &= ~(1UL << 17); | |
63 | if (task->thread.vxrs) | |
64 | cr_new |= (1UL << 17); | |
65 | } | |
c63badeb | 66 | if (cr_new != cr) |
a8a934e4 | 67 | __ctl_load(cr_new, 0, 0); |
80703617 MS |
68 | if (MACHINE_HAS_TE) { |
69 | /* Set/clear transaction execution TDC bits 62/63. */ | |
70 | __ctl_store(cr, 2, 2); | |
71 | cr_new = cr & ~3UL; | |
72 | if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND) { | |
73 | if (task->thread.per_flags & | |
74 | PER_FLAG_TE_ABORT_RAND_TEND) | |
75 | cr_new |= 1UL; | |
76 | else | |
77 | cr_new |= 2UL; | |
78 | } | |
79 | if (cr_new != cr) | |
80 | __ctl_load(cr_new, 2, 2); | |
64597f9d | 81 | } |
d35339a4 | 82 | } |
66389e85 | 83 | #endif |
a45aff52 MS |
84 | /* Copy user specified PER registers */ |
85 | new.control = thread->per_user.control; | |
86 | new.start = thread->per_user.start; | |
87 | new.end = thread->per_user.end; | |
88 | ||
89 | /* merge TIF_SINGLE_STEP into user specified PER registers. */ | |
2a0a5b22 JW |
90 | if (test_tsk_thread_flag(task, TIF_SINGLE_STEP) || |
91 | test_tsk_thread_flag(task, TIF_UPROBE_SINGLESTEP)) { | |
818a330c MS |
92 | if (test_tsk_thread_flag(task, TIF_BLOCK_STEP)) |
93 | new.control |= PER_EVENT_BRANCH; | |
94 | else | |
95 | new.control |= PER_EVENT_IFETCH; | |
d35339a4 MS |
96 | #ifdef CONFIG_64BIT |
97 | new.control |= PER_CONTROL_SUSPENSION; | |
98 | new.control |= PER_EVENT_TRANSACTION_END; | |
99 | #endif | |
2a0a5b22 JW |
100 | if (test_tsk_thread_flag(task, TIF_UPROBE_SINGLESTEP)) |
101 | new.control |= PER_EVENT_IFETCH; | |
a45aff52 MS |
102 | new.start = 0; |
103 | new.end = PSW_ADDR_INSN; | |
104 | } | |
5e9a2692 MS |
105 | |
106 | /* Take care of the PER enablement bit in the PSW. */ | |
a45aff52 | 107 | if (!(new.control & PER_EVENT_MASK)) { |
1da177e4 | 108 | regs->psw.mask &= ~PSW_MASK_PER; |
5e9a2692 | 109 | return; |
c3311c13 | 110 | } |
5e9a2692 MS |
111 | regs->psw.mask |= PSW_MASK_PER; |
112 | __ctl_store(old, 9, 11); | |
a45aff52 MS |
113 | if (memcmp(&new, &old, sizeof(struct per_regs)) != 0) |
114 | __ctl_load(new, 9, 11); | |
1da177e4 LT |
115 | } |
116 | ||
0ac30be4 | 117 | void user_enable_single_step(struct task_struct *task) |
1da177e4 | 118 | { |
818a330c | 119 | clear_tsk_thread_flag(task, TIF_BLOCK_STEP); |
5e9a2692 | 120 | set_tsk_thread_flag(task, TIF_SINGLE_STEP); |
1da177e4 LT |
121 | } |
122 | ||
0ac30be4 | 123 | void user_disable_single_step(struct task_struct *task) |
1da177e4 | 124 | { |
818a330c | 125 | clear_tsk_thread_flag(task, TIF_BLOCK_STEP); |
5e9a2692 | 126 | clear_tsk_thread_flag(task, TIF_SINGLE_STEP); |
1da177e4 LT |
127 | } |
128 | ||
818a330c MS |
129 | void user_enable_block_step(struct task_struct *task) |
130 | { | |
131 | set_tsk_thread_flag(task, TIF_SINGLE_STEP); | |
132 | set_tsk_thread_flag(task, TIF_BLOCK_STEP); | |
133 | } | |
134 | ||
1da177e4 LT |
135 | /* |
136 | * Called by kernel/ptrace.c when detaching.. | |
137 | * | |
5e9a2692 | 138 | * Clear all debugging related fields. |
1da177e4 | 139 | */ |
5e9a2692 | 140 | void ptrace_disable(struct task_struct *task) |
1da177e4 | 141 | { |
5e9a2692 MS |
142 | memset(&task->thread.per_user, 0, sizeof(task->thread.per_user)); |
143 | memset(&task->thread.per_event, 0, sizeof(task->thread.per_event)); | |
144 | clear_tsk_thread_flag(task, TIF_SINGLE_STEP); | |
d3a73acb | 145 | clear_pt_regs_flag(task_pt_regs(task), PIF_PER_TRAP); |
d35339a4 | 146 | task->thread.per_flags = 0; |
1da177e4 LT |
147 | } |
148 | ||
347a8dc3 | 149 | #ifndef CONFIG_64BIT |
1da177e4 LT |
150 | # define __ADDR_MASK 3 |
151 | #else | |
152 | # define __ADDR_MASK 7 | |
153 | #endif | |
154 | ||
5e9a2692 MS |
155 | static inline unsigned long __peek_user_per(struct task_struct *child, |
156 | addr_t addr) | |
157 | { | |
158 | struct per_struct_kernel *dummy = NULL; | |
159 | ||
160 | if (addr == (addr_t) &dummy->cr9) | |
161 | /* Control bits of the active per set. */ | |
162 | return test_thread_flag(TIF_SINGLE_STEP) ? | |
163 | PER_EVENT_IFETCH : child->thread.per_user.control; | |
164 | else if (addr == (addr_t) &dummy->cr10) | |
165 | /* Start address of the active per set. */ | |
166 | return test_thread_flag(TIF_SINGLE_STEP) ? | |
167 | 0 : child->thread.per_user.start; | |
168 | else if (addr == (addr_t) &dummy->cr11) | |
169 | /* End address of the active per set. */ | |
170 | return test_thread_flag(TIF_SINGLE_STEP) ? | |
171 | PSW_ADDR_INSN : child->thread.per_user.end; | |
172 | else if (addr == (addr_t) &dummy->bits) | |
173 | /* Single-step bit. */ | |
174 | return test_thread_flag(TIF_SINGLE_STEP) ? | |
175 | (1UL << (BITS_PER_LONG - 1)) : 0; | |
176 | else if (addr == (addr_t) &dummy->starting_addr) | |
177 | /* Start address of the user specified per set. */ | |
178 | return child->thread.per_user.start; | |
179 | else if (addr == (addr_t) &dummy->ending_addr) | |
180 | /* End address of the user specified per set. */ | |
181 | return child->thread.per_user.end; | |
182 | else if (addr == (addr_t) &dummy->perc_atmid) | |
183 | /* PER code, ATMID and AI of the last PER trap */ | |
184 | return (unsigned long) | |
185 | child->thread.per_event.cause << (BITS_PER_LONG - 16); | |
186 | else if (addr == (addr_t) &dummy->address) | |
187 | /* Address of the last PER trap */ | |
188 | return child->thread.per_event.address; | |
189 | else if (addr == (addr_t) &dummy->access_id) | |
190 | /* Access id of the last PER trap */ | |
191 | return (unsigned long) | |
192 | child->thread.per_event.paid << (BITS_PER_LONG - 8); | |
193 | return 0; | |
194 | } | |
195 | ||
1da177e4 LT |
196 | /* |
197 | * Read the word at offset addr from the user area of a process. The | |
198 | * trouble here is that the information is littered over different | |
199 | * locations. The process registers are found on the kernel stack, | |
200 | * the floating point stuff and the trace settings are stored in | |
201 | * the task structure. In addition the different structures in | |
202 | * struct user contain pad bytes that should be read as zeroes. | |
203 | * Lovely... | |
204 | */ | |
63506c41 | 205 | static unsigned long __peek_user(struct task_struct *child, addr_t addr) |
1da177e4 LT |
206 | { |
207 | struct user *dummy = NULL; | |
63506c41 | 208 | addr_t offset, tmp; |
1da177e4 LT |
209 | |
210 | if (addr < (addr_t) &dummy->regs.acrs) { | |
211 | /* | |
212 | * psw and gprs are stored on the stack | |
213 | */ | |
c7584fb6 | 214 | tmp = *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr); |
5ebf250d | 215 | if (addr == (addr_t) &dummy->regs.psw.mask) { |
b50511e4 | 216 | /* Return a clean psw mask. */ |
5ebf250d HC |
217 | tmp &= PSW_MASK_USER | PSW_MASK_RI; |
218 | tmp |= PSW_USER_BITS; | |
219 | } | |
1da177e4 LT |
220 | |
221 | } else if (addr < (addr_t) &dummy->regs.orig_gpr2) { | |
222 | /* | |
223 | * access registers are stored in the thread structure | |
224 | */ | |
225 | offset = addr - (addr_t) &dummy->regs.acrs; | |
347a8dc3 | 226 | #ifdef CONFIG_64BIT |
778959db MS |
227 | /* |
228 | * Very special case: old & broken 64 bit gdb reading | |
229 | * from acrs[15]. Result is a 64 bit value. Read the | |
230 | * 32 bit acrs[15] value and shift it by 32. Sick... | |
231 | */ | |
232 | if (addr == (addr_t) &dummy->regs.acrs[15]) | |
233 | tmp = ((unsigned long) child->thread.acrs[15]) << 32; | |
234 | else | |
235 | #endif | |
1da177e4 LT |
236 | tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset); |
237 | ||
238 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { | |
239 | /* | |
240 | * orig_gpr2 is stored on the kernel stack | |
241 | */ | |
c7584fb6 | 242 | tmp = (addr_t) task_pt_regs(child)->orig_gpr2; |
1da177e4 | 243 | |
3d6e48f4 JW |
244 | } else if (addr < (addr_t) &dummy->regs.fp_regs) { |
245 | /* | |
246 | * prevent reads of padding hole between | |
247 | * orig_gpr2 and fp_regs on s390. | |
248 | */ | |
249 | tmp = 0; | |
250 | ||
1da177e4 LT |
251 | } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) { |
252 | /* | |
253 | * floating point regs. are stored in the thread structure | |
254 | */ | |
255 | offset = addr - (addr_t) &dummy->regs.fp_regs; | |
256 | tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset); | |
778959db | 257 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc) |
4725c860 | 258 | tmp <<= BITS_PER_LONG - 32; |
1da177e4 LT |
259 | |
260 | } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) { | |
261 | /* | |
5e9a2692 | 262 | * Handle access to the per_info structure. |
1da177e4 | 263 | */ |
5e9a2692 MS |
264 | addr -= (addr_t) &dummy->regs.per_info; |
265 | tmp = __peek_user_per(child, addr); | |
1da177e4 LT |
266 | |
267 | } else | |
268 | tmp = 0; | |
269 | ||
63506c41 | 270 | return tmp; |
1da177e4 LT |
271 | } |
272 | ||
1da177e4 | 273 | static int |
63506c41 | 274 | peek_user(struct task_struct *child, addr_t addr, addr_t data) |
1da177e4 | 275 | { |
63506c41 | 276 | addr_t tmp, mask; |
1da177e4 LT |
277 | |
278 | /* | |
279 | * Stupid gdb peeks/pokes the access registers in 64 bit with | |
63506c41 | 280 | * an alignment of 4. Programmers from hell... |
1da177e4 | 281 | */ |
778959db | 282 | mask = __ADDR_MASK; |
347a8dc3 | 283 | #ifdef CONFIG_64BIT |
547e3cec MS |
284 | if (addr >= (addr_t) &((struct user *) NULL)->regs.acrs && |
285 | addr < (addr_t) &((struct user *) NULL)->regs.orig_gpr2) | |
778959db MS |
286 | mask = 3; |
287 | #endif | |
288 | if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) | |
1da177e4 LT |
289 | return -EIO; |
290 | ||
63506c41 MS |
291 | tmp = __peek_user(child, addr); |
292 | return put_user(tmp, (addr_t __user *) data); | |
293 | } | |
294 | ||
5e9a2692 MS |
295 | static inline void __poke_user_per(struct task_struct *child, |
296 | addr_t addr, addr_t data) | |
297 | { | |
298 | struct per_struct_kernel *dummy = NULL; | |
299 | ||
300 | /* | |
301 | * There are only three fields in the per_info struct that the | |
302 | * debugger user can write to. | |
303 | * 1) cr9: the debugger wants to set a new PER event mask | |
304 | * 2) starting_addr: the debugger wants to set a new starting | |
305 | * address to use with the PER event mask. | |
306 | * 3) ending_addr: the debugger wants to set a new ending | |
307 | * address to use with the PER event mask. | |
308 | * The user specified PER event mask and the start and end | |
309 | * addresses are used only if single stepping is not in effect. | |
310 | * Writes to any other field in per_info are ignored. | |
311 | */ | |
312 | if (addr == (addr_t) &dummy->cr9) | |
313 | /* PER event mask of the user specified per set. */ | |
314 | child->thread.per_user.control = | |
315 | data & (PER_EVENT_MASK | PER_CONTROL_MASK); | |
316 | else if (addr == (addr_t) &dummy->starting_addr) | |
317 | /* Starting address of the user specified per set. */ | |
318 | child->thread.per_user.start = data; | |
319 | else if (addr == (addr_t) &dummy->ending_addr) | |
320 | /* Ending address of the user specified per set. */ | |
321 | child->thread.per_user.end = data; | |
322 | } | |
323 | ||
63506c41 MS |
324 | /* |
325 | * Write a word to the user area of a process at location addr. This | |
326 | * operation does have an additional problem compared to peek_user. | |
327 | * Stores to the program status word and on the floating point | |
328 | * control register needs to get checked for validity. | |
329 | */ | |
330 | static int __poke_user(struct task_struct *child, addr_t addr, addr_t data) | |
331 | { | |
332 | struct user *dummy = NULL; | |
d4e81b35 | 333 | addr_t offset; |
63506c41 | 334 | |
1da177e4 LT |
335 | if (addr < (addr_t) &dummy->regs.acrs) { |
336 | /* | |
337 | * psw and gprs are stored on the stack | |
338 | */ | |
5ebf250d HC |
339 | if (addr == (addr_t) &dummy->regs.psw.mask) { |
340 | unsigned long mask = PSW_MASK_USER; | |
341 | ||
342 | mask |= is_ri_task(child) ? PSW_MASK_RI : 0; | |
dab6cf55 MS |
343 | if ((data ^ PSW_USER_BITS) & ~mask) |
344 | /* Invalid psw mask. */ | |
345 | return -EINVAL; | |
346 | if ((data & PSW_MASK_ASC) == PSW_ASC_HOME) | |
347 | /* Invalid address-space-control bits */ | |
5ebf250d HC |
348 | return -EINVAL; |
349 | if ((data & PSW_MASK_EA) && !(data & PSW_MASK_BA)) | |
dab6cf55 | 350 | /* Invalid addressing mode bits */ |
5ebf250d HC |
351 | return -EINVAL; |
352 | } | |
c7584fb6 | 353 | *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data; |
1da177e4 LT |
354 | |
355 | } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) { | |
356 | /* | |
357 | * access registers are stored in the thread structure | |
358 | */ | |
359 | offset = addr - (addr_t) &dummy->regs.acrs; | |
347a8dc3 | 360 | #ifdef CONFIG_64BIT |
778959db MS |
361 | /* |
362 | * Very special case: old & broken 64 bit gdb writing | |
363 | * to acrs[15] with a 64 bit value. Ignore the lower | |
364 | * half of the value and write the upper 32 bit to | |
365 | * acrs[15]. Sick... | |
366 | */ | |
367 | if (addr == (addr_t) &dummy->regs.acrs[15]) | |
368 | child->thread.acrs[15] = (unsigned int) (data >> 32); | |
369 | else | |
370 | #endif | |
1da177e4 LT |
371 | *(addr_t *)((addr_t) &child->thread.acrs + offset) = data; |
372 | ||
373 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { | |
374 | /* | |
375 | * orig_gpr2 is stored on the kernel stack | |
376 | */ | |
c7584fb6 | 377 | task_pt_regs(child)->orig_gpr2 = data; |
1da177e4 | 378 | |
3d6e48f4 JW |
379 | } else if (addr < (addr_t) &dummy->regs.fp_regs) { |
380 | /* | |
381 | * prevent writes of padding hole between | |
382 | * orig_gpr2 and fp_regs on s390. | |
383 | */ | |
384 | return 0; | |
385 | ||
1da177e4 LT |
386 | } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) { |
387 | /* | |
388 | * floating point regs. are stored in the thread structure | |
389 | */ | |
4725c860 MS |
390 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc) |
391 | if ((unsigned int) data != 0 || | |
392 | test_fp_ctl(data >> (BITS_PER_LONG - 32))) | |
393 | return -EINVAL; | |
1da177e4 LT |
394 | offset = addr - (addr_t) &dummy->regs.fp_regs; |
395 | *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data; | |
396 | ||
397 | } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) { | |
398 | /* | |
5e9a2692 | 399 | * Handle access to the per_info structure. |
1da177e4 | 400 | */ |
5e9a2692 MS |
401 | addr -= (addr_t) &dummy->regs.per_info; |
402 | __poke_user_per(child, addr, data); | |
1da177e4 LT |
403 | |
404 | } | |
405 | ||
1da177e4 LT |
406 | return 0; |
407 | } | |
408 | ||
5e9a2692 | 409 | static int poke_user(struct task_struct *child, addr_t addr, addr_t data) |
63506c41 | 410 | { |
63506c41 MS |
411 | addr_t mask; |
412 | ||
413 | /* | |
414 | * Stupid gdb peeks/pokes the access registers in 64 bit with | |
415 | * an alignment of 4. Programmers from hell indeed... | |
416 | */ | |
417 | mask = __ADDR_MASK; | |
418 | #ifdef CONFIG_64BIT | |
547e3cec MS |
419 | if (addr >= (addr_t) &((struct user *) NULL)->regs.acrs && |
420 | addr < (addr_t) &((struct user *) NULL)->regs.orig_gpr2) | |
63506c41 MS |
421 | mask = 3; |
422 | #endif | |
423 | if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) | |
424 | return -EIO; | |
425 | ||
426 | return __poke_user(child, addr, data); | |
427 | } | |
428 | ||
9b05a69e NK |
429 | long arch_ptrace(struct task_struct *child, long request, |
430 | unsigned long addr, unsigned long data) | |
1da177e4 | 431 | { |
1da177e4 LT |
432 | ptrace_area parea; |
433 | int copied, ret; | |
434 | ||
435 | switch (request) { | |
1da177e4 LT |
436 | case PTRACE_PEEKUSR: |
437 | /* read the word at location addr in the USER area. */ | |
438 | return peek_user(child, addr, data); | |
439 | ||
1da177e4 LT |
440 | case PTRACE_POKEUSR: |
441 | /* write the word at location addr in the USER area */ | |
442 | return poke_user(child, addr, data); | |
443 | ||
444 | case PTRACE_PEEKUSR_AREA: | |
445 | case PTRACE_POKEUSR_AREA: | |
2b67fc46 | 446 | if (copy_from_user(&parea, (void __force __user *) addr, |
1da177e4 LT |
447 | sizeof(parea))) |
448 | return -EFAULT; | |
449 | addr = parea.kernel_addr; | |
450 | data = parea.process_addr; | |
451 | copied = 0; | |
452 | while (copied < parea.len) { | |
453 | if (request == PTRACE_PEEKUSR_AREA) | |
454 | ret = peek_user(child, addr, data); | |
455 | else { | |
2b67fc46 HC |
456 | addr_t utmp; |
457 | if (get_user(utmp, | |
458 | (addr_t __force __user *) data)) | |
1da177e4 | 459 | return -EFAULT; |
2b67fc46 | 460 | ret = poke_user(child, addr, utmp); |
1da177e4 LT |
461 | } |
462 | if (ret) | |
463 | return ret; | |
464 | addr += sizeof(unsigned long); | |
465 | data += sizeof(unsigned long); | |
466 | copied += sizeof(unsigned long); | |
467 | } | |
468 | return 0; | |
86f2552b MS |
469 | case PTRACE_GET_LAST_BREAK: |
470 | put_user(task_thread_info(child)->last_break, | |
471 | (unsigned long __user *) data); | |
472 | return 0; | |
d35339a4 MS |
473 | case PTRACE_ENABLE_TE: |
474 | if (!MACHINE_HAS_TE) | |
475 | return -EIO; | |
476 | child->thread.per_flags &= ~PER_FLAG_NO_TE; | |
477 | return 0; | |
478 | case PTRACE_DISABLE_TE: | |
479 | if (!MACHINE_HAS_TE) | |
480 | return -EIO; | |
481 | child->thread.per_flags |= PER_FLAG_NO_TE; | |
64597f9d MM |
482 | child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND; |
483 | return 0; | |
484 | case PTRACE_TE_ABORT_RAND: | |
485 | if (!MACHINE_HAS_TE || (child->thread.per_flags & PER_FLAG_NO_TE)) | |
486 | return -EIO; | |
487 | switch (data) { | |
488 | case 0UL: | |
489 | child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND; | |
490 | break; | |
491 | case 1UL: | |
492 | child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND; | |
493 | child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND_TEND; | |
494 | break; | |
495 | case 2UL: | |
496 | child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND; | |
497 | child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND_TEND; | |
498 | break; | |
499 | default: | |
500 | return -EINVAL; | |
501 | } | |
d35339a4 | 502 | return 0; |
07805ac8 CB |
503 | default: |
504 | /* Removing high order bit from addr (only for 31 bit). */ | |
505 | addr &= PSW_ADDR_INSN; | |
506 | return ptrace_request(child, request, addr, data); | |
1da177e4 | 507 | } |
1da177e4 LT |
508 | } |
509 | ||
347a8dc3 | 510 | #ifdef CONFIG_COMPAT |
1da177e4 LT |
511 | /* |
512 | * Now the fun part starts... a 31 bit program running in the | |
513 | * 31 bit emulation tracing another program. PTRACE_PEEKTEXT, | |
514 | * PTRACE_PEEKDATA, PTRACE_POKETEXT and PTRACE_POKEDATA are easy | |
515 | * to handle, the difference to the 64 bit versions of the requests | |
516 | * is that the access is done in multiples of 4 byte instead of | |
517 | * 8 bytes (sizeof(unsigned long) on 31/64 bit). | |
518 | * The ugly part are PTRACE_PEEKUSR, PTRACE_PEEKUSR_AREA, | |
519 | * PTRACE_POKEUSR and PTRACE_POKEUSR_AREA. If the traced program | |
520 | * is a 31 bit program too, the content of struct user can be | |
521 | * emulated. A 31 bit program peeking into the struct user of | |
522 | * a 64 bit program is a no-no. | |
523 | */ | |
524 | ||
5e9a2692 MS |
525 | /* |
526 | * Same as peek_user_per but for a 31 bit program. | |
527 | */ | |
528 | static inline __u32 __peek_user_per_compat(struct task_struct *child, | |
529 | addr_t addr) | |
530 | { | |
531 | struct compat_per_struct_kernel *dummy32 = NULL; | |
532 | ||
533 | if (addr == (addr_t) &dummy32->cr9) | |
534 | /* Control bits of the active per set. */ | |
535 | return (__u32) test_thread_flag(TIF_SINGLE_STEP) ? | |
536 | PER_EVENT_IFETCH : child->thread.per_user.control; | |
537 | else if (addr == (addr_t) &dummy32->cr10) | |
538 | /* Start address of the active per set. */ | |
539 | return (__u32) test_thread_flag(TIF_SINGLE_STEP) ? | |
540 | 0 : child->thread.per_user.start; | |
541 | else if (addr == (addr_t) &dummy32->cr11) | |
542 | /* End address of the active per set. */ | |
543 | return test_thread_flag(TIF_SINGLE_STEP) ? | |
544 | PSW32_ADDR_INSN : child->thread.per_user.end; | |
545 | else if (addr == (addr_t) &dummy32->bits) | |
546 | /* Single-step bit. */ | |
547 | return (__u32) test_thread_flag(TIF_SINGLE_STEP) ? | |
548 | 0x80000000 : 0; | |
549 | else if (addr == (addr_t) &dummy32->starting_addr) | |
550 | /* Start address of the user specified per set. */ | |
551 | return (__u32) child->thread.per_user.start; | |
552 | else if (addr == (addr_t) &dummy32->ending_addr) | |
553 | /* End address of the user specified per set. */ | |
554 | return (__u32) child->thread.per_user.end; | |
555 | else if (addr == (addr_t) &dummy32->perc_atmid) | |
556 | /* PER code, ATMID and AI of the last PER trap */ | |
557 | return (__u32) child->thread.per_event.cause << 16; | |
558 | else if (addr == (addr_t) &dummy32->address) | |
559 | /* Address of the last PER trap */ | |
560 | return (__u32) child->thread.per_event.address; | |
561 | else if (addr == (addr_t) &dummy32->access_id) | |
562 | /* Access id of the last PER trap */ | |
563 | return (__u32) child->thread.per_event.paid << 24; | |
564 | return 0; | |
565 | } | |
566 | ||
1da177e4 LT |
567 | /* |
568 | * Same as peek_user but for a 31 bit program. | |
569 | */ | |
63506c41 | 570 | static u32 __peek_user_compat(struct task_struct *child, addr_t addr) |
1da177e4 | 571 | { |
5e9a2692 | 572 | struct compat_user *dummy32 = NULL; |
1da177e4 LT |
573 | addr_t offset; |
574 | __u32 tmp; | |
575 | ||
1da177e4 | 576 | if (addr < (addr_t) &dummy32->regs.acrs) { |
b50511e4 | 577 | struct pt_regs *regs = task_pt_regs(child); |
1da177e4 LT |
578 | /* |
579 | * psw and gprs are stored on the stack | |
580 | */ | |
581 | if (addr == (addr_t) &dummy32->regs.psw.mask) { | |
582 | /* Fake a 31 bit psw mask. */ | |
b50511e4 | 583 | tmp = (__u32)(regs->psw.mask >> 32); |
5ebf250d | 584 | tmp &= PSW32_MASK_USER | PSW32_MASK_RI; |
f26946d7 | 585 | tmp |= PSW32_USER_BITS; |
1da177e4 LT |
586 | } else if (addr == (addr_t) &dummy32->regs.psw.addr) { |
587 | /* Fake a 31 bit psw address. */ | |
d4e81b35 MS |
588 | tmp = (__u32) regs->psw.addr | |
589 | (__u32)(regs->psw.mask & PSW_MASK_BA); | |
1da177e4 LT |
590 | } else { |
591 | /* gpr 0-15 */ | |
b50511e4 | 592 | tmp = *(__u32 *)((addr_t) ®s->psw + addr*2 + 4); |
1da177e4 LT |
593 | } |
594 | } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) { | |
595 | /* | |
596 | * access registers are stored in the thread structure | |
597 | */ | |
598 | offset = addr - (addr_t) &dummy32->regs.acrs; | |
599 | tmp = *(__u32*)((addr_t) &child->thread.acrs + offset); | |
600 | ||
601 | } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) { | |
602 | /* | |
603 | * orig_gpr2 is stored on the kernel stack | |
604 | */ | |
c7584fb6 | 605 | tmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4); |
1da177e4 | 606 | |
3d6e48f4 JW |
607 | } else if (addr < (addr_t) &dummy32->regs.fp_regs) { |
608 | /* | |
609 | * prevent reads of padding hole between | |
610 | * orig_gpr2 and fp_regs on s390. | |
611 | */ | |
612 | tmp = 0; | |
613 | ||
1da177e4 LT |
614 | } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) { |
615 | /* | |
616 | * floating point regs. are stored in the thread structure | |
617 | */ | |
618 | offset = addr - (addr_t) &dummy32->regs.fp_regs; | |
619 | tmp = *(__u32 *)((addr_t) &child->thread.fp_regs + offset); | |
620 | ||
621 | } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) { | |
622 | /* | |
5e9a2692 | 623 | * Handle access to the per_info structure. |
1da177e4 | 624 | */ |
5e9a2692 MS |
625 | addr -= (addr_t) &dummy32->regs.per_info; |
626 | tmp = __peek_user_per_compat(child, addr); | |
1da177e4 LT |
627 | |
628 | } else | |
629 | tmp = 0; | |
630 | ||
63506c41 MS |
631 | return tmp; |
632 | } | |
633 | ||
634 | static int peek_user_compat(struct task_struct *child, | |
635 | addr_t addr, addr_t data) | |
636 | { | |
637 | __u32 tmp; | |
638 | ||
7757591a | 639 | if (!is_compat_task() || (addr & 3) || addr > sizeof(struct user) - 3) |
63506c41 MS |
640 | return -EIO; |
641 | ||
642 | tmp = __peek_user_compat(child, addr); | |
1da177e4 LT |
643 | return put_user(tmp, (__u32 __user *) data); |
644 | } | |
645 | ||
5e9a2692 MS |
646 | /* |
647 | * Same as poke_user_per but for a 31 bit program. | |
648 | */ | |
649 | static inline void __poke_user_per_compat(struct task_struct *child, | |
650 | addr_t addr, __u32 data) | |
651 | { | |
652 | struct compat_per_struct_kernel *dummy32 = NULL; | |
653 | ||
654 | if (addr == (addr_t) &dummy32->cr9) | |
655 | /* PER event mask of the user specified per set. */ | |
656 | child->thread.per_user.control = | |
657 | data & (PER_EVENT_MASK | PER_CONTROL_MASK); | |
658 | else if (addr == (addr_t) &dummy32->starting_addr) | |
659 | /* Starting address of the user specified per set. */ | |
660 | child->thread.per_user.start = data; | |
661 | else if (addr == (addr_t) &dummy32->ending_addr) | |
662 | /* Ending address of the user specified per set. */ | |
663 | child->thread.per_user.end = data; | |
664 | } | |
665 | ||
1da177e4 LT |
666 | /* |
667 | * Same as poke_user but for a 31 bit program. | |
668 | */ | |
63506c41 MS |
669 | static int __poke_user_compat(struct task_struct *child, |
670 | addr_t addr, addr_t data) | |
1da177e4 | 671 | { |
5e9a2692 | 672 | struct compat_user *dummy32 = NULL; |
63506c41 | 673 | __u32 tmp = (__u32) data; |
1da177e4 | 674 | addr_t offset; |
1da177e4 LT |
675 | |
676 | if (addr < (addr_t) &dummy32->regs.acrs) { | |
b50511e4 | 677 | struct pt_regs *regs = task_pt_regs(child); |
1da177e4 LT |
678 | /* |
679 | * psw, gprs, acrs and orig_gpr2 are stored on the stack | |
680 | */ | |
681 | if (addr == (addr_t) &dummy32->regs.psw.mask) { | |
5ebf250d HC |
682 | __u32 mask = PSW32_MASK_USER; |
683 | ||
684 | mask |= is_ri_task(child) ? PSW32_MASK_RI : 0; | |
1da177e4 | 685 | /* Build a 64 bit psw mask from 31 bit mask. */ |
dab6cf55 | 686 | if ((tmp ^ PSW32_USER_BITS) & ~mask) |
1da177e4 LT |
687 | /* Invalid psw mask. */ |
688 | return -EINVAL; | |
dab6cf55 MS |
689 | if ((data & PSW32_MASK_ASC) == PSW32_ASC_HOME) |
690 | /* Invalid address-space-control bits */ | |
691 | return -EINVAL; | |
b50511e4 | 692 | regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | |
d4e81b35 | 693 | (regs->psw.mask & PSW_MASK_BA) | |
5ebf250d | 694 | (__u64)(tmp & mask) << 32; |
1da177e4 LT |
695 | } else if (addr == (addr_t) &dummy32->regs.psw.addr) { |
696 | /* Build a 64 bit psw address from 31 bit address. */ | |
b50511e4 | 697 | regs->psw.addr = (__u64) tmp & PSW32_ADDR_INSN; |
d4e81b35 MS |
698 | /* Transfer 31 bit amode bit to psw mask. */ |
699 | regs->psw.mask = (regs->psw.mask & ~PSW_MASK_BA) | | |
700 | (__u64)(tmp & PSW32_ADDR_AMODE); | |
1da177e4 LT |
701 | } else { |
702 | /* gpr 0-15 */ | |
b50511e4 | 703 | *(__u32*)((addr_t) ®s->psw + addr*2 + 4) = tmp; |
1da177e4 LT |
704 | } |
705 | } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) { | |
706 | /* | |
707 | * access registers are stored in the thread structure | |
708 | */ | |
709 | offset = addr - (addr_t) &dummy32->regs.acrs; | |
710 | *(__u32*)((addr_t) &child->thread.acrs + offset) = tmp; | |
711 | ||
712 | } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) { | |
713 | /* | |
714 | * orig_gpr2 is stored on the kernel stack | |
715 | */ | |
c7584fb6 | 716 | *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4) = tmp; |
1da177e4 | 717 | |
3d6e48f4 JW |
718 | } else if (addr < (addr_t) &dummy32->regs.fp_regs) { |
719 | /* | |
720 | * prevent writess of padding hole between | |
721 | * orig_gpr2 and fp_regs on s390. | |
722 | */ | |
723 | return 0; | |
724 | ||
1da177e4 LT |
725 | } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) { |
726 | /* | |
727 | * floating point regs. are stored in the thread structure | |
728 | */ | |
729 | if (addr == (addr_t) &dummy32->regs.fp_regs.fpc && | |
4725c860 | 730 | test_fp_ctl(tmp)) |
1da177e4 LT |
731 | return -EINVAL; |
732 | offset = addr - (addr_t) &dummy32->regs.fp_regs; | |
733 | *(__u32 *)((addr_t) &child->thread.fp_regs + offset) = tmp; | |
734 | ||
735 | } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) { | |
736 | /* | |
5e9a2692 | 737 | * Handle access to the per_info structure. |
1da177e4 | 738 | */ |
5e9a2692 MS |
739 | addr -= (addr_t) &dummy32->regs.per_info; |
740 | __poke_user_per_compat(child, addr, data); | |
1da177e4 LT |
741 | } |
742 | ||
1da177e4 LT |
743 | return 0; |
744 | } | |
745 | ||
63506c41 MS |
746 | static int poke_user_compat(struct task_struct *child, |
747 | addr_t addr, addr_t data) | |
748 | { | |
5e9a2692 MS |
749 | if (!is_compat_task() || (addr & 3) || |
750 | addr > sizeof(struct compat_user) - 3) | |
63506c41 MS |
751 | return -EIO; |
752 | ||
753 | return __poke_user_compat(child, addr, data); | |
754 | } | |
755 | ||
b499d76b RM |
756 | long compat_arch_ptrace(struct task_struct *child, compat_long_t request, |
757 | compat_ulong_t caddr, compat_ulong_t cdata) | |
1da177e4 | 758 | { |
b499d76b RM |
759 | unsigned long addr = caddr; |
760 | unsigned long data = cdata; | |
5e9a2692 | 761 | compat_ptrace_area parea; |
1da177e4 LT |
762 | int copied, ret; |
763 | ||
764 | switch (request) { | |
1da177e4 LT |
765 | case PTRACE_PEEKUSR: |
766 | /* read the word at location addr in the USER area. */ | |
63506c41 | 767 | return peek_user_compat(child, addr, data); |
1da177e4 | 768 | |
1da177e4 LT |
769 | case PTRACE_POKEUSR: |
770 | /* write the word at location addr in the USER area */ | |
63506c41 | 771 | return poke_user_compat(child, addr, data); |
1da177e4 LT |
772 | |
773 | case PTRACE_PEEKUSR_AREA: | |
774 | case PTRACE_POKEUSR_AREA: | |
2b67fc46 | 775 | if (copy_from_user(&parea, (void __force __user *) addr, |
1da177e4 LT |
776 | sizeof(parea))) |
777 | return -EFAULT; | |
778 | addr = parea.kernel_addr; | |
779 | data = parea.process_addr; | |
780 | copied = 0; | |
781 | while (copied < parea.len) { | |
782 | if (request == PTRACE_PEEKUSR_AREA) | |
63506c41 | 783 | ret = peek_user_compat(child, addr, data); |
1da177e4 | 784 | else { |
2b67fc46 HC |
785 | __u32 utmp; |
786 | if (get_user(utmp, | |
787 | (__u32 __force __user *) data)) | |
1da177e4 | 788 | return -EFAULT; |
63506c41 | 789 | ret = poke_user_compat(child, addr, utmp); |
1da177e4 LT |
790 | } |
791 | if (ret) | |
792 | return ret; | |
793 | addr += sizeof(unsigned int); | |
794 | data += sizeof(unsigned int); | |
795 | copied += sizeof(unsigned int); | |
796 | } | |
797 | return 0; | |
86f2552b MS |
798 | case PTRACE_GET_LAST_BREAK: |
799 | put_user(task_thread_info(child)->last_break, | |
800 | (unsigned int __user *) data); | |
801 | return 0; | |
1da177e4 | 802 | } |
b499d76b | 803 | return compat_ptrace_request(child, request, addr, data); |
1da177e4 LT |
804 | } |
805 | #endif | |
806 | ||
753c4dd6 | 807 | asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) |
1da177e4 | 808 | { |
545c174d | 809 | long ret = 0; |
1da177e4 | 810 | |
bcf5cef7 | 811 | /* Do the secure computing check first. */ |
a4412fc9 | 812 | if (secure_computing()) { |
c63cb468 HC |
813 | /* seccomp failures shouldn't expose any additional code. */ |
814 | ret = -1; | |
815 | goto out; | |
816 | } | |
bcf5cef7 | 817 | |
c5c3a6d8 | 818 | /* |
753c4dd6 MS |
819 | * The sysc_tracesys code in entry.S stored the system |
820 | * call number to gprs[2]. | |
c5c3a6d8 | 821 | */ |
753c4dd6 MS |
822 | if (test_thread_flag(TIF_SYSCALL_TRACE) && |
823 | (tracehook_report_syscall_entry(regs) || | |
824 | regs->gprs[2] >= NR_syscalls)) { | |
825 | /* | |
826 | * Tracing decided this syscall should not happen or the | |
827 | * debugger stored an invalid system call number. Skip | |
828 | * the system call and the system call restart handling. | |
829 | */ | |
d3a73acb | 830 | clear_pt_regs_flag(regs, PIF_SYSCALL); |
753c4dd6 | 831 | ret = -1; |
1da177e4 | 832 | } |
753c4dd6 | 833 | |
66700001 | 834 | if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) |
1c569f02 | 835 | trace_sys_enter(regs, regs->gprs[2]); |
9bf1226b | 836 | |
91397401 | 837 | audit_syscall_entry(regs->gprs[2], regs->orig_gpr2, |
b05d8447 EP |
838 | regs->gprs[3], regs->gprs[4], |
839 | regs->gprs[5]); | |
c63cb468 | 840 | out: |
545c174d | 841 | return ret ?: regs->gprs[2]; |
753c4dd6 MS |
842 | } |
843 | ||
844 | asmlinkage void do_syscall_trace_exit(struct pt_regs *regs) | |
845 | { | |
d7e7528b | 846 | audit_syscall_exit(regs); |
753c4dd6 | 847 | |
66700001 | 848 | if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) |
1c569f02 | 849 | trace_sys_exit(regs, regs->gprs[2]); |
9bf1226b | 850 | |
753c4dd6 MS |
851 | if (test_thread_flag(TIF_SYSCALL_TRACE)) |
852 | tracehook_report_syscall_exit(regs, 0); | |
1da177e4 | 853 | } |
63506c41 MS |
854 | |
855 | /* | |
856 | * user_regset definitions. | |
857 | */ | |
858 | ||
859 | static int s390_regs_get(struct task_struct *target, | |
860 | const struct user_regset *regset, | |
861 | unsigned int pos, unsigned int count, | |
862 | void *kbuf, void __user *ubuf) | |
863 | { | |
864 | if (target == current) | |
865 | save_access_regs(target->thread.acrs); | |
866 | ||
867 | if (kbuf) { | |
868 | unsigned long *k = kbuf; | |
869 | while (count > 0) { | |
870 | *k++ = __peek_user(target, pos); | |
871 | count -= sizeof(*k); | |
872 | pos += sizeof(*k); | |
873 | } | |
874 | } else { | |
875 | unsigned long __user *u = ubuf; | |
876 | while (count > 0) { | |
877 | if (__put_user(__peek_user(target, pos), u++)) | |
878 | return -EFAULT; | |
879 | count -= sizeof(*u); | |
880 | pos += sizeof(*u); | |
881 | } | |
882 | } | |
883 | return 0; | |
884 | } | |
885 | ||
886 | static int s390_regs_set(struct task_struct *target, | |
887 | const struct user_regset *regset, | |
888 | unsigned int pos, unsigned int count, | |
889 | const void *kbuf, const void __user *ubuf) | |
890 | { | |
891 | int rc = 0; | |
892 | ||
893 | if (target == current) | |
894 | save_access_regs(target->thread.acrs); | |
895 | ||
896 | if (kbuf) { | |
897 | const unsigned long *k = kbuf; | |
898 | while (count > 0 && !rc) { | |
899 | rc = __poke_user(target, pos, *k++); | |
900 | count -= sizeof(*k); | |
901 | pos += sizeof(*k); | |
902 | } | |
903 | } else { | |
904 | const unsigned long __user *u = ubuf; | |
905 | while (count > 0 && !rc) { | |
906 | unsigned long word; | |
907 | rc = __get_user(word, u++); | |
908 | if (rc) | |
909 | break; | |
910 | rc = __poke_user(target, pos, word); | |
911 | count -= sizeof(*u); | |
912 | pos += sizeof(*u); | |
913 | } | |
914 | } | |
915 | ||
916 | if (rc == 0 && target == current) | |
917 | restore_access_regs(target->thread.acrs); | |
918 | ||
919 | return rc; | |
920 | } | |
921 | ||
922 | static int s390_fpregs_get(struct task_struct *target, | |
923 | const struct user_regset *regset, unsigned int pos, | |
924 | unsigned int count, void *kbuf, void __user *ubuf) | |
925 | { | |
4725c860 MS |
926 | if (target == current) { |
927 | save_fp_ctl(&target->thread.fp_regs.fpc); | |
928 | save_fp_regs(target->thread.fp_regs.fprs); | |
929 | } | |
80703617 MS |
930 | #ifdef CONFIG_64BIT |
931 | else if (target->thread.vxrs) { | |
932 | int i; | |
63506c41 | 933 | |
80703617 MS |
934 | for (i = 0; i < __NUM_VXRS_LOW; i++) |
935 | target->thread.fp_regs.fprs[i] = | |
936 | *(freg_t *)(target->thread.vxrs + i); | |
937 | } | |
938 | #endif | |
63506c41 MS |
939 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
940 | &target->thread.fp_regs, 0, -1); | |
941 | } | |
942 | ||
943 | static int s390_fpregs_set(struct task_struct *target, | |
944 | const struct user_regset *regset, unsigned int pos, | |
945 | unsigned int count, const void *kbuf, | |
946 | const void __user *ubuf) | |
947 | { | |
948 | int rc = 0; | |
949 | ||
4725c860 MS |
950 | if (target == current) { |
951 | save_fp_ctl(&target->thread.fp_regs.fpc); | |
952 | save_fp_regs(target->thread.fp_regs.fprs); | |
953 | } | |
63506c41 MS |
954 | |
955 | /* If setting FPC, must validate it first. */ | |
956 | if (count > 0 && pos < offsetof(s390_fp_regs, fprs)) { | |
4725c860 MS |
957 | u32 ufpc[2] = { target->thread.fp_regs.fpc, 0 }; |
958 | rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ufpc, | |
63506c41 MS |
959 | 0, offsetof(s390_fp_regs, fprs)); |
960 | if (rc) | |
961 | return rc; | |
4725c860 | 962 | if (ufpc[1] != 0 || test_fp_ctl(ufpc[0])) |
63506c41 | 963 | return -EINVAL; |
4725c860 | 964 | target->thread.fp_regs.fpc = ufpc[0]; |
63506c41 MS |
965 | } |
966 | ||
967 | if (rc == 0 && count > 0) | |
968 | rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | |
969 | target->thread.fp_regs.fprs, | |
970 | offsetof(s390_fp_regs, fprs), -1); | |
971 | ||
80703617 MS |
972 | if (rc == 0) { |
973 | if (target == current) { | |
974 | restore_fp_ctl(&target->thread.fp_regs.fpc); | |
975 | restore_fp_regs(target->thread.fp_regs.fprs); | |
976 | } | |
977 | #ifdef CONFIG_64BIT | |
978 | else if (target->thread.vxrs) { | |
979 | int i; | |
980 | ||
981 | for (i = 0; i < __NUM_VXRS_LOW; i++) | |
982 | *(freg_t *)(target->thread.vxrs + i) = | |
983 | target->thread.fp_regs.fprs[i]; | |
984 | } | |
985 | #endif | |
4725c860 | 986 | } |
63506c41 MS |
987 | |
988 | return rc; | |
989 | } | |
990 | ||
86f2552b MS |
991 | #ifdef CONFIG_64BIT |
992 | ||
993 | static int s390_last_break_get(struct task_struct *target, | |
994 | const struct user_regset *regset, | |
995 | unsigned int pos, unsigned int count, | |
996 | void *kbuf, void __user *ubuf) | |
997 | { | |
998 | if (count > 0) { | |
999 | if (kbuf) { | |
1000 | unsigned long *k = kbuf; | |
1001 | *k = task_thread_info(target)->last_break; | |
1002 | } else { | |
1003 | unsigned long __user *u = ubuf; | |
1004 | if (__put_user(task_thread_info(target)->last_break, u)) | |
1005 | return -EFAULT; | |
1006 | } | |
1007 | } | |
1008 | return 0; | |
1009 | } | |
1010 | ||
b934069c MS |
1011 | static int s390_last_break_set(struct task_struct *target, |
1012 | const struct user_regset *regset, | |
1013 | unsigned int pos, unsigned int count, | |
1014 | const void *kbuf, const void __user *ubuf) | |
1015 | { | |
1016 | return 0; | |
1017 | } | |
1018 | ||
d35339a4 MS |
1019 | static int s390_tdb_get(struct task_struct *target, |
1020 | const struct user_regset *regset, | |
1021 | unsigned int pos, unsigned int count, | |
1022 | void *kbuf, void __user *ubuf) | |
1023 | { | |
1024 | struct pt_regs *regs = task_pt_regs(target); | |
1025 | unsigned char *data; | |
1026 | ||
1027 | if (!(regs->int_code & 0x200)) | |
1028 | return -ENODATA; | |
1029 | data = target->thread.trap_tdb; | |
1030 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, data, 0, 256); | |
1031 | } | |
1032 | ||
1033 | static int s390_tdb_set(struct task_struct *target, | |
1034 | const struct user_regset *regset, | |
1035 | unsigned int pos, unsigned int count, | |
1036 | const void *kbuf, const void __user *ubuf) | |
1037 | { | |
1038 | return 0; | |
1039 | } | |
1040 | ||
80703617 MS |
1041 | static int s390_vxrs_active(struct task_struct *target, |
1042 | const struct user_regset *regset) | |
1043 | { | |
1044 | return !!target->thread.vxrs; | |
1045 | } | |
1046 | ||
1047 | static int s390_vxrs_low_get(struct task_struct *target, | |
1048 | const struct user_regset *regset, | |
1049 | unsigned int pos, unsigned int count, | |
1050 | void *kbuf, void __user *ubuf) | |
1051 | { | |
1052 | __u64 vxrs[__NUM_VXRS_LOW]; | |
1053 | int i; | |
1054 | ||
1055 | if (target->thread.vxrs) { | |
1056 | if (target == current) | |
1057 | save_vx_regs(target->thread.vxrs); | |
1058 | for (i = 0; i < __NUM_VXRS_LOW; i++) | |
1059 | vxrs[i] = *((__u64 *)(target->thread.vxrs + i) + 1); | |
1060 | } else | |
1061 | memset(vxrs, 0, sizeof(vxrs)); | |
1062 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1); | |
1063 | } | |
1064 | ||
1065 | static int s390_vxrs_low_set(struct task_struct *target, | |
1066 | const struct user_regset *regset, | |
1067 | unsigned int pos, unsigned int count, | |
1068 | const void *kbuf, const void __user *ubuf) | |
1069 | { | |
1070 | __u64 vxrs[__NUM_VXRS_LOW]; | |
1071 | int i, rc; | |
1072 | ||
1073 | if (!target->thread.vxrs) { | |
1074 | rc = alloc_vector_registers(target); | |
1075 | if (rc) | |
1076 | return rc; | |
1077 | } else if (target == current) | |
1078 | save_vx_regs(target->thread.vxrs); | |
1079 | ||
1080 | rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1); | |
1081 | if (rc == 0) { | |
1082 | for (i = 0; i < __NUM_VXRS_LOW; i++) | |
1083 | *((__u64 *)(target->thread.vxrs + i) + 1) = vxrs[i]; | |
1084 | if (target == current) | |
1085 | restore_vx_regs(target->thread.vxrs); | |
1086 | } | |
1087 | ||
1088 | return rc; | |
1089 | } | |
1090 | ||
1091 | static int s390_vxrs_high_get(struct task_struct *target, | |
1092 | const struct user_regset *regset, | |
1093 | unsigned int pos, unsigned int count, | |
1094 | void *kbuf, void __user *ubuf) | |
1095 | { | |
1096 | __vector128 vxrs[__NUM_VXRS_HIGH]; | |
1097 | ||
1098 | if (target->thread.vxrs) { | |
1099 | if (target == current) | |
1100 | save_vx_regs(target->thread.vxrs); | |
1101 | memcpy(vxrs, target->thread.vxrs + __NUM_VXRS_LOW, | |
1102 | sizeof(vxrs)); | |
1103 | } else | |
1104 | memset(vxrs, 0, sizeof(vxrs)); | |
1105 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1); | |
1106 | } | |
1107 | ||
1108 | static int s390_vxrs_high_set(struct task_struct *target, | |
1109 | const struct user_regset *regset, | |
1110 | unsigned int pos, unsigned int count, | |
1111 | const void *kbuf, const void __user *ubuf) | |
1112 | { | |
1113 | int rc; | |
1114 | ||
1115 | if (!target->thread.vxrs) { | |
1116 | rc = alloc_vector_registers(target); | |
1117 | if (rc) | |
1118 | return rc; | |
1119 | } else if (target == current) | |
1120 | save_vx_regs(target->thread.vxrs); | |
1121 | ||
1122 | rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | |
1123 | target->thread.vxrs + __NUM_VXRS_LOW, 0, -1); | |
1124 | if (rc == 0 && target == current) | |
1125 | restore_vx_regs(target->thread.vxrs); | |
1126 | ||
1127 | return rc; | |
1128 | } | |
1129 | ||
86f2552b MS |
1130 | #endif |
1131 | ||
20b40a79 MS |
1132 | static int s390_system_call_get(struct task_struct *target, |
1133 | const struct user_regset *regset, | |
1134 | unsigned int pos, unsigned int count, | |
1135 | void *kbuf, void __user *ubuf) | |
1136 | { | |
1137 | unsigned int *data = &task_thread_info(target)->system_call; | |
1138 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, | |
1139 | data, 0, sizeof(unsigned int)); | |
1140 | } | |
1141 | ||
1142 | static int s390_system_call_set(struct task_struct *target, | |
1143 | const struct user_regset *regset, | |
1144 | unsigned int pos, unsigned int count, | |
1145 | const void *kbuf, const void __user *ubuf) | |
1146 | { | |
1147 | unsigned int *data = &task_thread_info(target)->system_call; | |
1148 | return user_regset_copyin(&pos, &count, &kbuf, &ubuf, | |
1149 | data, 0, sizeof(unsigned int)); | |
1150 | } | |
1151 | ||
63506c41 | 1152 | static const struct user_regset s390_regsets[] = { |
80703617 | 1153 | { |
63506c41 MS |
1154 | .core_note_type = NT_PRSTATUS, |
1155 | .n = sizeof(s390_regs) / sizeof(long), | |
1156 | .size = sizeof(long), | |
1157 | .align = sizeof(long), | |
1158 | .get = s390_regs_get, | |
1159 | .set = s390_regs_set, | |
1160 | }, | |
80703617 | 1161 | { |
63506c41 MS |
1162 | .core_note_type = NT_PRFPREG, |
1163 | .n = sizeof(s390_fp_regs) / sizeof(long), | |
1164 | .size = sizeof(long), | |
1165 | .align = sizeof(long), | |
1166 | .get = s390_fpregs_get, | |
1167 | .set = s390_fpregs_set, | |
1168 | }, | |
80703617 MS |
1169 | { |
1170 | .core_note_type = NT_S390_SYSTEM_CALL, | |
1171 | .n = 1, | |
1172 | .size = sizeof(unsigned int), | |
1173 | .align = sizeof(unsigned int), | |
1174 | .get = s390_system_call_get, | |
1175 | .set = s390_system_call_set, | |
1176 | }, | |
86f2552b | 1177 | #ifdef CONFIG_64BIT |
80703617 | 1178 | { |
86f2552b MS |
1179 | .core_note_type = NT_S390_LAST_BREAK, |
1180 | .n = 1, | |
1181 | .size = sizeof(long), | |
1182 | .align = sizeof(long), | |
1183 | .get = s390_last_break_get, | |
b934069c | 1184 | .set = s390_last_break_set, |
86f2552b | 1185 | }, |
80703617 | 1186 | { |
d35339a4 MS |
1187 | .core_note_type = NT_S390_TDB, |
1188 | .n = 1, | |
1189 | .size = 256, | |
1190 | .align = 1, | |
1191 | .get = s390_tdb_get, | |
1192 | .set = s390_tdb_set, | |
1193 | }, | |
80703617 MS |
1194 | { |
1195 | .core_note_type = NT_S390_VXRS_LOW, | |
1196 | .n = __NUM_VXRS_LOW, | |
1197 | .size = sizeof(__u64), | |
1198 | .align = sizeof(__u64), | |
1199 | .active = s390_vxrs_active, | |
1200 | .get = s390_vxrs_low_get, | |
1201 | .set = s390_vxrs_low_set, | |
20b40a79 | 1202 | }, |
80703617 MS |
1203 | { |
1204 | .core_note_type = NT_S390_VXRS_HIGH, | |
1205 | .n = __NUM_VXRS_HIGH, | |
1206 | .size = sizeof(__vector128), | |
1207 | .align = sizeof(__vector128), | |
1208 | .active = s390_vxrs_active, | |
1209 | .get = s390_vxrs_high_get, | |
1210 | .set = s390_vxrs_high_set, | |
20b40a79 | 1211 | }, |
80703617 | 1212 | #endif |
63506c41 MS |
1213 | }; |
1214 | ||
1215 | static const struct user_regset_view user_s390_view = { | |
1216 | .name = UTS_MACHINE, | |
1217 | .e_machine = EM_S390, | |
1218 | .regsets = s390_regsets, | |
1219 | .n = ARRAY_SIZE(s390_regsets) | |
1220 | }; | |
1221 | ||
1222 | #ifdef CONFIG_COMPAT | |
1223 | static int s390_compat_regs_get(struct task_struct *target, | |
1224 | const struct user_regset *regset, | |
1225 | unsigned int pos, unsigned int count, | |
1226 | void *kbuf, void __user *ubuf) | |
1227 | { | |
1228 | if (target == current) | |
1229 | save_access_regs(target->thread.acrs); | |
1230 | ||
1231 | if (kbuf) { | |
1232 | compat_ulong_t *k = kbuf; | |
1233 | while (count > 0) { | |
1234 | *k++ = __peek_user_compat(target, pos); | |
1235 | count -= sizeof(*k); | |
1236 | pos += sizeof(*k); | |
1237 | } | |
1238 | } else { | |
1239 | compat_ulong_t __user *u = ubuf; | |
1240 | while (count > 0) { | |
1241 | if (__put_user(__peek_user_compat(target, pos), u++)) | |
1242 | return -EFAULT; | |
1243 | count -= sizeof(*u); | |
1244 | pos += sizeof(*u); | |
1245 | } | |
1246 | } | |
1247 | return 0; | |
1248 | } | |
1249 | ||
1250 | static int s390_compat_regs_set(struct task_struct *target, | |
1251 | const struct user_regset *regset, | |
1252 | unsigned int pos, unsigned int count, | |
1253 | const void *kbuf, const void __user *ubuf) | |
1254 | { | |
1255 | int rc = 0; | |
1256 | ||
1257 | if (target == current) | |
1258 | save_access_regs(target->thread.acrs); | |
1259 | ||
1260 | if (kbuf) { | |
1261 | const compat_ulong_t *k = kbuf; | |
1262 | while (count > 0 && !rc) { | |
1263 | rc = __poke_user_compat(target, pos, *k++); | |
1264 | count -= sizeof(*k); | |
1265 | pos += sizeof(*k); | |
1266 | } | |
1267 | } else { | |
1268 | const compat_ulong_t __user *u = ubuf; | |
1269 | while (count > 0 && !rc) { | |
1270 | compat_ulong_t word; | |
1271 | rc = __get_user(word, u++); | |
1272 | if (rc) | |
1273 | break; | |
1274 | rc = __poke_user_compat(target, pos, word); | |
1275 | count -= sizeof(*u); | |
1276 | pos += sizeof(*u); | |
1277 | } | |
1278 | } | |
1279 | ||
1280 | if (rc == 0 && target == current) | |
1281 | restore_access_regs(target->thread.acrs); | |
1282 | ||
1283 | return rc; | |
1284 | } | |
1285 | ||
ea2a4d3a HC |
1286 | static int s390_compat_regs_high_get(struct task_struct *target, |
1287 | const struct user_regset *regset, | |
1288 | unsigned int pos, unsigned int count, | |
1289 | void *kbuf, void __user *ubuf) | |
1290 | { | |
1291 | compat_ulong_t *gprs_high; | |
1292 | ||
1293 | gprs_high = (compat_ulong_t *) | |
1294 | &task_pt_regs(target)->gprs[pos / sizeof(compat_ulong_t)]; | |
1295 | if (kbuf) { | |
1296 | compat_ulong_t *k = kbuf; | |
1297 | while (count > 0) { | |
1298 | *k++ = *gprs_high; | |
1299 | gprs_high += 2; | |
1300 | count -= sizeof(*k); | |
1301 | } | |
1302 | } else { | |
1303 | compat_ulong_t __user *u = ubuf; | |
1304 | while (count > 0) { | |
1305 | if (__put_user(*gprs_high, u++)) | |
1306 | return -EFAULT; | |
1307 | gprs_high += 2; | |
1308 | count -= sizeof(*u); | |
1309 | } | |
1310 | } | |
1311 | return 0; | |
1312 | } | |
1313 | ||
1314 | static int s390_compat_regs_high_set(struct task_struct *target, | |
1315 | const struct user_regset *regset, | |
1316 | unsigned int pos, unsigned int count, | |
1317 | const void *kbuf, const void __user *ubuf) | |
1318 | { | |
1319 | compat_ulong_t *gprs_high; | |
1320 | int rc = 0; | |
1321 | ||
1322 | gprs_high = (compat_ulong_t *) | |
1323 | &task_pt_regs(target)->gprs[pos / sizeof(compat_ulong_t)]; | |
1324 | if (kbuf) { | |
1325 | const compat_ulong_t *k = kbuf; | |
1326 | while (count > 0) { | |
1327 | *gprs_high = *k++; | |
1328 | *gprs_high += 2; | |
1329 | count -= sizeof(*k); | |
1330 | } | |
1331 | } else { | |
1332 | const compat_ulong_t __user *u = ubuf; | |
1333 | while (count > 0 && !rc) { | |
1334 | unsigned long word; | |
1335 | rc = __get_user(word, u++); | |
1336 | if (rc) | |
1337 | break; | |
1338 | *gprs_high = word; | |
1339 | *gprs_high += 2; | |
1340 | count -= sizeof(*u); | |
1341 | } | |
1342 | } | |
1343 | ||
1344 | return rc; | |
1345 | } | |
1346 | ||
86f2552b MS |
1347 | static int s390_compat_last_break_get(struct task_struct *target, |
1348 | const struct user_regset *regset, | |
1349 | unsigned int pos, unsigned int count, | |
1350 | void *kbuf, void __user *ubuf) | |
1351 | { | |
1352 | compat_ulong_t last_break; | |
1353 | ||
1354 | if (count > 0) { | |
1355 | last_break = task_thread_info(target)->last_break; | |
1356 | if (kbuf) { | |
1357 | unsigned long *k = kbuf; | |
1358 | *k = last_break; | |
1359 | } else { | |
1360 | unsigned long __user *u = ubuf; | |
1361 | if (__put_user(last_break, u)) | |
1362 | return -EFAULT; | |
1363 | } | |
1364 | } | |
1365 | return 0; | |
1366 | } | |
1367 | ||
b934069c MS |
1368 | static int s390_compat_last_break_set(struct task_struct *target, |
1369 | const struct user_regset *regset, | |
1370 | unsigned int pos, unsigned int count, | |
1371 | const void *kbuf, const void __user *ubuf) | |
1372 | { | |
1373 | return 0; | |
1374 | } | |
1375 | ||
63506c41 | 1376 | static const struct user_regset s390_compat_regsets[] = { |
80703617 | 1377 | { |
63506c41 MS |
1378 | .core_note_type = NT_PRSTATUS, |
1379 | .n = sizeof(s390_compat_regs) / sizeof(compat_long_t), | |
1380 | .size = sizeof(compat_long_t), | |
1381 | .align = sizeof(compat_long_t), | |
1382 | .get = s390_compat_regs_get, | |
1383 | .set = s390_compat_regs_set, | |
1384 | }, | |
80703617 | 1385 | { |
63506c41 MS |
1386 | .core_note_type = NT_PRFPREG, |
1387 | .n = sizeof(s390_fp_regs) / sizeof(compat_long_t), | |
1388 | .size = sizeof(compat_long_t), | |
1389 | .align = sizeof(compat_long_t), | |
1390 | .get = s390_fpregs_get, | |
1391 | .set = s390_fpregs_set, | |
1392 | }, | |
80703617 MS |
1393 | { |
1394 | .core_note_type = NT_S390_SYSTEM_CALL, | |
1395 | .n = 1, | |
1396 | .size = sizeof(compat_uint_t), | |
1397 | .align = sizeof(compat_uint_t), | |
1398 | .get = s390_system_call_get, | |
1399 | .set = s390_system_call_set, | |
1400 | }, | |
1401 | { | |
86f2552b MS |
1402 | .core_note_type = NT_S390_LAST_BREAK, |
1403 | .n = 1, | |
1404 | .size = sizeof(long), | |
1405 | .align = sizeof(long), | |
1406 | .get = s390_compat_last_break_get, | |
b934069c | 1407 | .set = s390_compat_last_break_set, |
86f2552b | 1408 | }, |
80703617 | 1409 | { |
d35339a4 MS |
1410 | .core_note_type = NT_S390_TDB, |
1411 | .n = 1, | |
1412 | .size = 256, | |
1413 | .align = 1, | |
1414 | .get = s390_tdb_get, | |
1415 | .set = s390_tdb_set, | |
1416 | }, | |
80703617 MS |
1417 | { |
1418 | .core_note_type = NT_S390_VXRS_LOW, | |
1419 | .n = __NUM_VXRS_LOW, | |
1420 | .size = sizeof(__u64), | |
1421 | .align = sizeof(__u64), | |
1422 | .active = s390_vxrs_active, | |
1423 | .get = s390_vxrs_low_get, | |
1424 | .set = s390_vxrs_low_set, | |
1425 | }, | |
1426 | { | |
1427 | .core_note_type = NT_S390_VXRS_HIGH, | |
1428 | .n = __NUM_VXRS_HIGH, | |
1429 | .size = sizeof(__vector128), | |
1430 | .align = sizeof(__vector128), | |
1431 | .active = s390_vxrs_active, | |
1432 | .get = s390_vxrs_high_get, | |
1433 | .set = s390_vxrs_high_set, | |
20b40a79 | 1434 | }, |
80703617 | 1435 | { |
622e99bf | 1436 | .core_note_type = NT_S390_HIGH_GPRS, |
ea2a4d3a HC |
1437 | .n = sizeof(s390_compat_regs_high) / sizeof(compat_long_t), |
1438 | .size = sizeof(compat_long_t), | |
1439 | .align = sizeof(compat_long_t), | |
1440 | .get = s390_compat_regs_high_get, | |
1441 | .set = s390_compat_regs_high_set, | |
1442 | }, | |
63506c41 MS |
1443 | }; |
1444 | ||
1445 | static const struct user_regset_view user_s390_compat_view = { | |
1446 | .name = "s390", | |
1447 | .e_machine = EM_S390, | |
1448 | .regsets = s390_compat_regsets, | |
1449 | .n = ARRAY_SIZE(s390_compat_regsets) | |
1450 | }; | |
1451 | #endif | |
1452 | ||
1453 | const struct user_regset_view *task_user_regset_view(struct task_struct *task) | |
1454 | { | |
1455 | #ifdef CONFIG_COMPAT | |
1456 | if (test_tsk_thread_flag(task, TIF_31BIT)) | |
1457 | return &user_s390_compat_view; | |
1458 | #endif | |
1459 | return &user_s390_view; | |
1460 | } | |
952974ac HC |
1461 | |
1462 | static const char *gpr_names[NUM_GPRS] = { | |
1463 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
1464 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", | |
1465 | }; | |
1466 | ||
1467 | unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset) | |
1468 | { | |
1469 | if (offset >= NUM_GPRS) | |
1470 | return 0; | |
1471 | return regs->gprs[offset]; | |
1472 | } | |
1473 | ||
1474 | int regs_query_register_offset(const char *name) | |
1475 | { | |
1476 | unsigned long offset; | |
1477 | ||
1478 | if (!name || *name != 'r') | |
1479 | return -EINVAL; | |
958d9072 | 1480 | if (kstrtoul(name + 1, 10, &offset)) |
952974ac HC |
1481 | return -EINVAL; |
1482 | if (offset >= NUM_GPRS) | |
1483 | return -EINVAL; | |
1484 | return offset; | |
1485 | } | |
1486 | ||
1487 | const char *regs_query_register_name(unsigned int offset) | |
1488 | { | |
1489 | if (offset >= NUM_GPRS) | |
1490 | return NULL; | |
1491 | return gpr_names[offset]; | |
1492 | } | |
1493 | ||
1494 | static int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr) | |
1495 | { | |
1496 | unsigned long ksp = kernel_stack_pointer(regs); | |
1497 | ||
1498 | return (addr & ~(THREAD_SIZE - 1)) == (ksp & ~(THREAD_SIZE - 1)); | |
1499 | } | |
1500 | ||
1501 | /** | |
1502 | * regs_get_kernel_stack_nth() - get Nth entry of the stack | |
1503 | * @regs:pt_regs which contains kernel stack pointer. | |
1504 | * @n:stack entry number. | |
1505 | * | |
1506 | * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which | |
1507 | * is specifined by @regs. If the @n th entry is NOT in the kernel stack, | |
1508 | * this returns 0. | |
1509 | */ | |
1510 | unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n) | |
1511 | { | |
1512 | unsigned long addr; | |
1513 | ||
1514 | addr = kernel_stack_pointer(regs) + n * sizeof(long); | |
1515 | if (!regs_within_kernel_stack(regs, addr)) | |
1516 | return 0; | |
1517 | return *(unsigned long *)addr; | |
1518 | } |