process.c 1.3 KB
Newer Older
J
Jeff Dike 已提交
1
/*
J
Jeff Dike 已提交
2
 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
J
Jeff Dike 已提交
3 4 5 6
 * Licensed under the GPL
 */

#include "linux/init.h"
J
Jeff Dike 已提交
7
#include "linux/sched.h"
J
Jeff Dike 已提交
8
#include "as-layout.h"
J
Jeff Dike 已提交
9
#include "os.h"
J
Jeff Dike 已提交
10
#include "skas.h"
J
Jeff Dike 已提交
11 12 13 14 15 16

int new_mm(unsigned long stack)
{
	int fd;

	fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
J
Jeff Dike 已提交
17
	if (fd < 0)
18
		return fd;
J
Jeff Dike 已提交
19

J
Jeff Dike 已提交
20
	if (skas_needs_stub)
J
Jeff Dike 已提交
21 22
		map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack);

23
	return fd;
J
Jeff Dike 已提交
24 25 26 27
}

extern void start_kernel(void);

J
Jeff Dike 已提交
28
static int __init start_kernel_proc(void *unused)
J
Jeff Dike 已提交
29 30 31 32 33 34 35 36 37 38 39 40
{
	int pid;

	block_signals();
	pid = os_getpid();

	cpu_tasks[0].pid = pid;
	cpu_tasks[0].task = current;
#ifdef CONFIG_SMP
	cpu_online_map = cpumask_of_cpu(0);
#endif
	start_kernel();
41
	return 0;
J
Jeff Dike 已提交
42 43 44 45
}

extern int userspace_pid[];

J
Jeff Dike 已提交
46 47
extern char cpu0_irqstack[];

48
int __init start_uml(void)
J
Jeff Dike 已提交
49
{
J
Jeff Dike 已提交
50 51
	stack_protections((unsigned long) &cpu0_irqstack);
	set_sigstack(cpu0_irqstack, THREAD_SIZE);
J
Jeff Dike 已提交
52
	if (proc_mm)
J
Jeff Dike 已提交
53 54 55 56 57 58
		userspace_pid[0] = start_userspace(0);

	init_new_thread_signals();

	init_task.thread.request.u.thread.proc = start_kernel_proc;
	init_task.thread.request.u.thread.arg = NULL;
59 60
	return start_idle_thread(task_stack_page(&init_task),
				 &init_task.thread.switch_buf);
J
Jeff Dike 已提交
61 62 63 64
}

unsigned long current_stub_stack(void)
{
J
Jeff Dike 已提交
65
	if (current->mm == NULL)
66
		return 0;
J
Jeff Dike 已提交
67

68
	return current->mm->context.skas.id.stack;
J
Jeff Dike 已提交
69
}