Merge branch 'drm-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied...
[linux-drm-fsl-dcu.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 "kern_util.h"
12 #include "task.h"
13 #include "tt.h"
14 #include "os.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         int save_errno = errno, is_user = 0;
21         void (*handler)(int, union uml_pt_regs *);
22
23         /* This is done because to allow SIGSEGV to be delivered inside a SEGV
24          * handler.  This can happen in copy_user, and if SEGV is disabled,
25          * the process will die.
26          */
27         if(sig == SIGSEGV)
28                 change_sig(SIGSEGV, 1);
29
30         r = &TASK_REGS(get_current())->tt;
31         if ( sig == SIGFPE || sig == SIGSEGV ||
32              sig == SIGBUS || sig == SIGILL ||
33              sig == SIGTRAP ) {
34                 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
35         }
36         save_regs = *r;
37         if (sc)
38                 is_user = user_context(SC_SP(sc));
39         r->sc = sc;
40         if(sig != SIGUSR2) 
41                 r->syscall = -1;
42
43         handler = sig_info[sig];
44
45         /* unblock SIGALRM, SIGVTALRM, SIGIO if sig isn't IRQ signal */
46         if (sig != SIGIO && sig != SIGWINCH &&
47             sig != SIGVTALRM && sig != SIGALRM)
48                 unblock_signals();
49
50         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 }
60
61 /*
62  * Overrides for Emacs so that we follow Linus's tabbing style.
63  * Emacs will notice this stuff at the end of the file and automatically
64  * adjust the settings for this buffer only.  This must remain at the end
65  * of the file.
66  * ---------------------------------------------------------------------------
67  * Local variables:
68  * c-file-style: "linux"
69  * End:
70  */