diff options
Diffstat (limited to 'arch/um/kernel/um_arch.c')
-rw-r--r-- | arch/um/kernel/um_arch.c | 100 |
1 files changed, 38 insertions, 62 deletions
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index f1c71393f578..468aba990dbd 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -3,22 +3,23 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/delay.h" | 6 | #include <linux/delay.h> |
7 | #include "linux/mm.h" | 7 | #include <linux/init.h> |
8 | #include "linux/module.h" | 8 | #include <linux/mm.h> |
9 | #include "linux/seq_file.h" | 9 | #include <linux/module.h> |
10 | #include "linux/string.h" | 10 | #include <linux/seq_file.h> |
11 | #include "linux/utsname.h" | 11 | #include <linux/string.h> |
12 | #include "asm/pgtable.h" | 12 | #include <linux/utsname.h> |
13 | #include "asm/processor.h" | 13 | #include <asm/pgtable.h> |
14 | #include "asm/setup.h" | 14 | #include <asm/processor.h> |
15 | #include "arch.h" | 15 | #include <asm/setup.h> |
16 | #include "as-layout.h" | 16 | #include "as-layout.h" |
17 | #include "arch.h" | ||
17 | #include "init.h" | 18 | #include "init.h" |
18 | #include "kern.h" | 19 | #include "kern.h" |
20 | #include "kern_util.h" | ||
19 | #include "mem_user.h" | 21 | #include "mem_user.h" |
20 | #include "os.h" | 22 | #include "os.h" |
21 | #include "skas.h" | ||
22 | 23 | ||
23 | #define DEFAULT_COMMAND_LINE "root=98:0" | 24 | #define DEFAULT_COMMAND_LINE "root=98:0" |
24 | 25 | ||
@@ -100,8 +101,6 @@ const struct seq_operations cpuinfo_op = { | |||
100 | }; | 101 | }; |
101 | 102 | ||
102 | /* Set in linux_main */ | 103 | /* Set in linux_main */ |
103 | unsigned long host_task_size; | ||
104 | unsigned long task_size; | ||
105 | unsigned long uml_physmem; | 104 | unsigned long uml_physmem; |
106 | unsigned long uml_reserved; /* Also modified in mem_init */ | 105 | unsigned long uml_reserved; /* Also modified in mem_init */ |
107 | unsigned long start_vm; | 106 | unsigned long start_vm; |
@@ -197,20 +196,19 @@ __uml_setup("--help", Usage, | |||
197 | " Prints this message.\n\n" | 196 | " Prints this message.\n\n" |
198 | ); | 197 | ); |
199 | 198 | ||
200 | static int __init uml_checksetup(char *line, int *add) | 199 | static void __init uml_checksetup(char *line, int *add) |
201 | { | 200 | { |
202 | struct uml_param *p; | 201 | struct uml_param *p; |
203 | 202 | ||
204 | p = &__uml_setup_start; | 203 | p = &__uml_setup_start; |
205 | while(p < &__uml_setup_end) { | 204 | while (p < &__uml_setup_end) { |
206 | int n; | 205 | int n; |
207 | 206 | ||
208 | n = strlen(p->str); | 207 | n = strlen(p->str); |
209 | if (!strncmp(line, p->str, n) && p->setup_func(line + n, add)) | 208 | if (!strncmp(line, p->str, n) && p->setup_func(line + n, add)) |
210 | return 1; | 209 | return; |
211 | p++; | 210 | p++; |
212 | } | 211 | } |
213 | return 0; | ||
214 | } | 212 | } |
215 | 213 | ||
216 | static void __init uml_postsetup(void) | 214 | static void __init uml_postsetup(void) |
@@ -218,13 +216,30 @@ static void __init uml_postsetup(void) | |||
218 | initcall_t *p; | 216 | initcall_t *p; |
219 | 217 | ||
220 | p = &__uml_postsetup_start; | 218 | p = &__uml_postsetup_start; |
221 | while(p < &__uml_postsetup_end) { | 219 | while (p < &__uml_postsetup_end) { |
222 | (*p)(); | 220 | (*p)(); |
223 | p++; | 221 | p++; |
224 | } | 222 | } |
225 | return; | 223 | return; |
226 | } | 224 | } |
227 | 225 | ||
226 | static int panic_exit(struct notifier_block *self, unsigned long unused1, | ||
227 | void *unused2) | ||
228 | { | ||
229 | bust_spinlocks(1); | ||
230 | show_regs(&(current->thread.regs)); | ||
231 | bust_spinlocks(0); | ||
232 | uml_exitcode = 1; | ||
233 | os_dump_core(); | ||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | static struct notifier_block panic_exit_notifier = { | ||
238 | .notifier_call = panic_exit, | ||
239 | .next = NULL, | ||
240 | .priority = 0 | ||
241 | }; | ||
242 | |||
228 | /* Set during early boot */ | 243 | /* Set during early boot */ |
229 | unsigned long brk_start; | 244 | unsigned long brk_start; |
230 | unsigned long end_iomem; | 245 | unsigned long end_iomem; |
@@ -234,20 +249,6 @@ EXPORT_SYMBOL(end_iomem); | |||
234 | 249 | ||
235 | extern char __binary_start; | 250 | extern char __binary_start; |
236 | 251 | ||
237 | static unsigned long set_task_sizes_skas(unsigned long *task_size_out) | ||
238 | { | ||
239 | /* Round up to the nearest 4M */ | ||
240 | unsigned long host_task_size = ROUND_4M((unsigned long) | ||
241 | &host_task_size); | ||
242 | |||
243 | if (!skas_needs_stub) | ||
244 | *task_size_out = host_task_size; | ||
245 | else | ||
246 | *task_size_out = STUB_START & PGDIR_MASK; | ||
247 | |||
248 | return host_task_size; | ||
249 | } | ||
250 | |||
251 | int __init linux_main(int argc, char **argv) | 252 | int __init linux_main(int argc, char **argv) |
252 | { | 253 | { |
253 | unsigned long avail, diff; | 254 | unsigned long avail, diff; |
@@ -278,13 +279,6 @@ int __init linux_main(int argc, char **argv) | |||
278 | 279 | ||
279 | printf("UML running in %s mode\n", mode); | 280 | printf("UML running in %s mode\n", mode); |
280 | 281 | ||
281 | host_task_size = set_task_sizes_skas(&task_size); | ||
282 | |||
283 | /* | ||
284 | * Setting up handlers to 'sig_info' struct | ||
285 | */ | ||
286 | os_fill_handlinfo(handlinfo_kern); | ||
287 | |||
288 | brk_start = (unsigned long) sbrk(0); | 282 | brk_start = (unsigned long) sbrk(0); |
289 | 283 | ||
290 | /* | 284 | /* |
@@ -309,7 +303,7 @@ int __init linux_main(int argc, char **argv) | |||
309 | 303 | ||
310 | highmem = 0; | 304 | highmem = 0; |
311 | iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; | 305 | iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; |
312 | max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC; | 306 | max_physmem = CONFIG_TOP_ADDR - uml_physmem - iomem_size - MIN_VMALLOC; |
313 | 307 | ||
314 | /* | 308 | /* |
315 | * Zones have to begin on a 1 << MAX_ORDER page boundary, | 309 | * Zones have to begin on a 1 << MAX_ORDER page boundary, |
@@ -341,7 +335,7 @@ int __init linux_main(int argc, char **argv) | |||
341 | } | 335 | } |
342 | 336 | ||
343 | virtmem_size = physmem_size; | 337 | virtmem_size = physmem_size; |
344 | avail = get_kmem_end() - start_vm; | 338 | avail = CONFIG_TOP_ADDR - start_vm; |
345 | if (physmem_size > avail) | 339 | if (physmem_size > avail) |
346 | virtmem_size = avail; | 340 | virtmem_size = avail; |
347 | end_vm = start_vm + virtmem_size; | 341 | end_vm = start_vm + virtmem_size; |
@@ -350,6 +344,9 @@ int __init linux_main(int argc, char **argv) | |||
350 | printf("Kernel virtual memory size shrunk to %lu bytes\n", | 344 | printf("Kernel virtual memory size shrunk to %lu bytes\n", |
351 | virtmem_size); | 345 | virtmem_size); |
352 | 346 | ||
347 | atomic_notifier_chain_register(&panic_notifier_list, | ||
348 | &panic_exit_notifier); | ||
349 | |||
353 | uml_postsetup(); | 350 | uml_postsetup(); |
354 | 351 | ||
355 | stack_protections((unsigned long) &init_thread_info); | 352 | stack_protections((unsigned long) &init_thread_info); |
@@ -358,29 +355,8 @@ int __init linux_main(int argc, char **argv) | |||
358 | return start_uml(); | 355 | return start_uml(); |
359 | } | 356 | } |
360 | 357 | ||
361 | extern int uml_exitcode; | ||
362 | |||
363 | static int panic_exit(struct notifier_block *self, unsigned long unused1, | ||
364 | void *unused2) | ||
365 | { | ||
366 | bust_spinlocks(1); | ||
367 | show_regs(&(current->thread.regs)); | ||
368 | bust_spinlocks(0); | ||
369 | uml_exitcode = 1; | ||
370 | os_dump_core(); | ||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | static struct notifier_block panic_exit_notifier = { | ||
375 | .notifier_call = panic_exit, | ||
376 | .next = NULL, | ||
377 | .priority = 0 | ||
378 | }; | ||
379 | |||
380 | void __init setup_arch(char **cmdline_p) | 358 | void __init setup_arch(char **cmdline_p) |
381 | { | 359 | { |
382 | atomic_notifier_chain_register(&panic_notifier_list, | ||
383 | &panic_exit_notifier); | ||
384 | paging_init(); | 360 | paging_init(); |
385 | strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); | 361 | strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); |
386 | *cmdline_p = command_line; | 362 | *cmdline_p = command_line; |