Thomas Gleixner | caab277 | 2019-06-03 07:44:50 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 2 | /* |
| 3 | * AArch64-specific system calls implementation |
| 4 | * |
| 5 | * Copyright (C) 2012 ARM Ltd. |
| 6 | * Author: Catalin Marinas <catalin.marinas@arm.com> |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/compiler.h> |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/fs.h> |
| 12 | #include <linux/mm.h> |
| 13 | #include <linux/export.h> |
| 14 | #include <linux/sched.h> |
| 15 | #include <linux/slab.h> |
| 16 | #include <linux/syscalls.h> |
Mark Rutland | 27d83e6 | 2018-07-11 14:56:42 +0100 | [diff] [blame] | 17 | |
Suzuki K Poulose | 643d703 | 2016-04-18 10:28:37 +0100 | [diff] [blame] | 18 | #include <asm/cpufeature.h> |
Mark Rutland | 27d83e6 | 2018-07-11 14:56:42 +0100 | [diff] [blame] | 19 | #include <asm/syscall.h> |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 20 | |
Mark Rutland | d3516c9 | 2018-07-11 14:56:54 +0100 | [diff] [blame] | 21 | SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, |
| 22 | unsigned long, prot, unsigned long, flags, |
Boyang Zhou | f08cae2 | 2019-04-29 15:27:19 +0100 | [diff] [blame] | 23 | unsigned long, fd, unsigned long, off) |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 24 | { |
| 25 | if (offset_in_page(off) != 0) |
| 26 | return -EINVAL; |
| 27 | |
Dominik Brodowski | a90f590 | 2018-03-11 11:34:46 +0100 | [diff] [blame] | 28 | return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 29 | } |
| 30 | |
Suzuki K Poulose | 643d703 | 2016-04-18 10:28:37 +0100 | [diff] [blame] | 31 | SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) |
| 32 | { |
| 33 | if (personality(personality) == PER_LINUX32 && |
| 34 | !system_supports_32bit_el0()) |
| 35 | return -EINVAL; |
Mark Rutland | 3f7decc | 2018-07-11 14:56:52 +0100 | [diff] [blame] | 36 | return ksys_personality(personality); |
Suzuki K Poulose | 643d703 | 2016-04-18 10:28:37 +0100 | [diff] [blame] | 37 | } |
| 38 | |
Sami Tolvanen | 1e29ab3 | 2019-05-24 15:11:18 -0700 | [diff] [blame] | 39 | asmlinkage long sys_ni_syscall(void); |
| 40 | |
| 41 | asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused) |
| 42 | { |
| 43 | return sys_ni_syscall(); |
| 44 | } |
| 45 | |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 46 | /* |
| 47 | * Wrappers to pass the pt_regs argument. |
| 48 | */ |
Catalin Marinas | 0037727 | 2019-05-28 12:39:34 +0100 | [diff] [blame] | 49 | #define __arm64_sys_personality __arm64_sys_arm64_personality |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 50 | |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 51 | #undef __SYSCALL |
Mark Rutland | 4378a7d | 2018-07-11 14:56:56 +0100 | [diff] [blame] | 52 | #define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *); |
| 53 | #include <asm/unistd.h> |
| 54 | |
| 55 | #undef __SYSCALL |
Sami Tolvanen | 1e29ab3 | 2019-05-24 15:11:18 -0700 | [diff] [blame] | 56 | #define __SYSCALL(nr, sym) [nr] = __arm64_##sym, |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 57 | |
Mark Rutland | 80d63bc | 2018-07-11 14:56:49 +0100 | [diff] [blame] | 58 | const syscall_fn_t sys_call_table[__NR_syscalls] = { |
Sami Tolvanen | 1e29ab3 | 2019-05-24 15:11:18 -0700 | [diff] [blame] | 59 | [0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall, |
Catalin Marinas | 7992d60 | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 60 | #include <asm/unistd.h> |
| 61 | }; |