exec.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include <linux/stddef.h>
  6. #include <linux/module.h>
  7. #include <linux/fs.h>
  8. #include <linux/ptrace.h>
  9. #include <linux/sched.h>
  10. #include <linux/slab.h>
  11. #include <asm/current.h>
  12. #include <asm/processor.h>
  13. #include <asm/uaccess.h>
  14. #include <as-layout.h>
  15. #include <mem_user.h>
  16. #include <skas.h>
  17. #include <os.h>
  18. #include "internal.h"
  19. void flush_thread(void)
  20. {
  21. void *data = NULL;
  22. int ret;
  23. arch_flush_thread(&current->thread.arch);
  24. ret = unmap(&current->mm->context.id, 0, STUB_START, 0, &data);
  25. ret = ret || unmap(&current->mm->context.id, STUB_END,
  26. host_task_size - STUB_END, 1, &data);
  27. if (ret) {
  28. printk(KERN_ERR "flush_thread - clearing address space failed, "
  29. "err = %d\n", ret);
  30. force_sig(SIGKILL, current);
  31. }
  32. __switch_mm(&current->mm->context.id);
  33. }
  34. void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
  35. {
  36. get_safe_registers(regs->regs.gp, regs->regs.fp);
  37. PT_REGS_IP(regs) = eip;
  38. PT_REGS_SP(regs) = esp;
  39. current->ptrace &= ~PT_DTRACE;
  40. #ifdef SUBARCH_EXECVE1
  41. SUBARCH_EXECVE1(regs->regs);
  42. #endif
  43. }
  44. EXPORT_SYMBOL(start_thread);
  45. long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env)
  46. {
  47. long err;
  48. err = do_execve(file, argv, env, &current->thread.regs);
  49. if (!err)
  50. UML_LONGJMP(current->thread.exec_buf, 1);
  51. return err;
  52. }
  53. long sys_execve(const char __user *file, const char __user *const __user *argv,
  54. const char __user *const __user *env)
  55. {
  56. long error;
  57. char *filename;
  58. filename = getname(file);
  59. error = PTR_ERR(filename);
  60. if (IS_ERR(filename)) goto out;
  61. error = do_execve(filename, argv, env, &current->thread.regs);
  62. putname(filename);
  63. out:
  64. return error;
  65. }