blob: e53face44200bfc0c9929939a5ce5d57a0f4bbb8 [file] [log] [blame]
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -08001/*
Jeff Dikeba180fd2007-10-16 01:27:00 -07002 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Licensed under the GPL
4 */
5
Jeff Dikeba180fd2007-10-16 01:27:00 -07006#if 0
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include "kern_util.h"
Bodo Stroesserc5784552005-05-05 16:15:31 -07008#include "skas.h"
9#include "ptrace_user.h"
Bodo Stroesserc5784552005-05-05 16:15:31 -070010#include "sysdep/ptrace_user.h"
Jeff Dikeba180fd2007-10-16 01:27:00 -070011#endif
12
13#include <errno.h>
14#include <signal.h>
15#include "sysdep/ptrace.h"
16#include "kern_constants.h"
17#include "as-layout.h"
Gennady Sharapov0805d892006-01-08 01:01:29 -080018#include "os.h"
Jeff Dikeba180fd2007-10-16 01:27:00 -070019#include "sigcontext.h"
20#include "task.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Jeff Dike77bf4402007-10-16 01:26:58 -070022static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
Jeff Dike377fad32007-05-06 14:51:25 -070023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024void sig_handler_common_skas(int sig, void *sc_ptr)
25{
26 struct sigcontext *sc = sc_ptr;
Jeff Dike77bf4402007-10-16 01:26:58 -070027 struct uml_pt_regs *r;
28 void (*handler)(int, struct uml_pt_regs *);
Jeff Dike5d864562007-05-06 14:51:24 -070029 int save_user, save_errno = errno;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Jeff Dikeba180fd2007-10-16 01:27:00 -070031 /*
32 * This is done because to allow SIGSEGV to be delivered inside a SEGV
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * handler. This can happen in copy_user, and if SEGV is disabled,
34 * the process will die.
35 * XXX Figure out why this is better than SA_NODEFER
36 */
Jeff Dikeba180fd2007-10-16 01:27:00 -070037 if (sig == SIGSEGV) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 change_sig(SIGSEGV, 1);
Jeff Dikeba180fd2007-10-16 01:27:00 -070039 /*
40 * For segfaults, we want the data from the
Jeff Dike377fad32007-05-06 14:51:25 -070041 * sigcontext. In this case, we don't want to mangle
42 * the process registers, so use a static set of
43 * registers. For other signals, the process
44 * registers are OK.
45 */
46 r = &ksig_regs[cpu()];
47 copy_sc(r, sc_ptr);
48 }
49 else r = TASK_REGS(get_current());
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Jeff Dike77bf4402007-10-16 01:26:58 -070051 save_user = r->is_user;
52 r->is_user = 0;
Jeff Dikeba180fd2007-10-16 01:27:00 -070053 if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
54 (sig == SIGILL) || (sig == SIGTRAP))
Jeff Dike77bf4402007-10-16 01:26:58 -070055 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57 change_sig(SIGUSR1, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080059 handler = sig_info[sig];
60
61 /* unblock SIGALRM, SIGVTALRM, SIGIO if sig isn't IRQ signal */
62 if (sig != SIGIO && sig != SIGWINCH &&
63 sig != SIGVTALRM && sig != SIGALRM)
64 unblock_signals();
65
Jeff Dike5d864562007-05-06 14:51:24 -070066 handler(sig, r);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68 errno = save_errno;
Jeff Dike77bf4402007-10-16 01:26:58 -070069 r->is_user = save_user;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}