Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / arch / um / kernel / um_arch.c
index 9b5d2cd..8d84250 100644 (file)
@@ -3,23 +3,23 @@
  * Licensed under the GPL
  */
 
-#include "linux/delay.h"
-#include "linux/mm.h"
-#include "linux/module.h"
-#include "linux/seq_file.h"
-#include "linux/string.h"
-#include "linux/utsname.h"
-#include "asm/pgtable.h"
-#include "asm/processor.h"
-#include "asm/setup.h"
-#include "arch.h"
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/seq_file.h>
+#include <linux/string.h>
+#include <linux/utsname.h>
+#include <asm/pgtable.h>
+#include <asm/processor.h>
+#include <asm/setup.h>
 #include "as-layout.h"
+#include "arch.h"
 #include "init.h"
 #include "kern.h"
 #include "kern_util.h"
 #include "mem_user.h"
 #include "os.h"
-#include "skas.h"
 
 #define DEFAULT_COMMAND_LINE "root=98:0"
 
@@ -101,8 +101,6 @@ const struct seq_operations cpuinfo_op = {
 };
 
 /* Set in linux_main */
-unsigned long host_task_size;
-unsigned long task_size;
 unsigned long uml_physmem;
 unsigned long uml_reserved; /* Also modified in mem_init */
 unsigned long start_vm;
@@ -117,7 +115,7 @@ static int have_root __initdata = 0;
 /* Set in uml_mem_setup and modified in linux_main */
 long long physmem_size = 32 * 1024 * 1024;
 
-static char *usage_string =
+static const char *usage_string =
 "User Mode Linux v%s\n"
 "      available at http://user-mode-linux.sourceforge.net/\n\n";
 
@@ -152,7 +150,7 @@ __uml_setup("root=", uml_root_setup,
 static int __init no_skas_debug_setup(char *line, int *add)
 {
        printf("'debug' is not necessary to gdb UML in skas mode - run \n");
-       printf("'gdb linux'");
+       printf("'gdb linux'\n");
 
        return 0;
 }
@@ -198,20 +196,19 @@ __uml_setup("--help", Usage,
 "    Prints this message.\n\n"
 );
 
-static int __init uml_checksetup(char *line, int *add)
+static void __init uml_checksetup(char *line, int *add)
 {
        struct uml_param *p;
 
        p = &__uml_setup_start;
-       while(p < &__uml_setup_end) {
-               int n;
+       while (p < &__uml_setup_end) {
+               size_t n;
 
                n = strlen(p->str);
                if (!strncmp(line, p->str, n) && p->setup_func(line + n, add))
-                       return 1;
+                       return;
                p++;
        }
-       return 0;
 }
 
 static void __init uml_postsetup(void)
@@ -219,14 +216,36 @@ static void __init uml_postsetup(void)
        initcall_t *p;
 
        p = &__uml_postsetup_start;
-       while(p < &__uml_postsetup_end) {
+       while (p < &__uml_postsetup_end) {
                (*p)();
                p++;
        }
        return;
 }
 
+static int panic_exit(struct notifier_block *self, unsigned long unused1,
+                     void *unused2)
+{
+       bust_spinlocks(1);
+       show_regs(&(current->thread.regs));
+       bust_spinlocks(0);
+       uml_exitcode = 1;
+       os_dump_core();
+       return 0;
+}
+
+static struct notifier_block panic_exit_notifier = {
+       .notifier_call          = panic_exit,
+       .next                   = NULL,
+       .priority               = 0
+};
+
 /* Set during early boot */
+unsigned long task_size;
+EXPORT_SYMBOL(task_size);
+
+unsigned long host_task_size;
+
 unsigned long brk_start;
 unsigned long end_iomem;
 EXPORT_SYMBOL(end_iomem);
@@ -235,25 +254,13 @@ EXPORT_SYMBOL(end_iomem);
 
 extern char __binary_start;
 
-static unsigned long set_task_sizes_skas(unsigned long *task_size_out)
-{
-       /* Round up to the nearest 4M */
-       unsigned long host_task_size = ROUND_4M((unsigned long)
-                                               &host_task_size);
-
-       if (!skas_needs_stub)
-               *task_size_out = host_task_size;
-       else
-               *task_size_out = STUB_START & PGDIR_MASK;
-
-       return host_task_size;
-}
-
 int __init linux_main(int argc, char **argv)
 {
        unsigned long avail, diff;
        unsigned long virtmem_size, max_physmem;
-       unsigned int i, add;
+       unsigned long stack;
+       unsigned int i;
+       int add;
        char * mode;
 
        for (i = 1; i < argc; i++) {
@@ -267,6 +274,13 @@ int __init linux_main(int argc, char **argv)
        if (have_root == 0)
                add_arg(DEFAULT_COMMAND_LINE);
 
+       host_task_size = os_get_top_address();
+       /*
+        * TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
+        * out
+        */
+       task_size = host_task_size & PGDIR_MASK;
+
        /* OS sanity checks that need to happen before the kernel runs */
        os_early_checks();
 
@@ -279,8 +293,6 @@ int __init linux_main(int argc, char **argv)
 
        printf("UML running in %s mode\n", mode);
 
-       host_task_size = set_task_sizes_skas(&task_size);
-
        brk_start = (unsigned long) sbrk(0);
 
        /*
@@ -305,7 +317,7 @@ int __init linux_main(int argc, char **argv)
 
        highmem = 0;
        iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
-       max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC;
+       max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
 
        /*
         * Zones have to begin on a 1 << MAX_ORDER page boundary,
@@ -337,7 +349,9 @@ int __init linux_main(int argc, char **argv)
        }
 
        virtmem_size = physmem_size;
-       avail = get_kmem_end() - start_vm;
+       stack = (unsigned long) argv;
+       stack &= ~(1024 * 1024 - 1);
+       avail = stack - start_vm;
        if (physmem_size > avail)
                virtmem_size = avail;
        end_vm = start_vm + virtmem_size;
@@ -346,6 +360,9 @@ int __init linux_main(int argc, char **argv)
                printf("Kernel virtual memory size shrunk to %lu bytes\n",
                       virtmem_size);
 
+       atomic_notifier_chain_register(&panic_notifier_list,
+                                      &panic_exit_notifier);
+
        uml_postsetup();
 
        stack_protections((unsigned long) &init_thread_info);
@@ -354,29 +371,8 @@ int __init linux_main(int argc, char **argv)
        return start_uml();
 }
 
-extern int uml_exitcode;
-
-static int panic_exit(struct notifier_block *self, unsigned long unused1,
-                     void *unused2)
-{
-       bust_spinlocks(1);
-       show_regs(&(current->thread.regs));
-       bust_spinlocks(0);
-       uml_exitcode = 1;
-       os_dump_core();
-       return 0;
-}
-
-static struct notifier_block panic_exit_notifier = {
-       .notifier_call          = panic_exit,
-       .next                   = NULL,
-       .priority               = 0
-};
-
 void __init setup_arch(char **cmdline_p)
 {
-       atomic_notifier_chain_register(&panic_notifier_list,
-                       &panic_exit_notifier);
        paging_init();
        strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
        *cmdline_p = command_line;