upgrade to linux 2.6.10-1.12_FC2
[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 <asm/sigcontext.h>
10 #include "sysdep/ptrace.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         unprotect_kernel_mem();
25
26         /* This is done because to allow SIGSEGV to be delivered inside a SEGV
27          * handler.  This can happen in copy_user, and if SEGV is disabled,
28          * the process will die.
29          */
30         if(sig == SIGSEGV)
31                 change_sig(SIGSEGV, 1);
32
33         /* This is done because to allow SIGSEGV to be delivered inside a SEGV
34          * handler.  This can happen in copy_user, and if SEGV is disabled,
35          * the process will die.
36          */
37         if(sig == SIGSEGV)
38                 change_sig(SIGSEGV, 1);
39
40         r = &TASK_REGS(get_current())->tt;
41         save_regs = *r;
42         is_user = user_context(SC_SP(sc));
43         r->sc = sc;
44         if(sig != SIGUSR2) 
45                 r->syscall = -1;
46
47         info = &sig_info[sig];
48         if(!info->is_irq) unblock_signals();
49
50         (*info->handler)(sig, (union uml_pt_regs *) r);
51
52         if(is_user){
53                 interrupt_end();
54                 block_signals();
55                 set_user_mode(NULL);
56         }
57         *r = save_regs;
58         errno = save_errno;
59         if(is_user) protect_kernel_mem();
60 }
61
62 /*
63  * Overrides for Emacs so that we follow Linus's tabbing style.
64  * Emacs will notice this stuff at the end of the file and automatically
65  * adjust the settings for this buffer only.  This must remain at the end
66  * of the file.
67  * ---------------------------------------------------------------------------
68  * Local variables:
69  * c-file-style: "linux"
70  * End:
71  */