diff options
author | Steve French <sfrench@us.ibm.com> | 2006-01-12 17:47:08 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-01-12 17:47:08 -0500 |
commit | 94bc2be31a01a3055ec94176e595dfe208e92d3b (patch) | |
tree | ebfbe81c6718a6390bfa1b99c6d228237d818576 /arch/um/kernel | |
parent | c32a0b689cb9cc160cfcd19735bbf50bb70c6ef4 (diff) | |
parent | 58cba4650a7a414eabd2b40cc9d8e45fcdf192d9 (diff) |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r-- | arch/um/kernel/Makefile | 8 | ||||
-rw-r--r-- | arch/um/kernel/asm-offsets.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/irq_user.c | 49 | ||||
-rw-r--r-- | arch/um/kernel/process_kern.c | 7 | ||||
-rw-r--r-- | arch/um/kernel/reboot.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/sigio_user.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/signal_kern.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/signal_user.c | 157 | ||||
-rw-r--r-- | arch/um/kernel/skas/Makefile | 2 | ||||
-rw-r--r-- | arch/um/kernel/skas/include/skas.h | 1 | ||||
-rw-r--r-- | arch/um/kernel/skas/process.c | 15 | ||||
-rw-r--r-- | arch/um/kernel/skas/process_kern.c | 5 | ||||
-rw-r--r-- | arch/um/kernel/skas/trap_user.c | 78 | ||||
-rw-r--r-- | arch/um/kernel/time.c | 9 | ||||
-rw-r--r-- | arch/um/kernel/trap_kern.c | 25 | ||||
-rw-r--r-- | arch/um/kernel/trap_user.c | 98 | ||||
-rw-r--r-- | arch/um/kernel/tt/exec_kern.c | 3 | ||||
-rw-r--r-- | arch/um/kernel/tt/process_kern.c | 9 | ||||
-rw-r--r-- | arch/um/kernel/tt/tracer.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/tt/trap_user.c | 16 | ||||
-rw-r--r-- | arch/um/kernel/um_arch.c | 15 | ||||
-rw-r--r-- | arch/um/kernel/umid.c | 323 |
22 files changed, 89 insertions, 739 deletions
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 3de9d21e36bf..193cc2b7448d 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -9,9 +9,9 @@ clean-files := | |||
9 | obj-y = config.o exec_kern.o exitcode.o \ | 9 | obj-y = config.o exec_kern.o exitcode.o \ |
10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ | 10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ |
11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
12 | signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ | 12 | signal_kern.o smp.o syscall_kern.o sysrq.o time.o \ |
13 | time_kern.o tlb.o trap_kern.o trap_user.o uaccess.o um_arch.o \ | 13 | time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o \ |
14 | umid.o user_util.o | 14 | user_util.o |
15 | 15 | ||
16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o | 16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
17 | obj-$(CONFIG_GPROF) += gprof_syms.o | 17 | obj-$(CONFIG_GPROF) += gprof_syms.o |
@@ -24,7 +24,7 @@ obj-$(CONFIG_MODE_SKAS) += skas/ | |||
24 | 24 | ||
25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | 25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o |
26 | 26 | ||
27 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o umid.o user_util.o | 27 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o user_util.o |
28 | 28 | ||
29 | include arch/um/scripts/Makefile.rules | 29 | include arch/um/scripts/Makefile.rules |
30 | 30 | ||
diff --git a/arch/um/kernel/asm-offsets.c b/arch/um/kernel/asm-offsets.c index c13a64a288f6..91ea538e1612 100644 --- a/arch/um/kernel/asm-offsets.c +++ b/arch/um/kernel/asm-offsets.c | |||
@@ -1 +1 @@ | |||
/* Dummy file to make kbuild happy - unused! */ | #include "sysdep/kernel-offsets.h" | ||
diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c index c3ccaf24f3e0..0e32f5f4a887 100644 --- a/arch/um/kernel/irq_user.c +++ b/arch/um/kernel/irq_user.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "user.h" | 16 | #include "user.h" |
17 | #include "process.h" | 17 | #include "process.h" |
18 | #include "signal_user.h" | ||
19 | #include "sigio.h" | 18 | #include "sigio.h" |
20 | #include "irq_user.h" | 19 | #include "irq_user.h" |
21 | #include "os.h" | 20 | #include "os.h" |
@@ -29,7 +28,6 @@ struct irq_fd { | |||
29 | int pid; | 28 | int pid; |
30 | int events; | 29 | int events; |
31 | int current_events; | 30 | int current_events; |
32 | int freed; | ||
33 | }; | 31 | }; |
34 | 32 | ||
35 | static struct irq_fd *active_fds = NULL; | 33 | static struct irq_fd *active_fds = NULL; |
@@ -41,9 +39,11 @@ static int pollfds_size = 0; | |||
41 | 39 | ||
42 | extern int io_count, intr_count; | 40 | extern int io_count, intr_count; |
43 | 41 | ||
42 | extern void free_irqs(void); | ||
43 | |||
44 | void sigio_handler(int sig, union uml_pt_regs *regs) | 44 | void sigio_handler(int sig, union uml_pt_regs *regs) |
45 | { | 45 | { |
46 | struct irq_fd *irq_fd, *next; | 46 | struct irq_fd *irq_fd; |
47 | int i, n; | 47 | int i, n; |
48 | 48 | ||
49 | if(smp_sigio_handler()) return; | 49 | if(smp_sigio_handler()) return; |
@@ -66,29 +66,15 @@ void sigio_handler(int sig, union uml_pt_regs *regs) | |||
66 | irq_fd = irq_fd->next; | 66 | irq_fd = irq_fd->next; |
67 | } | 67 | } |
68 | 68 | ||
69 | for(irq_fd = active_fds; irq_fd != NULL; irq_fd = next){ | 69 | for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){ |
70 | next = irq_fd->next; | ||
71 | if(irq_fd->current_events != 0){ | 70 | if(irq_fd->current_events != 0){ |
72 | irq_fd->current_events = 0; | 71 | irq_fd->current_events = 0; |
73 | do_IRQ(irq_fd->irq, regs); | 72 | do_IRQ(irq_fd->irq, regs); |
74 | |||
75 | /* This is here because the next irq may be | ||
76 | * freed in the handler. If a console goes | ||
77 | * away, both the read and write irqs will be | ||
78 | * freed. After do_IRQ, ->next will point to | ||
79 | * a good IRQ. | ||
80 | * Irqs can't be freed inside their handlers, | ||
81 | * so the next best thing is to have them | ||
82 | * marked as needing freeing, so that they | ||
83 | * can be freed here. | ||
84 | */ | ||
85 | next = irq_fd->next; | ||
86 | if(irq_fd->freed){ | ||
87 | free_irq(irq_fd->irq, irq_fd->id); | ||
88 | } | ||
89 | } | 73 | } |
90 | } | 74 | } |
91 | } | 75 | } |
76 | |||
77 | free_irqs(); | ||
92 | } | 78 | } |
93 | 79 | ||
94 | int activate_ipi(int fd, int pid) | 80 | int activate_ipi(int fd, int pid) |
@@ -136,8 +122,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id) | |||
136 | .irq = irq, | 122 | .irq = irq, |
137 | .pid = pid, | 123 | .pid = pid, |
138 | .events = events, | 124 | .events = events, |
139 | .current_events = 0, | 125 | .current_events = 0 } ); |
140 | .freed = 0 } ); | ||
141 | 126 | ||
142 | /* Critical section - locked by a spinlock because this stuff can | 127 | /* Critical section - locked by a spinlock because this stuff can |
143 | * be changed from interrupt handlers. The stuff above is done | 128 | * be changed from interrupt handlers. The stuff above is done |
@@ -313,26 +298,6 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out) | |||
313 | return(irq); | 298 | return(irq); |
314 | } | 299 | } |
315 | 300 | ||
316 | void free_irq_later(int irq, void *dev_id) | ||
317 | { | ||
318 | struct irq_fd *irq_fd; | ||
319 | unsigned long flags; | ||
320 | |||
321 | flags = irq_lock(); | ||
322 | for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){ | ||
323 | if((irq_fd->irq == irq) && (irq_fd->id == dev_id)) | ||
324 | break; | ||
325 | } | ||
326 | if(irq_fd == NULL){ | ||
327 | printk("free_irq_later found no irq, irq = %d, " | ||
328 | "dev_id = 0x%p\n", irq, dev_id); | ||
329 | goto out; | ||
330 | } | ||
331 | irq_fd->freed = 1; | ||
332 | out: | ||
333 | irq_unlock(flags); | ||
334 | } | ||
335 | |||
336 | void reactivate_fd(int fd, int irqnum) | 301 | void reactivate_fd(int fd, int irqnum) |
337 | { | 302 | { |
338 | struct irq_fd *irq; | 303 | struct irq_fd *irq; |
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index 34b54a3e2132..7f13b85d2656 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include "kern_util.h" | 36 | #include "kern_util.h" |
37 | #include "kern.h" | 37 | #include "kern.h" |
38 | #include "signal_kern.h" | 38 | #include "signal_kern.h" |
39 | #include "signal_user.h" | ||
40 | #include "init.h" | 39 | #include "init.h" |
41 | #include "irq_user.h" | 40 | #include "irq_user.h" |
42 | #include "mem_user.h" | 41 | #include "mem_user.h" |
@@ -108,7 +107,7 @@ void set_current(void *t) | |||
108 | { | 107 | { |
109 | struct task_struct *task = t; | 108 | struct task_struct *task = t; |
110 | 109 | ||
111 | cpu_tasks[task->thread_info->cpu] = ((struct cpu_task) | 110 | cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task) |
112 | { external_pid(task), task }); | 111 | { external_pid(task), task }); |
113 | } | 112 | } |
114 | 113 | ||
@@ -324,10 +323,6 @@ int user_context(unsigned long sp) | |||
324 | return(stack != (unsigned long) current_thread); | 323 | return(stack != (unsigned long) current_thread); |
325 | } | 324 | } |
326 | 325 | ||
327 | extern void remove_umid_dir(void); | ||
328 | |||
329 | __uml_exitcall(remove_umid_dir); | ||
330 | |||
331 | extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end; | 326 | extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end; |
332 | 327 | ||
333 | void do_uml_exitcalls(void) | 328 | void do_uml_exitcalls(void) |
diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c index a637e885c583..6f1a3a288117 100644 --- a/arch/um/kernel/reboot.c +++ b/arch/um/kernel/reboot.c | |||
@@ -12,6 +12,8 @@ | |||
12 | #include "mode.h" | 12 | #include "mode.h" |
13 | #include "choose-mode.h" | 13 | #include "choose-mode.h" |
14 | 14 | ||
15 | void (*pm_power_off)(void); | ||
16 | |||
15 | #ifdef CONFIG_SMP | 17 | #ifdef CONFIG_SMP |
16 | static void kill_idlers(int me) | 18 | static void kill_idlers(int me) |
17 | { | 19 | { |
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c index 48b1f644b9a6..62e5cfdf2188 100644 --- a/arch/um/kernel/sigio_user.c +++ b/arch/um/kernel/sigio_user.c | |||
@@ -216,6 +216,8 @@ static int write_sigio_thread(void *unused) | |||
216 | "err = %d\n", -n); | 216 | "err = %d\n", -n); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | |||
220 | return 0; | ||
219 | } | 221 | } |
220 | 222 | ||
221 | static int need_poll(int n) | 223 | static int need_poll(int n) |
diff --git a/arch/um/kernel/signal_kern.c b/arch/um/kernel/signal_kern.c index 03618bd13d55..7b0e0e81c161 100644 --- a/arch/um/kernel/signal_kern.c +++ b/arch/um/kernel/signal_kern.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "asm/ucontext.h" | 22 | #include "asm/ucontext.h" |
23 | #include "kern_util.h" | 23 | #include "kern_util.h" |
24 | #include "signal_kern.h" | 24 | #include "signal_kern.h" |
25 | #include "signal_user.h" | ||
26 | #include "kern.h" | 25 | #include "kern.h" |
27 | #include "frame_kern.h" | 26 | #include "frame_kern.h" |
28 | #include "sigcontext.h" | 27 | #include "sigcontext.h" |
diff --git a/arch/um/kernel/signal_user.c b/arch/um/kernel/signal_user.c deleted file mode 100644 index 62f457835fb1..000000000000 --- a/arch/um/kernel/signal_user.c +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <unistd.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <signal.h> | ||
10 | #include <errno.h> | ||
11 | #include <stdarg.h> | ||
12 | #include <string.h> | ||
13 | #include <sys/mman.h> | ||
14 | #include "user_util.h" | ||
15 | #include "kern_util.h" | ||
16 | #include "user.h" | ||
17 | #include "signal_user.h" | ||
18 | #include "signal_kern.h" | ||
19 | #include "sysdep/sigcontext.h" | ||
20 | #include "sigcontext.h" | ||
21 | |||
22 | void set_sigstack(void *sig_stack, int size) | ||
23 | { | ||
24 | stack_t stack = ((stack_t) { .ss_flags = 0, | ||
25 | .ss_sp = (__ptr_t) sig_stack, | ||
26 | .ss_size = size - sizeof(void *) }); | ||
27 | |||
28 | if(sigaltstack(&stack, NULL) != 0) | ||
29 | panic("enabling signal stack failed, errno = %d\n", errno); | ||
30 | } | ||
31 | |||
32 | void set_handler(int sig, void (*handler)(int), int flags, ...) | ||
33 | { | ||
34 | struct sigaction action; | ||
35 | va_list ap; | ||
36 | int mask; | ||
37 | |||
38 | va_start(ap, flags); | ||
39 | action.sa_handler = handler; | ||
40 | sigemptyset(&action.sa_mask); | ||
41 | while((mask = va_arg(ap, int)) != -1){ | ||
42 | sigaddset(&action.sa_mask, mask); | ||
43 | } | ||
44 | va_end(ap); | ||
45 | action.sa_flags = flags; | ||
46 | action.sa_restorer = NULL; | ||
47 | if(sigaction(sig, &action, NULL) < 0) | ||
48 | panic("sigaction failed"); | ||
49 | } | ||
50 | |||
51 | int change_sig(int signal, int on) | ||
52 | { | ||
53 | sigset_t sigset, old; | ||
54 | |||
55 | sigemptyset(&sigset); | ||
56 | sigaddset(&sigset, signal); | ||
57 | sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old); | ||
58 | return(!sigismember(&old, signal)); | ||
59 | } | ||
60 | |||
61 | /* Both here and in set/get_signal we don't touch SIGPROF, because we must not | ||
62 | * disable profiling; it's safe because the profiling code does not interact | ||
63 | * with the kernel code at all.*/ | ||
64 | |||
65 | static void change_signals(int type) | ||
66 | { | ||
67 | sigset_t mask; | ||
68 | |||
69 | sigemptyset(&mask); | ||
70 | sigaddset(&mask, SIGVTALRM); | ||
71 | sigaddset(&mask, SIGALRM); | ||
72 | sigaddset(&mask, SIGIO); | ||
73 | if(sigprocmask(type, &mask, NULL) < 0) | ||
74 | panic("Failed to change signal mask - errno = %d", errno); | ||
75 | } | ||
76 | |||
77 | void block_signals(void) | ||
78 | { | ||
79 | change_signals(SIG_BLOCK); | ||
80 | } | ||
81 | |||
82 | void unblock_signals(void) | ||
83 | { | ||
84 | change_signals(SIG_UNBLOCK); | ||
85 | } | ||
86 | |||
87 | /* These are the asynchronous signals. SIGVTALRM and SIGARLM are handled | ||
88 | * together under SIGVTALRM_BIT. SIGPROF is excluded because we want to | ||
89 | * be able to profile all of UML, not just the non-critical sections. If | ||
90 | * profiling is not thread-safe, then that is not my problem. We can disable | ||
91 | * profiling when SMP is enabled in that case. | ||
92 | */ | ||
93 | #define SIGIO_BIT 0 | ||
94 | #define SIGVTALRM_BIT 1 | ||
95 | |||
96 | static int enable_mask(sigset_t *mask) | ||
97 | { | ||
98 | int sigs; | ||
99 | |||
100 | sigs = sigismember(mask, SIGIO) ? 0 : 1 << SIGIO_BIT; | ||
101 | sigs |= sigismember(mask, SIGVTALRM) ? 0 : 1 << SIGVTALRM_BIT; | ||
102 | sigs |= sigismember(mask, SIGALRM) ? 0 : 1 << SIGVTALRM_BIT; | ||
103 | return(sigs); | ||
104 | } | ||
105 | |||
106 | int get_signals(void) | ||
107 | { | ||
108 | sigset_t mask; | ||
109 | |||
110 | if(sigprocmask(SIG_SETMASK, NULL, &mask) < 0) | ||
111 | panic("Failed to get signal mask"); | ||
112 | return(enable_mask(&mask)); | ||
113 | } | ||
114 | |||
115 | int set_signals(int enable) | ||
116 | { | ||
117 | sigset_t mask; | ||
118 | int ret; | ||
119 | |||
120 | sigemptyset(&mask); | ||
121 | if(enable & (1 << SIGIO_BIT)) | ||
122 | sigaddset(&mask, SIGIO); | ||
123 | if(enable & (1 << SIGVTALRM_BIT)){ | ||
124 | sigaddset(&mask, SIGVTALRM); | ||
125 | sigaddset(&mask, SIGALRM); | ||
126 | } | ||
127 | |||
128 | /* This is safe - sigprocmask is guaranteed to copy locally the | ||
129 | * value of new_set, do his work and then, at the end, write to | ||
130 | * old_set. | ||
131 | */ | ||
132 | if(sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0) | ||
133 | panic("Failed to enable signals"); | ||
134 | ret = enable_mask(&mask); | ||
135 | sigemptyset(&mask); | ||
136 | if((enable & (1 << SIGIO_BIT)) == 0) | ||
137 | sigaddset(&mask, SIGIO); | ||
138 | if((enable & (1 << SIGVTALRM_BIT)) == 0){ | ||
139 | sigaddset(&mask, SIGVTALRM); | ||
140 | sigaddset(&mask, SIGALRM); | ||
141 | } | ||
142 | if(sigprocmask(SIG_BLOCK, &mask, NULL) < 0) | ||
143 | panic("Failed to block signals"); | ||
144 | |||
145 | return(ret); | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
150 | * Emacs will notice this stuff at the end of the file and automatically | ||
151 | * adjust the settings for this buffer only. This must remain at the end | ||
152 | * of the file. | ||
153 | * --------------------------------------------------------------------------- | ||
154 | * Local variables: | ||
155 | * c-file-style: "linux" | ||
156 | * End: | ||
157 | */ | ||
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 | ||
6 | obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ | 6 | obj-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 | ||
9 | USER_OBJS := process.o clone.o | 9 | USER_OBJS := process.o clone.o |
10 | 10 | ||
diff --git a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h index daa2f85b684c..01d489de3986 100644 --- a/arch/um/kernel/skas/include/skas.h +++ b/arch/um/kernel/skas/include/skas.h | |||
@@ -22,7 +22,6 @@ extern int start_idle_thread(void *stack, void *switch_buf_ptr, | |||
22 | extern int user_thread(unsigned long stack, int flags); | 22 | extern int user_thread(unsigned long stack, int flags); |
23 | extern void userspace(union uml_pt_regs *regs); | 23 | extern void userspace(union uml_pt_regs *regs); |
24 | extern void new_thread_proc(void *stack, void (*handler)(int sig)); | 24 | extern void new_thread_proc(void *stack, void (*handler)(int sig)); |
25 | extern void remove_sigstack(void); | ||
26 | extern void new_thread_handler(int sig); | 25 | extern void new_thread_handler(int sig); |
27 | extern void handle_syscall(union uml_pt_regs *regs); | 26 | extern void handle_syscall(union uml_pt_regs *regs); |
28 | extern int map(struct mm_id * mm_idp, unsigned long virt, | 27 | extern int map(struct mm_id * mm_idp, unsigned long virt, |
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c index 599d679bd4fc..3b3955d84407 100644 --- a/arch/um/kernel/skas/process.c +++ b/arch/um/kernel/skas/process.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include "proc_mm.h" | 31 | #include "proc_mm.h" |
32 | #include "skas_ptrace.h" | 32 | #include "skas_ptrace.h" |
33 | #include "chan_user.h" | 33 | #include "chan_user.h" |
34 | #include "signal_user.h" | ||
35 | #include "registers.h" | 34 | #include "registers.h" |
36 | #include "mem.h" | 35 | #include "mem.h" |
37 | #include "uml-config.h" | 36 | #include "uml-config.h" |
@@ -69,7 +68,7 @@ void wait_stub_done(int pid, int sig, char * fname) | |||
69 | 68 | ||
70 | if((n < 0) || !WIFSTOPPED(status) || | 69 | if((n < 0) || !WIFSTOPPED(status) || |
71 | (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ | 70 | (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ |
72 | unsigned long regs[FRAME_SIZE]; | 71 | unsigned long regs[HOST_FRAME_SIZE]; |
73 | if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) | 72 | if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) |
74 | printk("Failed to get registers from stub, " | 73 | printk("Failed to get registers from stub, " |
75 | "errno = %d\n", errno); | 74 | "errno = %d\n", errno); |
@@ -77,7 +76,7 @@ void wait_stub_done(int pid, int sig, char * fname) | |||
77 | int i; | 76 | int i; |
78 | 77 | ||
79 | printk("Stub registers -\n"); | 78 | printk("Stub registers -\n"); |
80 | for(i = 0; i < FRAME_SIZE; i++) | 79 | for(i = 0; i < HOST_FRAME_SIZE; i++) |
81 | printk("\t%d - %lx\n", i, regs[i]); | 80 | printk("\t%d - %lx\n", i, regs[i]); |
82 | } | 81 | } |
83 | panic("%s : failed to wait for SIGUSR1/SIGTRAP, " | 82 | panic("%s : failed to wait for SIGUSR1/SIGTRAP, " |
@@ -514,16 +513,6 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) | |||
514 | siglongjmp(**switch_buf, 1); | 513 | siglongjmp(**switch_buf, 1); |
515 | } | 514 | } |
516 | 515 | ||
517 | void remove_sigstack(void) | ||
518 | { | ||
519 | stack_t stack = ((stack_t) { .ss_flags = SS_DISABLE, | ||
520 | .ss_sp = NULL, | ||
521 | .ss_size = 0 }); | ||
522 | |||
523 | if(sigaltstack(&stack, NULL) != 0) | ||
524 | panic("disabling signal stack failed, errno = %d\n", errno); | ||
525 | } | ||
526 | |||
527 | void initial_thread_cb_skas(void (*proc)(void *), void *arg) | 516 | void initial_thread_cb_skas(void (*proc)(void *), void *arg) |
528 | { | 517 | { |
529 | sigjmp_buf here; | 518 | sigjmp_buf here; |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index 9c990253966c..dc41c6dc2f34 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include "asm/atomic.h" | 14 | #include "asm/atomic.h" |
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "time_user.h" | 16 | #include "time_user.h" |
17 | #include "signal_user.h" | ||
18 | #include "skas.h" | 17 | #include "skas.h" |
19 | #include "os.h" | 18 | #include "os.h" |
20 | #include "user_util.h" | 19 | #include "user_util.h" |
@@ -119,7 +118,7 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp, | |||
119 | handler = new_thread_handler; | 118 | handler = new_thread_handler; |
120 | } | 119 | } |
121 | 120 | ||
122 | new_thread(p->thread_info, &p->thread.mode.skas.switch_buf, | 121 | new_thread(task_stack_page(p), &p->thread.mode.skas.switch_buf, |
123 | &p->thread.mode.skas.fork_buf, handler); | 122 | &p->thread.mode.skas.fork_buf, handler); |
124 | return(0); | 123 | return(0); |
125 | } | 124 | } |
@@ -186,7 +185,7 @@ int start_uml_skas(void) | |||
186 | 185 | ||
187 | init_task.thread.request.u.thread.proc = start_kernel_proc; | 186 | init_task.thread.request.u.thread.proc = start_kernel_proc; |
188 | init_task.thread.request.u.thread.arg = NULL; | 187 | init_task.thread.request.u.thread.arg = NULL; |
189 | return(start_idle_thread(init_task.thread_info, | 188 | return(start_idle_thread(task_stack_page(&init_task), |
190 | &init_task.thread.mode.skas.switch_buf, | 189 | &init_task.thread.mode.skas.switch_buf, |
191 | &init_task.thread.mode.skas.fork_buf)); | 190 | &init_task.thread.mode.skas.fork_buf)); |
192 | } | 191 | } |
diff --git a/arch/um/kernel/skas/trap_user.c b/arch/um/kernel/skas/trap_user.c deleted file mode 100644 index 9950a6716fe5..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 "signal_user.h" | ||
9 | #include "user_util.h" | ||
10 | #include "kern_util.h" | ||
11 | #include "task.h" | ||
12 | #include "sigcontext.h" | ||
13 | #include "skas.h" | ||
14 | #include "ptrace_user.h" | ||
15 | #include "sysdep/ptrace.h" | ||
16 | #include "sysdep/ptrace_user.h" | ||
17 | |||
18 | void 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 | |||
53 | extern int ptrace_faultinfo; | ||
54 | |||
55 | void 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, ®s->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/time.c b/arch/um/kernel/time.c index c40b611e3d93..8fa2ae7f3026 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c | |||
@@ -14,9 +14,9 @@ | |||
14 | #include "kern_util.h" | 14 | #include "kern_util.h" |
15 | #include "user.h" | 15 | #include "user.h" |
16 | #include "process.h" | 16 | #include "process.h" |
17 | #include "signal_user.h" | ||
18 | #include "time_user.h" | 17 | #include "time_user.h" |
19 | #include "kern_constants.h" | 18 | #include "kern_constants.h" |
19 | #include "os.h" | ||
20 | 20 | ||
21 | /* XXX This really needs to be declared and initialized in a kernel file since | 21 | /* XXX This really needs to be declared and initialized in a kernel file since |
22 | * it's in <linux/time.h> | 22 | * it's in <linux/time.h> |
@@ -99,7 +99,8 @@ void uml_idle_timer(void) | |||
99 | set_interval(ITIMER_REAL); | 99 | set_interval(ITIMER_REAL); |
100 | } | 100 | } |
101 | 101 | ||
102 | extern int do_posix_clock_monotonic_gettime(struct timespec *tp); | 102 | extern void ktime_get_ts(struct timespec *ts); |
103 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) | ||
103 | 104 | ||
104 | void time_init(void) | 105 | void time_init(void) |
105 | { | 106 | { |
@@ -114,8 +115,8 @@ void time_init(void) | |||
114 | wall_to_monotonic.tv_nsec = -now.tv_nsec; | 115 | wall_to_monotonic.tv_nsec = -now.tv_nsec; |
115 | } | 116 | } |
116 | 117 | ||
117 | /* Declared in linux/time.h, which can't be included here */ | 118 | /* Defined in linux/ktimer.h, which can't be included here */ |
118 | extern void clock_was_set(void); | 119 | #define clock_was_set() do { } while (0) |
119 | 120 | ||
120 | void do_gettimeofday(struct timeval *tv) | 121 | void do_gettimeofday(struct timeval *tv) |
121 | { | 122 | { |
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c index 0d4c10a73607..d56046c2aba2 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 | */ |
@@ -26,9 +26,13 @@ | |||
26 | #include "mconsole_kern.h" | 26 | #include "mconsole_kern.h" |
27 | #include "mem.h" | 27 | #include "mem.h" |
28 | #include "mem_kern.h" | 28 | #include "mem_kern.h" |
29 | #include "sysdep/sigcontext.h" | ||
30 | #include "sysdep/ptrace.h" | ||
31 | #include "os.h" | ||
29 | #ifdef CONFIG_MODE_SKAS | 32 | #ifdef CONFIG_MODE_SKAS |
30 | #include "skas.h" | 33 | #include "skas.h" |
31 | #endif | 34 | #endif |
35 | #include "os.h" | ||
32 | 36 | ||
33 | /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ | 37 | /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ |
34 | int handle_page_fault(unsigned long address, unsigned long ip, | 38 | int handle_page_fault(unsigned long address, unsigned long ip, |
@@ -125,6 +129,25 @@ out_of_memory: | |||
125 | goto out; | 129 | goto out; |
126 | } | 130 | } |
127 | 131 | ||
132 | void segv_handler(int sig, union uml_pt_regs *regs) | ||
133 | { | ||
134 | struct faultinfo * fi = UPT_FAULTINFO(regs); | ||
135 | |||
136 | if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){ | ||
137 | bad_segv(*fi, UPT_IP(regs)); | ||
138 | return; | ||
139 | } | ||
140 | segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); | ||
141 | } | ||
142 | |||
143 | struct kern_handlers handlinfo_kern = { | ||
144 | .relay_signal = relay_signal, | ||
145 | .winch = winch, | ||
146 | .bus_handler = relay_signal, | ||
147 | .page_fault = segv_handler, | ||
148 | .sigio_handler = sigio_handler, | ||
149 | .timer_handler = timer_handler | ||
150 | }; | ||
128 | /* | 151 | /* |
129 | * We give a *copy* of the faultinfo in the regs to segv. | 152 | * We give a *copy* of the faultinfo in the regs to segv. |
130 | * This must be done, since nesting SEGVs could overwrite | 153 | * 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 deleted file mode 100644 index e9ccd6b8d3c7..000000000000 --- a/arch/um/kernel/trap_user.c +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdlib.h> | ||
7 | #include <errno.h> | ||
8 | #include <setjmp.h> | ||
9 | #include <signal.h> | ||
10 | #include <sys/time.h> | ||
11 | #include <sys/wait.h> | ||
12 | #include <asm/page.h> | ||
13 | #include <asm/unistd.h> | ||
14 | #include <asm/ptrace.h> | ||
15 | #include "init.h" | ||
16 | #include "sysdep/ptrace.h" | ||
17 | #include "sigcontext.h" | ||
18 | #include "sysdep/sigcontext.h" | ||
19 | #include "irq_user.h" | ||
20 | #include "signal_user.h" | ||
21 | #include "time_user.h" | ||
22 | #include "task.h" | ||
23 | #include "mode.h" | ||
24 | #include "choose-mode.h" | ||
25 | #include "kern_util.h" | ||
26 | #include "user_util.h" | ||
27 | #include "os.h" | ||
28 | |||
29 | void kill_child_dead(int pid) | ||
30 | { | ||
31 | kill(pid, SIGKILL); | ||
32 | kill(pid, SIGCONT); | ||
33 | do { | ||
34 | int n; | ||
35 | CATCH_EINTR(n = waitpid(pid, NULL, 0)); | ||
36 | if (n > 0) | ||
37 | kill(pid, SIGCONT); | ||
38 | else | ||
39 | break; | ||
40 | } while(1); | ||
41 | } | ||
42 | |||
43 | void segv_handler(int sig, union uml_pt_regs *regs) | ||
44 | { | ||
45 | struct faultinfo * fi = UPT_FAULTINFO(regs); | ||
46 | |||
47 | if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){ | ||
48 | bad_segv(*fi, UPT_IP(regs)); | ||
49 | return; | ||
50 | } | ||
51 | segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); | ||
52 | } | ||
53 | |||
54 | void usr2_handler(int sig, union uml_pt_regs *regs) | ||
55 | { | ||
56 | CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0); | ||
57 | } | ||
58 | |||
59 | struct signal_info sig_info[] = { | ||
60 | [ SIGTRAP ] { .handler = relay_signal, | ||
61 | .is_irq = 0 }, | ||
62 | [ SIGFPE ] { .handler = relay_signal, | ||
63 | .is_irq = 0 }, | ||
64 | [ SIGILL ] { .handler = relay_signal, | ||
65 | .is_irq = 0 }, | ||
66 | [ SIGWINCH ] { .handler = winch, | ||
67 | .is_irq = 1 }, | ||
68 | [ SIGBUS ] { .handler = bus_handler, | ||
69 | .is_irq = 0 }, | ||
70 | [ SIGSEGV] { .handler = segv_handler, | ||
71 | .is_irq = 0 }, | ||
72 | [ SIGIO ] { .handler = sigio_handler, | ||
73 | .is_irq = 1 }, | ||
74 | [ SIGVTALRM ] { .handler = timer_handler, | ||
75 | .is_irq = 1 }, | ||
76 | [ SIGALRM ] { .handler = timer_handler, | ||
77 | .is_irq = 1 }, | ||
78 | [ SIGUSR2 ] { .handler = usr2_handler, | ||
79 | .is_irq = 0 }, | ||
80 | }; | ||
81 | |||
82 | void do_longjmp(void *b, int val) | ||
83 | { | ||
84 | sigjmp_buf *buf = b; | ||
85 | |||
86 | siglongjmp(*buf, val); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
91 | * Emacs will notice this stuff at the end of the file and automatically | ||
92 | * adjust the settings for this buffer only. This must remain at the end | ||
93 | * of the file. | ||
94 | * --------------------------------------------------------------------------- | ||
95 | * Local variables: | ||
96 | * c-file-style: "linux" | ||
97 | * End: | ||
98 | */ | ||
diff --git a/arch/um/kernel/tt/exec_kern.c b/arch/um/kernel/tt/exec_kern.c index 065b504a653b..8f40e4838736 100644 --- a/arch/um/kernel/tt/exec_kern.c +++ b/arch/um/kernel/tt/exec_kern.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include "kern_util.h" | 14 | #include "kern_util.h" |
15 | #include "irq_user.h" | 15 | #include "irq_user.h" |
16 | #include "time_user.h" | 16 | #include "time_user.h" |
17 | #include "signal_user.h" | ||
18 | #include "mem_user.h" | 17 | #include "mem_user.h" |
19 | #include "os.h" | 18 | #include "os.h" |
20 | #include "tlb.h" | 19 | #include "tlb.h" |
@@ -40,7 +39,7 @@ void flush_thread_tt(void) | |||
40 | do_exit(SIGKILL); | 39 | do_exit(SIGKILL); |
41 | } | 40 | } |
42 | 41 | ||
43 | new_pid = start_fork_tramp(current->thread_info, stack, 0, exec_tramp); | 42 | new_pid = start_fork_tramp(task_stack_page(current), stack, 0, exec_tramp); |
44 | if(new_pid < 0){ | 43 | if(new_pid < 0){ |
45 | printk(KERN_ERR | 44 | printk(KERN_ERR |
46 | "flush_thread : new thread failed, errno = %d\n", | 45 | "flush_thread : new thread failed, errno = %d\n", |
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c index cfaa373a6e77..62535303aa27 100644 --- a/arch/um/kernel/tt/process_kern.c +++ b/arch/um/kernel/tt/process_kern.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include "asm/ptrace.h" | 13 | #include "asm/ptrace.h" |
14 | #include "asm/tlbflush.h" | 14 | #include "asm/tlbflush.h" |
15 | #include "irq_user.h" | 15 | #include "irq_user.h" |
16 | #include "signal_user.h" | ||
17 | #include "kern_util.h" | 16 | #include "kern_util.h" |
18 | #include "user_util.h" | 17 | #include "user_util.h" |
19 | #include "os.h" | 18 | #include "os.h" |
@@ -37,7 +36,7 @@ void switch_to_tt(void *prev, void *next) | |||
37 | from = prev; | 36 | from = prev; |
38 | to = next; | 37 | to = next; |
39 | 38 | ||
40 | cpu = from->thread_info->cpu; | 39 | cpu = task_thread_info(from)->cpu; |
41 | if(cpu == 0) | 40 | if(cpu == 0) |
42 | forward_interrupts(to->thread.mode.tt.extern_pid); | 41 | forward_interrupts(to->thread.mode.tt.extern_pid); |
43 | #ifdef CONFIG_SMP | 42 | #ifdef CONFIG_SMP |
@@ -254,7 +253,7 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp, | |||
254 | 253 | ||
255 | clone_flags &= CLONE_VM; | 254 | clone_flags &= CLONE_VM; |
256 | p->thread.temp_stack = stack; | 255 | p->thread.temp_stack = stack; |
257 | new_pid = start_fork_tramp(p->thread_info, stack, clone_flags, tramp); | 256 | new_pid = start_fork_tramp(task_stack_page(p), stack, clone_flags, tramp); |
258 | if(new_pid < 0){ | 257 | if(new_pid < 0){ |
259 | printk(KERN_ERR "copy_thread : clone failed - errno = %d\n", | 258 | printk(KERN_ERR "copy_thread : clone failed - errno = %d\n", |
260 | -new_pid); | 259 | -new_pid); |
@@ -344,7 +343,7 @@ int do_proc_op(void *t, int proc_id) | |||
344 | pid = thread->request.u.exec.pid; | 343 | pid = thread->request.u.exec.pid; |
345 | do_exec(thread->mode.tt.extern_pid, pid); | 344 | do_exec(thread->mode.tt.extern_pid, pid); |
346 | thread->mode.tt.extern_pid = pid; | 345 | thread->mode.tt.extern_pid = pid; |
347 | cpu_tasks[task->thread_info->cpu].pid = pid; | 346 | cpu_tasks[task_thread_info(task)->cpu].pid = pid; |
348 | break; | 347 | break; |
349 | case OP_FORK: | 348 | case OP_FORK: |
350 | attach_process(thread->request.u.fork.pid); | 349 | attach_process(thread->request.u.fork.pid); |
@@ -426,7 +425,7 @@ int start_uml_tt(void) | |||
426 | int pages; | 425 | int pages; |
427 | 426 | ||
428 | pages = (1 << CONFIG_KERNEL_STACK_ORDER); | 427 | pages = (1 << CONFIG_KERNEL_STACK_ORDER); |
429 | sp = (void *) ((unsigned long) init_task.thread_info) + | 428 | sp = task_stack_page(&init_task) + |
430 | pages * PAGE_SIZE - sizeof(unsigned long); | 429 | pages * PAGE_SIZE - sizeof(unsigned long); |
431 | return(tracer(start_kernel_proc, sp)); | 430 | return(tracer(start_kernel_proc, sp)); |
432 | } | 431 | } |
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c index d11e7399d7a1..71daae24e48a 100644 --- a/arch/um/kernel/tt/tracer.c +++ b/arch/um/kernel/tt/tracer.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include "sigcontext.h" | 19 | #include "sigcontext.h" |
20 | #include "sysdep/sigcontext.h" | 20 | #include "sysdep/sigcontext.h" |
21 | #include "os.h" | 21 | #include "os.h" |
22 | #include "signal_user.h" | ||
23 | #include "user_util.h" | 22 | #include "user_util.h" |
24 | #include "mem_user.h" | 23 | #include "mem_user.h" |
25 | #include "process.h" | 24 | #include "process.h" |
diff --git a/arch/um/kernel/tt/trap_user.c b/arch/um/kernel/tt/trap_user.c index fc108615beaf..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 | */ |
@@ -8,18 +8,18 @@ | |||
8 | #include <signal.h> | 8 | #include <signal.h> |
9 | #include "sysdep/ptrace.h" | 9 | #include "sysdep/ptrace.h" |
10 | #include "sysdep/sigcontext.h" | 10 | #include "sysdep/sigcontext.h" |
11 | #include "signal_user.h" | ||
12 | #include "user_util.h" | 11 | #include "user_util.h" |
13 | #include "kern_util.h" | 12 | #include "kern_util.h" |
14 | #include "task.h" | 13 | #include "task.h" |
15 | #include "tt.h" | 14 | #include "tt.h" |
15 | #include "os.h" | ||
16 | 16 | ||
17 | void sig_handler_common_tt(int sig, void *sc_ptr) | 17 | 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 142a9493912b..e2d3ca445ef5 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 | */ |
@@ -146,8 +146,8 @@ void set_cmdline(char *cmd) | |||
146 | 146 | ||
147 | if(CHOOSE_MODE(honeypot, 0)) return; | 147 | if(CHOOSE_MODE(honeypot, 0)) return; |
148 | 148 | ||
149 | umid = get_umid(1); | 149 | umid = get_umid(); |
150 | if(umid != NULL){ | 150 | if(*umid != '\0'){ |
151 | snprintf(argv1_begin, | 151 | snprintf(argv1_begin, |
152 | (argv1_end - argv1_begin) * sizeof(*ptr), | 152 | (argv1_end - argv1_begin) * sizeof(*ptr), |
153 | "(%s) ", umid); | 153 | "(%s) ", umid); |
@@ -243,10 +243,6 @@ static int __init mode_tt_setup(char *line, int *add) | |||
243 | return(0); | 243 | return(0); |
244 | } | 244 | } |
245 | 245 | ||
246 | #else | ||
247 | |||
248 | #error Either CONFIG_MODE_TT or CONFIG_MODE_SKAS must be enabled | ||
249 | |||
250 | #endif | 246 | #endif |
251 | #endif | 247 | #endif |
252 | #endif | 248 | #endif |
@@ -363,6 +359,11 @@ int linux_main(int argc, char **argv) | |||
363 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, | 359 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, |
364 | &host_task_size, &task_size); | 360 | &host_task_size, &task_size); |
365 | 361 | ||
362 | /* | ||
363 | * Setting up handlers to 'sig_info' struct | ||
364 | */ | ||
365 | os_fill_handlinfo(handlinfo_kern); | ||
366 | |||
366 | brk_start = (unsigned long) sbrk(0); | 367 | brk_start = (unsigned long) sbrk(0); |
367 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); | 368 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); |
368 | /* Increase physical memory size for exec-shield users | 369 | /* Increase physical memory size for exec-shield users |
diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c index 0b21d59ba0cd..4eaee823bfd2 100644 --- a/arch/um/kernel/umid.c +++ b/arch/um/kernel/umid.c | |||
@@ -3,61 +3,30 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include "asm/errno.h" |
7 | #include <unistd.h> | ||
8 | #include <errno.h> | ||
9 | #include <string.h> | ||
10 | #include <stdlib.h> | ||
11 | #include <dirent.h> | ||
12 | #include <signal.h> | ||
13 | #include <sys/stat.h> | ||
14 | #include <sys/param.h> | ||
15 | #include "user.h" | ||
16 | #include "umid.h" | ||
17 | #include "init.h" | 7 | #include "init.h" |
18 | #include "os.h" | 8 | #include "os.h" |
19 | #include "user_util.h" | 9 | #include "kern.h" |
20 | #include "choose-mode.h" | 10 | #include "linux/kernel.h" |
21 | 11 | ||
22 | #define UMID_LEN 64 | 12 | /* Changed by set_umid_arg */ |
23 | #define UML_DIR "~/.uml/" | ||
24 | |||
25 | /* Changed by set_umid and make_umid, which are run early in boot */ | ||
26 | static char umid[UMID_LEN] = { 0 }; | ||
27 | |||
28 | /* Changed by set_uml_dir and make_uml_dir, which are run early in boot */ | ||
29 | static char *uml_dir = UML_DIR; | ||
30 | |||
31 | /* Changed by set_umid */ | ||
32 | static int umid_is_random = 1; | ||
33 | static int umid_inited = 0; | 13 | static int umid_inited = 0; |
34 | /* Have we created the files? Should we remove them? */ | ||
35 | static int umid_owned = 0; | ||
36 | 14 | ||
37 | static int make_umid(int (*printer)(const char *fmt, ...)); | 15 | static int __init set_umid_arg(char *name, int *add) |
38 | |||
39 | static int __init set_umid(char *name, int is_random, | ||
40 | int (*printer)(const char *fmt, ...)) | ||
41 | { | 16 | { |
42 | if(umid_inited){ | 17 | int err; |
43 | (*printer)("Unique machine name can't be set twice\n"); | ||
44 | return(-1); | ||
45 | } | ||
46 | 18 | ||
47 | if(strlen(name) > UMID_LEN - 1) | 19 | if(umid_inited) |
48 | (*printer)("Unique machine name is being truncated to %d " | 20 | return 0; |
49 | "characters\n", UMID_LEN); | ||
50 | strlcpy(umid, name, sizeof(umid)); | ||
51 | 21 | ||
52 | umid_is_random = is_random; | ||
53 | umid_inited = 1; | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static int __init set_umid_arg(char *name, int *add) | ||
58 | { | ||
59 | *add = 0; | 22 | *add = 0; |
60 | return(set_umid(name, 0, printf)); | 23 | err = set_umid(name); |
24 | if(err == -EEXIST) | ||
25 | printf("umid '%s' already in use\n", name); | ||
26 | else if(!err) | ||
27 | umid_inited = 1; | ||
28 | |||
29 | return 0; | ||
61 | } | 30 | } |
62 | 31 | ||
63 | __uml_setup("umid=", set_umid_arg, | 32 | __uml_setup("umid=", set_umid_arg, |
@@ -66,265 +35,3 @@ __uml_setup("umid=", set_umid_arg, | |||
66 | " is used for naming the pid file and management console socket.\n\n" | 35 | " is used for naming the pid file and management console socket.\n\n" |
67 | ); | 36 | ); |
68 | 37 | ||
69 | int __init umid_file_name(char *name, char *buf, int len) | ||
70 | { | ||
71 | int n; | ||
72 | |||
73 | if(!umid_inited && make_umid(printk)) return(-1); | ||
74 | |||
75 | n = strlen(uml_dir) + strlen(umid) + strlen(name) + 1; | ||
76 | if(n > len){ | ||
77 | printk("umid_file_name : buffer too short\n"); | ||
78 | return(-1); | ||
79 | } | ||
80 | |||
81 | sprintf(buf, "%s%s/%s", uml_dir, umid, name); | ||
82 | return(0); | ||
83 | } | ||
84 | |||
85 | extern int tracing_pid; | ||
86 | |||
87 | static void __init create_pid_file(void) | ||
88 | { | ||
89 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; | ||
90 | char pid[sizeof("nnnnn\0")]; | ||
91 | int fd, n; | ||
92 | |||
93 | if(umid_file_name("pid", file, sizeof(file))) | ||
94 | return; | ||
95 | |||
96 | fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), | ||
97 | 0644); | ||
98 | if(fd < 0){ | ||
99 | printf("Open of machine pid file \"%s\" failed: %s\n", | ||
100 | file, strerror(-fd)); | ||
101 | return; | ||
102 | } | ||
103 | |||
104 | sprintf(pid, "%d\n", os_getpid()); | ||
105 | n = os_write_file(fd, pid, strlen(pid)); | ||
106 | if(n != strlen(pid)) | ||
107 | printf("Write of pid file failed - err = %d\n", -n); | ||
108 | os_close_file(fd); | ||
109 | } | ||
110 | |||
111 | static int actually_do_remove(char *dir) | ||
112 | { | ||
113 | DIR *directory; | ||
114 | struct dirent *ent; | ||
115 | int len; | ||
116 | char file[256]; | ||
117 | |||
118 | directory = opendir(dir); | ||
119 | if(directory == NULL){ | ||
120 | printk("actually_do_remove : couldn't open directory '%s', " | ||
121 | "errno = %d\n", dir, errno); | ||
122 | return(1); | ||
123 | } | ||
124 | while((ent = readdir(directory)) != NULL){ | ||
125 | if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) | ||
126 | continue; | ||
127 | len = strlen(dir) + sizeof("/") + strlen(ent->d_name) + 1; | ||
128 | if(len > sizeof(file)){ | ||
129 | printk("Not deleting '%s' from '%s' - name too long\n", | ||
130 | ent->d_name, dir); | ||
131 | continue; | ||
132 | } | ||
133 | sprintf(file, "%s/%s", dir, ent->d_name); | ||
134 | if(unlink(file) < 0){ | ||
135 | printk("actually_do_remove : couldn't remove '%s' " | ||
136 | "from '%s', errno = %d\n", ent->d_name, dir, | ||
137 | errno); | ||
138 | return(1); | ||
139 | } | ||
140 | } | ||
141 | if(rmdir(dir) < 0){ | ||
142 | printk("actually_do_remove : couldn't rmdir '%s', " | ||
143 | "errno = %d\n", dir, errno); | ||
144 | return(1); | ||
145 | } | ||
146 | return(0); | ||
147 | } | ||
148 | |||
149 | void remove_umid_dir(void) | ||
150 | { | ||
151 | char dir[strlen(uml_dir) + UMID_LEN + 1]; | ||
152 | if (!umid_owned) | ||
153 | return; | ||
154 | |||
155 | sprintf(dir, "%s%s", uml_dir, umid); | ||
156 | actually_do_remove(dir); | ||
157 | } | ||
158 | |||
159 | char *get_umid(int only_if_set) | ||
160 | { | ||
161 | if(only_if_set && umid_is_random) | ||
162 | return NULL; | ||
163 | return umid; | ||
164 | } | ||
165 | |||
166 | static int not_dead_yet(char *dir) | ||
167 | { | ||
168 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; | ||
169 | char pid[sizeof("nnnnn\0")], *end; | ||
170 | int dead, fd, p, n; | ||
171 | |||
172 | sprintf(file, "%s/pid", dir); | ||
173 | dead = 0; | ||
174 | fd = os_open_file(file, of_read(OPENFLAGS()), 0); | ||
175 | if(fd < 0){ | ||
176 | if(fd != -ENOENT){ | ||
177 | printk("not_dead_yet : couldn't open pid file '%s', " | ||
178 | "err = %d\n", file, -fd); | ||
179 | return(1); | ||
180 | } | ||
181 | dead = 1; | ||
182 | } | ||
183 | if(fd > 0){ | ||
184 | n = os_read_file(fd, pid, sizeof(pid)); | ||
185 | if(n < 0){ | ||
186 | printk("not_dead_yet : couldn't read pid file '%s', " | ||
187 | "err = %d\n", file, -n); | ||
188 | return(1); | ||
189 | } | ||
190 | p = strtoul(pid, &end, 0); | ||
191 | if(end == pid){ | ||
192 | printk("not_dead_yet : couldn't parse pid file '%s', " | ||
193 | "errno = %d\n", file, errno); | ||
194 | dead = 1; | ||
195 | } | ||
196 | if(((kill(p, 0) < 0) && (errno == ESRCH)) || | ||
197 | (p == CHOOSE_MODE(tracing_pid, os_getpid()))) | ||
198 | dead = 1; | ||
199 | } | ||
200 | if(!dead) | ||
201 | return(1); | ||
202 | return(actually_do_remove(dir)); | ||
203 | } | ||
204 | |||
205 | static int __init set_uml_dir(char *name, int *add) | ||
206 | { | ||
207 | if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){ | ||
208 | uml_dir = malloc(strlen(name) + 2); | ||
209 | if(uml_dir == NULL){ | ||
210 | printf("Failed to malloc uml_dir - error = %d\n", | ||
211 | errno); | ||
212 | uml_dir = name; | ||
213 | /* Return 0 here because do_initcalls doesn't look at | ||
214 | * the return value. | ||
215 | */ | ||
216 | return(0); | ||
217 | } | ||
218 | sprintf(uml_dir, "%s/", name); | ||
219 | } | ||
220 | else uml_dir = name; | ||
221 | return(0); | ||
222 | } | ||
223 | |||
224 | static int __init make_uml_dir(void) | ||
225 | { | ||
226 | char dir[MAXPATHLEN + 1] = { '\0' }; | ||
227 | int len; | ||
228 | |||
229 | if(*uml_dir == '~'){ | ||
230 | char *home = getenv("HOME"); | ||
231 | |||
232 | if(home == NULL){ | ||
233 | printf("make_uml_dir : no value in environment for " | ||
234 | "$HOME\n"); | ||
235 | exit(1); | ||
236 | } | ||
237 | strlcpy(dir, home, sizeof(dir)); | ||
238 | uml_dir++; | ||
239 | } | ||
240 | strlcat(dir, uml_dir, sizeof(dir)); | ||
241 | len = strlen(dir); | ||
242 | if (len > 0 && dir[len - 1] != '/') | ||
243 | strlcat(dir, "/", sizeof(dir)); | ||
244 | |||
245 | uml_dir = malloc(strlen(dir) + 1); | ||
246 | if (uml_dir == NULL) { | ||
247 | printf("make_uml_dir : malloc failed, errno = %d\n", errno); | ||
248 | exit(1); | ||
249 | } | ||
250 | strcpy(uml_dir, dir); | ||
251 | |||
252 | if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){ | ||
253 | printf("Failed to mkdir %s: %s\n", uml_dir, strerror(errno)); | ||
254 | return(-1); | ||
255 | } | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static int __init make_umid(int (*printer)(const char *fmt, ...)) | ||
260 | { | ||
261 | int fd, err; | ||
262 | char tmp[strlen(uml_dir) + UMID_LEN + 1]; | ||
263 | |||
264 | strlcpy(tmp, uml_dir, sizeof(tmp)); | ||
265 | |||
266 | if(!umid_inited){ | ||
267 | strcat(tmp, "XXXXXX"); | ||
268 | fd = mkstemp(tmp); | ||
269 | if(fd < 0){ | ||
270 | (*printer)("make_umid - mkstemp(%s) failed: %s\n", | ||
271 | tmp,strerror(errno)); | ||
272 | return(1); | ||
273 | } | ||
274 | |||
275 | os_close_file(fd); | ||
276 | /* There's a nice tiny little race between this unlink and | ||
277 | * the mkdir below. It'd be nice if there were a mkstemp | ||
278 | * for directories. | ||
279 | */ | ||
280 | unlink(tmp); | ||
281 | set_umid(&tmp[strlen(uml_dir)], 1, printer); | ||
282 | } | ||
283 | |||
284 | sprintf(tmp, "%s%s", uml_dir, umid); | ||
285 | |||
286 | err = mkdir(tmp, 0777); | ||
287 | if(err < 0){ | ||
288 | if(errno == EEXIST){ | ||
289 | if(not_dead_yet(tmp)){ | ||
290 | (*printer)("umid '%s' is in use\n", umid); | ||
291 | umid_owned = 0; | ||
292 | return(-1); | ||
293 | } | ||
294 | err = mkdir(tmp, 0777); | ||
295 | } | ||
296 | } | ||
297 | if(err < 0){ | ||
298 | (*printer)("Failed to create %s - errno = %d\n", umid, errno); | ||
299 | return(-1); | ||
300 | } | ||
301 | |||
302 | umid_owned = 1; | ||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | __uml_setup("uml_dir=", set_uml_dir, | ||
307 | "uml_dir=<directory>\n" | ||
308 | " The location to place the pid and umid files.\n\n" | ||
309 | ); | ||
310 | |||
311 | static int __init make_umid_setup(void) | ||
312 | { | ||
313 | /* one function with the ordering we need ... */ | ||
314 | make_uml_dir(); | ||
315 | make_umid(printf); | ||
316 | create_pid_file(); | ||
317 | return 0; | ||
318 | } | ||
319 | __uml_postsetup(make_umid_setup); | ||
320 | |||
321 | /* | ||
322 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
323 | * Emacs will notice this stuff at the end of the file and automatically | ||
324 | * adjust the settings for this buffer only. This must remain at the end | ||
325 | * of the file. | ||
326 | * --------------------------------------------------------------------------- | ||
327 | * Local variables: | ||
328 | * c-file-style: "linux" | ||
329 | * End: | ||
330 | */ | ||