exec_kern.c 2.1 KB

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