aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux/signal.c')
-rw-r--r--arch/um/os-Linux/signal.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 62a66f38a913..cde9e766b5b4 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -9,12 +9,74 @@
9#include <errno.h> 9#include <errno.h>
10#include <signal.h> 10#include <signal.h>
11#include <strings.h> 11#include <strings.h>
12#include "as-layout.h"
13#include "kern_constants.h"
12#include "kern_util.h" 14#include "kern_util.h"
13#include "os.h" 15#include "os.h"
14#include "sysdep/barrier.h" 16#include "sysdep/barrier.h"
15#include "sysdep/sigcontext.h" 17#include "sysdep/sigcontext.h"
18#include "task.h"
16#include "user.h" 19#include "user.h"
17 20
21void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
22 [SIGTRAP] = relay_signal,
23 [SIGFPE] = relay_signal,
24 [SIGILL] = relay_signal,
25 [SIGWINCH] = winch,
26 [SIGBUS] = bus_handler,
27 [SIGSEGV] = segv_handler,
28 [SIGIO] = sigio_handler,
29 [SIGVTALRM] = timer_handler };
30
31static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
32
33void sig_handler_common_skas(int sig, void *sc_ptr)
34{
35 struct sigcontext *sc = sc_ptr;
36 struct uml_pt_regs *r;
37 void (*handler)(int, struct uml_pt_regs *);
38 int save_user, save_errno = errno;
39
40 /*
41 * This is done because to allow SIGSEGV to be delivered inside a SEGV
42 * handler. This can happen in copy_user, and if SEGV is disabled,
43 * the process will die.
44 * XXX Figure out why this is better than SA_NODEFER
45 */
46 if (sig == SIGSEGV) {
47 change_sig(SIGSEGV, 1);
48 /*
49 * For segfaults, we want the data from the
50 * sigcontext. In this case, we don't want to mangle
51 * the process registers, so use a static set of
52 * registers. For other signals, the process
53 * registers are OK.
54 */
55 r = &ksig_regs[cpu()];
56 copy_sc(r, sc_ptr);
57 } else
58 r = TASK_REGS(get_current());
59
60 save_user = r->is_user;
61 r->is_user = 0;
62 if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
63 (sig == SIGILL) || (sig == SIGTRAP))
64 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
65
66 change_sig(SIGUSR1, 1);
67
68 handler = sig_info[sig];
69
70 /* unblock SIGVTALRM, SIGIO if sig isn't IRQ signal */
71 if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
72 unblock_signals();
73
74 handler(sig, r);
75
76 errno = save_errno;
77 r->is_user = save_user;
78}
79
18/* Copied from linux/compiler-gcc.h since we can't include it directly */ 80/* Copied from linux/compiler-gcc.h since we can't include it directly */
19#define barrier() __asm__ __volatile__("": : :"memory") 81#define barrier() __asm__ __volatile__("": : :"memory")
20 82