]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/um/os-Linux/skas/trap.c
6a20d08caf91bb45f3a8671b1262cdf416e1771d
[karo-tx-linux.git] / arch / um / os-Linux / skas / trap.c
1 /*
2  * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3  * Licensed under the GPL
4  */
5
6 #include <signal.h>
7 #include <errno.h>
8 #include "kern_util.h"
9 #include "as-layout.h"
10 #include "task.h"
11 #include "sigcontext.h"
12 #include "skas.h"
13 #include "ptrace_user.h"
14 #include "sysdep/ptrace.h"
15 #include "sysdep/ptrace_user.h"
16 #include "os.h"
17
18 void sig_handler_common_skas(int sig, void *sc_ptr)
19 {
20         struct sigcontext *sc = sc_ptr;
21         union uml_pt_regs *r;
22         void (*handler)(int, union uml_pt_regs *);
23         int save_user, save_errno = errno;
24
25         /* This is done because to allow SIGSEGV to be delivered inside a SEGV
26          * handler.  This can happen in copy_user, and if SEGV is disabled,
27          * the process will die.
28          * XXX Figure out why this is better than SA_NODEFER
29          */
30         if(sig == SIGSEGV)
31                 change_sig(SIGSEGV, 1);
32
33         r = TASK_REGS(get_current());
34         save_user = r->skas.is_user;
35         r->skas.is_user = 0;
36         if ( sig == SIGFPE || sig == SIGSEGV ||
37              sig == SIGBUS || sig == SIGILL ||
38              sig == SIGTRAP ) {
39                 GET_FAULTINFO_FROM_SC(r->skas.faultinfo, sc);
40         }
41
42         change_sig(SIGUSR1, 1);
43
44         handler = sig_info[sig];
45
46         /* unblock SIGALRM, SIGVTALRM, SIGIO if sig isn't IRQ signal */
47         if (sig != SIGIO && sig != SIGWINCH &&
48             sig != SIGVTALRM && sig != SIGALRM)
49                 unblock_signals();
50
51         handler(sig, r);
52
53         errno = save_errno;
54         r->skas.is_user = save_user;
55 }
56
57 extern int ptrace_faultinfo;
58
59 void user_signal(int sig, union uml_pt_regs *regs, int pid)
60 {
61         void (*handler)(int, union uml_pt_regs *);
62         int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
63                     (sig == SIGILL) || (sig == SIGTRAP));
64
65         if (segv)
66                 get_skas_faultinfo(pid, &regs->skas.faultinfo);
67
68         handler = sig_info[sig];
69         handler(sig, (union uml_pt_regs *) regs);
70
71         unblock_signals();
72 }