syscalls_64.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Copyright 2003 PathScale, Inc.
  4. *
  5. * Licensed under the GPL
  6. */
  7. #include <linux/sched.h>
  8. #include <linux/sched/mm.h>
  9. #include <linux/syscalls.h>
  10. #include <linux/uaccess.h>
  11. #include <asm/prctl.h> /* XXX This should get the constants from libc */
  12. #include <registers.h>
  13. #include <os.h>
  14. long arch_prctl(struct task_struct *task, int option,
  15. unsigned long __user *arg2)
  16. {
  17. long ret = -EINVAL;
  18. switch (option) {
  19. case ARCH_SET_FS:
  20. current->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)] =
  21. (unsigned long) arg2;
  22. ret = 0;
  23. break;
  24. case ARCH_SET_GS:
  25. current->thread.regs.regs.gp[GS_BASE / sizeof(unsigned long)] =
  26. (unsigned long) arg2;
  27. ret = 0;
  28. break;
  29. case ARCH_GET_FS:
  30. ret = put_user(current->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)], arg2);
  31. break;
  32. case ARCH_GET_GS:
  33. ret = put_user(current->thread.regs.regs.gp[GS_BASE / sizeof(unsigned long)], arg2);
  34. break;
  35. }
  36. return ret;
  37. }
  38. SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
  39. {
  40. return arch_prctl(current, option, (unsigned long __user *) arg2);
  41. }
  42. void arch_switch_to(struct task_struct *to)
  43. {
  44. /*
  45. * Nothing needs to be done on x86_64.
  46. * The FS_BASE/GS_BASE registers are saved in the ptrace register set.
  47. */
  48. }
  49. SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
  50. unsigned long, prot, unsigned long, flags,
  51. unsigned long, fd, unsigned long, off)
  52. {
  53. if (off & ~PAGE_MASK)
  54. return -EINVAL;
  55. return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
  56. }