diff options
Diffstat (limited to 'arch/um/kernel')
-rw-r--r-- | arch/um/kernel/Makefile | 16 | ||||
-rw-r--r-- | arch/um/kernel/helper.c | 12 | ||||
-rw-r--r-- | arch/um/kernel/init_task.c | 5 | ||||
-rw-r--r-- | arch/um/kernel/mem.c | 16 | ||||
-rw-r--r-- | arch/um/kernel/mem_user.c | 273 | ||||
-rw-r--r-- | arch/um/kernel/process_kern.c | 19 | ||||
-rw-r--r-- | arch/um/kernel/skas/include/mode_kern-skas.h | 2 | ||||
-rw-r--r-- | arch/um/kernel/skas/include/uaccess-skas.h | 6 | ||||
-rw-r--r-- | arch/um/kernel/skas/process_kern.c | 7 | ||||
-rw-r--r-- | arch/um/kernel/tempfile.c | 82 | ||||
-rw-r--r-- | arch/um/kernel/tlb.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/tt/include/mode_kern-tt.h | 2 | ||||
-rw-r--r-- | arch/um/kernel/tt/include/uaccess-tt.h | 6 | ||||
-rw-r--r-- | arch/um/kernel/tt/mem_user.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/tt/process_kern.c | 8 | ||||
-rw-r--r-- | arch/um/kernel/um_arch.c | 5 | ||||
-rw-r--r-- | arch/um/kernel/user_util.c | 18 |
17 files changed, 67 insertions, 413 deletions
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 614b8ebeb0ed..1a0001b3850c 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -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 | # |
@@ -7,11 +7,11 @@ extra-y := vmlinux.lds | |||
7 | clean-files := | 7 | clean-files := |
8 | 8 | ||
9 | obj-y = config.o exec_kern.o exitcode.o \ | 9 | obj-y = config.o exec_kern.o exitcode.o \ |
10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \ | 10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o physmem.o \ |
11 | physmem.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
12 | sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o \ | 12 | signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ |
13 | tempfile.o time.o time_kern.o tlb.o trap_kern.o trap_user.o \ | 13 | time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \ |
14 | uaccess_user.o um_arch.o umid.o user_util.o | 14 | umid.o 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,8 +24,8 @@ 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 helper.o main.o tempfile.o time.o \ | 27 | USER_OBJS := $(user-objs-y) config.o helper.o main.o time.o tty_log.o umid.o \ |
28 | tty_log.o umid.o user_util.o | 28 | user_util.o |
29 | 29 | ||
30 | include arch/um/scripts/Makefile.rules | 30 | include arch/um/scripts/Makefile.rules |
31 | 31 | ||
diff --git a/arch/um/kernel/helper.c b/arch/um/kernel/helper.c index f83e1e8e2392..33fb0bd3b11a 100644 --- a/arch/um/kernel/helper.c +++ b/arch/um/kernel/helper.c | |||
@@ -85,8 +85,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
85 | data.fd = fds[1]; | 85 | data.fd = fds[1]; |
86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); | 86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); |
87 | if(pid < 0){ | 87 | if(pid < 0){ |
88 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
89 | ret = -errno; | 88 | ret = -errno; |
89 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
90 | goto out_close; | 90 | goto out_close; |
91 | } | 91 | } |
92 | 92 | ||
@@ -122,7 +122,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
122 | unsigned long *stack_out, int stack_order) | 122 | unsigned long *stack_out, int stack_order) |
123 | { | 123 | { |
124 | unsigned long stack, sp; | 124 | unsigned long stack, sp; |
125 | int pid, status; | 125 | int pid, status, err; |
126 | 126 | ||
127 | stack = alloc_stack(stack_order, um_in_interrupt()); | 127 | stack = alloc_stack(stack_order, um_in_interrupt()); |
128 | if(stack == 0) return(-ENOMEM); | 128 | if(stack == 0) return(-ENOMEM); |
@@ -130,16 +130,18 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
130 | sp = stack + (page_size() << stack_order) - sizeof(void *); | 130 | sp = stack + (page_size() << stack_order) - sizeof(void *); |
131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); | 131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
132 | if(pid < 0){ | 132 | if(pid < 0){ |
133 | err = -errno; | ||
133 | printk("run_helper_thread : clone failed, errno = %d\n", | 134 | printk("run_helper_thread : clone failed, errno = %d\n", |
134 | errno); | 135 | errno); |
135 | return(-errno); | 136 | return err; |
136 | } | 137 | } |
137 | if(stack_out == NULL){ | 138 | if(stack_out == NULL){ |
138 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); | 139 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); |
139 | if(pid < 0){ | 140 | if(pid < 0){ |
141 | err = -errno; | ||
140 | printk("run_helper_thread - wait failed, errno = %d\n", | 142 | printk("run_helper_thread - wait failed, errno = %d\n", |
141 | errno); | 143 | errno); |
142 | pid = -errno; | 144 | pid = err; |
143 | } | 145 | } |
144 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) | 146 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) |
145 | printk("run_helper_thread - thread returned status " | 147 | printk("run_helper_thread - thread returned status " |
@@ -156,8 +158,8 @@ int helper_wait(int pid) | |||
156 | 158 | ||
157 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); | 159 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); |
158 | if(ret < 0){ | 160 | if(ret < 0){ |
161 | ret = -errno; | ||
159 | printk("helper_wait : waitpid failed, errno = %d\n", errno); | 162 | printk("helper_wait : waitpid failed, errno = %d\n", errno); |
160 | return(-errno); | ||
161 | } | 163 | } |
162 | return(ret); | 164 | return(ret); |
163 | } | 165 | } |
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c index cd7c85be0a1b..49ed5ddf0704 100644 --- a/arch/um/kernel/init_task.c +++ b/arch/um/kernel/init_task.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "asm/pgtable.h" | 13 | #include "asm/pgtable.h" |
14 | #include "user_util.h" | 14 | #include "user_util.h" |
15 | #include "mem_user.h" | 15 | #include "mem_user.h" |
16 | #include "os.h" | ||
16 | 17 | ||
17 | static struct fs_struct init_fs = INIT_FS; | 18 | static struct fs_struct init_fs = INIT_FS; |
18 | struct mm_struct init_mm = INIT_MM(init_mm); | 19 | struct mm_struct init_mm = INIT_MM(init_mm); |
@@ -45,8 +46,8 @@ __attribute__((__section__(".data.init_task"))) = | |||
45 | 46 | ||
46 | void unprotect_stack(unsigned long stack) | 47 | void unprotect_stack(unsigned long stack) |
47 | { | 48 | { |
48 | protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, | 49 | os_protect_memory((void *) stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, |
49 | 1, 1, 0, 1); | 50 | 1, 1, 0); |
50 | } | 51 | } |
51 | 52 | ||
52 | /* | 53 | /* |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 64fa062cc119..ea008b031a8f 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) | 2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -19,6 +19,10 @@ | |||
19 | #include "mem_user.h" | 19 | #include "mem_user.h" |
20 | #include "uml_uaccess.h" | 20 | #include "uml_uaccess.h" |
21 | #include "os.h" | 21 | #include "os.h" |
22 | #include "linux/types.h" | ||
23 | #include "linux/string.h" | ||
24 | #include "init.h" | ||
25 | #include "kern_constants.h" | ||
22 | 26 | ||
23 | extern char __binary_start; | 27 | extern char __binary_start; |
24 | 28 | ||
@@ -368,6 +372,16 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) | |||
368 | return pte; | 372 | return pte; |
369 | } | 373 | } |
370 | 374 | ||
375 | struct iomem_region *iomem_regions = NULL; | ||
376 | int iomem_size = 0; | ||
377 | |||
378 | extern int parse_iomem(char *str, int *add) __init; | ||
379 | |||
380 | __uml_setup("iomem=", parse_iomem, | ||
381 | "iomem=<name>,<file>\n" | ||
382 | " Configure <file> as an IO memory region named <name>.\n\n" | ||
383 | ); | ||
384 | |||
371 | /* | 385 | /* |
372 | * Overrides for Emacs so that we follow Linus's tabbing style. | 386 | * Overrides for Emacs so that we follow Linus's tabbing style. |
373 | * Emacs will notice this stuff at the end of the file and automatically | 387 | * Emacs will notice this stuff at the end of the file and automatically |
diff --git a/arch/um/kernel/mem_user.c b/arch/um/kernel/mem_user.c deleted file mode 100644 index 4a663fd434bb..000000000000 --- a/arch/um/kernel/mem_user.c +++ /dev/null | |||
@@ -1,273 +0,0 @@ | |||
1 | /* | ||
2 | * arch/um/kernel/mem_user.c | ||
3 | * | ||
4 | * BRIEF MODULE DESCRIPTION | ||
5 | * user side memory routines for supporting IO memory inside user mode linux | ||
6 | * | ||
7 | * Copyright (C) 2001 RidgeRun, Inc. | ||
8 | * Author: RidgeRun, Inc. | ||
9 | * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
19 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
22 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
23 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | */ | ||
31 | |||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <stddef.h> | ||
35 | #include <stdarg.h> | ||
36 | #include <unistd.h> | ||
37 | #include <errno.h> | ||
38 | #include <string.h> | ||
39 | #include <fcntl.h> | ||
40 | #include <sys/types.h> | ||
41 | #include <sys/mman.h> | ||
42 | #include "kern_util.h" | ||
43 | #include "user.h" | ||
44 | #include "user_util.h" | ||
45 | #include "mem_user.h" | ||
46 | #include "init.h" | ||
47 | #include "os.h" | ||
48 | #include "tempfile.h" | ||
49 | #include "kern_constants.h" | ||
50 | |||
51 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | ||
52 | |||
53 | static int create_tmp_file(unsigned long len) | ||
54 | { | ||
55 | int fd, err; | ||
56 | char zero; | ||
57 | |||
58 | fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); | ||
59 | if(fd < 0) { | ||
60 | os_print_error(fd, "make_tempfile"); | ||
61 | exit(1); | ||
62 | } | ||
63 | |||
64 | err = os_mode_fd(fd, 0777); | ||
65 | if(err < 0){ | ||
66 | os_print_error(err, "os_mode_fd"); | ||
67 | exit(1); | ||
68 | } | ||
69 | err = os_seek_file(fd, len); | ||
70 | if(err < 0){ | ||
71 | os_print_error(err, "os_seek_file"); | ||
72 | exit(1); | ||
73 | } | ||
74 | zero = 0; | ||
75 | err = os_write_file(fd, &zero, 1); | ||
76 | if(err != 1){ | ||
77 | os_print_error(err, "os_write_file"); | ||
78 | exit(1); | ||
79 | } | ||
80 | |||
81 | return(fd); | ||
82 | } | ||
83 | |||
84 | void check_tmpexec(void) | ||
85 | { | ||
86 | void *addr; | ||
87 | int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE); | ||
88 | |||
89 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | ||
90 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | ||
91 | printf("Checking PROT_EXEC mmap in /tmp..."); | ||
92 | fflush(stdout); | ||
93 | if(addr == MAP_FAILED){ | ||
94 | err = errno; | ||
95 | perror("failed"); | ||
96 | if(err == EPERM) | ||
97 | printf("/tmp must be not mounted noexec\n"); | ||
98 | exit(1); | ||
99 | } | ||
100 | printf("OK\n"); | ||
101 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
102 | |||
103 | os_close_file(fd); | ||
104 | } | ||
105 | |||
106 | static int have_devanon = 0; | ||
107 | |||
108 | void check_devanon(void) | ||
109 | { | ||
110 | int fd; | ||
111 | |||
112 | printk("Checking for /dev/anon on the host..."); | ||
113 | fd = open("/dev/anon", O_RDWR); | ||
114 | if(fd < 0){ | ||
115 | printk("Not available (open failed with errno %d)\n", errno); | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | printk("OK\n"); | ||
120 | have_devanon = 1; | ||
121 | } | ||
122 | |||
123 | static int create_anon_file(unsigned long len) | ||
124 | { | ||
125 | void *addr; | ||
126 | int fd; | ||
127 | |||
128 | fd = open("/dev/anon", O_RDWR); | ||
129 | if(fd < 0) { | ||
130 | os_print_error(fd, "opening /dev/anon"); | ||
131 | exit(1); | ||
132 | } | ||
133 | |||
134 | addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); | ||
135 | if(addr == MAP_FAILED){ | ||
136 | perror("mapping physmem file"); | ||
137 | exit(1); | ||
138 | } | ||
139 | munmap(addr, len); | ||
140 | |||
141 | return(fd); | ||
142 | } | ||
143 | |||
144 | int create_mem_file(unsigned long len) | ||
145 | { | ||
146 | int err, fd; | ||
147 | |||
148 | if(have_devanon) | ||
149 | fd = create_anon_file(len); | ||
150 | else fd = create_tmp_file(len); | ||
151 | |||
152 | err = os_set_exec_close(fd, 1); | ||
153 | if(err < 0) | ||
154 | os_print_error(err, "exec_close"); | ||
155 | return(fd); | ||
156 | } | ||
157 | |||
158 | struct iomem_region *iomem_regions = NULL; | ||
159 | int iomem_size = 0; | ||
160 | |||
161 | static int __init parse_iomem(char *str, int *add) | ||
162 | { | ||
163 | struct iomem_region *new; | ||
164 | struct uml_stat buf; | ||
165 | char *file, *driver; | ||
166 | int fd, err, size; | ||
167 | |||
168 | driver = str; | ||
169 | file = strchr(str,','); | ||
170 | if(file == NULL){ | ||
171 | printf("parse_iomem : failed to parse iomem\n"); | ||
172 | goto out; | ||
173 | } | ||
174 | *file = '\0'; | ||
175 | file++; | ||
176 | fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0); | ||
177 | if(fd < 0){ | ||
178 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | ||
179 | goto out; | ||
180 | } | ||
181 | |||
182 | err = os_stat_fd(fd, &buf); | ||
183 | if(err < 0){ | ||
184 | os_print_error(err, "parse_iomem - cannot stat_fd file"); | ||
185 | goto out_close; | ||
186 | } | ||
187 | |||
188 | new = malloc(sizeof(*new)); | ||
189 | if(new == NULL){ | ||
190 | perror("Couldn't allocate iomem_region struct"); | ||
191 | goto out_close; | ||
192 | } | ||
193 | |||
194 | size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1); | ||
195 | |||
196 | *new = ((struct iomem_region) { .next = iomem_regions, | ||
197 | .driver = driver, | ||
198 | .fd = fd, | ||
199 | .size = size, | ||
200 | .phys = 0, | ||
201 | .virt = 0 }); | ||
202 | iomem_regions = new; | ||
203 | iomem_size += new->size + UM_KERN_PAGE_SIZE; | ||
204 | |||
205 | return(0); | ||
206 | out_close: | ||
207 | os_close_file(fd); | ||
208 | out: | ||
209 | return(1); | ||
210 | } | ||
211 | |||
212 | __uml_setup("iomem=", parse_iomem, | ||
213 | "iomem=<name>,<file>\n" | ||
214 | " Configure <file> as an IO memory region named <name>.\n\n" | ||
215 | ); | ||
216 | |||
217 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, | ||
218 | int must_succeed) | ||
219 | { | ||
220 | int err; | ||
221 | |||
222 | err = os_protect_memory((void *) addr, len, r, w, x); | ||
223 | if(err < 0){ | ||
224 | if(must_succeed) | ||
225 | panic("protect failed, err = %d", -err); | ||
226 | else return(err); | ||
227 | } | ||
228 | return(0); | ||
229 | } | ||
230 | |||
231 | #if 0 | ||
232 | /* Debugging facility for dumping stuff out to the host, avoiding the timing | ||
233 | * problems that come with printf and breakpoints. | ||
234 | * Enable in case of emergency. | ||
235 | */ | ||
236 | |||
237 | int logging = 1; | ||
238 | int logging_fd = -1; | ||
239 | |||
240 | int logging_line = 0; | ||
241 | char logging_buf[512]; | ||
242 | |||
243 | void log(char *fmt, ...) | ||
244 | { | ||
245 | va_list ap; | ||
246 | struct timeval tv; | ||
247 | struct openflags flags; | ||
248 | |||
249 | if(logging == 0) return; | ||
250 | if(logging_fd < 0){ | ||
251 | flags = of_create(of_trunc(of_rdwr(OPENFLAGS()))); | ||
252 | logging_fd = os_open_file("log", flags, 0644); | ||
253 | } | ||
254 | gettimeofday(&tv, NULL); | ||
255 | sprintf(logging_buf, "%d\t %u.%u ", logging_line++, tv.tv_sec, | ||
256 | tv.tv_usec); | ||
257 | va_start(ap, fmt); | ||
258 | vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap); | ||
259 | va_end(ap); | ||
260 | write(logging_fd, logging_buf, strlen(logging_buf)); | ||
261 | } | ||
262 | #endif | ||
263 | |||
264 | /* | ||
265 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
266 | * Emacs will notice this stuff at the end of the file and automatically | ||
267 | * adjust the settings for this buffer only. This must remain at the end | ||
268 | * of the file. | ||
269 | * --------------------------------------------------------------------------- | ||
270 | * Local variables: | ||
271 | * c-file-style: "linux" | ||
272 | * End: | ||
273 | */ | ||
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index c23d8a08d0ff..39cf568ccfaf 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -113,8 +113,23 @@ void set_current(void *t) | |||
113 | 113 | ||
114 | void *_switch_to(void *prev, void *next, void *last) | 114 | void *_switch_to(void *prev, void *next, void *last) |
115 | { | 115 | { |
116 | return(CHOOSE_MODE(switch_to_tt(prev, next), | 116 | struct task_struct *from = prev; |
117 | switch_to_skas(prev, next))); | 117 | struct task_struct *to= next; |
118 | |||
119 | to->thread.prev_sched = from; | ||
120 | set_current(to); | ||
121 | |||
122 | do { | ||
123 | current->thread.saved_task = NULL ; | ||
124 | CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next); | ||
125 | if(current->thread.saved_task) | ||
126 | show_regs(&(current->thread.regs)); | ||
127 | next= current->thread.saved_task; | ||
128 | prev= current; | ||
129 | } while(current->thread.saved_task); | ||
130 | |||
131 | return(current->thread.prev_sched); | ||
132 | |||
118 | } | 133 | } |
119 | 134 | ||
120 | void interrupt_end(void) | 135 | void interrupt_end(void) |
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h index e48490028111..c97a80dfe370 100644 --- a/arch/um/kernel/skas/include/mode_kern-skas.h +++ b/arch/um/kernel/skas/include/mode_kern-skas.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
12 | 12 | ||
13 | extern void flush_thread_skas(void); | 13 | extern void flush_thread_skas(void); |
14 | extern void *switch_to_skas(void *prev, void *next); | 14 | extern void switch_to_skas(void *prev, void *next); |
15 | extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, | 15 | extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, |
16 | unsigned long esp); | 16 | unsigned long esp); |
17 | extern int copy_thread_skas(int nr, unsigned long clone_flags, | 17 | extern int copy_thread_skas(int nr, unsigned long clone_flags, |
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h index 6ee3f3902e68..7da0c2def0ef 100644 --- a/arch/um/kernel/skas/include/uaccess-skas.h +++ b/arch/um/kernel/skas/include/uaccess-skas.h | |||
@@ -18,12 +18,6 @@ | |||
18 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | 18 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ |
19 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) | 19 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) |
20 | 20 | ||
21 | static inline int verify_area_skas(int type, const void __user * addr, | ||
22 | unsigned long size) | ||
23 | { | ||
24 | return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); | ||
25 | } | ||
26 | |||
27 | extern int copy_from_user_skas(void *to, const void __user *from, int n); | 21 | extern int copy_from_user_skas(void *to, const void __user *from, int n); |
28 | extern int copy_to_user_skas(void __user *to, const void *from, int n); | 22 | extern int copy_to_user_skas(void __user *to, const void *from, int n); |
29 | extern int strncpy_from_user_skas(char *dst, const char __user *src, int count); | 23 | extern int strncpy_from_user_skas(char *dst, const char __user *src, int count); |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index 3d1b227226e6..efe92e8aa2a9 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "proc_mm.h" | 24 | #include "proc_mm.h" |
25 | #include "registers.h" | 25 | #include "registers.h" |
26 | 26 | ||
27 | void *switch_to_skas(void *prev, void *next) | 27 | void switch_to_skas(void *prev, void *next) |
28 | { | 28 | { |
29 | struct task_struct *from, *to; | 29 | struct task_struct *from, *to; |
30 | 30 | ||
@@ -35,16 +35,11 @@ void *switch_to_skas(void *prev, void *next) | |||
35 | if(current->pid == 0) | 35 | if(current->pid == 0) |
36 | switch_timers(0); | 36 | switch_timers(0); |
37 | 37 | ||
38 | to->thread.prev_sched = from; | ||
39 | set_current(to); | ||
40 | |||
41 | switch_threads(&from->thread.mode.skas.switch_buf, | 38 | switch_threads(&from->thread.mode.skas.switch_buf, |
42 | to->thread.mode.skas.switch_buf); | 39 | to->thread.mode.skas.switch_buf); |
43 | 40 | ||
44 | if(current->pid == 0) | 41 | if(current->pid == 0) |
45 | switch_timers(1); | 42 | switch_timers(1); |
46 | |||
47 | return(current->thread.prev_sched); | ||
48 | } | 43 | } |
49 | 44 | ||
50 | extern void schedule_tail(struct task_struct *prev); | 45 | extern void schedule_tail(struct task_struct *prev); |
diff --git a/arch/um/kernel/tempfile.c b/arch/um/kernel/tempfile.c deleted file mode 100644 index b1674bc1395d..000000000000 --- a/arch/um/kernel/tempfile.c +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <unistd.h> | ||
9 | #include <string.h> | ||
10 | #include <errno.h> | ||
11 | #include <sys/param.h> | ||
12 | #include "init.h" | ||
13 | |||
14 | /* Modified from create_mem_file and start_debugger */ | ||
15 | static char *tempdir = NULL; | ||
16 | |||
17 | static void __init find_tempdir(void) | ||
18 | { | ||
19 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | ||
20 | int i; | ||
21 | char *dir = NULL; | ||
22 | |||
23 | if(tempdir != NULL) return; /* We've already been called */ | ||
24 | for(i = 0; dirs[i]; i++){ | ||
25 | dir = getenv(dirs[i]); | ||
26 | if((dir != NULL) && (*dir != '\0')) | ||
27 | break; | ||
28 | } | ||
29 | if((dir == NULL) || (*dir == '\0')) | ||
30 | dir = "/tmp"; | ||
31 | |||
32 | tempdir = malloc(strlen(dir) + 2); | ||
33 | if(tempdir == NULL){ | ||
34 | fprintf(stderr, "Failed to malloc tempdir, " | ||
35 | "errno = %d\n", errno); | ||
36 | return; | ||
37 | } | ||
38 | strcpy(tempdir, dir); | ||
39 | strcat(tempdir, "/"); | ||
40 | } | ||
41 | |||
42 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | ||
43 | { | ||
44 | char tempname[MAXPATHLEN]; | ||
45 | int fd; | ||
46 | |||
47 | find_tempdir(); | ||
48 | if (*template != '/') | ||
49 | strcpy(tempname, tempdir); | ||
50 | else | ||
51 | *tempname = 0; | ||
52 | strcat(tempname, template); | ||
53 | fd = mkstemp(tempname); | ||
54 | if(fd < 0){ | ||
55 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | ||
56 | strerror(errno)); | ||
57 | return -1; | ||
58 | } | ||
59 | if(do_unlink && (unlink(tempname) < 0)){ | ||
60 | perror("unlink"); | ||
61 | return -1; | ||
62 | } | ||
63 | if(out_tempname){ | ||
64 | *out_tempname = strdup(tempname); | ||
65 | if(*out_tempname == NULL){ | ||
66 | perror("strdup"); | ||
67 | return -1; | ||
68 | } | ||
69 | } | ||
70 | return(fd); | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
75 | * Emacs will notice this stuff at the end of the file and automatically | ||
76 | * adjust the settings for this buffer only. This must remain at the end | ||
77 | * of the file. | ||
78 | * --------------------------------------------------------------------------- | ||
79 | * Local variables: | ||
80 | * c-file-style: "linux" | ||
81 | * End: | ||
82 | */ | ||
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index 80ed6188e8a2..0a562c3c0fd8 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c | |||
@@ -307,7 +307,7 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end) | |||
307 | } | 307 | } |
308 | else if(pte_newprot(*pte)){ | 308 | else if(pte_newprot(*pte)){ |
309 | updated = 1; | 309 | updated = 1; |
310 | protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1); | 310 | os_protect_memory((void *) addr, PAGE_SIZE, 1, 1, 1); |
311 | } | 311 | } |
312 | addr += PAGE_SIZE; | 312 | addr += PAGE_SIZE; |
313 | } | 313 | } |
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h index e0ca0e0b2516..2a35b15c5fef 100644 --- a/arch/um/kernel/tt/include/mode_kern-tt.h +++ b/arch/um/kernel/tt/include/mode_kern-tt.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
12 | #include "asm/uaccess.h" | 12 | #include "asm/uaccess.h" |
13 | 13 | ||
14 | extern void *switch_to_tt(void *prev, void *next); | 14 | extern void switch_to_tt(void *prev, void *next); |
15 | extern void flush_thread_tt(void); | 15 | extern void flush_thread_tt(void); |
16 | extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, | 16 | extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, |
17 | unsigned long esp); | 17 | unsigned long esp); |
diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h index aa6db384af80..dc2ebfa8c54f 100644 --- a/arch/um/kernel/tt/include/uaccess-tt.h +++ b/arch/um/kernel/tt/include/uaccess-tt.h | |||
@@ -33,12 +33,6 @@ extern unsigned long uml_physmem; | |||
33 | (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ | 33 | (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ |
34 | (under_task_size(addr, size) || is_stack(addr, size)))) | 34 | (under_task_size(addr, size) || is_stack(addr, size)))) |
35 | 35 | ||
36 | static inline int verify_area_tt(int type, const void __user * addr, | ||
37 | unsigned long size) | ||
38 | { | ||
39 | return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); | ||
40 | } | ||
41 | |||
42 | extern unsigned long get_fault_addr(void); | 36 | extern unsigned long get_fault_addr(void); |
43 | 37 | ||
44 | extern int __do_copy_from_user(void *to, const void *from, int n, | 38 | extern int __do_copy_from_user(void *to, const void *from, int n, |
diff --git a/arch/um/kernel/tt/mem_user.c b/arch/um/kernel/tt/mem_user.c index 3085267459b1..03e589895388 100644 --- a/arch/um/kernel/tt/mem_user.c +++ b/arch/um/kernel/tt/mem_user.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "tt.h" | 12 | #include "tt.h" |
13 | #include "mem_user.h" | 13 | #include "mem_user.h" |
14 | #include "user_util.h" | 14 | #include "user_util.h" |
15 | #include "os.h" | ||
15 | 16 | ||
16 | void remap_data(void *segment_start, void *segment_end, int w) | 17 | void remap_data(void *segment_start, void *segment_end, int w) |
17 | { | 18 | { |
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c index a189a2b92935..cfaa373a6e77 100644 --- a/arch/um/kernel/tt/process_kern.c +++ b/arch/um/kernel/tt/process_kern.c | |||
@@ -23,10 +23,11 @@ | |||
23 | #include "mem_user.h" | 23 | #include "mem_user.h" |
24 | #include "tlb.h" | 24 | #include "tlb.h" |
25 | #include "mode.h" | 25 | #include "mode.h" |
26 | #include "mode_kern.h" | ||
26 | #include "init.h" | 27 | #include "init.h" |
27 | #include "tt.h" | 28 | #include "tt.h" |
28 | 29 | ||
29 | void *switch_to_tt(void *prev, void *next, void *last) | 30 | void switch_to_tt(void *prev, void *next) |
30 | { | 31 | { |
31 | struct task_struct *from, *to, *prev_sched; | 32 | struct task_struct *from, *to, *prev_sched; |
32 | unsigned long flags; | 33 | unsigned long flags; |
@@ -36,8 +37,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
36 | from = prev; | 37 | from = prev; |
37 | to = next; | 38 | to = next; |
38 | 39 | ||
39 | to->thread.prev_sched = from; | ||
40 | |||
41 | cpu = from->thread_info->cpu; | 40 | cpu = from->thread_info->cpu; |
42 | if(cpu == 0) | 41 | if(cpu == 0) |
43 | forward_interrupts(to->thread.mode.tt.extern_pid); | 42 | forward_interrupts(to->thread.mode.tt.extern_pid); |
@@ -53,7 +52,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
53 | forward_pending_sigio(to->thread.mode.tt.extern_pid); | 52 | forward_pending_sigio(to->thread.mode.tt.extern_pid); |
54 | 53 | ||
55 | c = 0; | 54 | c = 0; |
56 | set_current(to); | ||
57 | 55 | ||
58 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); | 56 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); |
59 | if(err != sizeof(c)) | 57 | if(err != sizeof(c)) |
@@ -85,8 +83,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
85 | 83 | ||
86 | flush_tlb_all(); | 84 | flush_tlb_all(); |
87 | local_irq_restore(flags); | 85 | local_irq_restore(flags); |
88 | |||
89 | return(current->thread.prev_sched); | ||
90 | } | 86 | } |
91 | 87 | ||
92 | void release_thread_tt(struct task_struct *task) | 88 | void release_thread_tt(struct task_struct *task) |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 09f6f7ce4695..f0a275947d34 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -361,11 +361,6 @@ int linux_main(int argc, char **argv) | |||
361 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, | 361 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, |
362 | &host_task_size, &task_size); | 362 | &host_task_size, &task_size); |
363 | 363 | ||
364 | /* Need to check this early because mmapping happens before the | ||
365 | * kernel is running. | ||
366 | */ | ||
367 | check_tmpexec(); | ||
368 | |||
369 | brk_start = (unsigned long) sbrk(0); | 364 | brk_start = (unsigned long) sbrk(0); |
370 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); | 365 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); |
371 | /* Increase physical memory size for exec-shield users | 366 | /* Increase physical memory size for exec-shield users |
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c index 954ff67cc8b3..41d17c71511c 100644 --- a/arch/um/kernel/user_util.c +++ b/arch/um/kernel/user_util.c | |||
@@ -109,18 +109,14 @@ int raw(int fd) | |||
109 | int err; | 109 | int err; |
110 | 110 | ||
111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); | 111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); |
112 | if (err < 0) { | 112 | if(err < 0) |
113 | printk("tcgetattr failed, errno = %d\n", errno); | 113 | return -errno; |
114 | return(-errno); | ||
115 | } | ||
116 | 114 | ||
117 | cfmakeraw(&tt); | 115 | cfmakeraw(&tt); |
118 | 116 | ||
119 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); | 117 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); |
120 | if (err < 0) { | 118 | if(err < 0) |
121 | printk("tcsetattr failed, errno = %d\n", errno); | 119 | return -errno; |
122 | return(-errno); | ||
123 | } | ||
124 | 120 | ||
125 | /* XXX tcsetattr could have applied only some changes | 121 | /* XXX tcsetattr could have applied only some changes |
126 | * (and cfmakeraw() is a set of changes) */ | 122 | * (and cfmakeraw() is a set of changes) */ |
@@ -132,6 +128,12 @@ void setup_machinename(char *machine_out) | |||
132 | struct utsname host; | 128 | struct utsname host; |
133 | 129 | ||
134 | uname(&host); | 130 | uname(&host); |
131 | #if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT) | ||
132 | if (!strcmp(host.machine, "x86_64")) { | ||
133 | strcpy(machine_out, "i686"); | ||
134 | return; | ||
135 | } | ||
136 | #endif | ||
135 | strcpy(machine_out, host.machine); | 137 | strcpy(machine_out, host.machine); |
136 | } | 138 | } |
137 | 139 | ||