vserver 1.9.5.x5
[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 "signal_user.h"
11 #include "user_util.h"
12 #include "kern_util.h"
13 #include "task.h"
14 #include "tt.h"
15
16 void sig_handler_common_tt(int sig, void *sc_ptr)
17 {
18         struct sigcontext *sc = sc_ptr;
19         struct tt_regs save_regs, *r;
20         struct signal_info *info;
21         int save_errno = errno, is_user;
22
23         unprotect_kernel_mem();
24
25         /* This is done because to allow SIGSEGV to be delivered inside a SEGV
26          * handler.  This can happen in copy_user, and if SEGV is disabled,
27          * the process will die.
28          */
29         if(sig == SIGSEGV)
30                 change_sig(SIGSEGV, 1);
31
32         r = &TASK_REGS(get_current())->tt;
33         save_regs = *r;
34         is_user = user_context(SC_SP(sc));
35         r->sc = sc;
36         if(sig != SIGUSR2) 
37                 r->syscall = -1;
38
39         info = &sig_info[sig];
40         if(!info->is_irq) unblock_signals();
41
42         (*info->handler)(sig, (union uml_pt_regs *) r);
43
44         if(is_user){
45                 interrupt_end();
46                 block_signals();
47                 set_user_mode(NULL);
48         }
49         *r = save_regs;
50         errno = save_errno;
51         if(is_user) protect_kernel_mem();
52 }
53
54 /*
55  * Overrides for Emacs so that we follow Linus's tabbing style.
56  * Emacs will notice this stuff at the end of the file and automatically
57  * adjust the settings for this buffer only.  This must remain at the end
58  * of the file.
59  * ---------------------------------------------------------------------------
60  * Local variables:
61  * c-file-style: "linux"
62  * End:
63  */