exec_kern.c 2.0 KB

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