exec.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. PT_REGS_IP(regs) = eip;
  37. PT_REGS_SP(regs) = esp;
  38. current->ptrace &= ~PT_DTRACE;
  39. #ifdef SUBARCH_EXECVE1
  40. SUBARCH_EXECVE1(regs->regs);
  41. #endif
  42. }
  43. EXPORT_SYMBOL(start_thread);
  44. long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env)
  45. {
  46. long err;
  47. err = do_execve(file, argv, env, &current->thread.regs);
  48. if (!err)
  49. UML_LONGJMP(current->thread.exec_buf, 1);
  50. return err;
  51. }
  52. long sys_execve(const char __user *file, const char __user *const __user *argv,
  53. const char __user *const __user *env)
  54. {
  55. long error;
  56. char *filename;
  57. filename = getname(file);
  58. error = PTR_ERR(filename);
  59. if (IS_ERR(filename)) goto out;
  60. error = do_execve(filename, argv, env, &current->thread.regs);
  61. putname(filename);
  62. out:
  63. return error;
  64. }