exec_kern.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/kernel.h"
  6. #include "linux/mm.h"
  7. #include "asm/signal.h"
  8. #include "asm/ptrace.h"
  9. #include "asm/uaccess.h"
  10. #include "asm/pgalloc.h"
  11. #include "asm/tlbflush.h"
  12. #include "user_util.h"
  13. #include "kern_util.h"
  14. #include "irq_user.h"
  15. #include "mem_user.h"
  16. #include "os.h"
  17. #include "tlb.h"
  18. #include "mode.h"
  19. static int exec_tramp(void *sig_stack)
  20. {
  21. init_new_thread_stack(sig_stack, NULL);
  22. init_new_thread_signals();
  23. os_stop_process(os_getpid());
  24. return(0);
  25. }
  26. void flush_thread_tt(void)
  27. {
  28. unsigned long stack;
  29. int new_pid;
  30. stack = alloc_stack(0, 0);
  31. if(stack == 0){
  32. printk(KERN_ERR
  33. "flush_thread : failed to allocate temporary stack\n");
  34. do_exit(SIGKILL);
  35. }
  36. new_pid = start_fork_tramp(task_stack_page(current), stack, 0, exec_tramp);
  37. if(new_pid < 0){
  38. printk(KERN_ERR
  39. "flush_thread : new thread failed, errno = %d\n",
  40. -new_pid);
  41. do_exit(SIGKILL);
  42. }
  43. if(current_thread->cpu == 0)
  44. forward_interrupts(new_pid);
  45. current->thread.request.op = OP_EXEC;
  46. current->thread.request.u.exec.pid = new_pid;
  47. unprotect_stack((unsigned long) current_thread);
  48. os_usr1_process(os_getpid());
  49. change_sig(SIGUSR1, 1);
  50. change_sig(SIGUSR1, 0);
  51. enable_timer();
  52. free_page(stack);
  53. protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
  54. task_protections((unsigned long) current_thread);
  55. force_flush_all();
  56. unblock_signals();
  57. }
  58. void start_thread_tt(struct pt_regs *regs, unsigned long eip,
  59. unsigned long esp)
  60. {
  61. set_fs(USER_DS);
  62. flush_tlb_mm(current->mm);
  63. PT_REGS_IP(regs) = eip;
  64. PT_REGS_SP(regs) = esp;
  65. PT_FIX_EXEC_STACK(esp);
  66. }
  67. /*
  68. * Overrides for Emacs so that we follow Linus's tabbing style.
  69. * Emacs will notice this stuff at the end of the file and automatically
  70. * adjust the settings for this buffer only. This must remain at the end
  71. * of the file.
  72. * ---------------------------------------------------------------------------
  73. * Local variables:
  74. * c-file-style: "linux"
  75. * End:
  76. */