]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
init: add arch_call_rest_init to allow stack switching
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 31 Aug 2018 08:42:24 +0000 (10:42 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 9 Oct 2018 09:20:55 +0000 (11:20 +0200)
With CONFIG_VMAP_STACK=y the kernel stack of all tasks should be
allocated in the vmalloc space. The initial stack used for all
the early init code is in the init_thread_union. To be able to
switch from this early stack to a properly allocated stack
from vmalloc the architecture needs a switch-over point.

Introduce the arch_call_rest_init() function with a weak definition
in init/main.c with the only purpose to call rest_init() from the
end of start_kernel(). The architecture override can then do the
necessary magic to switch to the new vmalloc'ed stack.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
include/linux/start_kernel.h
init/main.c

index 4b268d86a784c6012a3148b14379cf27c9e4056e..8b369a41c03c0afe678d1469fa52d8c6aa0e79e8 100644 (file)
@@ -9,5 +9,7 @@
    up something else. */
 
 extern asmlinkage void __init start_kernel(void);
+extern void __init arch_call_rest_init(void);
+extern void __ref rest_init(void);
 
 #endif /* _LINUX_START_KERNEL_H */
index 18f8f0140fa0351691b45f1152e64ee1b10e3f24..78b714a5fa94b50a6e48f080d51f61a94f48a3e2 100644 (file)
@@ -394,7 +394,7 @@ static void __init setup_command_line(char *command_line)
 
 static __initdata DECLARE_COMPLETION(kthreadd_done);
 
-static noinline void __ref rest_init(void)
+noinline void __ref rest_init(void)
 {
        struct task_struct *tsk;
        int pid;
@@ -528,6 +528,11 @@ static void __init mm_init(void)
        pti_init();
 }
 
+void __init __weak arch_call_rest_init(void)
+{
+       rest_init();
+}
+
 asmlinkage __visible void __init start_kernel(void)
 {
        char *command_line;
@@ -736,7 +741,7 @@ asmlinkage __visible void __init start_kernel(void)
        }
 
        /* Do the rest non-__init'ed, we're now alive */
-       rest_init();
+       arch_call_rest_init();
 }
 
 /* Call all constructor functions linked into the kernel. */