aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/include/shared/process.h5
-rw-r--r--arch/um/os-Linux/internal.h1
-rw-r--r--arch/um/os-Linux/signal.c35
-rw-r--r--arch/um/os-Linux/time.c2
-rw-r--r--arch/um/sys-x86/shared/sysdep/sigcontext_32.h7
-rw-r--r--arch/um/sys-x86/shared/sysdep/sigcontext_64.h7
-rw-r--r--arch/um/sys-x86/stub_segv.c2
7 files changed, 33 insertions, 26 deletions
diff --git a/arch/um/include/shared/process.h b/arch/um/include/shared/process.h
index 28215300fc69..2ba310e1b656 100644
--- a/arch/um/include/shared/process.h
+++ b/arch/um/include/shared/process.h
@@ -6,9 +6,4 @@
6#ifndef __PROCESS_H__ 6#ifndef __PROCESS_H__
7#define __PROCESS_H__ 7#define __PROCESS_H__
8 8
9#include <signal.h>
10
11extern void sig_handler(int sig, struct sigcontext *sc);
12extern void alarm_handler(int sig, struct sigcontext *sc);
13
14#endif 9#endif
diff --git a/arch/um/os-Linux/internal.h b/arch/um/os-Linux/internal.h
new file mode 100644
index 000000000000..2c3c3ecd8c01
--- /dev/null
+++ b/arch/um/os-Linux/internal.h
@@ -0,0 +1 @@
void alarm_handler(int, mcontext_t *);
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 08d306176995..07d9905e44ef 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -26,7 +26,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
26 [SIGIO] = sigio_handler, 26 [SIGIO] = sigio_handler,
27 [SIGVTALRM] = timer_handler }; 27 [SIGVTALRM] = timer_handler };
28 28
29static void sig_handler_common(int sig, struct sigcontext *sc) 29static void sig_handler_common(int sig, mcontext_t *mc)
30{ 30{
31 struct uml_pt_regs r; 31 struct uml_pt_regs r;
32 int save_errno = errno; 32 int save_errno = errno;
@@ -34,8 +34,8 @@ static void sig_handler_common(int sig, struct sigcontext *sc)
34 r.is_user = 0; 34 r.is_user = 0;
35 if (sig == SIGSEGV) { 35 if (sig == SIGSEGV) {
36 /* For segfaults, we want the data from the sigcontext. */ 36 /* For segfaults, we want the data from the sigcontext. */
37 copy_sc(&r, sc); 37 copy_sc(&r, (struct sigcontext *)mc);
38 GET_FAULTINFO_FROM_SC(r.faultinfo, sc); 38 GET_FAULTINFO_FROM_MC(r.faultinfo, mc);
39 } 39 }
40 40
41 /* enable signals if sig isn't IRQ signal */ 41 /* enable signals if sig isn't IRQ signal */
@@ -62,7 +62,7 @@ static void sig_handler_common(int sig, struct sigcontext *sc)
62static int signals_enabled; 62static int signals_enabled;
63static unsigned int signals_pending; 63static unsigned int signals_pending;
64 64
65void sig_handler(int sig, struct sigcontext *sc) 65void sig_handler(int sig, mcontext_t *mc)
66{ 66{
67 int enabled; 67 int enabled;
68 68
@@ -74,23 +74,23 @@ void sig_handler(int sig, struct sigcontext *sc)
74 74
75 block_signals(); 75 block_signals();
76 76
77 sig_handler_common(sig, sc); 77 sig_handler_common(sig, mc);
78 78
79 set_signals(enabled); 79 set_signals(enabled);
80} 80}
81 81
82static void real_alarm_handler(struct sigcontext *sc) 82static void real_alarm_handler(mcontext_t *mc)
83{ 83{
84 struct uml_pt_regs regs; 84 struct uml_pt_regs regs;
85 85
86 if (sc != NULL) 86 if (mc != NULL)
87 copy_sc(&regs, sc); 87 copy_sc(&regs, (struct sigcontext *)mc);
88 regs.is_user = 0; 88 regs.is_user = 0;
89 unblock_signals(); 89 unblock_signals();
90 timer_handler(SIGVTALRM, &regs); 90 timer_handler(SIGVTALRM, &regs);
91} 91}
92 92
93void alarm_handler(int sig, struct sigcontext *sc) 93void alarm_handler(int sig, mcontext_t *mc)
94{ 94{
95 int enabled; 95 int enabled;
96 96
@@ -102,7 +102,7 @@ void alarm_handler(int sig, struct sigcontext *sc)
102 102
103 block_signals(); 103 block_signals();
104 104
105 real_alarm_handler(sc); 105 real_alarm_handler(mc);
106 set_signals(enabled); 106 set_signals(enabled);
107} 107}
108 108
@@ -121,7 +121,7 @@ void set_sigstack(void *sig_stack, int size)
121 panic("enabling signal stack failed, errno = %d\n", errno); 121 panic("enabling signal stack failed, errno = %d\n", errno);
122} 122}
123 123
124static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = { 124static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = {
125 [SIGSEGV] = sig_handler, 125 [SIGSEGV] = sig_handler,
126 [SIGBUS] = sig_handler, 126 [SIGBUS] = sig_handler,
127 [SIGILL] = sig_handler, 127 [SIGILL] = sig_handler,
@@ -133,8 +133,11 @@ static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = {
133 [SIGVTALRM] = alarm_handler 133 [SIGVTALRM] = alarm_handler
134}; 134};
135 135
136static void handle_signal(int sig, struct sigcontext *sc) 136
137static void hard_handler(int sig, siginfo_t *info, void *p)
137{ 138{
139 struct ucontext *uc = p;
140 mcontext_t *mc = &uc->uc_mcontext;
138 unsigned long pending = 1UL << sig; 141 unsigned long pending = 1UL << sig;
139 142
140 do { 143 do {
@@ -160,7 +163,7 @@ static void handle_signal(int sig, struct sigcontext *sc)
160 while ((sig = ffs(pending)) != 0){ 163 while ((sig = ffs(pending)) != 0){
161 sig--; 164 sig--;
162 pending &= ~(1 << sig); 165 pending &= ~(1 << sig);
163 (*handlers[sig])(sig, sc); 166 (*handlers[sig])(sig, mc);
164 } 167 }
165 168
166 /* 169 /*
@@ -174,12 +177,6 @@ static void handle_signal(int sig, struct sigcontext *sc)
174 } while (pending); 177 } while (pending);
175} 178}
176 179
177static void hard_handler(int sig, siginfo_t *info, void *p)
178{
179 struct ucontext *uc = p;
180 handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext);
181}
182
183void set_handler(int sig) 180void set_handler(int sig)
184{ 181{
185 struct sigaction action; 182 struct sigaction action;
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 995ca304f1c9..910499d76a67 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -10,7 +10,7 @@
10#include <sys/time.h> 10#include <sys/time.h>
11#include "kern_util.h" 11#include "kern_util.h"
12#include "os.h" 12#include "os.h"
13#include "process.h" 13#include "internal.h"
14 14
15int set_interval(void) 15int set_interval(void)
16{ 16{
diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext_32.h b/arch/um/sys-x86/shared/sysdep/sigcontext_32.h
index aebc2dd61f0d..548c3cdb743b 100644
--- a/arch/um/sys-x86/shared/sysdep/sigcontext_32.h
+++ b/arch/um/sys-x86/shared/sysdep/sigcontext_32.h
@@ -22,4 +22,11 @@
22 (fi).trap_no = SC_TRAPNO(sc); \ 22 (fi).trap_no = SC_TRAPNO(sc); \
23 } 23 }
24 24
25#define GET_FAULTINFO_FROM_MC(fi, mc) \
26 { \
27 (fi).cr2 = (mc)->cr2; \
28 (fi).error_code = (mc)->gregs[REG_ERR]; \
29 (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \
30 }
31
25#endif 32#endif
diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext_64.h b/arch/um/sys-x86/shared/sysdep/sigcontext_64.h
index 60d89a2fba06..5c4a6a359141 100644
--- a/arch/um/sys-x86/shared/sysdep/sigcontext_64.h
+++ b/arch/um/sys-x86/shared/sysdep/sigcontext_64.h
@@ -22,4 +22,11 @@
22 (fi).trap_no = SC_TRAPNO(sc); \ 22 (fi).trap_no = SC_TRAPNO(sc); \
23 } 23 }
24 24
25#define GET_FAULTINFO_FROM_MC(fi, mc) \
26 { \
27 (fi).cr2 = (mc)->gregs[REG_CR2]; \
28 (fi).error_code = (mc)->gregs[REG_ERR]; \
29 (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \
30 }
31
25#endif 32#endif
diff --git a/arch/um/sys-x86/stub_segv.c b/arch/um/sys-x86/stub_segv.c
index f62771cf236e..bd2eaf69103f 100644
--- a/arch/um/sys-x86/stub_segv.c
+++ b/arch/um/sys-x86/stub_segv.c
@@ -12,7 +12,7 @@ stub_segv_handler(int sig, siginfo_t *info, void *p)
12{ 12{
13 struct ucontext *uc = p; 13 struct ucontext *uc = p;
14 14
15 GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), 15 GET_FAULTINFO_FROM_MC(*((struct faultinfo *) STUB_DATA),
16 &uc->uc_mcontext); 16 &uc->uc_mcontext);
17 trap_myself(); 17 trap_myself();
18} 18}