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 cb7eef8..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"
 
@@ -115,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";
 
@@ -150,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;
 }
@@ -201,8 +201,8 @@ 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))
@@ -216,7 +216,7 @@ 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++;
        }
@@ -241,6 +241,11 @@ static struct notifier_block panic_exit_notifier = {
 };
 
 /* 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);
@@ -253,7 +258,9 @@ 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();
 
@@ -303,7 +317,7 @@ int __init linux_main(int argc, char **argv)
 
        highmem = 0;
        iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
-       max_physmem = CONFIG_TOP_ADDR - 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,
@@ -335,7 +349,9 @@ int __init linux_main(int argc, char **argv)
        }
 
        virtmem_size = physmem_size;
-       avail = CONFIG_TOP_ADDR - 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;