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/errno.h>
30 #include <linux/ptrace.h>
31 #include <linux/user.h>
32 #include <linux/security.h>
33 #include <linux/audit.h>
34 #include <linux/signal.h>
35 #include <linux/elf.h>
36 #include <linux/regset.h>
37 #include <linux/tracehook.h>
38 #include <linux/seccomp.h>
39 #include <trace/syscall.h>
40 #include <asm/compat.h>
41 #include <asm/segment.h>
43 #include <asm/pgtable.h>
44 #include <asm/pgalloc.h>
45 #include <asm/system.h>
46 #include <asm/uaccess.h>
47 #include <asm/unistd.h>
51 #include "compat_ptrace.h"
54 #define CREATE_TRACE_POINTS
55 #include <trace/events/syscalls.h>
63 FixPerRegisters(struct task_struct *task)
68 regs = task_pt_regs(task);
69 per_info = (per_struct *) &task->thread.per_info;
70 per_info->control_regs.bits.em_instruction_fetch =
71 per_info->single_step | per_info->instruction_fetch;
73 if (per_info->single_step) {
74 per_info->control_regs.bits.starting_addr = 0;
77 per_info->control_regs.bits.ending_addr = 0x7fffffffUL;
80 per_info->control_regs.bits.ending_addr = PSW_ADDR_INSN;
82 per_info->control_regs.bits.starting_addr =
83 per_info->starting_addr;
84 per_info->control_regs.bits.ending_addr =
85 per_info->ending_addr;
88 * if any of the control reg tracing bits are on
89 * we switch on per in the psw
91 if (per_info->control_regs.words.cr[0] & PER_EM_MASK)
92 regs->psw.mask |= PSW_MASK_PER;
94 regs->psw.mask &= ~PSW_MASK_PER;
96 if (per_info->control_regs.bits.em_storage_alteration)
97 per_info->control_regs.bits.storage_alt_space_ctl = 1;
99 per_info->control_regs.bits.storage_alt_space_ctl = 0;
102 void user_enable_single_step(struct task_struct *task)
104 task->thread.per_info.single_step = 1;
105 FixPerRegisters(task);
108 void user_disable_single_step(struct task_struct *task)
110 task->thread.per_info.single_step = 0;
111 FixPerRegisters(task);
115 * Called by kernel/ptrace.c when detaching..
117 * Make sure single step bits etc are not set.
120 ptrace_disable(struct task_struct *child)
122 /* make sure the single step bit is not set. */
123 user_disable_single_step(child);
127 # define __ADDR_MASK 3
129 # define __ADDR_MASK 7
133 * Read the word at offset addr from the user area of a process. The
134 * trouble here is that the information is littered over different
135 * locations. The process registers are found on the kernel stack,
136 * the floating point stuff and the trace settings are stored in
137 * the task structure. In addition the different structures in
138 * struct user contain pad bytes that should be read as zeroes.
141 static unsigned long __peek_user(struct task_struct *child, addr_t addr)
143 struct user *dummy = NULL;
146 if (addr < (addr_t) &dummy->regs.acrs) {
148 * psw and gprs are stored on the stack
150 tmp = *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr);
151 if (addr == (addr_t) &dummy->regs.psw.mask)
152 /* Remove per bit from user psw. */
153 tmp &= ~PSW_MASK_PER;
155 } else if (addr < (addr_t) &dummy->regs.orig_gpr2) {
157 * access registers are stored in the thread structure
159 offset = addr - (addr_t) &dummy->regs.acrs;
162 * Very special case: old & broken 64 bit gdb reading
163 * from acrs[15]. Result is a 64 bit value. Read the
164 * 32 bit acrs[15] value and shift it by 32. Sick...
166 if (addr == (addr_t) &dummy->regs.acrs[15])
167 tmp = ((unsigned long) child->thread.acrs[15]) << 32;
170 tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset);
172 } else if (addr == (addr_t) &dummy->regs.orig_gpr2) {
174 * orig_gpr2 is stored on the kernel stack
176 tmp = (addr_t) task_pt_regs(child)->orig_gpr2;
178 } else if (addr < (addr_t) &dummy->regs.fp_regs) {
180 * prevent reads of padding hole between
181 * orig_gpr2 and fp_regs on s390.
185 } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
187 * floating point regs. are stored in the thread structure
189 offset = addr - (addr_t) &dummy->regs.fp_regs;
190 tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset);
191 if (addr == (addr_t) &dummy->regs.fp_regs.fpc)
192 tmp &= (unsigned long) FPC_VALID_MASK
193 << (BITS_PER_LONG - 32);
195 } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) {
197 * per_info is found in the thread structure
199 offset = addr - (addr_t) &dummy->regs.per_info;
200 tmp = *(addr_t *)((addr_t) &child->thread.per_info + offset);
209 peek_user(struct task_struct *child, addr_t addr, addr_t data)
214 * Stupid gdb peeks/pokes the access registers in 64 bit with
215 * an alignment of 4. Programmers from hell...
219 if (addr >= (addr_t) &((struct user *) NULL)->regs.acrs &&
220 addr < (addr_t) &((struct user *) NULL)->regs.orig_gpr2)
223 if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK)
226 tmp = __peek_user(child, addr);
227 return put_user(tmp, (addr_t __user *) data);
231 * Write a word to the user area of a process at location addr. This
232 * operation does have an additional problem compared to peek_user.
233 * Stores to the program status word and on the floating point
234 * control register needs to get checked for validity.
236 static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
238 struct user *dummy = NULL;
241 if (addr < (addr_t) &dummy->regs.acrs) {
243 * psw and gprs are stored on the stack
245 if (addr == (addr_t) &dummy->regs.psw.mask &&
247 data != PSW_MASK_MERGE(psw_user32_bits, data) &&
249 data != PSW_MASK_MERGE(psw_user_bits, data))
250 /* Invalid psw mask. */
253 if (addr == (addr_t) &dummy->regs.psw.addr)
254 /* I'd like to reject addresses without the
255 high order bit but older gdb's rely on it */
256 data |= PSW_ADDR_AMODE;
258 *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data;
260 } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) {
262 * access registers are stored in the thread structure
264 offset = addr - (addr_t) &dummy->regs.acrs;
267 * Very special case: old & broken 64 bit gdb writing
268 * to acrs[15] with a 64 bit value. Ignore the lower
269 * half of the value and write the upper 32 bit to
272 if (addr == (addr_t) &dummy->regs.acrs[15])
273 child->thread.acrs[15] = (unsigned int) (data >> 32);
276 *(addr_t *)((addr_t) &child->thread.acrs + offset) = data;
278 } else if (addr == (addr_t) &dummy->regs.orig_gpr2) {
280 * orig_gpr2 is stored on the kernel stack
282 task_pt_regs(child)->orig_gpr2 = data;
284 } else if (addr < (addr_t) &dummy->regs.fp_regs) {
286 * prevent writes of padding hole between
287 * orig_gpr2 and fp_regs on s390.
291 } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
293 * floating point regs. are stored in the thread structure
295 if (addr == (addr_t) &dummy->regs.fp_regs.fpc &&
296 (data & ~((unsigned long) FPC_VALID_MASK
297 << (BITS_PER_LONG - 32))) != 0)
299 offset = addr - (addr_t) &dummy->regs.fp_regs;
300 *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data;
302 } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) {
304 * per_info is found in the thread structure
306 offset = addr - (addr_t) &dummy->regs.per_info;
307 *(addr_t *)((addr_t) &child->thread.per_info + offset) = data;
311 FixPerRegisters(child);
316 poke_user(struct task_struct *child, addr_t addr, addr_t data)
321 * Stupid gdb peeks/pokes the access registers in 64 bit with
322 * an alignment of 4. Programmers from hell indeed...
326 if (addr >= (addr_t) &((struct user *) NULL)->regs.acrs &&
327 addr < (addr_t) &((struct user *) NULL)->regs.orig_gpr2)
330 if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK)
333 return __poke_user(child, addr, data);
336 long arch_ptrace(struct task_struct *child, long request, long addr, long data)
343 /* read the word at location addr in the USER area. */
344 return peek_user(child, addr, data);
347 /* write the word at location addr in the USER area */
348 return poke_user(child, addr, data);
350 case PTRACE_PEEKUSR_AREA:
351 case PTRACE_POKEUSR_AREA:
352 if (copy_from_user(&parea, (void __force __user *) addr,
355 addr = parea.kernel_addr;
356 data = parea.process_addr;
358 while (copied < parea.len) {
359 if (request == PTRACE_PEEKUSR_AREA)
360 ret = peek_user(child, addr, data);
364 (addr_t __force __user *) data))
366 ret = poke_user(child, addr, utmp);
370 addr += sizeof(unsigned long);
371 data += sizeof(unsigned long);
372 copied += sizeof(unsigned long);
376 /* Removing high order bit from addr (only for 31 bit). */
377 addr &= PSW_ADDR_INSN;
378 return ptrace_request(child, request, addr, data);
384 * Now the fun part starts... a 31 bit program running in the
385 * 31 bit emulation tracing another program. PTRACE_PEEKTEXT,
386 * PTRACE_PEEKDATA, PTRACE_POKETEXT and PTRACE_POKEDATA are easy
387 * to handle, the difference to the 64 bit versions of the requests
388 * is that the access is done in multiples of 4 byte instead of
389 * 8 bytes (sizeof(unsigned long) on 31/64 bit).
390 * The ugly part are PTRACE_PEEKUSR, PTRACE_PEEKUSR_AREA,
391 * PTRACE_POKEUSR and PTRACE_POKEUSR_AREA. If the traced program
392 * is a 31 bit program too, the content of struct user can be
393 * emulated. A 31 bit program peeking into the struct user of
394 * a 64 bit program is a no-no.
398 * Same as peek_user but for a 31 bit program.
400 static u32 __peek_user_compat(struct task_struct *child, addr_t addr)
402 struct user32 *dummy32 = NULL;
403 per_struct32 *dummy_per32 = NULL;
407 if (addr < (addr_t) &dummy32->regs.acrs) {
409 * psw and gprs are stored on the stack
411 if (addr == (addr_t) &dummy32->regs.psw.mask) {
412 /* Fake a 31 bit psw mask. */
413 tmp = (__u32)(task_pt_regs(child)->psw.mask >> 32);
414 tmp = PSW32_MASK_MERGE(psw32_user_bits, tmp);
415 } else if (addr == (addr_t) &dummy32->regs.psw.addr) {
416 /* Fake a 31 bit psw address. */
417 tmp = (__u32) task_pt_regs(child)->psw.addr |
421 tmp = *(__u32 *)((addr_t) &task_pt_regs(child)->psw +
424 } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {
426 * access registers are stored in the thread structure
428 offset = addr - (addr_t) &dummy32->regs.acrs;
429 tmp = *(__u32*)((addr_t) &child->thread.acrs + offset);
431 } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) {
433 * orig_gpr2 is stored on the kernel stack
435 tmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4);
437 } else if (addr < (addr_t) &dummy32->regs.fp_regs) {
439 * prevent reads of padding hole between
440 * orig_gpr2 and fp_regs on s390.
444 } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {
446 * floating point regs. are stored in the thread structure
448 offset = addr - (addr_t) &dummy32->regs.fp_regs;
449 tmp = *(__u32 *)((addr_t) &child->thread.fp_regs + offset);
451 } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) {
453 * per_info is found in the thread structure
455 offset = addr - (addr_t) &dummy32->regs.per_info;
456 /* This is magic. See per_struct and per_struct32. */
457 if ((offset >= (addr_t) &dummy_per32->control_regs &&
458 offset < (addr_t) (&dummy_per32->control_regs + 1)) ||
459 (offset >= (addr_t) &dummy_per32->starting_addr &&
460 offset <= (addr_t) &dummy_per32->ending_addr) ||
461 offset == (addr_t) &dummy_per32->lowcore.words.address)
462 offset = offset*2 + 4;
465 tmp = *(__u32 *)((addr_t) &child->thread.per_info + offset);
473 static int peek_user_compat(struct task_struct *child,
474 addr_t addr, addr_t data)
478 if (!is_compat_task() || (addr & 3) || addr > sizeof(struct user) - 3)
481 tmp = __peek_user_compat(child, addr);
482 return put_user(tmp, (__u32 __user *) data);
486 * Same as poke_user but for a 31 bit program.
488 static int __poke_user_compat(struct task_struct *child,
489 addr_t addr, addr_t data)
491 struct user32 *dummy32 = NULL;
492 per_struct32 *dummy_per32 = NULL;
493 __u32 tmp = (__u32) data;
496 if (addr < (addr_t) &dummy32->regs.acrs) {
498 * psw, gprs, acrs and orig_gpr2 are stored on the stack
500 if (addr == (addr_t) &dummy32->regs.psw.mask) {
501 /* Build a 64 bit psw mask from 31 bit mask. */
502 if (tmp != PSW32_MASK_MERGE(psw32_user_bits, tmp))
503 /* Invalid psw mask. */
505 task_pt_regs(child)->psw.mask =
506 PSW_MASK_MERGE(psw_user32_bits, (__u64) tmp << 32);
507 } else if (addr == (addr_t) &dummy32->regs.psw.addr) {
508 /* Build a 64 bit psw address from 31 bit address. */
509 task_pt_regs(child)->psw.addr =
510 (__u64) tmp & PSW32_ADDR_INSN;
513 *(__u32*)((addr_t) &task_pt_regs(child)->psw
516 } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {
518 * access registers are stored in the thread structure
520 offset = addr - (addr_t) &dummy32->regs.acrs;
521 *(__u32*)((addr_t) &child->thread.acrs + offset) = tmp;
523 } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) {
525 * orig_gpr2 is stored on the kernel stack
527 *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4) = tmp;
529 } else if (addr < (addr_t) &dummy32->regs.fp_regs) {
531 * prevent writess of padding hole between
532 * orig_gpr2 and fp_regs on s390.
536 } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {
538 * floating point regs. are stored in the thread structure
540 if (addr == (addr_t) &dummy32->regs.fp_regs.fpc &&
541 (tmp & ~FPC_VALID_MASK) != 0)
542 /* Invalid floating point control. */
544 offset = addr - (addr_t) &dummy32->regs.fp_regs;
545 *(__u32 *)((addr_t) &child->thread.fp_regs + offset) = tmp;
547 } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) {
549 * per_info is found in the thread structure.
551 offset = addr - (addr_t) &dummy32->regs.per_info;
553 * This is magic. See per_struct and per_struct32.
554 * By incident the offsets in per_struct are exactly
555 * twice the offsets in per_struct32 for all fields.
556 * The 8 byte fields need special handling though,
557 * because the second half (bytes 4-7) is needed and
558 * not the first half.
560 if ((offset >= (addr_t) &dummy_per32->control_regs &&
561 offset < (addr_t) (&dummy_per32->control_regs + 1)) ||
562 (offset >= (addr_t) &dummy_per32->starting_addr &&
563 offset <= (addr_t) &dummy_per32->ending_addr) ||
564 offset == (addr_t) &dummy_per32->lowcore.words.address)
565 offset = offset*2 + 4;
568 *(__u32 *)((addr_t) &child->thread.per_info + offset) = tmp;
572 FixPerRegisters(child);
576 static int poke_user_compat(struct task_struct *child,
577 addr_t addr, addr_t data)
579 if (!is_compat_task() || (addr & 3) || addr > sizeof(struct user32) - 3)
582 return __poke_user_compat(child, addr, data);
585 long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
586 compat_ulong_t caddr, compat_ulong_t cdata)
588 unsigned long addr = caddr;
589 unsigned long data = cdata;
590 ptrace_area_emu31 parea;
595 /* read the word at location addr in the USER area. */
596 return peek_user_compat(child, addr, data);
599 /* write the word at location addr in the USER area */
600 return poke_user_compat(child, addr, data);
602 case PTRACE_PEEKUSR_AREA:
603 case PTRACE_POKEUSR_AREA:
604 if (copy_from_user(&parea, (void __force __user *) addr,
607 addr = parea.kernel_addr;
608 data = parea.process_addr;
610 while (copied < parea.len) {
611 if (request == PTRACE_PEEKUSR_AREA)
612 ret = peek_user_compat(child, addr, data);
616 (__u32 __force __user *) data))
618 ret = poke_user_compat(child, addr, utmp);
622 addr += sizeof(unsigned int);
623 data += sizeof(unsigned int);
624 copied += sizeof(unsigned int);
628 return compat_ptrace_request(child, request, addr, data);
632 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
636 /* Do the secure computing check first. */
637 secure_computing(regs->gprs[2]);
640 * The sysc_tracesys code in entry.S stored the system
641 * call number to gprs[2].
644 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
645 (tracehook_report_syscall_entry(regs) ||
646 regs->gprs[2] >= NR_syscalls)) {
648 * Tracing decided this syscall should not happen or the
649 * debugger stored an invalid system call number. Skip
650 * the system call and the system call restart handling.
656 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
657 trace_sys_enter(regs, regs->gprs[2]);
659 if (unlikely(current->audit_context))
660 audit_syscall_entry(is_compat_task() ?
661 AUDIT_ARCH_S390 : AUDIT_ARCH_S390X,
662 regs->gprs[2], regs->orig_gpr2,
663 regs->gprs[3], regs->gprs[4],
668 asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
670 if (unlikely(current->audit_context))
671 audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]),
674 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
675 trace_sys_exit(regs, regs->gprs[2]);
677 if (test_thread_flag(TIF_SYSCALL_TRACE))
678 tracehook_report_syscall_exit(regs, 0);
682 * user_regset definitions.
685 static int s390_regs_get(struct task_struct *target,
686 const struct user_regset *regset,
687 unsigned int pos, unsigned int count,
688 void *kbuf, void __user *ubuf)
690 if (target == current)
691 save_access_regs(target->thread.acrs);
694 unsigned long *k = kbuf;
696 *k++ = __peek_user(target, pos);
701 unsigned long __user *u = ubuf;
703 if (__put_user(__peek_user(target, pos), u++))
712 static int s390_regs_set(struct task_struct *target,
713 const struct user_regset *regset,
714 unsigned int pos, unsigned int count,
715 const void *kbuf, const void __user *ubuf)
719 if (target == current)
720 save_access_regs(target->thread.acrs);
723 const unsigned long *k = kbuf;
724 while (count > 0 && !rc) {
725 rc = __poke_user(target, pos, *k++);
730 const unsigned long __user *u = ubuf;
731 while (count > 0 && !rc) {
733 rc = __get_user(word, u++);
736 rc = __poke_user(target, pos, word);
742 if (rc == 0 && target == current)
743 restore_access_regs(target->thread.acrs);
748 static int s390_fpregs_get(struct task_struct *target,
749 const struct user_regset *regset, unsigned int pos,
750 unsigned int count, void *kbuf, void __user *ubuf)
752 if (target == current)
753 save_fp_regs(&target->thread.fp_regs);
755 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
756 &target->thread.fp_regs, 0, -1);
759 static int s390_fpregs_set(struct task_struct *target,
760 const struct user_regset *regset, unsigned int pos,
761 unsigned int count, const void *kbuf,
762 const void __user *ubuf)
766 if (target == current)
767 save_fp_regs(&target->thread.fp_regs);
769 /* If setting FPC, must validate it first. */
770 if (count > 0 && pos < offsetof(s390_fp_regs, fprs)) {
771 u32 fpc[2] = { target->thread.fp_regs.fpc, 0 };
772 rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fpc,
773 0, offsetof(s390_fp_regs, fprs));
776 if ((fpc[0] & ~FPC_VALID_MASK) != 0 || fpc[1] != 0)
778 target->thread.fp_regs.fpc = fpc[0];
781 if (rc == 0 && count > 0)
782 rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
783 target->thread.fp_regs.fprs,
784 offsetof(s390_fp_regs, fprs), -1);
786 if (rc == 0 && target == current)
787 restore_fp_regs(&target->thread.fp_regs);
792 static const struct user_regset s390_regsets[] = {
794 .core_note_type = NT_PRSTATUS,
795 .n = sizeof(s390_regs) / sizeof(long),
796 .size = sizeof(long),
797 .align = sizeof(long),
798 .get = s390_regs_get,
799 .set = s390_regs_set,
802 .core_note_type = NT_PRFPREG,
803 .n = sizeof(s390_fp_regs) / sizeof(long),
804 .size = sizeof(long),
805 .align = sizeof(long),
806 .get = s390_fpregs_get,
807 .set = s390_fpregs_set,
811 static const struct user_regset_view user_s390_view = {
813 .e_machine = EM_S390,
814 .regsets = s390_regsets,
815 .n = ARRAY_SIZE(s390_regsets)
819 static int s390_compat_regs_get(struct task_struct *target,
820 const struct user_regset *regset,
821 unsigned int pos, unsigned int count,
822 void *kbuf, void __user *ubuf)
824 if (target == current)
825 save_access_regs(target->thread.acrs);
828 compat_ulong_t *k = kbuf;
830 *k++ = __peek_user_compat(target, pos);
835 compat_ulong_t __user *u = ubuf;
837 if (__put_user(__peek_user_compat(target, pos), u++))
846 static int s390_compat_regs_set(struct task_struct *target,
847 const struct user_regset *regset,
848 unsigned int pos, unsigned int count,
849 const void *kbuf, const void __user *ubuf)
853 if (target == current)
854 save_access_regs(target->thread.acrs);
857 const compat_ulong_t *k = kbuf;
858 while (count > 0 && !rc) {
859 rc = __poke_user_compat(target, pos, *k++);
864 const compat_ulong_t __user *u = ubuf;
865 while (count > 0 && !rc) {
867 rc = __get_user(word, u++);
870 rc = __poke_user_compat(target, pos, word);
876 if (rc == 0 && target == current)
877 restore_access_regs(target->thread.acrs);
882 static const struct user_regset s390_compat_regsets[] = {
884 .core_note_type = NT_PRSTATUS,
885 .n = sizeof(s390_compat_regs) / sizeof(compat_long_t),
886 .size = sizeof(compat_long_t),
887 .align = sizeof(compat_long_t),
888 .get = s390_compat_regs_get,
889 .set = s390_compat_regs_set,
892 .core_note_type = NT_PRFPREG,
893 .n = sizeof(s390_fp_regs) / sizeof(compat_long_t),
894 .size = sizeof(compat_long_t),
895 .align = sizeof(compat_long_t),
896 .get = s390_fpregs_get,
897 .set = s390_fpregs_set,
901 static const struct user_regset_view user_s390_compat_view = {
903 .e_machine = EM_S390,
904 .regsets = s390_compat_regsets,
905 .n = ARRAY_SIZE(s390_compat_regsets)
909 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
912 if (test_tsk_thread_flag(task, TIF_31BIT))
913 return &user_s390_compat_view;
915 return &user_s390_view;