sys.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * AArch64-specific system calls implementation
  3. *
  4. * Copyright (C) 2012 ARM Ltd.
  5. * Author: Catalin Marinas <catalin.marinas@arm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/compiler.h>
  20. #include <linux/errno.h>
  21. #include <linux/fs.h>
  22. #include <linux/mm.h>
  23. #include <linux/export.h>
  24. #include <linux/sched.h>
  25. #include <linux/slab.h>
  26. #include <linux/syscalls.h>
  27. /*
  28. * Clone a task - this clones the calling program thread.
  29. */
  30. asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
  31. int __user *parent_tidptr, unsigned long tls_val,
  32. int __user *child_tidptr, struct pt_regs *regs)
  33. {
  34. if (!newsp)
  35. newsp = regs->sp;
  36. /* 16-byte aligned stack mandatory on AArch64 */
  37. if (newsp & 15)
  38. return -EINVAL;
  39. return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);
  40. }
  41. /*
  42. * sys_execve() executes a new program.
  43. */
  44. asmlinkage long sys_execve(const char __user *filenamei,
  45. const char __user *const __user *argv,
  46. const char __user *const __user *envp,
  47. struct pt_regs *regs)
  48. {
  49. long error;
  50. struct filename *filename;
  51. filename = getname(filenamei);
  52. error = PTR_ERR(filename);
  53. if (IS_ERR(filename))
  54. goto out;
  55. error = do_execve(filename->name, argv, envp, regs);
  56. putname(filename);
  57. out:
  58. return error;
  59. }
  60. asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
  61. unsigned long prot, unsigned long flags,
  62. unsigned long fd, off_t off)
  63. {
  64. if (offset_in_page(off) != 0)
  65. return -EINVAL;
  66. return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
  67. }
  68. /*
  69. * Wrappers to pass the pt_regs argument.
  70. */
  71. #define sys_execve sys_execve_wrapper
  72. #define sys_clone sys_clone_wrapper
  73. #define sys_rt_sigreturn sys_rt_sigreturn_wrapper
  74. #define sys_sigaltstack sys_sigaltstack_wrapper
  75. #include <asm/syscalls.h>
  76. #undef __SYSCALL
  77. #define __SYSCALL(nr, sym) [nr] = sym,
  78. /*
  79. * The sys_call_table array must be 4K aligned to be accessible from
  80. * kernel/entry.S.
  81. */
  82. void *sys_call_table[__NR_syscalls] __aligned(4096) = {
  83. [0 ... __NR_syscalls - 1] = sys_ni_syscall,
  84. #include <asm/unistd.h>
  85. };