2 * arch/s390/kernel/ptrace.c
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
7 * Martin Schwidefsky (schwidefsky@de.ibm.com)
9 * Based on PowerPC version
10 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
12 * Derived from "arch/m68k/kernel/ptrace.c"
13 * Copyright (C) 1994 by Hamish Macdonald
14 * Taken from linux/kernel/ptrace.c and modified for M680x0.
15 * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
17 * Modified by Cort Dougan (cort@cs.nmt.edu)
20 * This file is subject to the terms and conditions of the GNU General
21 * Public License. See the file README.legal in the main directory of
22 * this archive for more details.
25 #include <linux/kernel.h>
26 #include <linux/sched.h>
28 #include <linux/smp.h>
29 #include <linux/smp_lock.h>
30 #include <linux/errno.h>
31 #include <linux/ptrace.h>
32 #include <linux/user.h>
33 #include <linux/security.h>
34 #include <linux/audit.h>
35 #include <linux/signal.h>
36 #include <linux/elf.h>
37 #include <linux/regset.h>
39 #include <asm/segment.h>
41 #include <asm/pgtable.h>
42 #include <asm/pgalloc.h>
43 #include <asm/system.h>
44 #include <asm/uaccess.h>
45 #include <asm/unistd.h>
49 #include "compat_ptrace.h"
58 FixPerRegisters(struct task_struct
*task
)
63 regs
= task_pt_regs(task
);
64 per_info
= (per_struct
*) &task
->thread
.per_info
;
65 per_info
->control_regs
.bits
.em_instruction_fetch
=
66 per_info
->single_step
| per_info
->instruction_fetch
;
68 if (per_info
->single_step
) {
69 per_info
->control_regs
.bits
.starting_addr
= 0;
71 if (test_thread_flag(TIF_31BIT
))
72 per_info
->control_regs
.bits
.ending_addr
= 0x7fffffffUL
;
75 per_info
->control_regs
.bits
.ending_addr
= PSW_ADDR_INSN
;
77 per_info
->control_regs
.bits
.starting_addr
=
78 per_info
->starting_addr
;
79 per_info
->control_regs
.bits
.ending_addr
=
80 per_info
->ending_addr
;
83 * if any of the control reg tracing bits are on
84 * we switch on per in the psw
86 if (per_info
->control_regs
.words
.cr
[0] & PER_EM_MASK
)
87 regs
->psw
.mask
|= PSW_MASK_PER
;
89 regs
->psw
.mask
&= ~PSW_MASK_PER
;
91 if (per_info
->control_regs
.bits
.em_storage_alteration
)
92 per_info
->control_regs
.bits
.storage_alt_space_ctl
= 1;
94 per_info
->control_regs
.bits
.storage_alt_space_ctl
= 0;
97 void user_enable_single_step(struct task_struct
*task
)
99 task
->thread
.per_info
.single_step
= 1;
100 FixPerRegisters(task
);
103 void user_disable_single_step(struct task_struct
*task
)
105 task
->thread
.per_info
.single_step
= 0;
106 FixPerRegisters(task
);
110 * Called by kernel/ptrace.c when detaching..
112 * Make sure single step bits etc are not set.
115 ptrace_disable(struct task_struct
*child
)
117 /* make sure the single step bit is not set. */
118 user_disable_single_step(child
);
122 # define __ADDR_MASK 3
124 # define __ADDR_MASK 7
128 * Read the word at offset addr from the user area of a process. The
129 * trouble here is that the information is littered over different
130 * locations. The process registers are found on the kernel stack,
131 * the floating point stuff and the trace settings are stored in
132 * the task structure. In addition the different structures in
133 * struct user contain pad bytes that should be read as zeroes.
136 static unsigned long __peek_user(struct task_struct
*child
, addr_t addr
)
138 struct user
*dummy
= NULL
;
141 if (addr
< (addr_t
) &dummy
->regs
.acrs
) {
143 * psw and gprs are stored on the stack
145 tmp
= *(addr_t
*)((addr_t
) &task_pt_regs(child
)->psw
+ addr
);
146 if (addr
== (addr_t
) &dummy
->regs
.psw
.mask
)
147 /* Remove per bit from user psw. */
148 tmp
&= ~PSW_MASK_PER
;
150 } else if (addr
< (addr_t
) &dummy
->regs
.orig_gpr2
) {
152 * access registers are stored in the thread structure
154 offset
= addr
- (addr_t
) &dummy
->regs
.acrs
;
157 * Very special case: old & broken 64 bit gdb reading
158 * from acrs[15]. Result is a 64 bit value. Read the
159 * 32 bit acrs[15] value and shift it by 32. Sick...
161 if (addr
== (addr_t
) &dummy
->regs
.acrs
[15])
162 tmp
= ((unsigned long) child
->thread
.acrs
[15]) << 32;
165 tmp
= *(addr_t
*)((addr_t
) &child
->thread
.acrs
+ offset
);
167 } else if (addr
== (addr_t
) &dummy
->regs
.orig_gpr2
) {
169 * orig_gpr2 is stored on the kernel stack
171 tmp
= (addr_t
) task_pt_regs(child
)->orig_gpr2
;
173 } else if (addr
< (addr_t
) (&dummy
->regs
.fp_regs
+ 1)) {
175 * floating point regs. are stored in the thread structure
177 offset
= addr
- (addr_t
) &dummy
->regs
.fp_regs
;
178 tmp
= *(addr_t
*)((addr_t
) &child
->thread
.fp_regs
+ offset
);
179 if (addr
== (addr_t
) &dummy
->regs
.fp_regs
.fpc
)
180 tmp
&= (unsigned long) FPC_VALID_MASK
181 << (BITS_PER_LONG
- 32);
183 } else if (addr
< (addr_t
) (&dummy
->regs
.per_info
+ 1)) {
185 * per_info is found in the thread structure
187 offset
= addr
- (addr_t
) &dummy
->regs
.per_info
;
188 tmp
= *(addr_t
*)((addr_t
) &child
->thread
.per_info
+ offset
);
197 peek_user(struct task_struct
*child
, addr_t addr
, addr_t data
)
199 struct user
*dummy
= NULL
;
203 * Stupid gdb peeks/pokes the access registers in 64 bit with
204 * an alignment of 4. Programmers from hell...
208 if (addr
>= (addr_t
) &dummy
->regs
.acrs
&&
209 addr
< (addr_t
) &dummy
->regs
.orig_gpr2
)
212 if ((addr
& mask
) || addr
> sizeof(struct user
) - __ADDR_MASK
)
215 tmp
= __peek_user(child
, addr
);
216 return put_user(tmp
, (addr_t __user
*) data
);
220 * Write a word to the user area of a process at location addr. This
221 * operation does have an additional problem compared to peek_user.
222 * Stores to the program status word and on the floating point
223 * control register needs to get checked for validity.
225 static int __poke_user(struct task_struct
*child
, addr_t addr
, addr_t data
)
227 struct user
*dummy
= NULL
;
230 if (addr
< (addr_t
) &dummy
->regs
.acrs
) {
232 * psw and gprs are stored on the stack
234 if (addr
== (addr_t
) &dummy
->regs
.psw
.mask
&&
236 data
!= PSW_MASK_MERGE(psw_user32_bits
, data
) &&
238 data
!= PSW_MASK_MERGE(psw_user_bits
, data
))
239 /* Invalid psw mask. */
242 if (addr
== (addr_t
) &dummy
->regs
.psw
.addr
)
243 /* I'd like to reject addresses without the
244 high order bit but older gdb's rely on it */
245 data
|= PSW_ADDR_AMODE
;
247 *(addr_t
*)((addr_t
) &task_pt_regs(child
)->psw
+ addr
) = data
;
249 } else if (addr
< (addr_t
) (&dummy
->regs
.orig_gpr2
)) {
251 * access registers are stored in the thread structure
253 offset
= addr
- (addr_t
) &dummy
->regs
.acrs
;
256 * Very special case: old & broken 64 bit gdb writing
257 * to acrs[15] with a 64 bit value. Ignore the lower
258 * half of the value and write the upper 32 bit to
261 if (addr
== (addr_t
) &dummy
->regs
.acrs
[15])
262 child
->thread
.acrs
[15] = (unsigned int) (data
>> 32);
265 *(addr_t
*)((addr_t
) &child
->thread
.acrs
+ offset
) = data
;
267 } else if (addr
== (addr_t
) &dummy
->regs
.orig_gpr2
) {
269 * orig_gpr2 is stored on the kernel stack
271 task_pt_regs(child
)->orig_gpr2
= data
;
273 } else if (addr
< (addr_t
) (&dummy
->regs
.fp_regs
+ 1)) {
275 * floating point regs. are stored in the thread structure
277 if (addr
== (addr_t
) &dummy
->regs
.fp_regs
.fpc
&&
278 (data
& ~((unsigned long) FPC_VALID_MASK
279 << (BITS_PER_LONG
- 32))) != 0)
281 offset
= addr
- (addr_t
) &dummy
->regs
.fp_regs
;
282 *(addr_t
*)((addr_t
) &child
->thread
.fp_regs
+ offset
) = data
;
284 } else if (addr
< (addr_t
) (&dummy
->regs
.per_info
+ 1)) {
286 * per_info is found in the thread structure
288 offset
= addr
- (addr_t
) &dummy
->regs
.per_info
;
289 *(addr_t
*)((addr_t
) &child
->thread
.per_info
+ offset
) = data
;
293 FixPerRegisters(child
);
298 poke_user(struct task_struct
*child
, addr_t addr
, addr_t data
)
300 struct user
*dummy
= NULL
;
304 * Stupid gdb peeks/pokes the access registers in 64 bit with
305 * an alignment of 4. Programmers from hell indeed...
309 if (addr
>= (addr_t
) &dummy
->regs
.acrs
&&
310 addr
< (addr_t
) &dummy
->regs
.orig_gpr2
)
313 if ((addr
& mask
) || addr
> sizeof(struct user
) - __ADDR_MASK
)
316 return __poke_user(child
, addr
, data
);
319 long arch_ptrace(struct task_struct
*child
, long request
, long addr
, long data
)
325 case PTRACE_PEEKTEXT
:
326 case PTRACE_PEEKDATA
:
327 /* Remove high order bit from address (only for 31 bit). */
328 addr
&= PSW_ADDR_INSN
;
329 /* read word at location addr. */
330 return generic_ptrace_peekdata(child
, addr
, data
);
333 /* read the word at location addr in the USER area. */
334 return peek_user(child
, addr
, data
);
336 case PTRACE_POKETEXT
:
337 case PTRACE_POKEDATA
:
338 /* Remove high order bit from address (only for 31 bit). */
339 addr
&= PSW_ADDR_INSN
;
340 /* write the word at location addr. */
341 return generic_ptrace_pokedata(child
, addr
, data
);
344 /* write the word at location addr in the USER area */
345 return poke_user(child
, addr
, data
);
347 case PTRACE_PEEKUSR_AREA
:
348 case PTRACE_POKEUSR_AREA
:
349 if (copy_from_user(&parea
, (void __force __user
*) addr
,
352 addr
= parea
.kernel_addr
;
353 data
= parea
.process_addr
;
355 while (copied
< parea
.len
) {
356 if (request
== PTRACE_PEEKUSR_AREA
)
357 ret
= peek_user(child
, addr
, data
);
361 (addr_t __force __user
*) data
))
363 ret
= poke_user(child
, addr
, utmp
);
367 addr
+= sizeof(unsigned long);
368 data
+= sizeof(unsigned long);
369 copied
+= sizeof(unsigned long);
373 return ptrace_request(child
, request
, addr
, data
);
378 * Now the fun part starts... a 31 bit program running in the
379 * 31 bit emulation tracing another program. PTRACE_PEEKTEXT,
380 * PTRACE_PEEKDATA, PTRACE_POKETEXT and PTRACE_POKEDATA are easy
381 * to handle, the difference to the 64 bit versions of the requests
382 * is that the access is done in multiples of 4 byte instead of
383 * 8 bytes (sizeof(unsigned long) on 31/64 bit).
384 * The ugly part are PTRACE_PEEKUSR, PTRACE_PEEKUSR_AREA,
385 * PTRACE_POKEUSR and PTRACE_POKEUSR_AREA. If the traced program
386 * is a 31 bit program too, the content of struct user can be
387 * emulated. A 31 bit program peeking into the struct user of
388 * a 64 bit program is a no-no.
392 * Same as peek_user but for a 31 bit program.
394 static u32
__peek_user_compat(struct task_struct
*child
, addr_t addr
)
396 struct user32
*dummy32
= NULL
;
397 per_struct32
*dummy_per32
= NULL
;
401 if (addr
< (addr_t
) &dummy32
->regs
.acrs
) {
403 * psw and gprs are stored on the stack
405 if (addr
== (addr_t
) &dummy32
->regs
.psw
.mask
) {
406 /* Fake a 31 bit psw mask. */
407 tmp
= (__u32
)(task_pt_regs(child
)->psw
.mask
>> 32);
408 tmp
= PSW32_MASK_MERGE(psw32_user_bits
, tmp
);
409 } else if (addr
== (addr_t
) &dummy32
->regs
.psw
.addr
) {
410 /* Fake a 31 bit psw address. */
411 tmp
= (__u32
) task_pt_regs(child
)->psw
.addr
|
415 tmp
= *(__u32
*)((addr_t
) &task_pt_regs(child
)->psw
+
418 } else if (addr
< (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
420 * access registers are stored in the thread structure
422 offset
= addr
- (addr_t
) &dummy32
->regs
.acrs
;
423 tmp
= *(__u32
*)((addr_t
) &child
->thread
.acrs
+ offset
);
425 } else if (addr
== (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
427 * orig_gpr2 is stored on the kernel stack
429 tmp
= *(__u32
*)((addr_t
) &task_pt_regs(child
)->orig_gpr2
+ 4);
431 } else if (addr
< (addr_t
) (&dummy32
->regs
.fp_regs
+ 1)) {
433 * floating point regs. are stored in the thread structure
435 offset
= addr
- (addr_t
) &dummy32
->regs
.fp_regs
;
436 tmp
= *(__u32
*)((addr_t
) &child
->thread
.fp_regs
+ offset
);
438 } else if (addr
< (addr_t
) (&dummy32
->regs
.per_info
+ 1)) {
440 * per_info is found in the thread structure
442 offset
= addr
- (addr_t
) &dummy32
->regs
.per_info
;
443 /* This is magic. See per_struct and per_struct32. */
444 if ((offset
>= (addr_t
) &dummy_per32
->control_regs
&&
445 offset
< (addr_t
) (&dummy_per32
->control_regs
+ 1)) ||
446 (offset
>= (addr_t
) &dummy_per32
->starting_addr
&&
447 offset
<= (addr_t
) &dummy_per32
->ending_addr
) ||
448 offset
== (addr_t
) &dummy_per32
->lowcore
.words
.address
)
449 offset
= offset
*2 + 4;
452 tmp
= *(__u32
*)((addr_t
) &child
->thread
.per_info
+ offset
);
460 static int peek_user_compat(struct task_struct
*child
,
461 addr_t addr
, addr_t data
)
465 if (!test_thread_flag(TIF_31BIT
) ||
466 (addr
& 3) || addr
> sizeof(struct user
) - 3)
469 tmp
= __peek_user_compat(child
, addr
);
470 return put_user(tmp
, (__u32 __user
*) data
);
474 * Same as poke_user but for a 31 bit program.
476 static int __poke_user_compat(struct task_struct
*child
,
477 addr_t addr
, addr_t data
)
479 struct user32
*dummy32
= NULL
;
480 per_struct32
*dummy_per32
= NULL
;
481 __u32 tmp
= (__u32
) data
;
484 if (addr
< (addr_t
) &dummy32
->regs
.acrs
) {
486 * psw, gprs, acrs and orig_gpr2 are stored on the stack
488 if (addr
== (addr_t
) &dummy32
->regs
.psw
.mask
) {
489 /* Build a 64 bit psw mask from 31 bit mask. */
490 if (tmp
!= PSW32_MASK_MERGE(psw32_user_bits
, tmp
))
491 /* Invalid psw mask. */
493 task_pt_regs(child
)->psw
.mask
=
494 PSW_MASK_MERGE(psw_user32_bits
, (__u64
) tmp
<< 32);
495 } else if (addr
== (addr_t
) &dummy32
->regs
.psw
.addr
) {
496 /* Build a 64 bit psw address from 31 bit address. */
497 task_pt_regs(child
)->psw
.addr
=
498 (__u64
) tmp
& PSW32_ADDR_INSN
;
501 *(__u32
*)((addr_t
) &task_pt_regs(child
)->psw
504 } else if (addr
< (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
506 * access registers are stored in the thread structure
508 offset
= addr
- (addr_t
) &dummy32
->regs
.acrs
;
509 *(__u32
*)((addr_t
) &child
->thread
.acrs
+ offset
) = tmp
;
511 } else if (addr
== (addr_t
) (&dummy32
->regs
.orig_gpr2
)) {
513 * orig_gpr2 is stored on the kernel stack
515 *(__u32
*)((addr_t
) &task_pt_regs(child
)->orig_gpr2
+ 4) = tmp
;
517 } else if (addr
< (addr_t
) (&dummy32
->regs
.fp_regs
+ 1)) {
519 * floating point regs. are stored in the thread structure
521 if (addr
== (addr_t
) &dummy32
->regs
.fp_regs
.fpc
&&
522 (tmp
& ~FPC_VALID_MASK
) != 0)
523 /* Invalid floating point control. */
525 offset
= addr
- (addr_t
) &dummy32
->regs
.fp_regs
;
526 *(__u32
*)((addr_t
) &child
->thread
.fp_regs
+ offset
) = tmp
;
528 } else if (addr
< (addr_t
) (&dummy32
->regs
.per_info
+ 1)) {
530 * per_info is found in the thread structure.
532 offset
= addr
- (addr_t
) &dummy32
->regs
.per_info
;
534 * This is magic. See per_struct and per_struct32.
535 * By incident the offsets in per_struct are exactly
536 * twice the offsets in per_struct32 for all fields.
537 * The 8 byte fields need special handling though,
538 * because the second half (bytes 4-7) is needed and
539 * not the first half.
541 if ((offset
>= (addr_t
) &dummy_per32
->control_regs
&&
542 offset
< (addr_t
) (&dummy_per32
->control_regs
+ 1)) ||
543 (offset
>= (addr_t
) &dummy_per32
->starting_addr
&&
544 offset
<= (addr_t
) &dummy_per32
->ending_addr
) ||
545 offset
== (addr_t
) &dummy_per32
->lowcore
.words
.address
)
546 offset
= offset
*2 + 4;
549 *(__u32
*)((addr_t
) &child
->thread
.per_info
+ offset
) = tmp
;
553 FixPerRegisters(child
);
557 static int poke_user_compat(struct task_struct
*child
,
558 addr_t addr
, addr_t data
)
560 if (!test_thread_flag(TIF_31BIT
) ||
561 (addr
& 3) || addr
> sizeof(struct user32
) - 3)
564 return __poke_user_compat(child
, addr
, data
);
567 long compat_arch_ptrace(struct task_struct
*child
, compat_long_t request
,
568 compat_ulong_t caddr
, compat_ulong_t cdata
)
570 unsigned long addr
= caddr
;
571 unsigned long data
= cdata
;
572 ptrace_area_emu31 parea
;
577 /* read the word at location addr in the USER area. */
578 return peek_user_compat(child
, addr
, data
);
581 /* write the word at location addr in the USER area */
582 return poke_user_compat(child
, addr
, data
);
584 case PTRACE_PEEKUSR_AREA
:
585 case PTRACE_POKEUSR_AREA
:
586 if (copy_from_user(&parea
, (void __force __user
*) addr
,
589 addr
= parea
.kernel_addr
;
590 data
= parea
.process_addr
;
592 while (copied
< parea
.len
) {
593 if (request
== PTRACE_PEEKUSR_AREA
)
594 ret
= peek_user_compat(child
, addr
, data
);
598 (__u32 __force __user
*) data
))
600 ret
= poke_user_compat(child
, addr
, utmp
);
604 addr
+= sizeof(unsigned int);
605 data
+= sizeof(unsigned int);
606 copied
+= sizeof(unsigned int);
610 return compat_ptrace_request(child
, request
, addr
, data
);
615 syscall_trace(struct pt_regs
*regs
, int entryexit
)
617 if (unlikely(current
->audit_context
) && entryexit
)
618 audit_syscall_exit(AUDITSC_RESULT(regs
->gprs
[2]), regs
->gprs
[2]);
620 if (!test_thread_flag(TIF_SYSCALL_TRACE
))
622 if (!(current
->ptrace
& PT_PTRACED
))
624 ptrace_notify(SIGTRAP
| ((current
->ptrace
& PT_TRACESYSGOOD
)
628 * If the debuffer has set an invalid system call number,
629 * we prepare to skip the system call restart handling.
631 if (!entryexit
&& regs
->gprs
[2] >= NR_syscalls
)
635 * this isn't the same as continuing with a signal, but it will do
636 * for normal use. strace only continues with a signal if the
637 * stopping signal is not SIGTRAP. -brl
639 if (current
->exit_code
) {
640 send_sig(current
->exit_code
, current
, 1);
641 current
->exit_code
= 0;
644 if (unlikely(current
->audit_context
) && !entryexit
)
645 audit_syscall_entry(test_thread_flag(TIF_31BIT
)?AUDIT_ARCH_S390
:AUDIT_ARCH_S390X
,
646 regs
->gprs
[2], regs
->orig_gpr2
, regs
->gprs
[3],
647 regs
->gprs
[4], regs
->gprs
[5]);
651 * user_regset definitions.
654 static int s390_regs_get(struct task_struct
*target
,
655 const struct user_regset
*regset
,
656 unsigned int pos
, unsigned int count
,
657 void *kbuf
, void __user
*ubuf
)
659 if (target
== current
)
660 save_access_regs(target
->thread
.acrs
);
663 unsigned long *k
= kbuf
;
665 *k
++ = __peek_user(target
, pos
);
670 unsigned long __user
*u
= ubuf
;
672 if (__put_user(__peek_user(target
, pos
), u
++))
681 static int s390_regs_set(struct task_struct
*target
,
682 const struct user_regset
*regset
,
683 unsigned int pos
, unsigned int count
,
684 const void *kbuf
, const void __user
*ubuf
)
688 if (target
== current
)
689 save_access_regs(target
->thread
.acrs
);
692 const unsigned long *k
= kbuf
;
693 while (count
> 0 && !rc
) {
694 rc
= __poke_user(target
, pos
, *k
++);
699 const unsigned long __user
*u
= ubuf
;
700 while (count
> 0 && !rc
) {
702 rc
= __get_user(word
, u
++);
705 rc
= __poke_user(target
, pos
, word
);
711 if (rc
== 0 && target
== current
)
712 restore_access_regs(target
->thread
.acrs
);
717 static int s390_fpregs_get(struct task_struct
*target
,
718 const struct user_regset
*regset
, unsigned int pos
,
719 unsigned int count
, void *kbuf
, void __user
*ubuf
)
721 if (target
== current
)
722 save_fp_regs(&target
->thread
.fp_regs
);
724 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
,
725 &target
->thread
.fp_regs
, 0, -1);
728 static int s390_fpregs_set(struct task_struct
*target
,
729 const struct user_regset
*regset
, unsigned int pos
,
730 unsigned int count
, const void *kbuf
,
731 const void __user
*ubuf
)
735 if (target
== current
)
736 save_fp_regs(&target
->thread
.fp_regs
);
738 /* If setting FPC, must validate it first. */
739 if (count
> 0 && pos
< offsetof(s390_fp_regs
, fprs
)) {
740 u32 fpc
[2] = { target
->thread
.fp_regs
.fpc
, 0 };
741 rc
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
, &fpc
,
742 0, offsetof(s390_fp_regs
, fprs
));
745 if ((fpc
[0] & ~FPC_VALID_MASK
) != 0 || fpc
[1] != 0)
747 target
->thread
.fp_regs
.fpc
= fpc
[0];
750 if (rc
== 0 && count
> 0)
751 rc
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
752 target
->thread
.fp_regs
.fprs
,
753 offsetof(s390_fp_regs
, fprs
), -1);
755 if (rc
== 0 && target
== current
)
756 restore_fp_regs(&target
->thread
.fp_regs
);
761 static const struct user_regset s390_regsets
[] = {
763 .core_note_type
= NT_PRSTATUS
,
764 .n
= sizeof(s390_regs
) / sizeof(long),
765 .size
= sizeof(long),
766 .align
= sizeof(long),
767 .get
= s390_regs_get
,
768 .set
= s390_regs_set
,
771 .core_note_type
= NT_PRFPREG
,
772 .n
= sizeof(s390_fp_regs
) / sizeof(long),
773 .size
= sizeof(long),
774 .align
= sizeof(long),
775 .get
= s390_fpregs_get
,
776 .set
= s390_fpregs_set
,
780 static const struct user_regset_view user_s390_view
= {
782 .e_machine
= EM_S390
,
783 .regsets
= s390_regsets
,
784 .n
= ARRAY_SIZE(s390_regsets
)
788 static int s390_compat_regs_get(struct task_struct
*target
,
789 const struct user_regset
*regset
,
790 unsigned int pos
, unsigned int count
,
791 void *kbuf
, void __user
*ubuf
)
793 if (target
== current
)
794 save_access_regs(target
->thread
.acrs
);
797 compat_ulong_t
*k
= kbuf
;
799 *k
++ = __peek_user_compat(target
, pos
);
804 compat_ulong_t __user
*u
= ubuf
;
806 if (__put_user(__peek_user_compat(target
, pos
), u
++))
815 static int s390_compat_regs_set(struct task_struct
*target
,
816 const struct user_regset
*regset
,
817 unsigned int pos
, unsigned int count
,
818 const void *kbuf
, const void __user
*ubuf
)
822 if (target
== current
)
823 save_access_regs(target
->thread
.acrs
);
826 const compat_ulong_t
*k
= kbuf
;
827 while (count
> 0 && !rc
) {
828 rc
= __poke_user_compat(target
, pos
, *k
++);
833 const compat_ulong_t __user
*u
= ubuf
;
834 while (count
> 0 && !rc
) {
836 rc
= __get_user(word
, u
++);
839 rc
= __poke_user_compat(target
, pos
, word
);
845 if (rc
== 0 && target
== current
)
846 restore_access_regs(target
->thread
.acrs
);
851 static const struct user_regset s390_compat_regsets
[] = {
853 .core_note_type
= NT_PRSTATUS
,
854 .n
= sizeof(s390_compat_regs
) / sizeof(compat_long_t
),
855 .size
= sizeof(compat_long_t
),
856 .align
= sizeof(compat_long_t
),
857 .get
= s390_compat_regs_get
,
858 .set
= s390_compat_regs_set
,
861 .core_note_type
= NT_PRFPREG
,
862 .n
= sizeof(s390_fp_regs
) / sizeof(compat_long_t
),
863 .size
= sizeof(compat_long_t
),
864 .align
= sizeof(compat_long_t
),
865 .get
= s390_fpregs_get
,
866 .set
= s390_fpregs_set
,
870 static const struct user_regset_view user_s390_compat_view
= {
872 .e_machine
= EM_S390
,
873 .regsets
= s390_compat_regsets
,
874 .n
= ARRAY_SIZE(s390_compat_regsets
)
878 const struct user_regset_view
*task_user_regset_view(struct task_struct
*task
)
881 if (test_tsk_thread_flag(task
, TIF_31BIT
))
882 return &user_s390_compat_view
;
884 return &user_s390_view
;