1 // SPDX-License-Identifier: GPL-2.0
2 /* arch/sparc64/kernel/signal32.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
8 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/signal.h>
14 #include <linux/errno.h>
15 #include <linux/wait.h>
16 #include <linux/ptrace.h>
17 #include <linux/unistd.h>
19 #include <linux/tty.h>
20 #include <linux/binfmts.h>
21 #include <linux/compat.h>
22 #include <linux/bitops.h>
23 #include <linux/tracehook.h>
25 #include <linux/uaccess.h>
26 #include <asm/ptrace.h>
27 #include <asm/pgtable.h>
28 #include <asm/psrcompat.h>
29 #include <asm/fpumacro.h>
30 #include <asm/visasm.h>
31 #include <asm/compat_signal.h>
32 #include <asm/switch_to.h>
37 /* This magic should be in g_upper[0] for all upper parts
40 #define SIGINFO_EXTRA_V8PLUS_MAGIC 0x130e269
42 unsigned int g_upper
[8];
43 unsigned int o_upper
[8];
45 } siginfo_extra_v8plus_t
;
47 struct signal_frame32
{
48 struct sparc_stackf32 ss
;
50 /* __siginfo_fpu_t * */ u32 fpu_save
;
51 unsigned int insns
[2];
52 unsigned int extramask
[_COMPAT_NSIG_WORDS
- 1];
53 unsigned int extra_size
; /* Should be sizeof(siginfo_extra_v8plus_t) */
54 /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
55 siginfo_extra_v8plus_t v8plus
;
56 /* __siginfo_rwin_t * */u32 rwin_save
;
57 } __attribute__((aligned(8)));
59 struct rt_signal_frame32
{
60 struct sparc_stackf32 ss
;
61 compat_siginfo_t info
;
62 struct pt_regs32 regs
;
64 /* __siginfo_fpu_t * */ u32 fpu_save
;
65 unsigned int insns
[2];
67 unsigned int extra_size
; /* Should be sizeof(siginfo_extra_v8plus_t) */
68 /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
69 siginfo_extra_v8plus_t v8plus
;
70 /* __siginfo_rwin_t * */u32 rwin_save
;
71 } __attribute__((aligned(8)));
73 /* Checks if the fp is valid. We always build signal frames which are
74 * 16-byte aligned, therefore we can always enforce that the restore
75 * frame has that property as well.
77 static bool invalid_frame_pointer(void __user
*fp
, int fplen
)
79 if ((((unsigned long) fp
) & 15) ||
80 ((unsigned long)fp
) > 0x100000000ULL
- fplen
)
85 void do_sigreturn32(struct pt_regs
*regs
)
87 struct signal_frame32 __user
*sf
;
88 compat_uptr_t fpu_save
;
89 compat_uptr_t rwin_save
;
90 unsigned int psr
, ufp
;
96 /* Always make any pending restarted system calls return -EINTR */
97 current
->restart_block
.fn
= do_no_restart_syscall
;
99 synchronize_user_stack();
101 regs
->u_regs
[UREG_FP
] &= 0x00000000ffffffffUL
;
102 sf
= (struct signal_frame32 __user
*) regs
->u_regs
[UREG_FP
];
104 /* 1. Make sure we are not getting garbage from the user */
105 if (invalid_frame_pointer(sf
, sizeof(*sf
)))
108 if (get_user(ufp
, &sf
->info
.si_regs
.u_regs
[UREG_FP
]))
114 if (__get_user(pc
, &sf
->info
.si_regs
.pc
) ||
115 __get_user(npc
, &sf
->info
.si_regs
.npc
))
121 if (test_thread_flag(TIF_32BIT
)) {
128 /* 2. Restore the state */
129 err
= __get_user(regs
->y
, &sf
->info
.si_regs
.y
);
130 err
|= __get_user(psr
, &sf
->info
.si_regs
.psr
);
132 for (i
= UREG_G1
; i
<= UREG_I7
; i
++)
133 err
|= __get_user(regs
->u_regs
[i
], &sf
->info
.si_regs
.u_regs
[i
]);
134 if ((psr
& (PSR_VERS
|PSR_IMPL
)) == PSR_V8PLUS
) {
135 err
|= __get_user(i
, &sf
->v8plus
.g_upper
[0]);
136 if (i
== SIGINFO_EXTRA_V8PLUS_MAGIC
) {
139 for (i
= UREG_G1
; i
<= UREG_I7
; i
++)
140 err
|= __get_user(((u32
*)regs
->u_regs
)[2*i
], &sf
->v8plus
.g_upper
[i
]);
141 err
|= __get_user(asi
, &sf
->v8plus
.asi
);
142 regs
->tstate
&= ~TSTATE_ASI
;
143 regs
->tstate
|= ((asi
& 0xffUL
) << 24UL);
147 /* User can only change condition codes in %tstate. */
148 regs
->tstate
&= ~(TSTATE_ICC
|TSTATE_XCC
);
149 regs
->tstate
|= psr_to_tstate_icc(psr
);
151 /* Prevent syscall restart. */
152 pt_regs_clear_syscall(regs
);
154 err
|= __get_user(fpu_save
, &sf
->fpu_save
);
155 if (!err
&& fpu_save
)
156 err
|= restore_fpu_state(regs
, compat_ptr(fpu_save
));
157 err
|= __get_user(rwin_save
, &sf
->rwin_save
);
158 if (!err
&& rwin_save
) {
159 if (restore_rwin_state(compat_ptr(rwin_save
)))
162 err
|= __get_user(seta
.sig
[0], &sf
->info
.si_mask
);
163 err
|= copy_from_user(&seta
.sig
[1], &sf
->extramask
,
164 (_COMPAT_NSIG_WORDS
- 1) * sizeof(unsigned int));
168 set
.sig
[0] = seta
.sig
[0] + (((long)seta
.sig
[1]) << 32);
169 set_current_blocked(&set
);
176 asmlinkage
void do_rt_sigreturn32(struct pt_regs
*regs
)
178 struct rt_signal_frame32 __user
*sf
;
179 unsigned int psr
, pc
, npc
, ufp
;
180 compat_uptr_t fpu_save
;
181 compat_uptr_t rwin_save
;
185 /* Always make any pending restarted system calls return -EINTR */
186 current
->restart_block
.fn
= do_no_restart_syscall
;
188 synchronize_user_stack();
189 regs
->u_regs
[UREG_FP
] &= 0x00000000ffffffffUL
;
190 sf
= (struct rt_signal_frame32 __user
*) regs
->u_regs
[UREG_FP
];
192 /* 1. Make sure we are not getting garbage from the user */
193 if (invalid_frame_pointer(sf
, sizeof(*sf
)))
196 if (get_user(ufp
, &sf
->regs
.u_regs
[UREG_FP
]))
202 if (__get_user(pc
, &sf
->regs
.pc
) ||
203 __get_user(npc
, &sf
->regs
.npc
))
209 if (test_thread_flag(TIF_32BIT
)) {
216 /* 2. Restore the state */
217 err
= __get_user(regs
->y
, &sf
->regs
.y
);
218 err
|= __get_user(psr
, &sf
->regs
.psr
);
220 for (i
= UREG_G1
; i
<= UREG_I7
; i
++)
221 err
|= __get_user(regs
->u_regs
[i
], &sf
->regs
.u_regs
[i
]);
222 if ((psr
& (PSR_VERS
|PSR_IMPL
)) == PSR_V8PLUS
) {
223 err
|= __get_user(i
, &sf
->v8plus
.g_upper
[0]);
224 if (i
== SIGINFO_EXTRA_V8PLUS_MAGIC
) {
227 for (i
= UREG_G1
; i
<= UREG_I7
; i
++)
228 err
|= __get_user(((u32
*)regs
->u_regs
)[2*i
], &sf
->v8plus
.g_upper
[i
]);
229 err
|= __get_user(asi
, &sf
->v8plus
.asi
);
230 regs
->tstate
&= ~TSTATE_ASI
;
231 regs
->tstate
|= ((asi
& 0xffUL
) << 24UL);
235 /* User can only change condition codes in %tstate. */
236 regs
->tstate
&= ~(TSTATE_ICC
|TSTATE_XCC
);
237 regs
->tstate
|= psr_to_tstate_icc(psr
);
239 /* Prevent syscall restart. */
240 pt_regs_clear_syscall(regs
);
242 err
|= __get_user(fpu_save
, &sf
->fpu_save
);
243 if (!err
&& fpu_save
)
244 err
|= restore_fpu_state(regs
, compat_ptr(fpu_save
));
245 err
|= get_compat_sigset(&set
, &sf
->mask
);
246 err
|= compat_restore_altstack(&sf
->stack
);
250 err
|= __get_user(rwin_save
, &sf
->rwin_save
);
251 if (!err
&& rwin_save
) {
252 if (restore_rwin_state(compat_ptr(rwin_save
)))
256 set_current_blocked(&set
);
262 static void __user
*get_sigframe(struct ksignal
*ksig
, struct pt_regs
*regs
, unsigned long framesize
)
266 regs
->u_regs
[UREG_FP
] &= 0x00000000ffffffffUL
;
267 sp
= regs
->u_regs
[UREG_FP
];
270 * If we are on the alternate signal stack and would overflow it, don't.
271 * Return an always-bogus address instead so we will die with SIGSEGV.
273 if (on_sig_stack(sp
) && !likely(on_sig_stack(sp
- framesize
)))
274 return (void __user
*) -1L;
276 /* This is the X/Open sanctioned signal stack switching. */
277 sp
= sigsp(sp
, ksig
) - framesize
;
279 /* Always align the stack frame. This handles two cases. First,
280 * sigaltstack need not be mindful of platform specific stack
281 * alignment. Second, if we took this signal because the stack
282 * is not aligned properly, we'd like to take the signal cleanly
287 return (void __user
*) sp
;
290 /* The I-cache flush instruction only works in the primary ASI, which
291 * right now is the nucleus, aka. kernel space.
293 * Therefore we have to kick the instructions out using the kernel
294 * side linear mapping of the physical address backing the user
297 static void flush_signal_insns(unsigned long address
)
299 unsigned long pstate
, paddr
;
306 /* Commit all stores of the instructions we are about to flush. */
309 /* Disable cross-call reception. In this way even a very wide
310 * munmap() on another cpu can't tear down the page table
311 * hierarchy from underneath us, since that can't complete
312 * until the IPI tlb flush returns.
315 __asm__
__volatile__("rdpr %%pstate, %0" : "=r" (pstate
));
316 __asm__
__volatile__("wrpr %0, %1, %%pstate"
317 : : "r" (pstate
), "i" (PSTATE_IE
));
319 pgdp
= pgd_offset(current
->mm
, address
);
322 p4dp
= p4d_offset(pgdp
, address
);
325 pudp
= pud_offset(p4dp
, address
);
328 pmdp
= pmd_offset(pudp
, address
);
332 ptep
= pte_offset_map(pmdp
, address
);
334 if (!pte_present(pte
))
337 paddr
= (unsigned long) page_address(pte_page(pte
));
339 __asm__
__volatile__("flush %0 + %1"
342 "r" (address
& (PAGE_SIZE
- 1))
348 __asm__
__volatile__("wrpr %0, 0x0, %%pstate" : : "r" (pstate
));
352 static int setup_frame32(struct ksignal
*ksig
, struct pt_regs
*regs
,
355 struct signal_frame32 __user
*sf
;
360 compat_sigset_t seta
;
362 /* 1. Make sure everything is clean */
363 synchronize_user_stack();
364 save_and_clear_fpu();
366 wsaved
= get_thread_wsaved();
368 sigframe_size
= sizeof(*sf
);
369 if (current_thread_info()->fpsaved
[0] & FPRS_FEF
)
370 sigframe_size
+= sizeof(__siginfo_fpu_t
);
372 sigframe_size
+= sizeof(__siginfo_rwin_t
);
374 sf
= (struct signal_frame32 __user
*)
375 get_sigframe(ksig
, regs
, sigframe_size
);
377 if (invalid_frame_pointer(sf
, sigframe_size
)) {
378 if (show_unhandled_signals
)
379 pr_info("%s[%d] bad frame in setup_frame32: %08lx TPC %08lx O7 %08lx\n",
380 current
->comm
, current
->pid
, (unsigned long)sf
,
381 regs
->tpc
, regs
->u_regs
[UREG_I7
]);
382 force_sigsegv(ksig
->sig
);
388 /* 2. Save the current process state */
389 if (test_thread_flag(TIF_32BIT
)) {
390 regs
->tpc
&= 0xffffffff;
391 regs
->tnpc
&= 0xffffffff;
393 err
= put_user(regs
->tpc
, &sf
->info
.si_regs
.pc
);
394 err
|= __put_user(regs
->tnpc
, &sf
->info
.si_regs
.npc
);
395 err
|= __put_user(regs
->y
, &sf
->info
.si_regs
.y
);
396 psr
= tstate_to_psr(regs
->tstate
);
397 if (current_thread_info()->fpsaved
[0] & FPRS_FEF
)
399 err
|= __put_user(psr
, &sf
->info
.si_regs
.psr
);
400 for (i
= 0; i
< 16; i
++)
401 err
|= __put_user(regs
->u_regs
[i
], &sf
->info
.si_regs
.u_regs
[i
]);
402 err
|= __put_user(sizeof(siginfo_extra_v8plus_t
), &sf
->extra_size
);
403 err
|= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC
, &sf
->v8plus
.g_upper
[0]);
404 for (i
= 1; i
< 16; i
++)
405 err
|= __put_user(((u32
*)regs
->u_regs
)[2*i
],
406 &sf
->v8plus
.g_upper
[i
]);
407 err
|= __put_user((regs
->tstate
& TSTATE_ASI
) >> 24UL,
411 __siginfo_fpu_t __user
*fp
= tail
;
413 err
|= save_fpu_state(regs
, fp
);
414 err
|= __put_user((u64
)fp
, &sf
->fpu_save
);
416 err
|= __put_user(0, &sf
->fpu_save
);
419 __siginfo_rwin_t __user
*rwp
= tail
;
420 tail
+= sizeof(*rwp
);
421 err
|= save_rwin_state(wsaved
, rwp
);
422 err
|= __put_user((u64
)rwp
, &sf
->rwin_save
);
423 set_thread_wsaved(0);
425 err
|= __put_user(0, &sf
->rwin_save
);
428 /* If these change we need to know - assignments to seta relies on these sizes */
429 BUILD_BUG_ON(_NSIG_WORDS
!= 1);
430 BUILD_BUG_ON(_COMPAT_NSIG_WORDS
!= 2);
431 seta
.sig
[1] = (oldset
->sig
[0] >> 32);
432 seta
.sig
[0] = oldset
->sig
[0];
434 err
|= __put_user(seta
.sig
[0], &sf
->info
.si_mask
);
435 err
|= __copy_to_user(sf
->extramask
, &seta
.sig
[1],
436 (_COMPAT_NSIG_WORDS
- 1) * sizeof(unsigned int));
439 err
|= copy_in_user((u32 __user
*)sf
,
440 (u32 __user
*)(regs
->u_regs
[UREG_FP
]),
441 sizeof(struct reg_window32
));
443 struct reg_window
*rp
;
445 rp
= ¤t_thread_info()->reg_window
[wsaved
- 1];
446 for (i
= 0; i
< 8; i
++)
447 err
|= __put_user(rp
->locals
[i
], &sf
->ss
.locals
[i
]);
448 for (i
= 0; i
< 6; i
++)
449 err
|= __put_user(rp
->ins
[i
], &sf
->ss
.ins
[i
]);
450 err
|= __put_user(rp
->ins
[6], &sf
->ss
.fp
);
451 err
|= __put_user(rp
->ins
[7], &sf
->ss
.callers_pc
);
456 /* 3. signal handler back-trampoline and parameters */
457 regs
->u_regs
[UREG_FP
] = (unsigned long) sf
;
458 regs
->u_regs
[UREG_I0
] = ksig
->sig
;
459 regs
->u_regs
[UREG_I1
] = (unsigned long) &sf
->info
;
460 regs
->u_regs
[UREG_I2
] = (unsigned long) &sf
->info
;
462 /* 4. signal handler */
463 regs
->tpc
= (unsigned long) ksig
->ka
.sa
.sa_handler
;
464 regs
->tnpc
= (regs
->tpc
+ 4);
465 if (test_thread_flag(TIF_32BIT
)) {
466 regs
->tpc
&= 0xffffffff;
467 regs
->tnpc
&= 0xffffffff;
470 /* 5. return to kernel instructions */
471 if (ksig
->ka
.ka_restorer
) {
472 regs
->u_regs
[UREG_I7
] = (unsigned long)ksig
->ka
.ka_restorer
;
474 unsigned long address
= ((unsigned long)&(sf
->insns
[0]));
476 regs
->u_regs
[UREG_I7
] = (unsigned long) (&(sf
->insns
[0]) - 2);
478 err
= __put_user(0x821020d8, &sf
->insns
[0]); /*mov __NR_sigreturn, %g1*/
479 err
|= __put_user(0x91d02010, &sf
->insns
[1]); /*t 0x10*/
482 flush_signal_insns(address
);
487 static int setup_rt_frame32(struct ksignal
*ksig
, struct pt_regs
*regs
,
490 struct rt_signal_frame32 __user
*sf
;
496 /* 1. Make sure everything is clean */
497 synchronize_user_stack();
498 save_and_clear_fpu();
500 wsaved
= get_thread_wsaved();
502 sigframe_size
= sizeof(*sf
);
503 if (current_thread_info()->fpsaved
[0] & FPRS_FEF
)
504 sigframe_size
+= sizeof(__siginfo_fpu_t
);
506 sigframe_size
+= sizeof(__siginfo_rwin_t
);
508 sf
= (struct rt_signal_frame32 __user
*)
509 get_sigframe(ksig
, regs
, sigframe_size
);
511 if (invalid_frame_pointer(sf
, sigframe_size
)) {
512 if (show_unhandled_signals
)
513 pr_info("%s[%d] bad frame in setup_rt_frame32: %08lx TPC %08lx O7 %08lx\n",
514 current
->comm
, current
->pid
, (unsigned long)sf
,
515 regs
->tpc
, regs
->u_regs
[UREG_I7
]);
516 force_sigsegv(ksig
->sig
);
522 /* 2. Save the current process state */
523 if (test_thread_flag(TIF_32BIT
)) {
524 regs
->tpc
&= 0xffffffff;
525 regs
->tnpc
&= 0xffffffff;
527 err
= put_user(regs
->tpc
, &sf
->regs
.pc
);
528 err
|= __put_user(regs
->tnpc
, &sf
->regs
.npc
);
529 err
|= __put_user(regs
->y
, &sf
->regs
.y
);
530 psr
= tstate_to_psr(regs
->tstate
);
531 if (current_thread_info()->fpsaved
[0] & FPRS_FEF
)
533 err
|= __put_user(psr
, &sf
->regs
.psr
);
534 for (i
= 0; i
< 16; i
++)
535 err
|= __put_user(regs
->u_regs
[i
], &sf
->regs
.u_regs
[i
]);
536 err
|= __put_user(sizeof(siginfo_extra_v8plus_t
), &sf
->extra_size
);
537 err
|= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC
, &sf
->v8plus
.g_upper
[0]);
538 for (i
= 1; i
< 16; i
++)
539 err
|= __put_user(((u32
*)regs
->u_regs
)[2*i
],
540 &sf
->v8plus
.g_upper
[i
]);
541 err
|= __put_user((regs
->tstate
& TSTATE_ASI
) >> 24UL,
545 __siginfo_fpu_t __user
*fp
= tail
;
547 err
|= save_fpu_state(regs
, fp
);
548 err
|= __put_user((u64
)fp
, &sf
->fpu_save
);
550 err
|= __put_user(0, &sf
->fpu_save
);
553 __siginfo_rwin_t __user
*rwp
= tail
;
554 tail
+= sizeof(*rwp
);
555 err
|= save_rwin_state(wsaved
, rwp
);
556 err
|= __put_user((u64
)rwp
, &sf
->rwin_save
);
557 set_thread_wsaved(0);
559 err
|= __put_user(0, &sf
->rwin_save
);
562 /* Update the siginfo structure. */
563 err
|= copy_siginfo_to_user32(&sf
->info
, &ksig
->info
);
565 /* Setup sigaltstack */
566 err
|= __compat_save_altstack(&sf
->stack
, regs
->u_regs
[UREG_FP
]);
568 err
|= put_compat_sigset(&sf
->mask
, oldset
, sizeof(compat_sigset_t
));
571 err
|= copy_in_user((u32 __user
*)sf
,
572 (u32 __user
*)(regs
->u_regs
[UREG_FP
]),
573 sizeof(struct reg_window32
));
575 struct reg_window
*rp
;
577 rp
= ¤t_thread_info()->reg_window
[wsaved
- 1];
578 for (i
= 0; i
< 8; i
++)
579 err
|= __put_user(rp
->locals
[i
], &sf
->ss
.locals
[i
]);
580 for (i
= 0; i
< 6; i
++)
581 err
|= __put_user(rp
->ins
[i
], &sf
->ss
.ins
[i
]);
582 err
|= __put_user(rp
->ins
[6], &sf
->ss
.fp
);
583 err
|= __put_user(rp
->ins
[7], &sf
->ss
.callers_pc
);
588 /* 3. signal handler back-trampoline and parameters */
589 regs
->u_regs
[UREG_FP
] = (unsigned long) sf
;
590 regs
->u_regs
[UREG_I0
] = ksig
->sig
;
591 regs
->u_regs
[UREG_I1
] = (unsigned long) &sf
->info
;
592 regs
->u_regs
[UREG_I2
] = (unsigned long) &sf
->regs
;
594 /* 4. signal handler */
595 regs
->tpc
= (unsigned long) ksig
->ka
.sa
.sa_handler
;
596 regs
->tnpc
= (regs
->tpc
+ 4);
597 if (test_thread_flag(TIF_32BIT
)) {
598 regs
->tpc
&= 0xffffffff;
599 regs
->tnpc
&= 0xffffffff;
602 /* 5. return to kernel instructions */
603 if (ksig
->ka
.ka_restorer
)
604 regs
->u_regs
[UREG_I7
] = (unsigned long)ksig
->ka
.ka_restorer
;
606 unsigned long address
= ((unsigned long)&(sf
->insns
[0]));
608 regs
->u_regs
[UREG_I7
] = (unsigned long) (&(sf
->insns
[0]) - 2);
610 /* mov __NR_rt_sigreturn, %g1 */
611 err
|= __put_user(0x82102065, &sf
->insns
[0]);
614 err
|= __put_user(0x91d02010, &sf
->insns
[1]);
618 flush_signal_insns(address
);
623 static inline void handle_signal32(struct ksignal
*ksig
,
624 struct pt_regs
*regs
)
626 sigset_t
*oldset
= sigmask_to_save();
629 if (ksig
->ka
.sa
.sa_flags
& SA_SIGINFO
)
630 err
= setup_rt_frame32(ksig
, regs
, oldset
);
632 err
= setup_frame32(ksig
, regs
, oldset
);
634 signal_setup_done(err
, ksig
, 0);
637 static inline void syscall_restart32(unsigned long orig_i0
, struct pt_regs
*regs
,
638 struct sigaction
*sa
)
640 switch (regs
->u_regs
[UREG_I0
]) {
641 case ERESTART_RESTARTBLOCK
:
643 no_system_call_restart
:
644 regs
->u_regs
[UREG_I0
] = EINTR
;
645 regs
->tstate
|= TSTATE_ICARRY
;
648 if (!(sa
->sa_flags
& SA_RESTART
))
649 goto no_system_call_restart
;
652 regs
->u_regs
[UREG_I0
] = orig_i0
;
658 /* Note that 'init' is a special process: it doesn't get signals it doesn't
659 * want to handle. Thus you cannot kill init even with a SIGKILL even by
662 void do_signal32(struct pt_regs
* regs
)
665 unsigned long orig_i0
= 0;
666 int restart_syscall
= 0;
667 bool has_handler
= get_signal(&ksig
);
669 if (pt_regs_is_syscall(regs
) &&
670 (regs
->tstate
& (TSTATE_XCARRY
| TSTATE_ICARRY
))) {
672 orig_i0
= regs
->u_regs
[UREG_G6
];
677 syscall_restart32(orig_i0
, regs
, &ksig
.ka
.sa
);
678 handle_signal32(&ksig
, regs
);
680 if (restart_syscall
) {
681 switch (regs
->u_regs
[UREG_I0
]) {
685 /* replay the system call when we are done */
686 regs
->u_regs
[UREG_I0
] = orig_i0
;
689 pt_regs_clear_syscall(regs
);
691 case ERESTART_RESTARTBLOCK
:
692 regs
->u_regs
[UREG_G1
] = __NR_restart_syscall
;
695 pt_regs_clear_syscall(regs
);
698 restore_saved_sigmask();
707 asmlinkage
int do_sys32_sigstack(u32 u_ssptr
, u32 u_ossptr
, unsigned long sp
)
709 struct sigstack32 __user
*ssptr
=
710 (struct sigstack32 __user
*)((unsigned long)(u_ssptr
));
711 struct sigstack32 __user
*ossptr
=
712 (struct sigstack32 __user
*)((unsigned long)(u_ossptr
));
715 /* First see if old state is wanted. */
717 if (put_user(current
->sas_ss_sp
+ current
->sas_ss_size
,
718 &ossptr
->the_stack
) ||
719 __put_user(on_sig_stack(sp
), &ossptr
->cur_status
))
723 /* Now see if we want to update the new state. */
727 if (get_user(ss_sp
, &ssptr
->the_stack
))
730 /* If the current stack was set with sigaltstack, don't
731 * swap stacks while we are on it.
734 if (current
->sas_ss_sp
&& on_sig_stack(sp
))
737 /* Since we don't know the extent of the stack, and we don't
738 * track onstack-ness, but rather calculate it, we must
739 * presume a size. Ho hum this interface is lossy.
741 current
->sas_ss_sp
= (unsigned long)ss_sp
- SIGSTKSZ
;
742 current
->sas_ss_size
= SIGSTKSZ
;