xref: /linux/arch/arm64/kernel/sys.c (revision 7a6cf9328c1b64db67f887f5f0dede9b76114214)
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 
20 #include <linux/compiler.h>
21 #include <linux/errno.h>
22 #include <linux/fs.h>
23 #include <linux/mm.h>
24 #include <linux/export.h>
25 #include <linux/sched.h>
26 #include <linux/slab.h>
27 #include <linux/syscalls.h>
28 
29 /*
30  * Clone a task - this clones the calling program thread.
31  */
32 asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
33 			  int __user *parent_tidptr, unsigned long tls_val,
34 			  int __user *child_tidptr)
35 {
36 	return do_fork(clone_flags, newsp, current_pt_regs(), 0,
37 			parent_tidptr, child_tidptr);
38 }
39 
40 asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
41 			 unsigned long prot, unsigned long flags,
42 			 unsigned long fd, off_t off)
43 {
44 	if (offset_in_page(off) != 0)
45 		return -EINVAL;
46 
47 	return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
48 }
49 
50 /*
51  * Wrappers to pass the pt_regs argument.
52  */
53 #define sys_rt_sigreturn	sys_rt_sigreturn_wrapper
54 #define sys_sigaltstack		sys_sigaltstack_wrapper
55 
56 #include <asm/syscalls.h>
57 
58 #undef __SYSCALL
59 #define __SYSCALL(nr, sym)	[nr] = sym,
60 
61 /*
62  * The sys_call_table array must be 4K aligned to be accessible from
63  * kernel/entry.S.
64  */
65 void *sys_call_table[__NR_syscalls] __aligned(4096) = {
66 	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
67 #include <asm/unistd.h>
68 };
69