exec_kern.c 2.0 KB

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