vserver 2.0 rc7
[linux-2.6.git] / arch / um / kernel / tt / trap_user.c
1 /* 
2  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include <stdlib.h>
7 #include <errno.h>
8 #include <signal.h>
9 #include "sysdep/ptrace.h"
10 #include "sysdep/sigcontext.h"
11 #include "signal_user.h"
12 #include "user_util.h"
13 #include "kern_util.h"
14 #include "task.h"
15 #include "tt.h"
16
17 void sig_handler_common_tt(int sig, void *sc_ptr)
18 {
19         struct sigcontext *sc = sc_ptr;
20         struct tt_regs save_regs, *r;
21         struct signal_info *info;
22         int save_errno = errno, is_user;
23
24         /* This is done because to allow SIGSEGV to be delivered inside a SEGV
25          * handler.  This can happen in copy_user, and if SEGV is disabled,
26          * the process will die.
27          */
28         if(sig == SIGSEGV)
29                 change_sig(SIGSEGV, 1);
30
31         r = &TASK_REGS(get_current())->tt;
32         if ( sig == SIGFPE || sig == SIGSEGV ||
33              sig == SIGBUS || sig == SIGILL ||
34              sig == SIGTRAP ) {
35                 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
36         }
37         save_regs = *r;
38         is_user = user_context(SC_SP(sc));
39         r->sc = sc;
40         if(sig != SIGUSR2) 
41                 r->syscall = -1;
42
43         info = &sig_info[sig];
44         if(!info->is_irq) unblock_signals();
45
46         (*info->handler)(sig, (union uml_pt_regs *) r);
47
48         if(is_user){
49                 interrupt_end();
50                 block_signals();
51                 set_user_mode(NULL);
52         }
53         *r = save_regs;
54         errno = save_errno;
55 }
56
57 /*
58  * Overrides for Emacs so that we follow Linus's tabbing style.
59  * Emacs will notice this stuff at the end of the file and automatically
60  * adjust the settings for this buffer only.  This must remain at the end
61  * of the file.
62  * ---------------------------------------------------------------------------
63  * Local variables:
64  * c-file-style: "linux"
65  * End:
66  */