xref: /linux/arch/um/kernel/skas/process.c (revision beb6c8326eb4e7006c4aa16b0fee3e303d42e685)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4  */
5 
6 #include <linux/init.h>
7 #include <linux/sched/mm.h>
8 #include <linux/sched/task_stack.h>
9 #include <linux/sched/task.h>
10 
11 #include <asm/tlbflush.h>
12 
13 #include <as-layout.h>
14 #include <kern.h>
15 #include <os.h>
16 #include <skas.h>
17 #include <kern_util.h>
18 
19 extern void start_kernel(void);
20 
start_kernel_proc(void * unused)21 static int __init start_kernel_proc(void *unused)
22 {
23 	block_signals_trace();
24 
25 	start_kernel();
26 	return 0;
27 }
28 
29 static char cpu0_irqstack[THREAD_SIZE] __aligned(THREAD_SIZE);
30 
start_uml(void)31 int __init start_uml(void)
32 {
33 	stack_protections((unsigned long) &cpu0_irqstack);
34 	set_sigstack(cpu0_irqstack, THREAD_SIZE);
35 
36 	init_new_thread_signals();
37 
38 	init_task.thread.request.thread.proc = start_kernel_proc;
39 	init_task.thread.request.thread.arg = NULL;
40 	return start_idle_thread(task_stack_page(&init_task),
41 				 &init_task.thread.switch_buf);
42 }
43 
current_stub_stack(void)44 unsigned long current_stub_stack(void)
45 {
46 	if (current->mm == NULL)
47 		return 0;
48 
49 	return current->mm->context.id.stack;
50 }
51 
current_mm_id(void)52 struct mm_id *current_mm_id(void)
53 {
54 	if (current->mm == NULL)
55 		return NULL;
56 
57 	return &current->mm->context.id;
58 }
59 
current_mm_sync(void)60 void current_mm_sync(void)
61 {
62 	if (current->mm == NULL)
63 		return;
64 
65 	um_tlb_sync(current->mm);
66 }
67