blob: 19ff04bdec90886a2e6a4dcfe498788470adf8df [file] [log] [blame]
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -08001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include <signal.h>
7#include <errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include "user_util.h"
9#include "kern_util.h"
Jeff Dike4ff83ce2007-05-06 14:51:08 -070010#include "as-layout.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include "task.h"
12#include "sigcontext.h"
Bodo Stroesserc5784552005-05-05 16:15:31 -070013#include "skas.h"
14#include "ptrace_user.h"
15#include "sysdep/ptrace.h"
16#include "sysdep/ptrace_user.h"
Gennady Sharapov0805d892006-01-08 01:01:29 -080017#include "os.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19void sig_handler_common_skas(int sig, void *sc_ptr)
20{
21 struct sigcontext *sc = sc_ptr;
22 struct skas_regs *r;
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080023 void (*handler)(int, union uml_pt_regs *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 int save_errno = errno;
25 int save_user;
26
27 /* This is done because to allow SIGSEGV to be delivered inside a SEGV
28 * handler. This can happen in copy_user, and if SEGV is disabled,
29 * the process will die.
30 * XXX Figure out why this is better than SA_NODEFER
31 */
32 if(sig == SIGSEGV)
33 change_sig(SIGSEGV, 1);
34
35 r = &TASK_REGS(get_current())->skas;
36 save_user = r->is_user;
37 r->is_user = 0;
Jeff Dikec0a689d2006-01-08 01:01:33 -080038 if ( sig == SIGFPE || sig == SIGSEGV ||
39 sig == SIGBUS || sig == SIGILL ||
40 sig == SIGTRAP ) {
41 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
42 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44 change_sig(SIGUSR1, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080046 handler = sig_info[sig];
47
48 /* unblock SIGALRM, SIGVTALRM, SIGIO if sig isn't IRQ signal */
49 if (sig != SIGIO && sig != SIGWINCH &&
50 sig != SIGVTALRM && sig != SIGALRM)
51 unblock_signals();
52
53 handler(sig, (union uml_pt_regs *) r);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 errno = save_errno;
56 r->is_user = save_user;
57}
58
Bodo Stroesserc5784552005-05-05 16:15:31 -070059extern int ptrace_faultinfo;
60
61void user_signal(int sig, union uml_pt_regs *regs, int pid)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062{
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080063 void (*handler)(int, union uml_pt_regs *);
Jeff Dikec0a689d2006-01-08 01:01:33 -080064 int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
65 (sig == SIGILL) || (sig == SIGTRAP));
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Bodo Stroesserc5784552005-05-05 16:15:31 -070067 if (segv)
68 get_skas_faultinfo(pid, &regs->skas.faultinfo);
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080069
70 handler = sig_info[sig];
71 handler(sig, (union uml_pt_regs *) regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73 unblock_signals();
74}