aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel
diff options
context:
space:
mode:
authorGennady Sharapov <Gennady.V.Sharapov@intel.com>2006-01-08 04:01:31 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:13:39 -0500
commitea2ba7dc3dd3f85034e6da6abacc813d723a2ad5 (patch)
tree56f3d2a22d3ba3d91042d9a536b659b9c967dc03 /arch/um/kernel
parent0805d89c151b4800eade4c2f50d39c5253d7d054 (diff)
[PATCH] uml: move libc-dependent code from trap_user.c
The serial UML OS-abstraction layer patch (um/kernel dir). This moves all systemcalls from trap_user.c file under os-Linux dir Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r--arch/um/kernel/skas/Makefile2
-rw-r--r--arch/um/kernel/skas/trap_user.c78
-rw-r--r--arch/um/kernel/trap_kern.c11
-rw-r--r--arch/um/kernel/trap_user.c65
-rw-r--r--arch/um/kernel/tt/trap_user.c14
-rw-r--r--arch/um/kernel/um_arch.c7
6 files changed, 39 insertions, 138 deletions
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
index 8de471b59c1c..7a9fc16d71d4 100644
--- a/arch/um/kernel/skas/Makefile
+++ b/arch/um/kernel/skas/Makefile
@@ -4,7 +4,7 @@
4# 4#
5 5
6obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ 6obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
7 syscall.o tlb.o trap_user.o uaccess.o 7 syscall.o tlb.o uaccess.o
8 8
9USER_OBJS := process.o clone.o 9USER_OBJS := process.o clone.o
10 10
diff --git a/arch/um/kernel/skas/trap_user.c b/arch/um/kernel/skas/trap_user.c
deleted file mode 100644
index 28403d2cafe6..000000000000
--- a/arch/um/kernel/skas/trap_user.c
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include <signal.h>
7#include <errno.h>
8#include "user_util.h"
9#include "kern_util.h"
10#include "task.h"
11#include "sigcontext.h"
12#include "skas.h"
13#include "ptrace_user.h"
14#include "sysdep/ptrace.h"
15#include "sysdep/ptrace_user.h"
16#include "os.h"
17
18void sig_handler_common_skas(int sig, void *sc_ptr)
19{
20 struct sigcontext *sc = sc_ptr;
21 struct skas_regs *r;
22 struct signal_info *info;
23 int save_errno = errno;
24 int save_user;
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 * XXX Figure out why this is better than SA_NODEFER
30 */
31 if(sig == SIGSEGV)
32 change_sig(SIGSEGV, 1);
33
34 r = &TASK_REGS(get_current())->skas;
35 save_user = r->is_user;
36 r->is_user = 0;
37 if ( sig == SIGFPE || sig == SIGSEGV ||
38 sig == SIGBUS || sig == SIGILL ||
39 sig == SIGTRAP ) {
40 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
41 }
42
43 change_sig(SIGUSR1, 1);
44 info = &sig_info[sig];
45 if(!info->is_irq) unblock_signals();
46
47 (*info->handler)(sig, (union uml_pt_regs *) r);
48
49 errno = save_errno;
50 r->is_user = save_user;
51}
52
53extern int ptrace_faultinfo;
54
55void user_signal(int sig, union uml_pt_regs *regs, int pid)
56{
57 struct signal_info *info;
58 int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
59 (sig == SIGILL) || (sig == SIGTRAP));
60
61 if (segv)
62 get_skas_faultinfo(pid, &regs->skas.faultinfo);
63 info = &sig_info[sig];
64 (*info->handler)(sig, regs);
65
66 unblock_signals();
67}
68
69/*
70 * Overrides for Emacs so that we follow Linus's tabbing style.
71 * Emacs will notice this stuff at the end of the file and automatically
72 * adjust the settings for this buffer only. This must remain at the end
73 * of the file.
74 * ---------------------------------------------------------------------------
75 * Local variables:
76 * c-file-style: "linux"
77 * End:
78 */
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
index 0d4c10a73607..b79f805bdc00 100644
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -29,6 +29,7 @@
29#ifdef CONFIG_MODE_SKAS 29#ifdef CONFIG_MODE_SKAS
30#include "skas.h" 30#include "skas.h"
31#endif 31#endif
32#include "os.h"
32 33
33/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ 34/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
34int handle_page_fault(unsigned long address, unsigned long ip, 35int handle_page_fault(unsigned long address, unsigned long ip,
@@ -125,6 +126,14 @@ out_of_memory:
125 goto out; 126 goto out;
126} 127}
127 128
129struct kern_handlers handlinfo_kern = {
130 .relay_signal = relay_signal,
131 .winch = winch,
132 .bus_handler = relay_signal,
133 .page_fault = segv_handler,
134 .sigio_handler = sigio_handler,
135 .timer_handler = timer_handler
136};
128/* 137/*
129 * We give a *copy* of the faultinfo in the regs to segv. 138 * We give a *copy* of the faultinfo in the regs to segv.
130 * This must be done, since nesting SEGVs could overwrite 139 * This must be done, since nesting SEGVs could overwrite
diff --git a/arch/um/kernel/trap_user.c b/arch/um/kernel/trap_user.c
index e55110725124..5590b5739db9 100644
--- a/arch/um/kernel/trap_user.c
+++ b/arch/um/kernel/trap_user.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -25,20 +25,6 @@
25#include "user_util.h" 25#include "user_util.h"
26#include "os.h" 26#include "os.h"
27 27
28void kill_child_dead(int pid)
29{
30 kill(pid, SIGKILL);
31 kill(pid, SIGCONT);
32 do {
33 int n;
34 CATCH_EINTR(n = waitpid(pid, NULL, 0));
35 if (n > 0)
36 kill(pid, SIGCONT);
37 else
38 break;
39 } while(1);
40}
41
42void segv_handler(int sig, union uml_pt_regs *regs) 28void segv_handler(int sig, union uml_pt_regs *regs)
43{ 29{
44 struct faultinfo * fi = UPT_FAULTINFO(regs); 30 struct faultinfo * fi = UPT_FAULTINFO(regs);
@@ -55,43 +41,18 @@ void usr2_handler(int sig, union uml_pt_regs *regs)
55 CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0); 41 CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
56} 42}
57 43
58struct signal_info sig_info[] = { 44void (*sig_info[NSIG])(int, union uml_pt_regs *);
59 [ SIGTRAP ] { .handler = relay_signal,
60 .is_irq = 0 },
61 [ SIGFPE ] { .handler = relay_signal,
62 .is_irq = 0 },
63 [ SIGILL ] { .handler = relay_signal,
64 .is_irq = 0 },
65 [ SIGWINCH ] { .handler = winch,
66 .is_irq = 1 },
67 [ SIGBUS ] { .handler = bus_handler,
68 .is_irq = 0 },
69 [ SIGSEGV] { .handler = segv_handler,
70 .is_irq = 0 },
71 [ SIGIO ] { .handler = sigio_handler,
72 .is_irq = 1 },
73 [ SIGVTALRM ] { .handler = timer_handler,
74 .is_irq = 1 },
75 [ SIGALRM ] { .handler = timer_handler,
76 .is_irq = 1 },
77 [ SIGUSR2 ] { .handler = usr2_handler,
78 .is_irq = 0 },
79};
80 45
81void do_longjmp(void *b, int val) 46void os_fill_handlinfo(struct kern_handlers h)
82{ 47{
83 sigjmp_buf *buf = b; 48 sig_info[SIGTRAP] = h.relay_signal;
84 49 sig_info[SIGFPE] = h.relay_signal;
85 siglongjmp(*buf, val); 50 sig_info[SIGILL] = h.relay_signal;
51 sig_info[SIGWINCH] = h.winch;
52 sig_info[SIGBUS] = h.bus_handler;
53 sig_info[SIGSEGV] = h.page_fault;
54 sig_info[SIGIO] = h.sigio_handler;
55 sig_info[SIGVTALRM] = h.timer_handler;
56 sig_info[SIGALRM] = h.timer_handler;
57 sig_info[SIGUSR2] = usr2_handler;
86} 58}
87
88/*
89 * Overrides for Emacs so that we follow Linus's tabbing style.
90 * Emacs will notice this stuff at the end of the file and automatically
91 * adjust the settings for this buffer only. This must remain at the end
92 * of the file.
93 * ---------------------------------------------------------------------------
94 * Local variables:
95 * c-file-style: "linux"
96 * End:
97 */
diff --git a/arch/um/kernel/tt/trap_user.c b/arch/um/kernel/tt/trap_user.c
index 7501900f8941..a414c529fbcd 100644
--- a/arch/um/kernel/tt/trap_user.c
+++ b/arch/um/kernel/tt/trap_user.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -18,8 +18,8 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
18{ 18{
19 struct sigcontext *sc = sc_ptr; 19 struct sigcontext *sc = sc_ptr;
20 struct tt_regs save_regs, *r; 20 struct tt_regs save_regs, *r;
21 struct signal_info *info;
22 int save_errno = errno, is_user; 21 int save_errno = errno, is_user;
22 void (*handler)(int, union uml_pt_regs *);
23 23
24 /* This is done because to allow SIGSEGV to be delivered inside a SEGV 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, 25 * handler. This can happen in copy_user, and if SEGV is disabled,
@@ -40,10 +40,14 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
40 if(sig != SIGUSR2) 40 if(sig != SIGUSR2)
41 r->syscall = -1; 41 r->syscall = -1;
42 42
43 info = &sig_info[sig]; 43 handler = sig_info[sig];
44 if(!info->is_irq) unblock_signals(); 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();
45 49
46 (*info->handler)(sig, (union uml_pt_regs *) r); 50 handler(sig, (union uml_pt_regs *) r);
47 51
48 if(is_user){ 52 if(is_user){
49 interrupt_end(); 53 interrupt_end();
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 26626b2b9172..73747ac19774 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -363,6 +363,11 @@ int linux_main(int argc, char **argv)
363 uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, 363 uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
364 &host_task_size, &task_size); 364 &host_task_size, &task_size);
365 365
366 /*
367 * Setting up handlers to 'sig_info' struct
368 */
369 os_fill_handlinfo(handlinfo_kern);
370
366 brk_start = (unsigned long) sbrk(0); 371 brk_start = (unsigned long) sbrk(0);
367 CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); 372 CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start);
368 /* Increase physical memory size for exec-shield users 373 /* Increase physical memory size for exec-shield users