process.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/init.h"
  6. #include "linux/sched.h"
  7. #include "as-layout.h"
  8. #include "os.h"
  9. #include "skas.h"
  10. int new_mm(unsigned long stack)
  11. {
  12. int fd;
  13. fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
  14. if (fd < 0)
  15. return fd;
  16. if (skas_needs_stub)
  17. map_stub_pages(fd, STUB_CODE, STUB_DATA, stack);
  18. return fd;
  19. }
  20. extern void start_kernel(void);
  21. static int __init start_kernel_proc(void *unused)
  22. {
  23. int pid;
  24. block_signals();
  25. pid = os_getpid();
  26. cpu_tasks[0].pid = pid;
  27. cpu_tasks[0].task = current;
  28. #ifdef CONFIG_SMP
  29. cpu_online_map = cpumask_of_cpu(0);
  30. #endif
  31. start_kernel();
  32. return 0;
  33. }
  34. extern int userspace_pid[];
  35. extern char cpu0_irqstack[];
  36. int __init start_uml(void)
  37. {
  38. stack_protections((unsigned long) &cpu0_irqstack);
  39. set_sigstack(cpu0_irqstack, THREAD_SIZE);
  40. if (proc_mm)
  41. userspace_pid[0] = start_userspace(0);
  42. init_new_thread_signals();
  43. init_task.thread.request.u.thread.proc = start_kernel_proc;
  44. init_task.thread.request.u.thread.arg = NULL;
  45. return start_idle_thread(task_stack_page(&init_task),
  46. &init_task.thread.switch_buf);
  47. }
  48. unsigned long current_stub_stack(void)
  49. {
  50. if (current->mm == NULL)
  51. return 0;
  52. return current->mm->context.id.stack;
  53. }