2 * Ptrace user space interface.
4 * Copyright IBM Corp. 1999, 2010
5 * Author(s): Denis Joseph Barrow
6 * Martin Schwidefsky (schwidefsky@de.ibm.com)
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/sched/task_stack.h>
13 #include <linux/smp.h>
14 #include <linux/errno.h>
15 #include <linux/ptrace.h>
16 #include <linux/user.h>
17 #include <linux/security.h>
18 #include <linux/audit.h>
19 #include <linux/signal.h>
20 #include <linux/elf.h>
21 #include <linux/regset.h>
22 #include <linux/tracehook.h>
23 #include <linux/seccomp.h>
24 #include <linux/compat.h>
25 #include <trace/syscall.h>
26 #include <asm/segment.h>
28 #include <asm/pgtable.h>
29 #include <asm/pgalloc.h>
30 #include <linux/uaccess.h>
31 #include <asm/unistd.h>
32 #include <asm/switch_to.h>
36 #include "compat_ptrace.h"
39 #define CREATE_TRACE_POINTS
40 #include <trace/events/syscalls.h>
42 void update_cr_regs(struct task_struct
*task
)
44 struct pt_regs
*regs
= task_pt_regs(task
);
45 struct thread_struct
*thread
= &task
->thread
;
46 struct per_regs old
, new;
48 /* Take care of the enable/disable of transactional execution. */
50 unsigned long cr
, cr_new
;
52 __ctl_store(cr
, 0, 0);
53 /* Set or clear transaction execution TXC bit 8. */
54 cr_new
= cr
| (1UL << 55);
55 if (task
->thread
.per_flags
& PER_FLAG_NO_TE
)
56 cr_new
&= ~(1UL << 55);
58 __ctl_load(cr_new
, 0, 0);
59 /* Set or clear transaction execution TDC bits 62 and 63. */
60 __ctl_store(cr
, 2, 2);
62 if (task
->thread
.per_flags
& PER_FLAG_TE_ABORT_RAND
) {
63 if (task
->thread
.per_flags
& PER_FLAG_TE_ABORT_RAND_TEND
)
69 __ctl_load(cr_new
, 2, 2);
71 /* Copy user specified PER registers */
72 new.control
= thread
->per_user
.control
;
73 new.start
= thread
->per_user
.start
;
74 new.end
= thread
->per_user
.end
;
76 /* merge TIF_SINGLE_STEP into user specified PER registers. */
77 if (test_tsk_thread_flag(task
, TIF_SINGLE_STEP
) ||
78 test_tsk_thread_flag(task
, TIF_UPROBE_SINGLESTEP
)) {
79 if (test_tsk_thread_flag(task
, TIF_BLOCK_STEP
))
80 new.control
|= PER_EVENT_BRANCH
;
82 new.control
|= PER_EVENT_IFETCH
;
83 new.control
|= PER_CONTROL_SUSPENSION
;
84 new.control
|= PER_EVENT_TRANSACTION_END
;
85 if (test_tsk_thread_flag(task
, TIF_UPROBE_SINGLESTEP
))
86 new.control
|= PER_EVENT_IFETCH
;
91 /* Take care of the PER enablement bit in the PSW. */
92 if (!(new.control
& PER_EVENT_MASK
)) {
93 regs
->psw
.mask
&= ~PSW_MASK_PER
;
96 regs
->psw
.mask
|= PSW_MASK_PER
;
97 __ctl_store(old
, 9, 11);
98 if (memcmp(&new, &old
, sizeof(struct per_regs
)) != 0)
99 __ctl_load(new, 9, 11);
102 void user_enable_single_step(struct task_struct
*task
)
104 clear_tsk_thread_flag(task
, TIF_BLOCK_STEP
);
105 set_tsk_thread_flag(task
, TIF_SINGLE_STEP
);
108 void user_disable_single_step(struct task_struct
*task
)
110 clear_tsk_thread_flag(task
, TIF_BLOCK_STEP
);
111 clear_tsk_thread_flag(task
, TIF_SINGLE_STEP
);
114 void user_enable_block_step(struct task_struct
*task
)
116 set_tsk_thread_flag(task
, TIF_SINGLE_STEP
);
117 set_tsk_thread_flag(task
, TIF_BLOCK_STEP
);
121 * Called by kernel/ptrace.c when detaching..
123 * Clear all debugging related fields.
125 void ptrace_disable(struct task_struct
*task
)
127 memset(&task
->thread
.per_user
, 0, sizeof(task
->thread
.per_user
));
128 memset(&task
->thread
.per_event
, 0, sizeof(task
->thread
.per_event
));
129 clear_tsk_thread_flag(task
, TIF_SINGLE_STEP
);
130 clear_pt_regs_flag(task_pt_regs(task
), PIF_PER_TRAP
);
131 task
->thread
.per_flags
= 0;
134 #define __ADDR_MASK 7
136 static inline unsigned long __peek_user_per(struct task_struct
*child
,
139 struct per_struct_kernel
*dummy
= NULL
;
141 if (addr
== (addr_t
) &dummy
->cr9
)
142 /* Control bits of the active per set. */
143 return test_thread_flag(TIF_SINGLE_STEP
) ?
144 PER_EVENT_IFETCH
: child
->thread
.per_user
.control
;
145 else if (addr
== (addr_t
) &dummy
->cr10
)
146 /* Start address of the active per set. */
147 return test_thread_flag(TIF_SINGLE_STEP
) ?
148 0 : child
->thread
.per_user
.start
;
149 else if (addr
== (addr_t
) &dummy
->cr11
)
150 /* End address of the active per set. */
151 return test_thread_flag(TIF_SINGLE_STEP
) ?
152 -1UL : child
->thread
.per_user
.end
;
153 else if (addr
== (addr_t
) &dummy
->bits
)
154 /* Single-step bit. */
155 return test_thread_flag(TIF_SINGLE_STEP
) ?
156 (1UL << (BITS_PER_LONG
- 1)) : 0;
157 else if (addr
== (addr_t
) &dummy
->starting_addr
)
158 /* Start address of the user specified per set. */
159 return child
->thread
.per_user
.start
;
160 else if (addr
== (addr_t
) &dummy
->ending_addr
)
161 /* End address of the user specified per set. */
162 return child
->thread
.per_user
.end
;
163 else if (addr
== (addr_t
) &dummy
->perc_atmid
)
164 /* PER code, ATMID and AI of the last PER trap */
165 return (unsigned long)
166 child
->thread
.per_event
.cause
<< (BITS_PER_LONG
- 16);
167 else if (addr
== (addr_t
) &dummy
->address
)
168 /* Address of the last PER trap */
169 return child
->thread
.per_event
.address
;
170 else if (addr
== (addr_t
) &dummy
->access_id
)
171 /* Access id of the last PER trap */
172 return (unsigned long)
173 child
->thread
.per_event
.paid
<< (BITS_PER_LONG
- 8);
178 * Read the word at offset addr from the user area of a process. The
179 * trouble here is that the information is littered over different
180 * locations. The process registers are found on the kernel stack,
181 * the floating point stuff and the trace settings are stored in
182 * the task structure. In addition the different structures in
183 * struct user contain pad bytes that should be read as zeroes.
186 static unsigned long __peek_user(struct task_struct
*child
, addr_t addr
)
188 struct user
*dummy
= NULL
;
191 if (addr
< (addr_t
) &dummy
->regs
.acrs
) {
193 * psw and gprs are stored on the stack
195 tmp
= *(addr_t
*)((addr_t
) &task_pt_regs(child
)->psw
+ addr
);
196 if (addr
== (addr_t
) &dummy
->regs
.psw
.mask
) {
197 /* Return a clean psw mask. */
198 tmp
&= PSW_MASK_USER
| PSW_MASK_RI
;
199 tmp
|= PSW_USER_BITS
;
202 } else if (addr
< (addr_t
) &dummy
->regs
.orig_gpr2
) {
204 * access registers are stored in the thread structure
206 offset
= addr
- (addr_t
) &dummy
->regs
.acrs
;
208 * Very special case: old & broken 64 bit gdb reading
209 * from acrs[15]. Result is a 64 bit value. Read the
210 * 32 bit acrs[15] value and shift it by 32. Sick...
212 if (addr
== (addr_t
) &dummy
->regs
.acrs
[15])
213 tmp
= ((unsigned long) child
->thread
.acrs
[15]) << 32;
215 tmp
= *(addr_t
*)((addr_t
) &child
->thread
.acrs
+ offset
);
217 } else if (addr
== (addr_t
) &dummy
->regs
.orig_gpr2
) {
219 * orig_gpr2 is stored on the kernel stack
221 tmp
= (addr_t
) task_pt_regs(child
)->orig_gpr2
;
223 } else if (addr
< (addr_t
) &dummy
->regs
.fp_regs
) {
225 * prevent reads of padding hole between
226 * orig_gpr2 and fp_regs on s390.
230 } else if (addr
== (addr_t
) &dummy
->regs
.fp_regs
.fpc
) {
232 * floating point control reg. is in the thread structure
234 tmp
= child
->thread
.fpu
.fpc
;
235 tmp
<<= BITS_PER_LONG
- 32;
237 } else if (addr
< (addr_t
) (&dummy
->regs
.fp_regs
+ 1)) {
239 * floating point regs. are either in child->thread.fpu
240 * or the child->thread.fpu.vxrs array
242 offset
= addr
- (addr_t
) &dummy
->regs
.fp_regs
.fprs
;
245 ((addr_t
) child
->thread
.fpu
.vxrs
+ 2*offset
);
248 ((addr_t
) child
->thread
.fpu
.fprs
+ offset
);
250 } else if (addr
< (addr_t
) (&dummy
->regs
.per_info
+ 1)) {
252 * Handle access to the per_info structure.
254 addr
-= (addr_t
) &dummy
->regs
.per_info
;
255 tmp
= __peek_user_per(child
, addr
);
264 peek_user(struct task_struct
*child
, addr_t addr
, addr_t data
)
269 * Stupid gdb peeks/pokes the access registers in 64 bit with
270 * an alignment of 4. Programmers from hell...
273 if (addr
>= (addr_t
) &((struct user
*) NULL
)->regs
.acrs
&&
274 addr
< (addr_t
) &((struct user
*) NULL
)->regs
.orig_gpr2
)
276 if ((addr
& mask
) || addr
> sizeof(struct user
) - __ADDR_MASK
)
279 tmp
= __peek_user(child
, addr
);
280 return put_user(tmp
, (addr_t __user
*) data
);
283 static inline void __poke_user_per(struct task_struct
*child
,
284 addr_t addr
, addr_t data
)
286 struct per_struct_kernel
*dummy
= NULL
;
289 * There are only three fields in the per_info struct that the
290 * debugger user can write to.
291 * 1) cr9: the debugger wants to set a new PER event mask
292 * 2) starting_addr: the debugger wants to set a new starting
293 * address to use with the PER event mask.
294 * 3) ending_addr: the debugger wants to set a new ending
295 * address to use with the PER event mask.
296 * The user specified PER event mask and the start and end
297 * addresses are used only if single stepping is not in effect.
298 * Writes to any other field in per_info are ignored.
300 if (addr
== (addr_t
) &dummy
->cr9
)
301 /* PER event mask of the user specified per set. */
302 child
->thread
.per_user
.control
=
303 data
& (PER_EVENT_MASK
| PER_CONTROL_MASK
);
304 else if (addr
== (addr_t
) &dummy
->starting_addr
)
305 /* Starting address of the user specified per set. */
306 child
->thread
.per_user
.start
= data
;
307 else if (addr
== (addr_t
) &dummy
->ending_addr
)
308 /* Ending address of the user specified per set. */
309 child
->thread
.per_user
.end
= data
;
313 * Write a word to the user area of a process at location addr. This
314 * operation does have an additional problem compared to peek_user.
315 * Stores to the program status word and on the floating point
316 * control register needs to get checked for validity.
318 static int __poke_user(struct task_struct
*child
, addr_t addr
, addr_t data
)
320 struct user
*dummy
= NULL
;
323 if (addr
< (addr_t
) &dummy
->regs
.acrs
) {
325 * psw and gprs are stored on the stack
327 if (addr
== (addr_t
) &dummy
->regs
.psw
.mask
) {
328 unsigned long mask
= PSW_MASK_USER
;
330 mask
|= is_ri_task(child
) ? PSW_MASK_RI
: 0;
331 if ((data
^ PSW_USER_BITS
) & ~mask
)
332 /* Invalid psw mask. */
334 if ((data
& PSW_MASK_ASC
) == PSW_ASC_HOME
)
335 /* Invalid address-space-control bits */
337 if ((data
& PSW_MASK_EA
) && !(data
& PSW_MASK_BA
))
338 /* Invalid addressing mode bits */
341 *(addr_t
*)((addr_t
) &task_pt_regs(child
)->psw
+ addr
) = data
;
343 } else if (addr
< (addr_t
) (&dummy
->regs
.orig_gpr2
)) {
345 * access registers are stored in the thread structure
347 offset
= addr
- (addr_t
) &dummy
->regs
.acrs
;
349 * Very special case: old & broken 64 bit gdb writing
350 * to acrs[15] with a 64 bit value. Ignore the lower
351 * half of the value and write the upper 32 bit to
354 if (addr
== (addr_t
) &dummy
->regs
.acrs
[15])
355 child
->thread
.acrs
[15] = (unsigned int) (data
>> 32);
357 *(addr_t
*)((addr_t
) &child
->thread
.acrs
+ offset
) = data
;
359 } else if (addr
== (addr_t
) &dummy
->regs
.orig_gpr2
) {
361 * orig_gpr2 is stored on the kernel stack
363 task_pt_regs(child
)->orig_gpr2
= data
;
365 } else if (addr
< (addr_t
) &dummy
->regs
.fp_regs
) {
367 * prevent writes of padding hole between
368 * orig_gpr2 and fp_regs on s390.
372 } else if (addr
== (addr_t
) &dummy
->regs
.fp_regs
.fpc
) {
374 * floating point control reg. is in the thread structure
376 if ((unsigned int) data
!= 0 ||
377 test_fp_ctl(data
>> (BITS_PER_LONG
- 32)))
379 child
->thread
.fpu
.fpc
= data
>> (BITS_PER_LONG
- 32);
381 } else if (addr
< (addr_t
) (&dummy
->regs
.fp_regs
+ 1)) {
383 * floating point regs. are either in child->thread.fpu
384 * or the child->thread.fpu.vxrs array
386 offset
= addr
- (addr_t
) &dummy
->regs
.fp_regs
.fprs
;
389 child
->thread
.fpu
.vxrs
+ 2*offset
) = data
;
392 child
->thread
.fpu
.fprs
+ offset
) = data
;
394 } else if (addr
< (addr_t
) (&dummy
->regs
.per_info
+ 1)) {
396 * Handle access to the per_info structure.
398 addr
-= (addr_t
) &dummy
->regs
.per_info
;
399 __poke_user_per(child
, addr
, data
);
406 static int poke_user(struct task_struct
*child
, addr_t addr
, addr_t data
)
411 * Stupid gdb peeks/pokes the access registers in 64 bit with
412 * an alignment of 4. Programmers from hell indeed...
415 if (addr
>= (addr_t
) &((struct user
*) NULL
)->regs
.acrs
&&
416 addr
< (addr_t
) &((struct user
*) NULL
)->regs
.orig_gpr2
)
418 if ((addr
& mask
) || addr
> sizeof(struct user
) - __ADDR_MASK
)
421 return __poke_user(child
, addr
, data
);
424 long arch_ptrace(struct task_struct
*child
, long request
,
425 unsigned long addr
, unsigned long data
)
432 /* read the word at location addr in the USER area. */
433 return peek_user(child
, addr
, data
);
436 /* write the word at location addr in the USER area */
437 return poke_user(child
, addr
, data
);
439 case PTRACE_PEEKUSR_AREA
:
440 case PTRACE_POKEUSR_AREA
:
441 if (copy_from_user(&parea
, (void __force __user
*) addr
,
444 addr
= parea
.kernel_addr
;
445 data
= parea
.process_addr
;
447 while (copied
< parea
.len
) {
448 if (request
== PTRACE_PEEKUSR_AREA
)
449 ret
= peek_user(child
, addr
, data
);
453 (addr_t __force __user
*) data
))
455 ret
= poke_user(child
, addr
, utmp
);
459 addr
+= sizeof(unsigned long);
460 data
+= sizeof(unsigned long);
461 copied
+= sizeof(unsigned long);
464 case PTRACE_GET_LAST_BREAK
:
465 put_user(child
->thread
.last_break
,
466 (unsigned long __user
*) data
);
468 case PTRACE_ENABLE_TE
:
471 child
->thread
.per_flags
&= ~PER_FLAG_NO_TE
;
473 case PTRACE_DISABLE_TE
:
476 child
->thread
.per_flags
|= PER_FLAG_NO_TE
;
477 child
->thread
.per_flags
&= ~PER_FLAG_TE_ABORT_RAND
;
479 case PTRACE_TE_ABORT_RAND
:
480 if (!MACHINE_HAS_TE
|| (child
->thread
.per_flags
& PER_FLAG_NO_TE
))
484 child
->thread
.per_flags
&= ~PER_FLAG_TE_ABORT_RAND
;
487 child
->thread
.per_flags
|= PER_FLAG_TE_ABORT_RAND
;
488 child
->thread
.per_flags
|= PER_FLAG_TE_ABORT_RAND_TEND
;
491 child
->thread
.per_flags
|= PER_FLAG_TE_ABORT_RAND
;
492 child
->thread
.per_flags
&= ~PER_FLAG_TE_ABORT_RAND_TEND
;
499 return ptrace_request(child
, request
, addr
, data
);
505 * Now the fun part starts... a 31 bit program running in the
506 * 31 bit emulation tracing another program. PTRACE_PEEKTEXT,
507 * PTRACE_PEEKDATA, PTRACE_POKETEXT and PTRACE_POKEDATA are easy
508 * to handle, the difference to the 64 bit versions of the requests
509 * is that the access is done in multiples of 4 byte instead of
510 * 8 bytes (sizeof(unsigned long) on 31/64 bit).
511 * The ugly part are PTRACE_PEEKUSR, PTRACE_PEEKUSR_AREA,
512 * PTRACE_POKEUSR and PTRACE_POKEUSR_AREA. If the traced program
513 * is a 31 bit program too, the content of struct user can be
514 * emulated. A 31 bit program peeking into the struct user of
515 * a 64 bit program is a no-no.
519 * Same as peek_user_per but for a 31 bit program.
521 static inline __u32
__peek_user_per_compat(struct task_struct
*child
,
524 struct compat_per_struct_kernel
*dummy32
= NULL
;
526 if (addr
== (addr_t
) &dummy32
->cr9
)
527 /* Control bits of the active per set. */
528 return (__u32
) test_thread_flag(TIF_SINGLE_STEP
) ?
529 PER_EVENT_IFETCH
: child
->thread
.per_user
.control
;
530 else if (addr
== (addr_t
) &dummy32
->cr10
)
531 /* Start address of the active per set. */
532 return (__u32
) test_thread_flag(TIF_SINGLE_STEP
) ?
533 0 : child
->thread
.per_user
.start
;
534 else if (addr
== (addr_t
) &dummy32
->cr11
)
535 /* End address of the active per set. */
536 return test_thread_flag(TIF_SINGLE_STEP
) ?
537 PSW32_ADDR_INSN
: child
->thread
.per_user
.end
;
538 else if (addr
== (addr_t
) &dummy32
->bits
)
539 /* Single-step bit. */
540 return (__u32
) test_thread_flag(TIF_SINGLE_STEP
) ?
542 else if (addr
== (addr_t
) &dummy32
->starting_addr
)
543 /* Start address of the user specified per set. */
544 return (__u32
) child
->thread
.per_user
.start
;
545 else if (addr
== (addr_t
) &dummy32
->ending_addr
)
546 /* End address of the user specified per set. */
547 return (__u32
) child
->thread
.per_user
.end
;
548 else if (addr
== (addr_t
) &dummy32
->perc_atmid
)
549 /* PER code, ATMID and AI of the last PER trap */
550 return (__u32
) child
->thread
.per_event
.cause
<< 16;
551 else if (addr
== (addr_t
) &dummy32
->address
)
552 /* Address of the last PER trap */
553 return (__u32
) child
->thread
.per_event
.address
;
554 else if (addr
== (addr_t
) &dummy32
->access_id
)
555 /* Access id of the last PER trap */
556 return (__u32
) child
->thread
.per_event
.paid
<< 24;
561 * Same as peek_user but for a 31 bit program.
563 static u32
__peek_user_compat(struct task_struct
*child
, addr_t addr
)
565 struct compat_user
*dummy32
= NULL
;
569 if (addr
< (addr_t
) &dummy32
->regs
.acrs
) {
570 struct pt_regs
*regs
= task_pt_regs(child
);
572 * psw and gprs are stored on the stack
574 if (addr
== (addr_t
) &dummy32
->regs
.psw
.mask
) {
575 /* Fake a 31 bit psw mask. */
576 tmp
= (__u32
)(regs
->psw
.mask
>> 32);
577 tmp
&= PSW32_MASK_USER
| PSW32_MASK_RI
;
578 tmp
|= PSW32_USER_BITS
;
579 } else if (addr
== (addr_t
) &dummy32
->regs
.psw
.addr
) {
580 /* Fake a 31 bit psw address. */
581 tmp
= (__u32
) regs
->psw
.addr
|
582 (__u32
)(regs
->psw
.mask
& PSW_MASK_BA
);
585 tmp
= *(__u32
*)((addr_t
) ®s
->psw
+ addr
*2 + 4);
587 } else if (addr
< (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
589 * access registers are stored in the thread structure
591 offset
= addr
- (addr_t
) &dummy32
->regs
.acrs
;
592 tmp
= *(__u32
*)((addr_t
) &child
->thread
.acrs
+ offset
);
594 } else if (addr
== (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
596 * orig_gpr2 is stored on the kernel stack
598 tmp
= *(__u32
*)((addr_t
) &task_pt_regs(child
)->orig_gpr2
+ 4);
600 } else if (addr
< (addr_t
) &dummy32
->regs
.fp_regs
) {
602 * prevent reads of padding hole between
603 * orig_gpr2 and fp_regs on s390.
607 } else if (addr
== (addr_t
) &dummy32
->regs
.fp_regs
.fpc
) {
609 * floating point control reg. is in the thread structure
611 tmp
= child
->thread
.fpu
.fpc
;
613 } else if (addr
< (addr_t
) (&dummy32
->regs
.fp_regs
+ 1)) {
615 * floating point regs. are either in child->thread.fpu
616 * or the child->thread.fpu.vxrs array
618 offset
= addr
- (addr_t
) &dummy32
->regs
.fp_regs
.fprs
;
621 ((addr_t
) child
->thread
.fpu
.vxrs
+ 2*offset
);
624 ((addr_t
) child
->thread
.fpu
.fprs
+ offset
);
626 } else if (addr
< (addr_t
) (&dummy32
->regs
.per_info
+ 1)) {
628 * Handle access to the per_info structure.
630 addr
-= (addr_t
) &dummy32
->regs
.per_info
;
631 tmp
= __peek_user_per_compat(child
, addr
);
639 static int peek_user_compat(struct task_struct
*child
,
640 addr_t addr
, addr_t data
)
644 if (!is_compat_task() || (addr
& 3) || addr
> sizeof(struct user
) - 3)
647 tmp
= __peek_user_compat(child
, addr
);
648 return put_user(tmp
, (__u32 __user
*) data
);
652 * Same as poke_user_per but for a 31 bit program.
654 static inline void __poke_user_per_compat(struct task_struct
*child
,
655 addr_t addr
, __u32 data
)
657 struct compat_per_struct_kernel
*dummy32
= NULL
;
659 if (addr
== (addr_t
) &dummy32
->cr9
)
660 /* PER event mask of the user specified per set. */
661 child
->thread
.per_user
.control
=
662 data
& (PER_EVENT_MASK
| PER_CONTROL_MASK
);
663 else if (addr
== (addr_t
) &dummy32
->starting_addr
)
664 /* Starting address of the user specified per set. */
665 child
->thread
.per_user
.start
= data
;
666 else if (addr
== (addr_t
) &dummy32
->ending_addr
)
667 /* Ending address of the user specified per set. */
668 child
->thread
.per_user
.end
= data
;
672 * Same as poke_user but for a 31 bit program.
674 static int __poke_user_compat(struct task_struct
*child
,
675 addr_t addr
, addr_t data
)
677 struct compat_user
*dummy32
= NULL
;
678 __u32 tmp
= (__u32
) data
;
681 if (addr
< (addr_t
) &dummy32
->regs
.acrs
) {
682 struct pt_regs
*regs
= task_pt_regs(child
);
684 * psw, gprs, acrs and orig_gpr2 are stored on the stack
686 if (addr
== (addr_t
) &dummy32
->regs
.psw
.mask
) {
687 __u32 mask
= PSW32_MASK_USER
;
689 mask
|= is_ri_task(child
) ? PSW32_MASK_RI
: 0;
690 /* Build a 64 bit psw mask from 31 bit mask. */
691 if ((tmp
^ PSW32_USER_BITS
) & ~mask
)
692 /* Invalid psw mask. */
694 if ((data
& PSW32_MASK_ASC
) == PSW32_ASC_HOME
)
695 /* Invalid address-space-control bits */
697 regs
->psw
.mask
= (regs
->psw
.mask
& ~PSW_MASK_USER
) |
698 (regs
->psw
.mask
& PSW_MASK_BA
) |
699 (__u64
)(tmp
& mask
) << 32;
700 } else if (addr
== (addr_t
) &dummy32
->regs
.psw
.addr
) {
701 /* Build a 64 bit psw address from 31 bit address. */
702 regs
->psw
.addr
= (__u64
) tmp
& PSW32_ADDR_INSN
;
703 /* Transfer 31 bit amode bit to psw mask. */
704 regs
->psw
.mask
= (regs
->psw
.mask
& ~PSW_MASK_BA
) |
705 (__u64
)(tmp
& PSW32_ADDR_AMODE
);
708 *(__u32
*)((addr_t
) ®s
->psw
+ addr
*2 + 4) = tmp
;
710 } else if (addr
< (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
712 * access registers are stored in the thread structure
714 offset
= addr
- (addr_t
) &dummy32
->regs
.acrs
;
715 *(__u32
*)((addr_t
) &child
->thread
.acrs
+ offset
) = tmp
;
717 } else if (addr
== (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
719 * orig_gpr2 is stored on the kernel stack
721 *(__u32
*)((addr_t
) &task_pt_regs(child
)->orig_gpr2
+ 4) = tmp
;
723 } else if (addr
< (addr_t
) &dummy32
->regs
.fp_regs
) {
725 * prevent writess of padding hole between
726 * orig_gpr2 and fp_regs on s390.
730 } else if (addr
== (addr_t
) &dummy32
->regs
.fp_regs
.fpc
) {
732 * floating point control reg. is in the thread structure
734 if (test_fp_ctl(tmp
))
736 child
->thread
.fpu
.fpc
= data
;
738 } else if (addr
< (addr_t
) (&dummy32
->regs
.fp_regs
+ 1)) {
740 * floating point regs. are either in child->thread.fpu
741 * or the child->thread.fpu.vxrs array
743 offset
= addr
- (addr_t
) &dummy32
->regs
.fp_regs
.fprs
;
746 child
->thread
.fpu
.vxrs
+ 2*offset
) = tmp
;
749 child
->thread
.fpu
.fprs
+ offset
) = tmp
;
751 } else if (addr
< (addr_t
) (&dummy32
->regs
.per_info
+ 1)) {
753 * Handle access to the per_info structure.
755 addr
-= (addr_t
) &dummy32
->regs
.per_info
;
756 __poke_user_per_compat(child
, addr
, data
);
762 static int poke_user_compat(struct task_struct
*child
,
763 addr_t addr
, addr_t data
)
765 if (!is_compat_task() || (addr
& 3) ||
766 addr
> sizeof(struct compat_user
) - 3)
769 return __poke_user_compat(child
, addr
, data
);
772 long compat_arch_ptrace(struct task_struct
*child
, compat_long_t request
,
773 compat_ulong_t caddr
, compat_ulong_t cdata
)
775 unsigned long addr
= caddr
;
776 unsigned long data
= cdata
;
777 compat_ptrace_area parea
;
782 /* read the word at location addr in the USER area. */
783 return peek_user_compat(child
, addr
, data
);
786 /* write the word at location addr in the USER area */
787 return poke_user_compat(child
, addr
, data
);
789 case PTRACE_PEEKUSR_AREA
:
790 case PTRACE_POKEUSR_AREA
:
791 if (copy_from_user(&parea
, (void __force __user
*) addr
,
794 addr
= parea
.kernel_addr
;
795 data
= parea
.process_addr
;
797 while (copied
< parea
.len
) {
798 if (request
== PTRACE_PEEKUSR_AREA
)
799 ret
= peek_user_compat(child
, addr
, data
);
803 (__u32 __force __user
*) data
))
805 ret
= poke_user_compat(child
, addr
, utmp
);
809 addr
+= sizeof(unsigned int);
810 data
+= sizeof(unsigned int);
811 copied
+= sizeof(unsigned int);
814 case PTRACE_GET_LAST_BREAK
:
815 put_user(child
->thread
.last_break
,
816 (unsigned int __user
*) data
);
819 return compat_ptrace_request(child
, request
, addr
, data
);
823 asmlinkage
long do_syscall_trace_enter(struct pt_regs
*regs
)
825 unsigned long mask
= -1UL;
828 * The sysc_tracesys code in entry.S stored the system
829 * call number to gprs[2].
831 if (test_thread_flag(TIF_SYSCALL_TRACE
) &&
832 (tracehook_report_syscall_entry(regs
) ||
833 regs
->gprs
[2] >= NR_syscalls
)) {
835 * Tracing decided this syscall should not happen or the
836 * debugger stored an invalid system call number. Skip
837 * the system call and the system call restart handling.
839 clear_pt_regs_flag(regs
, PIF_SYSCALL
);
843 /* Do the secure computing check after ptrace. */
844 if (secure_computing(NULL
)) {
845 /* seccomp failures shouldn't expose any additional code. */
849 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT
)))
850 trace_sys_enter(regs
, regs
->gprs
[2]);
852 if (is_compat_task())
855 audit_syscall_entry(regs
->gprs
[2], regs
->orig_gpr2
& mask
,
856 regs
->gprs
[3] &mask
, regs
->gprs
[4] &mask
,
857 regs
->gprs
[5] &mask
);
859 return regs
->gprs
[2];
862 asmlinkage
void do_syscall_trace_exit(struct pt_regs
*regs
)
864 audit_syscall_exit(regs
);
866 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT
)))
867 trace_sys_exit(regs
, regs
->gprs
[2]);
869 if (test_thread_flag(TIF_SYSCALL_TRACE
))
870 tracehook_report_syscall_exit(regs
, 0);
874 * user_regset definitions.
877 static int s390_regs_get(struct task_struct
*target
,
878 const struct user_regset
*regset
,
879 unsigned int pos
, unsigned int count
,
880 void *kbuf
, void __user
*ubuf
)
882 if (target
== current
)
883 save_access_regs(target
->thread
.acrs
);
886 unsigned long *k
= kbuf
;
888 *k
++ = __peek_user(target
, pos
);
893 unsigned long __user
*u
= ubuf
;
895 if (__put_user(__peek_user(target
, pos
), u
++))
904 static int s390_regs_set(struct task_struct
*target
,
905 const struct user_regset
*regset
,
906 unsigned int pos
, unsigned int count
,
907 const void *kbuf
, const void __user
*ubuf
)
911 if (target
== current
)
912 save_access_regs(target
->thread
.acrs
);
915 const unsigned long *k
= kbuf
;
916 while (count
> 0 && !rc
) {
917 rc
= __poke_user(target
, pos
, *k
++);
922 const unsigned long __user
*u
= ubuf
;
923 while (count
> 0 && !rc
) {
925 rc
= __get_user(word
, u
++);
928 rc
= __poke_user(target
, pos
, word
);
934 if (rc
== 0 && target
== current
)
935 restore_access_regs(target
->thread
.acrs
);
940 static int s390_fpregs_get(struct task_struct
*target
,
941 const struct user_regset
*regset
, unsigned int pos
,
942 unsigned int count
, void *kbuf
, void __user
*ubuf
)
944 _s390_fp_regs fp_regs
;
946 if (target
== current
)
949 fp_regs
.fpc
= target
->thread
.fpu
.fpc
;
950 fpregs_store(&fp_regs
, &target
->thread
.fpu
);
952 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
,
956 static int s390_fpregs_set(struct task_struct
*target
,
957 const struct user_regset
*regset
, unsigned int pos
,
958 unsigned int count
, const void *kbuf
,
959 const void __user
*ubuf
)
962 freg_t fprs
[__NUM_FPRS
];
964 if (target
== current
)
968 convert_vx_to_fp(fprs
, target
->thread
.fpu
.vxrs
);
970 memcpy(&fprs
, target
->thread
.fpu
.fprs
, sizeof(fprs
));
972 /* If setting FPC, must validate it first. */
973 if (count
> 0 && pos
< offsetof(s390_fp_regs
, fprs
)) {
974 u32 ufpc
[2] = { target
->thread
.fpu
.fpc
, 0 };
975 rc
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
, &ufpc
,
976 0, offsetof(s390_fp_regs
, fprs
));
979 if (ufpc
[1] != 0 || test_fp_ctl(ufpc
[0]))
981 target
->thread
.fpu
.fpc
= ufpc
[0];
984 if (rc
== 0 && count
> 0)
985 rc
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
986 fprs
, offsetof(s390_fp_regs
, fprs
), -1);
991 convert_fp_to_vx(target
->thread
.fpu
.vxrs
, fprs
);
993 memcpy(target
->thread
.fpu
.fprs
, &fprs
, sizeof(fprs
));
998 static int s390_last_break_get(struct task_struct
*target
,
999 const struct user_regset
*regset
,
1000 unsigned int pos
, unsigned int count
,
1001 void *kbuf
, void __user
*ubuf
)
1005 unsigned long *k
= kbuf
;
1006 *k
= target
->thread
.last_break
;
1008 unsigned long __user
*u
= ubuf
;
1009 if (__put_user(target
->thread
.last_break
, u
))
1016 static int s390_last_break_set(struct task_struct
*target
,
1017 const struct user_regset
*regset
,
1018 unsigned int pos
, unsigned int count
,
1019 const void *kbuf
, const void __user
*ubuf
)
1024 static int s390_tdb_get(struct task_struct
*target
,
1025 const struct user_regset
*regset
,
1026 unsigned int pos
, unsigned int count
,
1027 void *kbuf
, void __user
*ubuf
)
1029 struct pt_regs
*regs
= task_pt_regs(target
);
1030 unsigned char *data
;
1032 if (!(regs
->int_code
& 0x200))
1034 data
= target
->thread
.trap_tdb
;
1035 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
, data
, 0, 256);
1038 static int s390_tdb_set(struct task_struct
*target
,
1039 const struct user_regset
*regset
,
1040 unsigned int pos
, unsigned int count
,
1041 const void *kbuf
, const void __user
*ubuf
)
1046 static int s390_vxrs_low_get(struct task_struct
*target
,
1047 const struct user_regset
*regset
,
1048 unsigned int pos
, unsigned int count
,
1049 void *kbuf
, void __user
*ubuf
)
1051 __u64 vxrs
[__NUM_VXRS_LOW
];
1054 if (!MACHINE_HAS_VX
)
1056 if (target
== current
)
1058 for (i
= 0; i
< __NUM_VXRS_LOW
; i
++)
1059 vxrs
[i
] = *((__u64
*)(target
->thread
.fpu
.vxrs
+ i
) + 1);
1060 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
, vxrs
, 0, -1);
1063 static int s390_vxrs_low_set(struct task_struct
*target
,
1064 const struct user_regset
*regset
,
1065 unsigned int pos
, unsigned int count
,
1066 const void *kbuf
, const void __user
*ubuf
)
1068 __u64 vxrs
[__NUM_VXRS_LOW
];
1071 if (!MACHINE_HAS_VX
)
1073 if (target
== current
)
1076 for (i
= 0; i
< __NUM_VXRS_LOW
; i
++)
1077 vxrs
[i
] = *((__u64
*)(target
->thread
.fpu
.vxrs
+ i
) + 1);
1079 rc
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
, vxrs
, 0, -1);
1081 for (i
= 0; i
< __NUM_VXRS_LOW
; i
++)
1082 *((__u64
*)(target
->thread
.fpu
.vxrs
+ i
) + 1) = vxrs
[i
];
1087 static int s390_vxrs_high_get(struct task_struct
*target
,
1088 const struct user_regset
*regset
,
1089 unsigned int pos
, unsigned int count
,
1090 void *kbuf
, void __user
*ubuf
)
1092 __vector128 vxrs
[__NUM_VXRS_HIGH
];
1094 if (!MACHINE_HAS_VX
)
1096 if (target
== current
)
1098 memcpy(vxrs
, target
->thread
.fpu
.vxrs
+ __NUM_VXRS_LOW
, sizeof(vxrs
));
1100 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
, vxrs
, 0, -1);
1103 static int s390_vxrs_high_set(struct task_struct
*target
,
1104 const struct user_regset
*regset
,
1105 unsigned int pos
, unsigned int count
,
1106 const void *kbuf
, const void __user
*ubuf
)
1110 if (!MACHINE_HAS_VX
)
1112 if (target
== current
)
1115 rc
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
1116 target
->thread
.fpu
.vxrs
+ __NUM_VXRS_LOW
, 0, -1);
1120 static int s390_system_call_get(struct task_struct
*target
,
1121 const struct user_regset
*regset
,
1122 unsigned int pos
, unsigned int count
,
1123 void *kbuf
, void __user
*ubuf
)
1125 unsigned int *data
= &target
->thread
.system_call
;
1126 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
,
1127 data
, 0, sizeof(unsigned int));
1130 static int s390_system_call_set(struct task_struct
*target
,
1131 const struct user_regset
*regset
,
1132 unsigned int pos
, unsigned int count
,
1133 const void *kbuf
, const void __user
*ubuf
)
1135 unsigned int *data
= &target
->thread
.system_call
;
1136 return user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
1137 data
, 0, sizeof(unsigned int));
1140 static const struct user_regset s390_regsets
[] = {
1142 .core_note_type
= NT_PRSTATUS
,
1143 .n
= sizeof(s390_regs
) / sizeof(long),
1144 .size
= sizeof(long),
1145 .align
= sizeof(long),
1146 .get
= s390_regs_get
,
1147 .set
= s390_regs_set
,
1150 .core_note_type
= NT_PRFPREG
,
1151 .n
= sizeof(s390_fp_regs
) / sizeof(long),
1152 .size
= sizeof(long),
1153 .align
= sizeof(long),
1154 .get
= s390_fpregs_get
,
1155 .set
= s390_fpregs_set
,
1158 .core_note_type
= NT_S390_SYSTEM_CALL
,
1160 .size
= sizeof(unsigned int),
1161 .align
= sizeof(unsigned int),
1162 .get
= s390_system_call_get
,
1163 .set
= s390_system_call_set
,
1166 .core_note_type
= NT_S390_LAST_BREAK
,
1168 .size
= sizeof(long),
1169 .align
= sizeof(long),
1170 .get
= s390_last_break_get
,
1171 .set
= s390_last_break_set
,
1174 .core_note_type
= NT_S390_TDB
,
1178 .get
= s390_tdb_get
,
1179 .set
= s390_tdb_set
,
1182 .core_note_type
= NT_S390_VXRS_LOW
,
1183 .n
= __NUM_VXRS_LOW
,
1184 .size
= sizeof(__u64
),
1185 .align
= sizeof(__u64
),
1186 .get
= s390_vxrs_low_get
,
1187 .set
= s390_vxrs_low_set
,
1190 .core_note_type
= NT_S390_VXRS_HIGH
,
1191 .n
= __NUM_VXRS_HIGH
,
1192 .size
= sizeof(__vector128
),
1193 .align
= sizeof(__vector128
),
1194 .get
= s390_vxrs_high_get
,
1195 .set
= s390_vxrs_high_set
,
1199 static const struct user_regset_view user_s390_view
= {
1200 .name
= UTS_MACHINE
,
1201 .e_machine
= EM_S390
,
1202 .regsets
= s390_regsets
,
1203 .n
= ARRAY_SIZE(s390_regsets
)
1206 #ifdef CONFIG_COMPAT
1207 static int s390_compat_regs_get(struct task_struct
*target
,
1208 const struct user_regset
*regset
,
1209 unsigned int pos
, unsigned int count
,
1210 void *kbuf
, void __user
*ubuf
)
1212 if (target
== current
)
1213 save_access_regs(target
->thread
.acrs
);
1216 compat_ulong_t
*k
= kbuf
;
1218 *k
++ = __peek_user_compat(target
, pos
);
1219 count
-= sizeof(*k
);
1223 compat_ulong_t __user
*u
= ubuf
;
1225 if (__put_user(__peek_user_compat(target
, pos
), u
++))
1227 count
-= sizeof(*u
);
1234 static int s390_compat_regs_set(struct task_struct
*target
,
1235 const struct user_regset
*regset
,
1236 unsigned int pos
, unsigned int count
,
1237 const void *kbuf
, const void __user
*ubuf
)
1241 if (target
== current
)
1242 save_access_regs(target
->thread
.acrs
);
1245 const compat_ulong_t
*k
= kbuf
;
1246 while (count
> 0 && !rc
) {
1247 rc
= __poke_user_compat(target
, pos
, *k
++);
1248 count
-= sizeof(*k
);
1252 const compat_ulong_t __user
*u
= ubuf
;
1253 while (count
> 0 && !rc
) {
1254 compat_ulong_t word
;
1255 rc
= __get_user(word
, u
++);
1258 rc
= __poke_user_compat(target
, pos
, word
);
1259 count
-= sizeof(*u
);
1264 if (rc
== 0 && target
== current
)
1265 restore_access_regs(target
->thread
.acrs
);
1270 static int s390_compat_regs_high_get(struct task_struct
*target
,
1271 const struct user_regset
*regset
,
1272 unsigned int pos
, unsigned int count
,
1273 void *kbuf
, void __user
*ubuf
)
1275 compat_ulong_t
*gprs_high
;
1277 gprs_high
= (compat_ulong_t
*)
1278 &task_pt_regs(target
)->gprs
[pos
/ sizeof(compat_ulong_t
)];
1280 compat_ulong_t
*k
= kbuf
;
1284 count
-= sizeof(*k
);
1287 compat_ulong_t __user
*u
= ubuf
;
1289 if (__put_user(*gprs_high
, u
++))
1292 count
-= sizeof(*u
);
1298 static int s390_compat_regs_high_set(struct task_struct
*target
,
1299 const struct user_regset
*regset
,
1300 unsigned int pos
, unsigned int count
,
1301 const void *kbuf
, const void __user
*ubuf
)
1303 compat_ulong_t
*gprs_high
;
1306 gprs_high
= (compat_ulong_t
*)
1307 &task_pt_regs(target
)->gprs
[pos
/ sizeof(compat_ulong_t
)];
1309 const compat_ulong_t
*k
= kbuf
;
1313 count
-= sizeof(*k
);
1316 const compat_ulong_t __user
*u
= ubuf
;
1317 while (count
> 0 && !rc
) {
1319 rc
= __get_user(word
, u
++);
1324 count
-= sizeof(*u
);
1331 static int s390_compat_last_break_get(struct task_struct
*target
,
1332 const struct user_regset
*regset
,
1333 unsigned int pos
, unsigned int count
,
1334 void *kbuf
, void __user
*ubuf
)
1336 compat_ulong_t last_break
;
1339 last_break
= target
->thread
.last_break
;
1341 unsigned long *k
= kbuf
;
1344 unsigned long __user
*u
= ubuf
;
1345 if (__put_user(last_break
, u
))
1352 static int s390_compat_last_break_set(struct task_struct
*target
,
1353 const struct user_regset
*regset
,
1354 unsigned int pos
, unsigned int count
,
1355 const void *kbuf
, const void __user
*ubuf
)
1360 static const struct user_regset s390_compat_regsets
[] = {
1362 .core_note_type
= NT_PRSTATUS
,
1363 .n
= sizeof(s390_compat_regs
) / sizeof(compat_long_t
),
1364 .size
= sizeof(compat_long_t
),
1365 .align
= sizeof(compat_long_t
),
1366 .get
= s390_compat_regs_get
,
1367 .set
= s390_compat_regs_set
,
1370 .core_note_type
= NT_PRFPREG
,
1371 .n
= sizeof(s390_fp_regs
) / sizeof(compat_long_t
),
1372 .size
= sizeof(compat_long_t
),
1373 .align
= sizeof(compat_long_t
),
1374 .get
= s390_fpregs_get
,
1375 .set
= s390_fpregs_set
,
1378 .core_note_type
= NT_S390_SYSTEM_CALL
,
1380 .size
= sizeof(compat_uint_t
),
1381 .align
= sizeof(compat_uint_t
),
1382 .get
= s390_system_call_get
,
1383 .set
= s390_system_call_set
,
1386 .core_note_type
= NT_S390_LAST_BREAK
,
1388 .size
= sizeof(long),
1389 .align
= sizeof(long),
1390 .get
= s390_compat_last_break_get
,
1391 .set
= s390_compat_last_break_set
,
1394 .core_note_type
= NT_S390_TDB
,
1398 .get
= s390_tdb_get
,
1399 .set
= s390_tdb_set
,
1402 .core_note_type
= NT_S390_VXRS_LOW
,
1403 .n
= __NUM_VXRS_LOW
,
1404 .size
= sizeof(__u64
),
1405 .align
= sizeof(__u64
),
1406 .get
= s390_vxrs_low_get
,
1407 .set
= s390_vxrs_low_set
,
1410 .core_note_type
= NT_S390_VXRS_HIGH
,
1411 .n
= __NUM_VXRS_HIGH
,
1412 .size
= sizeof(__vector128
),
1413 .align
= sizeof(__vector128
),
1414 .get
= s390_vxrs_high_get
,
1415 .set
= s390_vxrs_high_set
,
1418 .core_note_type
= NT_S390_HIGH_GPRS
,
1419 .n
= sizeof(s390_compat_regs_high
) / sizeof(compat_long_t
),
1420 .size
= sizeof(compat_long_t
),
1421 .align
= sizeof(compat_long_t
),
1422 .get
= s390_compat_regs_high_get
,
1423 .set
= s390_compat_regs_high_set
,
1427 static const struct user_regset_view user_s390_compat_view
= {
1429 .e_machine
= EM_S390
,
1430 .regsets
= s390_compat_regsets
,
1431 .n
= ARRAY_SIZE(s390_compat_regsets
)
1435 const struct user_regset_view
*task_user_regset_view(struct task_struct
*task
)
1437 #ifdef CONFIG_COMPAT
1438 if (test_tsk_thread_flag(task
, TIF_31BIT
))
1439 return &user_s390_compat_view
;
1441 return &user_s390_view
;
1444 static const char *gpr_names
[NUM_GPRS
] = {
1445 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
1446 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
1449 unsigned long regs_get_register(struct pt_regs
*regs
, unsigned int offset
)
1451 if (offset
>= NUM_GPRS
)
1453 return regs
->gprs
[offset
];
1456 int regs_query_register_offset(const char *name
)
1458 unsigned long offset
;
1460 if (!name
|| *name
!= 'r')
1462 if (kstrtoul(name
+ 1, 10, &offset
))
1464 if (offset
>= NUM_GPRS
)
1469 const char *regs_query_register_name(unsigned int offset
)
1471 if (offset
>= NUM_GPRS
)
1473 return gpr_names
[offset
];
1476 static int regs_within_kernel_stack(struct pt_regs
*regs
, unsigned long addr
)
1478 unsigned long ksp
= kernel_stack_pointer(regs
);
1480 return (addr
& ~(THREAD_SIZE
- 1)) == (ksp
& ~(THREAD_SIZE
- 1));
1484 * regs_get_kernel_stack_nth() - get Nth entry of the stack
1485 * @regs:pt_regs which contains kernel stack pointer.
1486 * @n:stack entry number.
1488 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
1489 * is specifined by @regs. If the @n th entry is NOT in the kernel stack,
1492 unsigned long regs_get_kernel_stack_nth(struct pt_regs
*regs
, unsigned int n
)
1496 addr
= kernel_stack_pointer(regs
) + n
* sizeof(long);
1497 if (!regs_within_kernel_stack(regs
, addr
))
1499 return *(unsigned long *)addr
;