Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 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> |
Mark Rutland | 27d83e6 | 2018-07-11 14:56:42 +0100 | [diff] [blame^] | 28 | |
Suzuki K Poulose | 643d703 | 2016-04-18 10:28:37 +0100 | [diff] [blame] | 29 | #include <asm/cpufeature.h> |
Mark Rutland | 27d83e6 | 2018-07-11 14:56:42 +0100 | [diff] [blame^] | 30 | #include <asm/syscall.h> |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 31 | |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 32 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, |
| 33 | unsigned long prot, unsigned long flags, |
| 34 | unsigned long fd, off_t off) |
| 35 | { |
| 36 | if (offset_in_page(off) != 0) |
| 37 | return -EINVAL; |
| 38 | |
Dominik Brodowski | a90f590 | 2018-03-11 11:34:46 +0100 | [diff] [blame] | 39 | return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Suzuki K Poulose | 643d703 | 2016-04-18 10:28:37 +0100 | [diff] [blame] | 42 | SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) |
| 43 | { |
| 44 | if (personality(personality) == PER_LINUX32 && |
| 45 | !system_supports_32bit_el0()) |
| 46 | return -EINVAL; |
| 47 | return sys_personality(personality); |
| 48 | } |
| 49 | |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 50 | /* |
| 51 | * Wrappers to pass the pt_regs argument. |
| 52 | */ |
Mark Rutland | 3085e16 | 2018-07-11 14:56:41 +0100 | [diff] [blame] | 53 | asmlinkage long sys_rt_sigreturn(void); |
Suzuki K Poulose | 643d703 | 2016-04-18 10:28:37 +0100 | [diff] [blame] | 54 | #define sys_personality sys_arm64_personality |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 55 | |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 56 | #undef __SYSCALL |
Mark Rutland | 27d83e6 | 2018-07-11 14:56:42 +0100 | [diff] [blame^] | 57 | #define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)sym, |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * The sys_call_table array must be 4K aligned to be accessible from |
| 61 | * kernel/entry.S. |
| 62 | */ |
Mark Rutland | 27d83e6 | 2018-07-11 14:56:42 +0100 | [diff] [blame^] | 63 | const syscall_fn_t sys_call_table[__NR_syscalls] __aligned(4096) = { |
| 64 | [0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall, |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 65 | #include <asm/unistd.h> |
| 66 | }; |