2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
8 #include "sysdep/ptrace.h"
9 #include "kern_constants.h"
10 #include "as-layout.h"
11 #include "kern_util.h"
13 #include "sigcontext.h"
16 void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
17 [SIGTRAP] = relay_signal,
18 [SIGFPE] = relay_signal,
19 [SIGILL] = relay_signal,
21 [SIGBUS] = bus_handler,
22 [SIGSEGV] = segv_handler,
23 [SIGIO] = sigio_handler,
24 [SIGVTALRM] = timer_handler };
26 static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
28 void sig_handler_common_skas(int sig, void *sc_ptr)
30 struct sigcontext *sc = sc_ptr;
31 struct uml_pt_regs *r;
32 void (*handler)(int, struct uml_pt_regs *);
33 int save_user, save_errno = errno;
36 * This is done because to allow SIGSEGV to be delivered inside a SEGV
37 * handler. This can happen in copy_user, and if SEGV is disabled,
38 * the process will die.
39 * XXX Figure out why this is better than SA_NODEFER
42 change_sig(SIGSEGV, 1);
44 * For segfaults, we want the data from the
45 * sigcontext. In this case, we don't want to mangle
46 * the process registers, so use a static set of
47 * registers. For other signals, the process
50 r = &ksig_regs[cpu()];
53 else r = TASK_REGS(get_current());
55 save_user = r->is_user;
57 if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
58 (sig == SIGILL) || (sig == SIGTRAP))
59 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
61 change_sig(SIGUSR1, 1);
63 handler = sig_info[sig];
65 /* unblock SIGVTALRM, SIGIO if sig isn't IRQ signal */
66 if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
72 r->is_user = save_user;