Skip to content

Commit 53c99bd

Browse files
author
Martin Schwidefsky
committed
init: add arch_call_rest_init to allow stack switching
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 <[email protected]>
1 parent 00e9e66 commit 53c99bd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/linux/start_kernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
up something else. */
1010

1111
extern asmlinkage void __init start_kernel(void);
12+
extern void __init arch_call_rest_init(void);
13+
extern void __ref rest_init(void);
1214

1315
#endif /* _LINUX_START_KERNEL_H */

init/main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ static void __init setup_command_line(char *command_line)
394394

395395
static __initdata DECLARE_COMPLETION(kthreadd_done);
396396

397-
static noinline void __ref rest_init(void)
397+
noinline void __ref rest_init(void)
398398
{
399399
struct task_struct *tsk;
400400
int pid;
@@ -528,6 +528,11 @@ static void __init mm_init(void)
528528
pti_init();
529529
}
530530

531+
void __init __weak arch_call_rest_init(void)
532+
{
533+
rest_init();
534+
}
535+
531536
asmlinkage __visible void __init start_kernel(void)
532537
{
533538
char *command_line;
@@ -736,7 +741,7 @@ asmlinkage __visible void __init start_kernel(void)
736741
}
737742

738743
/* Do the rest non-__init'ed, we're now alive */
739-
rest_init();
744+
arch_call_rest_init();
740745
}
741746

742747
/* Call all constructor functions linked into the kernel. */

0 commit comments

Comments
 (0)