uml: tidy fault code
[pv_ops_mirror.git] / arch / um / os-Linux / skas / trap.c
blob6a20d08caf91bb45f3a8671b1262cdf416e1771d
1 /*
2 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
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"
18 void sig_handler_common_skas(int sig, void *sc_ptr)
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;
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
30 if(sig == SIGSEGV)
31 change_sig(SIGSEGV, 1);
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);
42 change_sig(SIGUSR1, 1);
44 handler = sig_info[sig];
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();
51 handler(sig, r);
53 errno = save_errno;
54 r->skas.is_user = save_user;
57 extern int ptrace_faultinfo;
59 void user_signal(int sig, union uml_pt_regs *regs, int pid)
61 void (*handler)(int, union uml_pt_regs *);
62 int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
63 (sig == SIGILL) || (sig == SIGTRAP));
65 if (segv)
66 get_skas_faultinfo(pid, &regs->skas.faultinfo);
68 handler = sig_info[sig];
69 handler(sig, (union uml_pt_regs *) regs);
71 unblock_signals();