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