xref: /openbmc/linux/arch/s390/kernel/compat_signal.c (revision 63dc02bd)
1 /*
2  *  arch/s390/kernel/compat_signal.c
3  *
4  *    Copyright (C) IBM Corp. 2000,2006
5  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
6  *               Gerhard Tonn (ton@de.ibm.com)
7  *
8  *  Copyright (C) 1991, 1992  Linus Torvalds
9  *
10  *  1997-11-28  Modified for POSIX.1b signals by Richard Henderson
11  */
12 
13 #include <linux/compat.h>
14 #include <linux/sched.h>
15 #include <linux/mm.h>
16 #include <linux/smp.h>
17 #include <linux/kernel.h>
18 #include <linux/signal.h>
19 #include <linux/errno.h>
20 #include <linux/wait.h>
21 #include <linux/ptrace.h>
22 #include <linux/unistd.h>
23 #include <linux/stddef.h>
24 #include <linux/tty.h>
25 #include <linux/personality.h>
26 #include <linux/binfmts.h>
27 #include <asm/ucontext.h>
28 #include <asm/uaccess.h>
29 #include <asm/lowcore.h>
30 #include <asm/switch_to.h>
31 #include "compat_linux.h"
32 #include "compat_ptrace.h"
33 #include "entry.h"
34 
35 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
36 
37 typedef struct
38 {
39 	__u8 callee_used_stack[__SIGNAL_FRAMESIZE32];
40 	struct sigcontext32 sc;
41 	_sigregs32 sregs;
42 	int signo;
43 	__u32 gprs_high[NUM_GPRS];
44 	__u8 retcode[S390_SYSCALL_SIZE];
45 } sigframe32;
46 
47 typedef struct
48 {
49 	__u8 callee_used_stack[__SIGNAL_FRAMESIZE32];
50 	__u8 retcode[S390_SYSCALL_SIZE];
51 	compat_siginfo_t info;
52 	struct ucontext32 uc;
53 	__u32 gprs_high[NUM_GPRS];
54 } rt_sigframe32;
55 
56 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
57 {
58 	int err;
59 
60 	if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
61 		return -EFAULT;
62 
63 	/* If you change siginfo_t structure, please be sure
64 	   this code is fixed accordingly.
65 	   It should never copy any pad contained in the structure
66 	   to avoid security leaks, but must copy the generic
67 	   3 ints plus the relevant union member.
68 	   This routine must convert siginfo from 64bit to 32bit as well
69 	   at the same time.  */
70 	err = __put_user(from->si_signo, &to->si_signo);
71 	err |= __put_user(from->si_errno, &to->si_errno);
72 	err |= __put_user((short)from->si_code, &to->si_code);
73 	if (from->si_code < 0)
74 		err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
75 	else {
76 		switch (from->si_code >> 16) {
77 		case __SI_RT >> 16: /* This is not generated by the kernel as of now.  */
78 		case __SI_MESGQ >> 16:
79 			err |= __put_user(from->si_int, &to->si_int);
80 			/* fallthrough */
81 		case __SI_KILL >> 16:
82 			err |= __put_user(from->si_pid, &to->si_pid);
83 			err |= __put_user(from->si_uid, &to->si_uid);
84 			break;
85 		case __SI_CHLD >> 16:
86 			err |= __put_user(from->si_pid, &to->si_pid);
87 			err |= __put_user(from->si_uid, &to->si_uid);
88 			err |= __put_user(from->si_utime, &to->si_utime);
89 			err |= __put_user(from->si_stime, &to->si_stime);
90 			err |= __put_user(from->si_status, &to->si_status);
91 			break;
92 		case __SI_FAULT >> 16:
93 			err |= __put_user((unsigned long) from->si_addr,
94 					  &to->si_addr);
95 			break;
96 		case __SI_POLL >> 16:
97 			err |= __put_user(from->si_band, &to->si_band);
98 			err |= __put_user(from->si_fd, &to->si_fd);
99 			break;
100 		case __SI_TIMER >> 16:
101 			err |= __put_user(from->si_tid, &to->si_tid);
102 			err |= __put_user(from->si_overrun, &to->si_overrun);
103 			err |= __put_user(from->si_int, &to->si_int);
104 			break;
105 		default:
106 			break;
107 		}
108 	}
109 	return err;
110 }
111 
112 int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
113 {
114 	int err;
115 	u32 tmp;
116 
117 	if (!access_ok (VERIFY_READ, from, sizeof(compat_siginfo_t)))
118 		return -EFAULT;
119 
120 	err = __get_user(to->si_signo, &from->si_signo);
121 	err |= __get_user(to->si_errno, &from->si_errno);
122 	err |= __get_user(to->si_code, &from->si_code);
123 
124 	if (to->si_code < 0)
125 		err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
126 	else {
127 		switch (to->si_code >> 16) {
128 		case __SI_RT >> 16: /* This is not generated by the kernel as of now.  */
129 		case __SI_MESGQ >> 16:
130 			err |= __get_user(to->si_int, &from->si_int);
131 			/* fallthrough */
132 		case __SI_KILL >> 16:
133 			err |= __get_user(to->si_pid, &from->si_pid);
134 			err |= __get_user(to->si_uid, &from->si_uid);
135 			break;
136 		case __SI_CHLD >> 16:
137 			err |= __get_user(to->si_pid, &from->si_pid);
138 			err |= __get_user(to->si_uid, &from->si_uid);
139 			err |= __get_user(to->si_utime, &from->si_utime);
140 			err |= __get_user(to->si_stime, &from->si_stime);
141 			err |= __get_user(to->si_status, &from->si_status);
142 			break;
143 		case __SI_FAULT >> 16:
144 			err |= __get_user(tmp, &from->si_addr);
145 			to->si_addr = (void __force __user *)
146 				(u64) (tmp & PSW32_ADDR_INSN);
147 			break;
148 		case __SI_POLL >> 16:
149 			err |= __get_user(to->si_band, &from->si_band);
150 			err |= __get_user(to->si_fd, &from->si_fd);
151 			break;
152 		case __SI_TIMER >> 16:
153 			err |= __get_user(to->si_tid, &from->si_tid);
154 			err |= __get_user(to->si_overrun, &from->si_overrun);
155 			err |= __get_user(to->si_int, &from->si_int);
156 			break;
157 		default:
158 			break;
159 		}
160 	}
161 	return err;
162 }
163 
164 asmlinkage long
165 sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
166 		 struct old_sigaction32 __user *oact)
167 {
168         struct k_sigaction new_ka, old_ka;
169 	unsigned long sa_handler, sa_restorer;
170         int ret;
171 
172         if (act) {
173 		compat_old_sigset_t mask;
174 		if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
175 		    __get_user(sa_handler, &act->sa_handler) ||
176 		    __get_user(sa_restorer, &act->sa_restorer) ||
177 		    __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
178 		    __get_user(mask, &act->sa_mask))
179 			return -EFAULT;
180 		new_ka.sa.sa_handler = (__sighandler_t) sa_handler;
181 		new_ka.sa.sa_restorer = (void (*)(void)) sa_restorer;
182 		siginitset(&new_ka.sa.sa_mask, mask);
183         }
184 
185         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
186 
187 	if (!ret && oact) {
188 		sa_handler = (unsigned long) old_ka.sa.sa_handler;
189 		sa_restorer = (unsigned long) old_ka.sa.sa_restorer;
190 		if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
191 		    __put_user(sa_handler, &oact->sa_handler) ||
192 		    __put_user(sa_restorer, &oact->sa_restorer) ||
193 		    __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
194 		    __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
195 			return -EFAULT;
196         }
197 
198 	return ret;
199 }
200 
201 asmlinkage long
202 sys32_rt_sigaction(int sig, const struct sigaction32 __user *act,
203 	   struct sigaction32 __user *oact,  size_t sigsetsize)
204 {
205 	struct k_sigaction new_ka, old_ka;
206 	unsigned long sa_handler;
207 	int ret;
208 	compat_sigset_t set32;
209 
210 	/* XXX: Don't preclude handling different sized sigset_t's.  */
211 	if (sigsetsize != sizeof(compat_sigset_t))
212 		return -EINVAL;
213 
214 	if (act) {
215 		ret = get_user(sa_handler, &act->sa_handler);
216 		ret |= __copy_from_user(&set32, &act->sa_mask,
217 					sizeof(compat_sigset_t));
218 		new_ka.sa.sa_mask.sig[0] =
219 			set32.sig[0] | (((long)set32.sig[1]) << 32);
220 		ret |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
221 
222 		if (ret)
223 			return -EFAULT;
224 		new_ka.sa.sa_handler = (__sighandler_t) sa_handler;
225 	}
226 
227 	ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
228 
229 	if (!ret && oact) {
230 		set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
231 		set32.sig[0] = old_ka.sa.sa_mask.sig[0];
232 		ret = put_user((unsigned long)old_ka.sa.sa_handler, &oact->sa_handler);
233 		ret |= __copy_to_user(&oact->sa_mask, &set32,
234 				      sizeof(compat_sigset_t));
235 		ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
236 	}
237 
238 	return ret;
239 }
240 
241 asmlinkage long
242 sys32_sigaltstack(const stack_t32 __user *uss, stack_t32 __user *uoss)
243 {
244 	struct pt_regs *regs = task_pt_regs(current);
245 	stack_t kss, koss;
246 	unsigned long ss_sp;
247 	int ret, err = 0;
248 	mm_segment_t old_fs = get_fs();
249 
250 	if (uss) {
251 		if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
252 			return -EFAULT;
253 		err |= __get_user(ss_sp, &uss->ss_sp);
254 		err |= __get_user(kss.ss_size, &uss->ss_size);
255 		err |= __get_user(kss.ss_flags, &uss->ss_flags);
256 		if (err)
257 			return -EFAULT;
258 		kss.ss_sp = (void __user *) ss_sp;
259 	}
260 
261 	set_fs (KERNEL_DS);
262 	ret = do_sigaltstack((stack_t __force __user *) (uss ? &kss : NULL),
263 			     (stack_t __force __user *) (uoss ? &koss : NULL),
264 			     regs->gprs[15]);
265 	set_fs (old_fs);
266 
267 	if (!ret && uoss) {
268 		if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
269 			return -EFAULT;
270 		ss_sp = (unsigned long) koss.ss_sp;
271 		err |= __put_user(ss_sp, &uoss->ss_sp);
272 		err |= __put_user(koss.ss_size, &uoss->ss_size);
273 		err |= __put_user(koss.ss_flags, &uoss->ss_flags);
274 		if (err)
275 			return -EFAULT;
276 	}
277 	return ret;
278 }
279 
280 static int save_sigregs32(struct pt_regs *regs, _sigregs32 __user *sregs)
281 {
282 	_s390_regs_common32 regs32;
283 	int err, i;
284 
285 	regs32.psw.mask = psw32_user_bits |
286 		((__u32)(regs->psw.mask >> 32) & PSW32_MASK_USER);
287 	regs32.psw.addr = (__u32) regs->psw.addr |
288 		(__u32)(regs->psw.mask & PSW_MASK_BA);
289 	for (i = 0; i < NUM_GPRS; i++)
290 		regs32.gprs[i] = (__u32) regs->gprs[i];
291 	save_access_regs(current->thread.acrs);
292 	memcpy(regs32.acrs, current->thread.acrs, sizeof(regs32.acrs));
293 	err = __copy_to_user(&sregs->regs, &regs32, sizeof(regs32));
294 	if (err)
295 		return err;
296 	save_fp_regs(&current->thread.fp_regs);
297 	/* s390_fp_regs and _s390_fp_regs32 are the same ! */
298 	return __copy_to_user(&sregs->fpregs, &current->thread.fp_regs,
299 			      sizeof(_s390_fp_regs32));
300 }
301 
302 static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
303 {
304 	_s390_regs_common32 regs32;
305 	int err, i;
306 
307 	/* Alwys make any pending restarted system call return -EINTR */
308 	current_thread_info()->restart_block.fn = do_no_restart_syscall;
309 
310 	err = __copy_from_user(&regs32, &sregs->regs, sizeof(regs32));
311 	if (err)
312 		return err;
313 	regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
314 		(__u64)(regs32.psw.mask & PSW32_MASK_USER) << 32 |
315 		(__u64)(regs32.psw.addr & PSW32_ADDR_AMODE);
316 	regs->psw.addr = (__u64)(regs32.psw.addr & PSW32_ADDR_INSN);
317 	for (i = 0; i < NUM_GPRS; i++)
318 		regs->gprs[i] = (__u64) regs32.gprs[i];
319 	memcpy(current->thread.acrs, regs32.acrs, sizeof(current->thread.acrs));
320 	restore_access_regs(current->thread.acrs);
321 
322 	err = __copy_from_user(&current->thread.fp_regs, &sregs->fpregs,
323 			       sizeof(_s390_fp_regs32));
324 	current->thread.fp_regs.fpc &= FPC_VALID_MASK;
325 	if (err)
326 		return err;
327 
328 	restore_fp_regs(&current->thread.fp_regs);
329 	clear_thread_flag(TIF_SYSCALL);	/* No longer in a system call */
330 	return 0;
331 }
332 
333 static int save_sigregs_gprs_high(struct pt_regs *regs, __u32 __user *uregs)
334 {
335 	__u32 gprs_high[NUM_GPRS];
336 	int i;
337 
338 	for (i = 0; i < NUM_GPRS; i++)
339 		gprs_high[i] = regs->gprs[i] >> 32;
340 
341 	return __copy_to_user(uregs, &gprs_high, sizeof(gprs_high));
342 }
343 
344 static int restore_sigregs_gprs_high(struct pt_regs *regs, __u32 __user *uregs)
345 {
346 	__u32 gprs_high[NUM_GPRS];
347 	int err, i;
348 
349 	err = __copy_from_user(&gprs_high, uregs, sizeof(gprs_high));
350 	if (err)
351 		return err;
352 	for (i = 0; i < NUM_GPRS; i++)
353 		*(__u32 *)&regs->gprs[i] = gprs_high[i];
354 	return 0;
355 }
356 
357 asmlinkage long sys32_sigreturn(void)
358 {
359 	struct pt_regs *regs = task_pt_regs(current);
360 	sigframe32 __user *frame = (sigframe32 __user *)regs->gprs[15];
361 	sigset_t set;
362 
363 	if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
364 		goto badframe;
365 	if (__copy_from_user(&set.sig, &frame->sc.oldmask, _SIGMASK_COPY_SIZE32))
366 		goto badframe;
367 	sigdelsetmask(&set, ~_BLOCKABLE);
368 	set_current_blocked(&set);
369 	if (restore_sigregs32(regs, &frame->sregs))
370 		goto badframe;
371 	if (restore_sigregs_gprs_high(regs, frame->gprs_high))
372 		goto badframe;
373 	return regs->gprs[2];
374 badframe:
375 	force_sig(SIGSEGV, current);
376 	return 0;
377 }
378 
379 asmlinkage long sys32_rt_sigreturn(void)
380 {
381 	struct pt_regs *regs = task_pt_regs(current);
382 	rt_sigframe32 __user *frame = (rt_sigframe32 __user *)regs->gprs[15];
383 	sigset_t set;
384 	stack_t st;
385 	__u32 ss_sp;
386 	int err;
387 	mm_segment_t old_fs = get_fs();
388 
389 	if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
390 		goto badframe;
391 	if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
392 		goto badframe;
393 	sigdelsetmask(&set, ~_BLOCKABLE);
394 	set_current_blocked(&set);
395 	if (restore_sigregs32(regs, &frame->uc.uc_mcontext))
396 		goto badframe;
397 	if (restore_sigregs_gprs_high(regs, frame->gprs_high))
398 		goto badframe;
399 	err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp);
400 	st.ss_sp = compat_ptr(ss_sp);
401 	err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size);
402 	err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags);
403 	if (err)
404 		goto badframe;
405 	set_fs (KERNEL_DS);
406 	do_sigaltstack((stack_t __force __user *)&st, NULL, regs->gprs[15]);
407 	set_fs (old_fs);
408 	return regs->gprs[2];
409 badframe:
410 	force_sig(SIGSEGV, current);
411 	return 0;
412 }
413 
414 /*
415  * Set up a signal frame.
416  */
417 
418 
419 /*
420  * Determine which stack to use..
421  */
422 static inline void __user *
423 get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
424 {
425 	unsigned long sp;
426 
427 	/* Default to using normal stack */
428 	sp = (unsigned long) A(regs->gprs[15]);
429 
430 	/* Overflow on alternate signal stack gives SIGSEGV. */
431 	if (on_sig_stack(sp) && !on_sig_stack((sp - frame_size) & -8UL))
432 		return (void __user *) -1UL;
433 
434 	/* This is the X/Open sanctioned signal stack switching.  */
435 	if (ka->sa.sa_flags & SA_ONSTACK) {
436 		if (! sas_ss_flags(sp))
437 			sp = current->sas_ss_sp + current->sas_ss_size;
438 	}
439 
440 	/* This is the legacy signal stack switching. */
441 	else if (!user_mode(regs) &&
442 		 !(ka->sa.sa_flags & SA_RESTORER) &&
443 		 ka->sa.sa_restorer) {
444 		sp = (unsigned long) ka->sa.sa_restorer;
445 	}
446 
447 	return (void __user *)((sp - frame_size) & -8ul);
448 }
449 
450 static inline int map_signal(int sig)
451 {
452 	if (current_thread_info()->exec_domain
453 	    && current_thread_info()->exec_domain->signal_invmap
454 	    && sig < 32)
455 		return current_thread_info()->exec_domain->signal_invmap[sig];
456         else
457 		return sig;
458 }
459 
460 static int setup_frame32(int sig, struct k_sigaction *ka,
461 			sigset_t *set, struct pt_regs * regs)
462 {
463 	sigframe32 __user *frame = get_sigframe(ka, regs, sizeof(sigframe32));
464 	if (!access_ok(VERIFY_WRITE, frame, sizeof(sigframe32)))
465 		goto give_sigsegv;
466 
467 	if (frame == (void __user *) -1UL)
468 		goto give_sigsegv;
469 
470 	if (__copy_to_user(&frame->sc.oldmask, &set->sig, _SIGMASK_COPY_SIZE32))
471 		goto give_sigsegv;
472 
473 	if (save_sigregs32(regs, &frame->sregs))
474 		goto give_sigsegv;
475 	if (save_sigregs_gprs_high(regs, frame->gprs_high))
476 		goto give_sigsegv;
477 	if (__put_user((unsigned long) &frame->sregs, &frame->sc.sregs))
478 		goto give_sigsegv;
479 
480 	/* Set up to return from userspace.  If provided, use a stub
481 	   already in userspace.  */
482 	if (ka->sa.sa_flags & SA_RESTORER) {
483 		regs->gprs[14] = (__u64) ka->sa.sa_restorer | PSW32_ADDR_AMODE;
484 	} else {
485 		regs->gprs[14] = (__u64) frame->retcode | PSW32_ADDR_AMODE;
486 		if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn,
487 			       (u16 __force __user *)(frame->retcode)))
488 			goto give_sigsegv;
489         }
490 
491 	/* Set up backchain. */
492 	if (__put_user(regs->gprs[15], (unsigned int __user *) frame))
493 		goto give_sigsegv;
494 
495 	/* Set up registers for signal handler */
496 	regs->gprs[15] = (__force __u64) frame;
497 	regs->psw.mask |= PSW_MASK_BA;		/* force amode 31 */
498 	regs->psw.addr = (__force __u64) ka->sa.sa_handler;
499 
500 	regs->gprs[2] = map_signal(sig);
501 	regs->gprs[3] = (__force __u64) &frame->sc;
502 
503 	/* We forgot to include these in the sigcontext.
504 	   To avoid breaking binary compatibility, they are passed as args. */
505 	if (sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
506 	    sig == SIGTRAP || sig == SIGFPE) {
507 		/* set extra registers only for synchronous signals */
508 		regs->gprs[4] = regs->int_code & 127;
509 		regs->gprs[5] = regs->int_parm_long;
510 	}
511 
512 	/* Place signal number on stack to allow backtrace from handler.  */
513 	if (__put_user(regs->gprs[2], (int __force __user *) &frame->signo))
514 		goto give_sigsegv;
515 	return 0;
516 
517 give_sigsegv:
518 	force_sigsegv(sig, current);
519 	return -EFAULT;
520 }
521 
522 static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info,
523 			   sigset_t *set, struct pt_regs * regs)
524 {
525 	int err = 0;
526 	rt_sigframe32 __user *frame = get_sigframe(ka, regs, sizeof(rt_sigframe32));
527 	if (!access_ok(VERIFY_WRITE, frame, sizeof(rt_sigframe32)))
528 		goto give_sigsegv;
529 
530 	if (frame == (void __user *) -1UL)
531 		goto give_sigsegv;
532 
533 	if (copy_siginfo_to_user32(&frame->info, info))
534 		goto give_sigsegv;
535 
536 	/* Create the ucontext.  */
537 	err |= __put_user(UC_EXTENDED, &frame->uc.uc_flags);
538 	err |= __put_user(0, &frame->uc.uc_link);
539 	err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
540 	err |= __put_user(sas_ss_flags(regs->gprs[15]),
541 	                  &frame->uc.uc_stack.ss_flags);
542 	err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
543 	err |= save_sigregs32(regs, &frame->uc.uc_mcontext);
544 	err |= save_sigregs_gprs_high(regs, frame->gprs_high);
545 	err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
546 	if (err)
547 		goto give_sigsegv;
548 
549 	/* Set up to return from userspace.  If provided, use a stub
550 	   already in userspace.  */
551 	if (ka->sa.sa_flags & SA_RESTORER) {
552 		regs->gprs[14] = (__u64) ka->sa.sa_restorer | PSW32_ADDR_AMODE;
553 	} else {
554 		regs->gprs[14] = (__u64) frame->retcode | PSW32_ADDR_AMODE;
555 		err |= __put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn,
556 				  (u16 __force __user *)(frame->retcode));
557 	}
558 
559 	/* Set up backchain. */
560 	if (__put_user(regs->gprs[15], (unsigned int __force __user *) frame))
561 		goto give_sigsegv;
562 
563 	/* Set up registers for signal handler */
564 	regs->gprs[15] = (__force __u64) frame;
565 	regs->psw.mask |= PSW_MASK_BA;		/* force amode 31 */
566 	regs->psw.addr = (__u64) ka->sa.sa_handler;
567 
568 	regs->gprs[2] = map_signal(sig);
569 	regs->gprs[3] = (__force __u64) &frame->info;
570 	regs->gprs[4] = (__force __u64) &frame->uc;
571 	return 0;
572 
573 give_sigsegv:
574 	force_sigsegv(sig, current);
575 	return -EFAULT;
576 }
577 
578 /*
579  * OK, we're invoking a handler
580  */
581 
582 int handle_signal32(unsigned long sig, struct k_sigaction *ka,
583 		    siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
584 {
585 	int ret;
586 
587 	/* Set up the stack frame */
588 	if (ka->sa.sa_flags & SA_SIGINFO)
589 		ret = setup_rt_frame32(sig, ka, info, oldset, regs);
590 	else
591 		ret = setup_frame32(sig, ka, oldset, regs);
592 	if (ret)
593 		return ret;
594 	block_sigmask(ka, sig);
595 	return 0;
596 }
597 
598