1 /* $Id: signal.c,v 1.54 2000/09/05 21:44:54 davem Exp $
2 * arch/sparc64/kernel/signal.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/config.h>
12 #include <linux/sched.h>
13 #include <linux/kernel.h>
14 #include <linux/signal.h>
15 #include <linux/errno.h>
16 #include <linux/wait.h>
17 #include <linux/ptrace.h>
18 #include <linux/unistd.h>
20 #include <linux/smp_lock.h>
22 #include <asm/uaccess.h>
23 #include <asm/bitops.h>
24 #include <asm/ptrace.h>
26 #include <asm/pgtable.h>
27 #include <asm/fpumacro.h>
29 #include <asm/siginfo.h>
30 #include <asm/visasm.h>
32 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
34 asmlinkage
int sys_wait4(pid_t pid
, unsigned long *stat_addr
,
35 int options
, unsigned long *ru
);
37 asmlinkage
int do_signal(sigset_t
*oldset
, struct pt_regs
* regs
,
38 unsigned long orig_o0
, int ret_from_syscall
);
40 /* This turned off for production... */
41 /* #define DEBUG_SIGNALS 1 */
42 /* #define DEBUG_SIGNALS_TRACE 1 */
43 /* #define DEBUG_SIGNALS_MAPS 1 */
45 int copy_siginfo_to_user(siginfo_t
*to
, siginfo_t
*from
)
47 if (!access_ok (VERIFY_WRITE
, to
, sizeof(siginfo_t
)))
49 if (from
->si_code
< 0)
50 return __copy_to_user(to
, from
, sizeof(siginfo_t
));
54 /* If you change siginfo_t structure, please be sure
55 this code is fixed accordingly.
56 It should never copy any pad contained in the structure
57 to avoid security leaks, but must copy the generic
58 3 ints plus the relevant union member. */
59 err
= __put_user(*(long *)&from
->si_signo
, (long *)&to
->si_signo
);
60 err
|= __put_user((short)from
->si_code
, &to
->si_code
);
61 switch (from
->si_code
>> 16) {
63 err
|= __put_user(from
->si_utime
, &to
->si_utime
);
64 err
|= __put_user(from
->si_stime
, &to
->si_stime
);
65 case __SI_FAULT
>> 16:
67 err
|= __put_user(from
->si_trapno
, &to
->si_trapno
);
69 err
|= __put_user(from
->si_addr
, &to
->si_addr
);
71 /* case __SI_RT: This is not generated by the kernel as of now. */
77 /* {set, get}context() needed for 64-bit SparcLinux userland. */
78 asmlinkage
void sparc64_set_context(struct pt_regs
*regs
)
80 struct ucontext
*ucp
= (struct ucontext
*) regs
->u_regs
[UREG_I0
];
81 struct thread_struct
*tp
= ¤t
->thread
;
83 unsigned long pc
, npc
, tstate
;
90 (((unsigned long)ucp
) & (sizeof(unsigned long)-1)) ||
91 (!__access_ok((unsigned long)ucp
, sizeof(*ucp
))))
93 grp
= &ucp
->uc_mcontext
.mc_gregs
;
94 err
= __get_user(pc
, &((*grp
)[MC_PC
]));
95 err
|= __get_user(npc
, &((*grp
)[MC_NPC
]));
96 if(err
|| ((pc
| npc
) & 3))
98 if(regs
->u_regs
[UREG_I1
]) {
101 if (_NSIG_WORDS
== 1) {
102 if (__get_user(set
.sig
[0], &ucp
->uc_sigmask
.sig
[0]))
105 if (__copy_from_user(&set
, &ucp
->uc_sigmask
, sizeof(sigset_t
)))
108 sigdelsetmask(&set
, ~_BLOCKABLE
);
109 spin_lock_irq(¤t
->sigmask_lock
);
110 current
->blocked
= set
;
111 recalc_sigpending(current
);
112 spin_unlock_irq(¤t
->sigmask_lock
);
116 err
|= __get_user(regs
->y
, &((*grp
)[MC_Y
]));
117 err
|= __get_user(tstate
, &((*grp
)[MC_TSTATE
]));
118 regs
->tstate
&= ~(TSTATE_ICC
| TSTATE_XCC
);
119 regs
->tstate
|= (tstate
& (TSTATE_ICC
| TSTATE_XCC
));
120 err
|= __get_user(regs
->u_regs
[UREG_G1
], (&(*grp
)[MC_G1
]));
121 err
|= __get_user(regs
->u_regs
[UREG_G2
], (&(*grp
)[MC_G2
]));
122 err
|= __get_user(regs
->u_regs
[UREG_G3
], (&(*grp
)[MC_G3
]));
123 err
|= __get_user(regs
->u_regs
[UREG_G4
], (&(*grp
)[MC_G4
]));
124 err
|= __get_user(regs
->u_regs
[UREG_G5
], (&(*grp
)[MC_G5
]));
125 err
|= __get_user(regs
->u_regs
[UREG_G6
], (&(*grp
)[MC_G6
]));
126 err
|= __get_user(regs
->u_regs
[UREG_G7
], (&(*grp
)[MC_G7
]));
127 err
|= __get_user(regs
->u_regs
[UREG_I0
], (&(*grp
)[MC_O0
]));
128 err
|= __get_user(regs
->u_regs
[UREG_I1
], (&(*grp
)[MC_O1
]));
129 err
|= __get_user(regs
->u_regs
[UREG_I2
], (&(*grp
)[MC_O2
]));
130 err
|= __get_user(regs
->u_regs
[UREG_I3
], (&(*grp
)[MC_O3
]));
131 err
|= __get_user(regs
->u_regs
[UREG_I4
], (&(*grp
)[MC_O4
]));
132 err
|= __get_user(regs
->u_regs
[UREG_I5
], (&(*grp
)[MC_O5
]));
133 err
|= __get_user(regs
->u_regs
[UREG_I6
], (&(*grp
)[MC_O6
]));
134 err
|= __get_user(regs
->u_regs
[UREG_I7
], (&(*grp
)[MC_O7
]));
136 err
|= __get_user(fp
, &(ucp
->uc_mcontext
.mc_fp
));
137 err
|= __get_user(i7
, &(ucp
->uc_mcontext
.mc_i7
));
138 err
|= __put_user(fp
,
139 (&(((struct reg_window
*)(STACK_BIAS
+regs
->u_regs
[UREG_I6
]))->ins
[6])));
140 err
|= __put_user(i7
,
141 (&(((struct reg_window
*)(STACK_BIAS
+regs
->u_regs
[UREG_I6
]))->ins
[7])));
143 err
|= __get_user(fenab
, &(ucp
->uc_mcontext
.mc_fpregs
.mcfpu_enab
));
145 unsigned long *fpregs
= (unsigned long *)(((char *)current
) + AOFF_task_fpregs
);
149 err
|= __get_user(fprs
, &(ucp
->uc_mcontext
.mc_fpregs
.mcfpu_fprs
));
151 err
|= copy_from_user(fpregs
,
152 &(ucp
->uc_mcontext
.mc_fpregs
.mcfpu_fregs
),
153 (sizeof(unsigned int) * 32));
155 err
|= copy_from_user(fpregs
+16,
156 ((unsigned long *)&(ucp
->uc_mcontext
.mc_fpregs
.mcfpu_fregs
))+16,
157 (sizeof(unsigned int) * 32));
158 err
|= __get_user(current
->thread
.xfsr
[0],
159 &(ucp
->uc_mcontext
.mc_fpregs
.mcfpu_fsr
));
160 err
|= __get_user(current
->thread
.gsr
[0],
161 &(ucp
->uc_mcontext
.mc_fpregs
.mcfpu_gsr
));
162 regs
->tstate
&= ~TSTATE_PEF
;
172 asmlinkage
void sparc64_get_context(struct pt_regs
*regs
)
174 struct ucontext
*ucp
= (struct ucontext
*) regs
->u_regs
[UREG_I0
];
175 struct thread_struct
*tp
= ¤t
->thread
;
178 unsigned long fp
, i7
;
182 synchronize_user_stack();
183 if(tp
->w_saved
|| clear_user(ucp
, sizeof(*ucp
)))
187 fenab
= 0; /* IMO get_context is like any other system call, thus modifies FPU state -jj */
189 fenab
= (current
->thread
.fpsaved
[0] & FPRS_FEF
);
192 mcp
= &ucp
->uc_mcontext
;
193 grp
= &mcp
->mc_gregs
;
195 /* Skip over the trap instruction, first. */
196 regs
->tpc
= regs
->tnpc
;
200 if (_NSIG_WORDS
== 1)
201 err
|= __put_user(current
->blocked
.sig
[0],
202 (unsigned long *)&ucp
->uc_sigmask
);
204 err
|= __copy_to_user(&ucp
->uc_sigmask
, ¤t
->blocked
,
207 err
|= __put_user(regs
->tstate
, &((*grp
)[MC_TSTATE
]));
208 err
|= __put_user(regs
->tpc
, &((*grp
)[MC_PC
]));
209 err
|= __put_user(regs
->tnpc
, &((*grp
)[MC_NPC
]));
210 err
|= __put_user(regs
->y
, &((*grp
)[MC_Y
]));
211 err
|= __put_user(regs
->u_regs
[UREG_G1
], &((*grp
)[MC_G1
]));
212 err
|= __put_user(regs
->u_regs
[UREG_G2
], &((*grp
)[MC_G2
]));
213 err
|= __put_user(regs
->u_regs
[UREG_G3
], &((*grp
)[MC_G3
]));
214 err
|= __put_user(regs
->u_regs
[UREG_G4
], &((*grp
)[MC_G4
]));
215 err
|= __put_user(regs
->u_regs
[UREG_G5
], &((*grp
)[MC_G5
]));
216 err
|= __put_user(regs
->u_regs
[UREG_G6
], &((*grp
)[MC_G6
]));
217 err
|= __put_user(regs
->u_regs
[UREG_G6
], &((*grp
)[MC_G7
]));
218 err
|= __put_user(regs
->u_regs
[UREG_I0
], &((*grp
)[MC_O0
]));
219 err
|= __put_user(regs
->u_regs
[UREG_I1
], &((*grp
)[MC_O1
]));
220 err
|= __put_user(regs
->u_regs
[UREG_I2
], &((*grp
)[MC_O2
]));
221 err
|= __put_user(regs
->u_regs
[UREG_I3
], &((*grp
)[MC_O3
]));
222 err
|= __put_user(regs
->u_regs
[UREG_I4
], &((*grp
)[MC_O4
]));
223 err
|= __put_user(regs
->u_regs
[UREG_I5
], &((*grp
)[MC_O5
]));
224 err
|= __put_user(regs
->u_regs
[UREG_I6
], &((*grp
)[MC_O6
]));
225 err
|= __put_user(regs
->u_regs
[UREG_I7
], &((*grp
)[MC_O7
]));
227 err
|= __get_user(fp
,
228 (&(((struct reg_window
*)(STACK_BIAS
+regs
->u_regs
[UREG_I6
]))->ins
[6])));
229 err
|= __get_user(i7
,
230 (&(((struct reg_window
*)(STACK_BIAS
+regs
->u_regs
[UREG_I6
]))->ins
[7])));
231 err
|= __put_user(fp
, &(mcp
->mc_fp
));
232 err
|= __put_user(i7
, &(mcp
->mc_i7
));
234 err
|= __put_user(fenab
, &(mcp
->mc_fpregs
.mcfpu_enab
));
236 unsigned long *fpregs
= (unsigned long *)(((char *)current
) + AOFF_task_fpregs
);
239 fprs
= current
->thread
.fpsaved
[0];
241 err
|= copy_to_user(&(mcp
->mc_fpregs
.mcfpu_fregs
), fpregs
,
242 (sizeof(unsigned int) * 32));
245 ((unsigned long *)&(mcp
->mc_fpregs
.mcfpu_fregs
))+16, fpregs
+16,
246 (sizeof(unsigned int) * 32));
247 err
|= __put_user(current
->thread
.xfsr
[0], &(mcp
->mc_fpregs
.mcfpu_fsr
));
248 err
|= __put_user(current
->thread
.gsr
[0], &(mcp
->mc_fpregs
.mcfpu_gsr
));
249 err
|= __put_user(fprs
, &(mcp
->mc_fpregs
.mcfpu_fprs
));
259 struct rt_signal_frame
{
260 struct sparc_stackf ss
;
263 __siginfo_fpu_t
* fpu_save
;
266 __siginfo_fpu_t fpu_state
;
270 #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame) + 7) & (~7)))
273 * atomically swap in the new signal mask, and wait for a signal.
274 * This is really tricky on the Sparc, watch out...
276 asmlinkage
void _sigpause_common(old_sigset_t set
, struct pt_regs
*regs
)
280 #ifdef CONFIG_SPARC32_COMPAT
281 if (current
->thread
.flags
& SPARC_FLAG_32BIT
) {
282 extern asmlinkage
void _sigpause32_common(old_sigset_t32
,
284 _sigpause32_common(set
, regs
);
289 spin_lock_irq(¤t
->sigmask_lock
);
290 saveset
= current
->blocked
;
291 siginitset(¤t
->blocked
, set
);
292 recalc_sigpending(current
);
293 spin_unlock_irq(¤t
->sigmask_lock
);
295 regs
->tpc
= regs
->tnpc
;
298 /* Condition codes and return value where set here for sigpause,
299 * and so got used by setup_frame, which again causes sigreturn()
303 current
->state
= TASK_INTERRUPTIBLE
;
306 * Return -EINTR and set condition code here,
307 * so the interrupted system call actually returns
310 regs
->tstate
|= (TSTATE_ICARRY
|TSTATE_XCARRY
);
311 regs
->u_regs
[UREG_I0
] = EINTR
;
312 if (do_signal(&saveset
, regs
, 0, 0))
317 asmlinkage
void do_sigpause(unsigned int set
, struct pt_regs
*regs
)
319 _sigpause_common(set
, regs
);
322 asmlinkage
void do_sigsuspend(struct pt_regs
*regs
)
324 _sigpause_common(regs
->u_regs
[UREG_I0
], regs
);
327 asmlinkage
void do_rt_sigsuspend(sigset_t
*uset
, size_t sigsetsize
, struct pt_regs
*regs
)
329 sigset_t oldset
, set
;
331 /* XXX: Don't preclude handling different sized sigset_t's. */
332 if (sigsetsize
!= sizeof(sigset_t
)) {
333 regs
->tstate
|= (TSTATE_ICARRY
|TSTATE_XCARRY
);
334 regs
->u_regs
[UREG_I0
] = EINVAL
;
337 if (copy_from_user(&set
, uset
, sizeof(set
))) {
338 regs
->tstate
|= (TSTATE_ICARRY
|TSTATE_XCARRY
);
339 regs
->u_regs
[UREG_I0
] = EFAULT
;
343 sigdelsetmask(&set
, ~_BLOCKABLE
);
344 spin_lock_irq(¤t
->sigmask_lock
);
345 oldset
= current
->blocked
;
346 current
->blocked
= set
;
347 recalc_sigpending(current
);
348 spin_unlock_irq(¤t
->sigmask_lock
);
350 regs
->tpc
= regs
->tnpc
;
353 /* Condition codes and return value where set here for sigpause,
354 * and so got used by setup_frame, which again causes sigreturn()
358 current
->state
= TASK_INTERRUPTIBLE
;
361 * Return -EINTR and set condition code here,
362 * so the interrupted system call actually returns
365 regs
->tstate
|= (TSTATE_ICARRY
|TSTATE_XCARRY
);
366 regs
->u_regs
[UREG_I0
] = EINTR
;
367 if (do_signal(&oldset
, regs
, 0, 0))
373 restore_fpu_state(struct pt_regs
*regs
, __siginfo_fpu_t
*fpu
)
375 unsigned long *fpregs
= (unsigned long *)(((char *)current
) + AOFF_task_fpregs
);
379 err
= __get_user(fprs
, &fpu
->si_fprs
);
381 regs
->tstate
&= ~TSTATE_PEF
;
383 err
|= copy_from_user(fpregs
, &fpu
->si_float_regs
[0],
384 (sizeof(unsigned int) * 32));
386 err
|= copy_from_user(fpregs
+16, &fpu
->si_float_regs
[32],
387 (sizeof(unsigned int) * 32));
388 err
|= __get_user(current
->thread
.xfsr
[0], &fpu
->si_fsr
);
389 err
|= __get_user(current
->thread
.gsr
[0], &fpu
->si_gsr
);
390 current
->thread
.fpsaved
[0] |= fprs
;
394 void do_rt_sigreturn(struct pt_regs
*regs
)
396 struct rt_signal_frame
*sf
;
397 unsigned long tpc
, tnpc
, tstate
;
398 __siginfo_fpu_t
*fpu_save
;
403 synchronize_user_stack ();
404 sf
= (struct rt_signal_frame
*)
405 (regs
->u_regs
[UREG_FP
] + STACK_BIAS
);
407 /* 1. Make sure we are not getting garbage from the user */
408 if (((unsigned long) sf
) & 3)
411 err
= get_user(tpc
, &sf
->regs
.tpc
);
412 err
|= __get_user(tnpc
, &sf
->regs
.tnpc
);
413 err
|= ((tpc
| tnpc
) & 3);
415 /* 2. Restore the state */
416 err
|= __get_user(regs
->y
, &sf
->regs
.y
);
417 err
|= __get_user(tstate
, &sf
->regs
.tstate
);
418 err
|= copy_from_user(regs
->u_regs
, sf
->regs
.u_regs
, sizeof(regs
->u_regs
));
420 /* User can only change condition codes in %tstate. */
421 regs
->tstate
&= ~(TSTATE_ICC
);
422 regs
->tstate
|= (tstate
& TSTATE_ICC
);
424 err
|= __get_user(fpu_save
, &sf
->fpu_save
);
426 err
|= restore_fpu_state(regs
, &sf
->fpu_state
);
428 err
|= __copy_from_user(&set
, &sf
->mask
, sizeof(sigset_t
));
429 err
|= __copy_from_user(&st
, &sf
->stack
, sizeof(stack_t
));
437 /* It is more difficult to avoid calling this function than to
438 call it and ignore errors. */
439 do_sigaltstack(&st
, NULL
, (unsigned long)sf
);
441 sigdelsetmask(&set
, ~_BLOCKABLE
);
442 spin_lock_irq(¤t
->sigmask_lock
);
443 current
->blocked
= set
;
444 recalc_sigpending(current
);
445 spin_unlock_irq(¤t
->sigmask_lock
);
448 send_sig(SIGSEGV
, current
, 1);
451 /* Checks if the fp is valid */
452 static int invalid_frame_pointer(void *fp
, int fplen
)
454 if (((unsigned long) fp
) & 7)
460 save_fpu_state(struct pt_regs
*regs
, __siginfo_fpu_t
*fpu
)
462 unsigned long *fpregs
= (unsigned long *)(regs
+1);
466 fprs
= current
->thread
.fpsaved
[0];
468 err
|= copy_to_user(&fpu
->si_float_regs
[0], fpregs
,
469 (sizeof(unsigned int) * 32));
471 err
|= copy_to_user(&fpu
->si_float_regs
[32], fpregs
+16,
472 (sizeof(unsigned int) * 32));
473 err
|= __put_user(current
->thread
.xfsr
[0], &fpu
->si_fsr
);
474 err
|= __put_user(current
->thread
.gsr
[0], &fpu
->si_gsr
);
475 err
|= __put_user(fprs
, &fpu
->si_fprs
);
480 static inline void *get_sigframe(struct k_sigaction
*ka
, struct pt_regs
*regs
, unsigned long framesize
)
484 sp
= regs
->u_regs
[UREG_FP
] + STACK_BIAS
;
486 /* This is the X/Open sanctioned signal stack switching. */
487 if (ka
->sa
.sa_flags
& SA_ONSTACK
) {
488 if (!on_sig_stack(sp
) &&
489 !((current
->sas_ss_sp
+ current
->sas_ss_size
) & 7))
490 sp
= current
->sas_ss_sp
+ current
->sas_ss_size
;
492 return (void *)(sp
- framesize
);
496 setup_rt_frame(struct k_sigaction
*ka
, struct pt_regs
*regs
,
497 int signo
, sigset_t
*oldset
, siginfo_t
*info
)
499 struct rt_signal_frame
*sf
;
500 int sigframe_size
, err
;
502 /* 1. Make sure everything is clean */
503 synchronize_user_stack();
504 save_and_clear_fpu();
506 sigframe_size
= RT_ALIGNEDSZ
;
507 if (!(current
->thread
.fpsaved
[0] & FPRS_FEF
))
508 sigframe_size
-= sizeof(__siginfo_fpu_t
);
510 sf
= (struct rt_signal_frame
*)get_sigframe(ka
, regs
, sigframe_size
);
512 if (invalid_frame_pointer (sf
, sigframe_size
))
515 if (current
->thread
.w_saved
!= 0) {
517 printk ("%s[%d]: Invalid user stack frame for "
518 "signal delivery.\n", current
->comm
, current
->pid
);
523 /* 2. Save the current process state */
524 err
= copy_to_user(&sf
->regs
, regs
, sizeof (*regs
));
526 if (current
->thread
.fpsaved
[0] & FPRS_FEF
) {
527 err
|= save_fpu_state(regs
, &sf
->fpu_state
);
528 err
|= __put_user((u64
)&sf
->fpu_state
, &sf
->fpu_save
);
530 err
|= __put_user(0, &sf
->fpu_save
);
533 /* Setup sigaltstack */
534 err
|= __put_user(current
->sas_ss_sp
, &sf
->stack
.ss_sp
);
535 err
|= __put_user(sas_ss_flags(regs
->u_regs
[UREG_FP
]), &sf
->stack
.ss_flags
);
536 err
|= __put_user(current
->sas_ss_size
, &sf
->stack
.ss_size
);
538 err
|= copy_to_user(&sf
->mask
, oldset
, sizeof(sigset_t
));
540 err
|= copy_in_user((u64
*)sf
,
541 (u64
*)(regs
->u_regs
[UREG_FP
]+STACK_BIAS
),
542 sizeof(struct reg_window
));
545 err
|= copy_siginfo_to_user(&sf
->info
, info
);
547 err
|= __put_user(signo
, &sf
->info
.si_signo
);
548 err
|= __put_user(SI_NOINFO
, &sf
->info
.si_code
);
553 /* 3. signal handler back-trampoline and parameters */
554 regs
->u_regs
[UREG_FP
] = ((unsigned long) sf
) - STACK_BIAS
;
555 regs
->u_regs
[UREG_I0
] = signo
;
556 regs
->u_regs
[UREG_I1
] = (unsigned long) &sf
->info
;
558 /* 5. signal handler */
559 regs
->tpc
= (unsigned long) ka
->sa
.sa_handler
;
560 regs
->tnpc
= (regs
->tpc
+ 4);
562 /* 4. return to kernel instructions */
563 regs
->u_regs
[UREG_I7
] = (unsigned long)ka
->ka_restorer
;
572 static inline void handle_signal(unsigned long signr
, struct k_sigaction
*ka
,
574 sigset_t
*oldset
, struct pt_regs
*regs
)
576 setup_rt_frame(ka
, regs
, signr
, oldset
, (ka
->sa
.sa_flags
& SA_SIGINFO
) ? info
: NULL
);
577 if(ka
->sa
.sa_flags
& SA_ONESHOT
)
578 ka
->sa
.sa_handler
= SIG_DFL
;
579 if(!(ka
->sa
.sa_flags
& SA_NOMASK
)) {
580 spin_lock_irq(¤t
->sigmask_lock
);
581 sigorsets(¤t
->blocked
,¤t
->blocked
,&ka
->sa
.sa_mask
);
582 sigaddset(¤t
->blocked
,signr
);
583 recalc_sigpending(current
);
584 spin_unlock_irq(¤t
->sigmask_lock
);
588 static inline void syscall_restart(unsigned long orig_i0
, struct pt_regs
*regs
,
589 struct sigaction
*sa
)
591 switch(regs
->u_regs
[UREG_I0
]) {
593 no_system_call_restart
:
594 regs
->u_regs
[UREG_I0
] = EINTR
;
595 regs
->tstate
|= (TSTATE_ICARRY
|TSTATE_XCARRY
);
598 if(!(sa
->sa_flags
& SA_RESTART
))
599 goto no_system_call_restart
;
602 regs
->u_regs
[UREG_I0
] = orig_i0
;
608 #ifdef DEBUG_SIGNALS_MAPS
610 #define MAPS_LINE_FORMAT "%016lx-%016lx %s %016lx %s %lu "
612 static inline void read_maps (void)
614 struct vm_area_struct
* map
, * next
;
618 buffer
= (char*)__get_free_page(GFP_KERNEL
);
622 for (map
= current
->mm
->mmap
; map
; map
= next
) {
623 /* produce the next line */
625 char str
[5], *cp
= str
;
631 * Get the next vma now (but it won't be used if we sleep).
634 flags
= map
->vm_flags
;
636 *cp
++ = flags
& VM_READ
? 'r' : '-';
637 *cp
++ = flags
& VM_WRITE
? 'w' : '-';
638 *cp
++ = flags
& VM_EXEC
? 'x' : '-';
639 *cp
++ = flags
& VM_MAYSHARE
? 's' : 'p';
644 if (map
->vm_file
!= NULL
) {
645 dev
= map
->vm_file
->f_dentry
->d_inode
->i_dev
;
646 ino
= map
->vm_file
->f_dentry
->d_inode
->i_ino
;
647 line
= d_path(map
->vm_file
->f_dentry
,
648 map
->vm_file
->f_vfsmnt
,
651 printk(MAPS_LINE_FORMAT
, map
->vm_start
, map
->vm_end
, str
, map
->vm_pgoff
<< PAGE_SHIFT
,
653 if (map
->vm_file
!= NULL
)
654 printk("%s\n", line
);
658 free_page((unsigned long)buffer
);
664 /* Note that 'init' is a special process: it doesn't get signals it doesn't
665 * want to handle. Thus you cannot kill init even with a SIGKILL even by
668 asmlinkage
int do_signal(sigset_t
*oldset
, struct pt_regs
* regs
,
669 unsigned long orig_i0
, int restart_syscall
)
673 struct k_sigaction
*ka
;
676 oldset
= ¤t
->blocked
;
678 #ifdef CONFIG_SPARC32_COMPAT
679 if (current
->thread
.flags
& SPARC_FLAG_32BIT
) {
680 extern asmlinkage
int do_signal32(sigset_t
*, struct pt_regs
*,
682 return do_signal32(oldset
, regs
, orig_i0
, restart_syscall
);
686 spin_lock_irq(¤t
->sigmask_lock
);
687 signr
= dequeue_signal(¤t
->blocked
, &info
);
688 spin_unlock_irq(¤t
->sigmask_lock
);
692 if ((current
->ptrace
& PT_PTRACED
) && signr
!= SIGKILL
) {
693 current
->exit_code
= signr
;
694 current
->state
= TASK_STOPPED
;
695 notify_parent(current
, SIGCHLD
);
697 if (!(signr
= current
->exit_code
))
699 current
->exit_code
= 0;
700 if (signr
== SIGSTOP
)
703 /* Update the siginfo structure. Is this good? */
704 if (signr
!= info
.si_signo
) {
705 info
.si_signo
= signr
;
707 info
.si_code
= SI_USER
;
708 info
.si_pid
= current
->p_pptr
->pid
;
709 info
.si_uid
= current
->p_pptr
->uid
;
712 /* If the (new) signal is now blocked, requeue it. */
713 if (sigismember(¤t
->blocked
, signr
)) {
714 send_sig_info(signr
, &info
, current
);
719 ka
= ¤t
->sig
->action
[signr
-1];
721 if(ka
->sa
.sa_handler
== SIG_IGN
) {
725 /* sys_wait4() grabs the master kernel lock, so
726 * we need not do so, that sucker should be
727 * threaded and would not be that difficult to
730 while(sys_wait4(-1, NULL
, WNOHANG
, NULL
) > 0)
734 if(ka
->sa
.sa_handler
== SIG_DFL
) {
735 unsigned long exit_code
= signr
;
737 if(current
->pid
== 1)
740 case SIGCONT
: case SIGCHLD
: case SIGWINCH
:
743 case SIGTSTP
: case SIGTTIN
: case SIGTTOU
:
744 if (is_orphaned_pgrp(current
->pgrp
))
748 if (current
->ptrace
& PT_PTRACED
)
750 current
->state
= TASK_STOPPED
;
751 current
->exit_code
= signr
;
752 if(!(current
->p_pptr
->sig
->action
[SIGCHLD
-1].sa
.sa_flags
&
754 notify_parent(current
, SIGCHLD
);
758 case SIGQUIT
: case SIGILL
: case SIGTRAP
:
759 case SIGABRT
: case SIGFPE
: case SIGSEGV
:
760 case SIGBUS
: case SIGSYS
: case SIGXCPU
: case SIGXFSZ
:
761 if (do_coredump(signr
, regs
))
764 /* Very useful to debug the dynamic linker */
765 printk ("Sig %d going...\n", (int)signr
);
767 #ifdef DEBUG_SIGNALS_TRACE
769 struct reg_window
*rw
= (struct reg_window
*)(regs
->u_regs
[UREG_FP
] + STACK_BIAS
);
770 unsigned long ins
[8];
773 !(((unsigned long) rw
) & 0x3)) {
774 copy_from_user(ins
, &rw
->ins
[0], sizeof(ins
));
775 printk("Caller[%016lx](%016lx,%016lx,%016lx,%016lx,%016lx,%016lx)\n", ins
[7], ins
[0], ins
[1], ins
[2], ins
[3], ins
[4], ins
[5]);
776 rw
= (struct reg_window
*)(unsigned long)(ins
[6] + STACK_BIAS
);
780 #ifdef DEBUG_SIGNALS_MAPS
787 sigaddset(¤t
->pending
.signal
, signr
);
788 recalc_sigpending(current
);
789 current
->flags
|= PF_SIGNALED
;
795 syscall_restart(orig_i0
, regs
, &ka
->sa
);
796 handle_signal(signr
, ka
, &info
, oldset
, regs
);
799 if(restart_syscall
&&
800 (regs
->u_regs
[UREG_I0
] == ERESTARTNOHAND
||
801 regs
->u_regs
[UREG_I0
] == ERESTARTSYS
||
802 regs
->u_regs
[UREG_I0
] == ERESTARTNOINTR
)) {
803 /* replay the system call when we are done */
804 regs
->u_regs
[UREG_I0
] = orig_i0
;