Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: 32-bit (compat) applications support

This patch adds support for 32-bit applications. The vectors page is a
binary blob mapped into the application user space at 0xffff0000 (the
AArch64 toolchain does not support compilation of AArch32 code). Full
compatibility with ARMv7 user space is supported. The use of deprecated
ARMv7 functionality (SWP, CP15 barriers) has been disabled by default on
AArch64 kernels and unaligned LDM/STM is not supported.

Please note that only the ARM 32-bit EABI is supported, so no OABI
compatibility.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

authored by

Will Deacon and committed by
Catalin Marinas
3dd681d9 0aea86a2

+2452
+242
arch/arm64/include/asm/compat.h
··· 1 + /* 2 + * Copyright (C) 2012 ARM Ltd. 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + * 13 + * You should have received a copy of the GNU General Public License 14 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 + */ 16 + #ifndef __ASM_COMPAT_H 17 + #define __ASM_COMPAT_H 18 + #ifdef __KERNEL__ 19 + #ifdef CONFIG_COMPAT 20 + 21 + /* 22 + * Architecture specific compatibility types 23 + */ 24 + #include <linux/types.h> 25 + #include <linux/sched.h> 26 + 27 + #define COMPAT_USER_HZ 100 28 + #define COMPAT_UTS_MACHINE "armv8l\0\0" 29 + 30 + typedef u32 compat_size_t; 31 + typedef s32 compat_ssize_t; 32 + typedef s32 compat_time_t; 33 + typedef s32 compat_clock_t; 34 + typedef s32 compat_pid_t; 35 + typedef u32 __compat_uid_t; 36 + typedef u32 __compat_gid_t; 37 + typedef u32 __compat_uid32_t; 38 + typedef u32 __compat_gid32_t; 39 + typedef u32 compat_mode_t; 40 + typedef u32 compat_ino_t; 41 + typedef u32 compat_dev_t; 42 + typedef s32 compat_off_t; 43 + typedef s64 compat_loff_t; 44 + typedef s16 compat_nlink_t; 45 + typedef u16 compat_ipc_pid_t; 46 + typedef s32 compat_daddr_t; 47 + typedef u32 compat_caddr_t; 48 + typedef __kernel_fsid_t compat_fsid_t; 49 + typedef s32 compat_key_t; 50 + typedef s32 compat_timer_t; 51 + 52 + typedef s32 compat_int_t; 53 + typedef s32 compat_long_t; 54 + typedef s64 compat_s64; 55 + typedef u32 compat_uint_t; 56 + typedef u32 compat_ulong_t; 57 + typedef u64 compat_u64; 58 + 59 + struct compat_timespec { 60 + compat_time_t tv_sec; 61 + s32 tv_nsec; 62 + }; 63 + 64 + struct compat_timeval { 65 + compat_time_t tv_sec; 66 + s32 tv_usec; 67 + }; 68 + 69 + struct compat_stat { 70 + compat_dev_t st_dev; 71 + compat_ino_t st_ino; 72 + compat_mode_t st_mode; 73 + compat_nlink_t st_nlink; 74 + __compat_uid32_t st_uid; 75 + __compat_gid32_t st_gid; 76 + compat_dev_t st_rdev; 77 + compat_off_t st_size; 78 + compat_off_t st_blksize; 79 + compat_off_t st_blocks; 80 + compat_time_t st_atime; 81 + u32 st_atime_nsec; 82 + compat_time_t st_mtime; 83 + u32 st_mtime_nsec; 84 + compat_time_t st_ctime; 85 + u32 st_ctime_nsec; 86 + u32 __unused4[2]; 87 + }; 88 + 89 + struct compat_flock { 90 + short l_type; 91 + short l_whence; 92 + compat_off_t l_start; 93 + compat_off_t l_len; 94 + compat_pid_t l_pid; 95 + }; 96 + 97 + #define F_GETLK64 12 /* using 'struct flock64' */ 98 + #define F_SETLK64 13 99 + #define F_SETLKW64 14 100 + 101 + struct compat_flock64 { 102 + short l_type; 103 + short l_whence; 104 + compat_loff_t l_start; 105 + compat_loff_t l_len; 106 + compat_pid_t l_pid; 107 + }; 108 + 109 + struct compat_statfs { 110 + int f_type; 111 + int f_bsize; 112 + int f_blocks; 113 + int f_bfree; 114 + int f_bavail; 115 + int f_files; 116 + int f_ffree; 117 + compat_fsid_t f_fsid; 118 + int f_namelen; /* SunOS ignores this field. */ 119 + int f_frsize; 120 + int f_flags; 121 + int f_spare[4]; 122 + }; 123 + 124 + #define COMPAT_RLIM_INFINITY 0xffffffff 125 + 126 + typedef u32 compat_old_sigset_t; 127 + 128 + #define _COMPAT_NSIG 64 129 + #define _COMPAT_NSIG_BPW 32 130 + 131 + typedef u32 compat_sigset_word; 132 + 133 + #define COMPAT_OFF_T_MAX 0x7fffffff 134 + #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL 135 + 136 + /* 137 + * A pointer passed in from user mode. This should not 138 + * be used for syscall parameters, just declare them 139 + * as pointers because the syscall entry code will have 140 + * appropriately converted them already. 141 + */ 142 + typedef u32 compat_uptr_t; 143 + 144 + static inline void __user *compat_ptr(compat_uptr_t uptr) 145 + { 146 + return (void __user *)(unsigned long)uptr; 147 + } 148 + 149 + static inline compat_uptr_t ptr_to_compat(void __user *uptr) 150 + { 151 + return (u32)(unsigned long)uptr; 152 + } 153 + 154 + static inline void __user *arch_compat_alloc_user_space(long len) 155 + { 156 + struct pt_regs *regs = task_pt_regs(current); 157 + return (void __user *)regs->compat_sp - len; 158 + } 159 + 160 + struct compat_ipc64_perm { 161 + compat_key_t key; 162 + __compat_uid32_t uid; 163 + __compat_gid32_t gid; 164 + __compat_uid32_t cuid; 165 + __compat_gid32_t cgid; 166 + unsigned short mode; 167 + unsigned short __pad1; 168 + unsigned short seq; 169 + unsigned short __pad2; 170 + compat_ulong_t unused1; 171 + compat_ulong_t unused2; 172 + }; 173 + 174 + struct compat_semid64_ds { 175 + struct compat_ipc64_perm sem_perm; 176 + compat_time_t sem_otime; 177 + compat_ulong_t __unused1; 178 + compat_time_t sem_ctime; 179 + compat_ulong_t __unused2; 180 + compat_ulong_t sem_nsems; 181 + compat_ulong_t __unused3; 182 + compat_ulong_t __unused4; 183 + }; 184 + 185 + struct compat_msqid64_ds { 186 + struct compat_ipc64_perm msg_perm; 187 + compat_time_t msg_stime; 188 + compat_ulong_t __unused1; 189 + compat_time_t msg_rtime; 190 + compat_ulong_t __unused2; 191 + compat_time_t msg_ctime; 192 + compat_ulong_t __unused3; 193 + compat_ulong_t msg_cbytes; 194 + compat_ulong_t msg_qnum; 195 + compat_ulong_t msg_qbytes; 196 + compat_pid_t msg_lspid; 197 + compat_pid_t msg_lrpid; 198 + compat_ulong_t __unused4; 199 + compat_ulong_t __unused5; 200 + }; 201 + 202 + struct compat_shmid64_ds { 203 + struct compat_ipc64_perm shm_perm; 204 + compat_size_t shm_segsz; 205 + compat_time_t shm_atime; 206 + compat_ulong_t __unused1; 207 + compat_time_t shm_dtime; 208 + compat_ulong_t __unused2; 209 + compat_time_t shm_ctime; 210 + compat_ulong_t __unused3; 211 + compat_pid_t shm_cpid; 212 + compat_pid_t shm_lpid; 213 + compat_ulong_t shm_nattch; 214 + compat_ulong_t __unused4; 215 + compat_ulong_t __unused5; 216 + }; 217 + 218 + static inline int is_compat_task(void) 219 + { 220 + return test_thread_flag(TIF_32BIT); 221 + } 222 + 223 + static inline int is_compat_thread(struct thread_info *thread) 224 + { 225 + return test_ti_thread_flag(thread, TIF_32BIT); 226 + } 227 + 228 + #else /* !CONFIG_COMPAT */ 229 + 230 + static inline int is_compat_task(void) 231 + { 232 + return 0; 233 + } 234 + 235 + static inline int is_compat_thread(struct thread_info *thread) 236 + { 237 + return 0; 238 + } 239 + 240 + #endif /* CONFIG_COMPAT */ 241 + #endif /* __KERNEL__ */ 242 + #endif /* __ASM_COMPAT_H */
+53
arch/arm64/include/asm/signal32.h
··· 1 + /* 2 + * Copyright (C) 2012 ARM Ltd. 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + * 13 + * You should have received a copy of the GNU General Public License 14 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 + */ 16 + #ifndef __ASM_SIGNAL32_H 17 + #define __ASM_SIGNAL32_H 18 + 19 + #ifdef __KERNEL__ 20 + #ifdef CONFIG_COMPAT 21 + #include <linux/compat.h> 22 + 23 + #define AARCH32_KERN_SIGRET_CODE_OFFSET 0x500 24 + 25 + extern const compat_ulong_t aarch32_sigret_code[6]; 26 + 27 + int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, 28 + struct pt_regs *regs); 29 + int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, 30 + sigset_t *set, struct pt_regs *regs); 31 + 32 + void compat_setup_restart_syscall(struct pt_regs *regs); 33 + #else 34 + 35 + static inline int compat_setup_frame(int usid, struct k_sigaction *ka, 36 + sigset_t *set, struct pt_regs *regs) 37 + { 38 + return -ENOSYS; 39 + } 40 + 41 + static inline int compat_setup_rt_frame(int usig, struct k_sigaction *ka, 42 + siginfo_t *info, sigset_t *set, 43 + struct pt_regs *regs) 44 + { 45 + return -ENOSYS; 46 + } 47 + 48 + static inline void compat_setup_restart_syscall(struct pt_regs *regs) 49 + { 50 + } 51 + #endif /* CONFIG_COMPAT */ 52 + #endif /* __KERNEL__ */ 53 + #endif /* __ASM_SIGNAL32_H */
+758
arch/arm64/include/asm/unistd32.h
··· 1 + /* 2 + * Based on arch/arm/include/asm/unistd.h 3 + * 4 + * Copyright (C) 2001-2005 Russell King 5 + * Copyright (C) 2012 ARM Ltd. 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 + #if !defined(__ASM_UNISTD32_H) || defined(__SYSCALL) 20 + #define __ASM_UNISTD32_H 21 + 22 + #ifndef __SYSCALL 23 + #define __SYSCALL(x, y) 24 + #endif 25 + 26 + /* 27 + * This file contains the system call numbers. 28 + */ 29 + 30 + #ifdef __SYSCALL_COMPAT 31 + 32 + #define __NR_restart_syscall 0 33 + __SYSCALL(__NR_restart_syscall, sys_restart_syscall) 34 + #define __NR_exit 1 35 + __SYSCALL(__NR_exit, sys_exit) 36 + #define __NR_fork 2 37 + __SYSCALL(__NR_fork, sys_fork) 38 + #define __NR_read 3 39 + __SYSCALL(__NR_read, sys_read) 40 + #define __NR_write 4 41 + __SYSCALL(__NR_write, sys_write) 42 + #define __NR_open 5 43 + __SYSCALL(__NR_open, sys_open) 44 + #define __NR_close 6 45 + __SYSCALL(__NR_close, sys_close) 46 + __SYSCALL(7, sys_ni_syscall) /* 7 was sys_waitpid */ 47 + #define __NR_creat 8 48 + __SYSCALL(__NR_creat, sys_creat) 49 + #define __NR_link 9 50 + __SYSCALL(__NR_link, sys_link) 51 + #define __NR_unlink 10 52 + __SYSCALL(__NR_unlink, sys_unlink) 53 + #define __NR_execve 11 54 + __SYSCALL(__NR_execve, sys_execve) 55 + #define __NR_chdir 12 56 + __SYSCALL(__NR_chdir, sys_chdir) 57 + __SYSCALL(13, sys_ni_syscall) /* 13 was sys_time */ 58 + #define __NR_mknod 14 59 + __SYSCALL(__NR_mknod, sys_mknod) 60 + #define __NR_chmod 15 61 + __SYSCALL(__NR_chmod, sys_chmod) 62 + #define __NR_lchown 16 63 + __SYSCALL(__NR_lchown, sys_lchown16) 64 + __SYSCALL(17, sys_ni_syscall) /* 17 was sys_break */ 65 + __SYSCALL(18, sys_ni_syscall) /* 18 was sys_stat */ 66 + #define __NR_lseek 19 67 + __SYSCALL(__NR_lseek, sys_lseek) 68 + #define __NR_getpid 20 69 + __SYSCALL(__NR_getpid, sys_getpid) 70 + #define __NR_mount 21 71 + __SYSCALL(__NR_mount, sys_mount) 72 + __SYSCALL(22, sys_ni_syscall) /* 22 was sys_umount */ 73 + #define __NR_setuid 23 74 + __SYSCALL(__NR_setuid, sys_setuid16) 75 + #define __NR_getuid 24 76 + __SYSCALL(__NR_getuid, sys_getuid16) 77 + __SYSCALL(25, sys_ni_syscall) /* 25 was sys_stime */ 78 + #define __NR_ptrace 26 79 + __SYSCALL(__NR_ptrace, sys_ptrace) 80 + __SYSCALL(27, sys_ni_syscall) /* 27 was sys_alarm */ 81 + __SYSCALL(28, sys_ni_syscall) /* 28 was sys_fstat */ 82 + #define __NR_pause 29 83 + __SYSCALL(__NR_pause, sys_pause) 84 + __SYSCALL(30, sys_ni_syscall) /* 30 was sys_utime */ 85 + __SYSCALL(31, sys_ni_syscall) /* 31 was sys_stty */ 86 + __SYSCALL(32, sys_ni_syscall) /* 32 was sys_gtty */ 87 + #define __NR_access 33 88 + __SYSCALL(__NR_access, sys_access) 89 + #define __NR_nice 34 90 + __SYSCALL(__NR_nice, sys_nice) 91 + __SYSCALL(35, sys_ni_syscall) /* 35 was sys_ftime */ 92 + #define __NR_sync 36 93 + __SYSCALL(__NR_sync, sys_sync) 94 + #define __NR_kill 37 95 + __SYSCALL(__NR_kill, sys_kill) 96 + #define __NR_rename 38 97 + __SYSCALL(__NR_rename, sys_rename) 98 + #define __NR_mkdir 39 99 + __SYSCALL(__NR_mkdir, sys_mkdir) 100 + #define __NR_rmdir 40 101 + __SYSCALL(__NR_rmdir, sys_rmdir) 102 + #define __NR_dup 41 103 + __SYSCALL(__NR_dup, sys_dup) 104 + #define __NR_pipe 42 105 + __SYSCALL(__NR_pipe, sys_pipe) 106 + #define __NR_times 43 107 + __SYSCALL(__NR_times, sys_times) 108 + __SYSCALL(44, sys_ni_syscall) /* 44 was sys_prof */ 109 + #define __NR_brk 45 110 + __SYSCALL(__NR_brk, sys_brk) 111 + #define __NR_setgid 46 112 + __SYSCALL(__NR_setgid, sys_setgid16) 113 + #define __NR_getgid 47 114 + __SYSCALL(__NR_getgid, sys_getgid16) 115 + __SYSCALL(48, sys_ni_syscall) /* 48 was sys_signal */ 116 + #define __NR_geteuid 49 117 + __SYSCALL(__NR_geteuid, sys_geteuid16) 118 + #define __NR_getegid 50 119 + __SYSCALL(__NR_getegid, sys_getegid16) 120 + #define __NR_acct 51 121 + __SYSCALL(__NR_acct, sys_acct) 122 + #define __NR_umount2 52 123 + __SYSCALL(__NR_umount2, sys_umount) 124 + __SYSCALL(53, sys_ni_syscall) /* 53 was sys_lock */ 125 + #define __NR_ioctl 54 126 + __SYSCALL(__NR_ioctl, sys_ioctl) 127 + #define __NR_fcntl 55 128 + __SYSCALL(__NR_fcntl, sys_fcntl) 129 + __SYSCALL(56, sys_ni_syscall) /* 56 was sys_mpx */ 130 + #define __NR_setpgid 57 131 + __SYSCALL(__NR_setpgid, sys_setpgid) 132 + __SYSCALL(58, sys_ni_syscall) /* 58 was sys_ulimit */ 133 + __SYSCALL(59, sys_ni_syscall) /* 59 was sys_olduname */ 134 + #define __NR_umask 60 135 + __SYSCALL(__NR_umask, sys_umask) 136 + #define __NR_chroot 61 137 + __SYSCALL(__NR_chroot, sys_chroot) 138 + #define __NR_ustat 62 139 + __SYSCALL(__NR_ustat, sys_ustat) 140 + #define __NR_dup2 63 141 + __SYSCALL(__NR_dup2, sys_dup2) 142 + #define __NR_getppid 64 143 + __SYSCALL(__NR_getppid, sys_getppid) 144 + #define __NR_getpgrp 65 145 + __SYSCALL(__NR_getpgrp, sys_getpgrp) 146 + #define __NR_setsid 66 147 + __SYSCALL(__NR_setsid, sys_setsid) 148 + #define __NR_sigaction 67 149 + __SYSCALL(__NR_sigaction, sys_sigaction) 150 + __SYSCALL(68, sys_ni_syscall) /* 68 was sys_sgetmask */ 151 + __SYSCALL(69, sys_ni_syscall) /* 69 was sys_ssetmask */ 152 + #define __NR_setreuid 70 153 + __SYSCALL(__NR_setreuid, sys_setreuid16) 154 + #define __NR_setregid 71 155 + __SYSCALL(__NR_setregid, sys_setregid16) 156 + #define __NR_sigsuspend 72 157 + __SYSCALL(__NR_sigsuspend, sys_sigsuspend) 158 + #define __NR_sigpending 73 159 + __SYSCALL(__NR_sigpending, sys_sigpending) 160 + #define __NR_sethostname 74 161 + __SYSCALL(__NR_sethostname, sys_sethostname) 162 + #define __NR_setrlimit 75 163 + __SYSCALL(__NR_setrlimit, sys_setrlimit) 164 + __SYSCALL(76, sys_ni_syscall) /* 76 was sys_getrlimit */ 165 + #define __NR_getrusage 77 166 + __SYSCALL(__NR_getrusage, sys_getrusage) 167 + #define __NR_gettimeofday 78 168 + __SYSCALL(__NR_gettimeofday, sys_gettimeofday) 169 + #define __NR_settimeofday 79 170 + __SYSCALL(__NR_settimeofday, sys_settimeofday) 171 + #define __NR_getgroups 80 172 + __SYSCALL(__NR_getgroups, sys_getgroups16) 173 + #define __NR_setgroups 81 174 + __SYSCALL(__NR_setgroups, sys_setgroups16) 175 + __SYSCALL(82, sys_ni_syscall) /* 82 was sys_select */ 176 + #define __NR_symlink 83 177 + __SYSCALL(__NR_symlink, sys_symlink) 178 + __SYSCALL(84, sys_ni_syscall) /* 84 was sys_lstat */ 179 + #define __NR_readlink 85 180 + __SYSCALL(__NR_readlink, sys_readlink) 181 + #define __NR_uselib 86 182 + __SYSCALL(__NR_uselib, sys_uselib) 183 + #define __NR_swapon 87 184 + __SYSCALL(__NR_swapon, sys_swapon) 185 + #define __NR_reboot 88 186 + __SYSCALL(__NR_reboot, sys_reboot) 187 + __SYSCALL(89, sys_ni_syscall) /* 89 was sys_readdir */ 188 + __SYSCALL(90, sys_ni_syscall) /* 90 was sys_mmap */ 189 + #define __NR_munmap 91 190 + __SYSCALL(__NR_munmap, sys_munmap) 191 + #define __NR_truncate 92 192 + __SYSCALL(__NR_truncate, sys_truncate) 193 + #define __NR_ftruncate 93 194 + __SYSCALL(__NR_ftruncate, sys_ftruncate) 195 + #define __NR_fchmod 94 196 + __SYSCALL(__NR_fchmod, sys_fchmod) 197 + #define __NR_fchown 95 198 + __SYSCALL(__NR_fchown, sys_fchown16) 199 + #define __NR_getpriority 96 200 + __SYSCALL(__NR_getpriority, sys_getpriority) 201 + #define __NR_setpriority 97 202 + __SYSCALL(__NR_setpriority, sys_setpriority) 203 + __SYSCALL(98, sys_ni_syscall) /* 98 was sys_profil */ 204 + #define __NR_statfs 99 205 + __SYSCALL(__NR_statfs, sys_statfs) 206 + #define __NR_fstatfs 100 207 + __SYSCALL(__NR_fstatfs, sys_fstatfs) 208 + __SYSCALL(101, sys_ni_syscall) /* 101 was sys_ioperm */ 209 + __SYSCALL(102, sys_ni_syscall) /* 102 was sys_socketcall */ 210 + #define __NR_syslog 103 211 + __SYSCALL(__NR_syslog, sys_syslog) 212 + #define __NR_setitimer 104 213 + __SYSCALL(__NR_setitimer, sys_setitimer) 214 + #define __NR_getitimer 105 215 + __SYSCALL(__NR_getitimer, sys_getitimer) 216 + #define __NR_stat 106 217 + __SYSCALL(__NR_stat, sys_newstat) 218 + #define __NR_lstat 107 219 + __SYSCALL(__NR_lstat, sys_newlstat) 220 + #define __NR_fstat 108 221 + __SYSCALL(__NR_fstat, sys_newfstat) 222 + __SYSCALL(109, sys_ni_syscall) /* 109 was sys_uname */ 223 + __SYSCALL(110, sys_ni_syscall) /* 110 was sys_iopl */ 224 + #define __NR_vhangup 111 225 + __SYSCALL(__NR_vhangup, sys_vhangup) 226 + __SYSCALL(112, sys_ni_syscall) /* 112 was sys_idle */ 227 + __SYSCALL(113, sys_ni_syscall) /* 113 was sys_syscall */ 228 + #define __NR_wait4 114 229 + __SYSCALL(__NR_wait4, sys_wait4) 230 + #define __NR_swapoff 115 231 + __SYSCALL(__NR_swapoff, sys_swapoff) 232 + #define __NR_sysinfo 116 233 + __SYSCALL(__NR_sysinfo, sys_sysinfo) 234 + __SYSCALL(117, sys_ni_syscall) /* 117 was sys_ipc */ 235 + #define __NR_fsync 118 236 + __SYSCALL(__NR_fsync, sys_fsync) 237 + #define __NR_sigreturn 119 238 + __SYSCALL(__NR_sigreturn, sys_sigreturn) 239 + #define __NR_clone 120 240 + __SYSCALL(__NR_clone, sys_clone) 241 + #define __NR_setdomainname 121 242 + __SYSCALL(__NR_setdomainname, sys_setdomainname) 243 + #define __NR_uname 122 244 + __SYSCALL(__NR_uname, sys_newuname) 245 + __SYSCALL(123, sys_ni_syscall) /* 123 was sys_modify_ldt */ 246 + #define __NR_adjtimex 124 247 + __SYSCALL(__NR_adjtimex, sys_adjtimex) 248 + #define __NR_mprotect 125 249 + __SYSCALL(__NR_mprotect, sys_mprotect) 250 + #define __NR_sigprocmask 126 251 + __SYSCALL(__NR_sigprocmask, sys_sigprocmask) 252 + __SYSCALL(127, sys_ni_syscall) /* 127 was sys_create_module */ 253 + #define __NR_init_module 128 254 + __SYSCALL(__NR_init_module, sys_init_module) 255 + #define __NR_delete_module 129 256 + __SYSCALL(__NR_delete_module, sys_delete_module) 257 + __SYSCALL(130, sys_ni_syscall) /* 130 was sys_get_kernel_syms */ 258 + #define __NR_quotactl 131 259 + __SYSCALL(__NR_quotactl, sys_quotactl) 260 + #define __NR_getpgid 132 261 + __SYSCALL(__NR_getpgid, sys_getpgid) 262 + #define __NR_fchdir 133 263 + __SYSCALL(__NR_fchdir, sys_fchdir) 264 + #define __NR_bdflush 134 265 + __SYSCALL(__NR_bdflush, sys_bdflush) 266 + #define __NR_sysfs 135 267 + __SYSCALL(__NR_sysfs, sys_sysfs) 268 + #define __NR_personality 136 269 + __SYSCALL(__NR_personality, sys_personality) 270 + __SYSCALL(137, sys_ni_syscall) /* 137 was sys_afs_syscall */ 271 + #define __NR_setfsuid 138 272 + __SYSCALL(__NR_setfsuid, sys_setfsuid16) 273 + #define __NR_setfsgid 139 274 + __SYSCALL(__NR_setfsgid, sys_setfsgid16) 275 + #define __NR__llseek 140 276 + __SYSCALL(__NR__llseek, sys_llseek) 277 + #define __NR_getdents 141 278 + __SYSCALL(__NR_getdents, sys_getdents) 279 + #define __NR__newselect 142 280 + __SYSCALL(__NR__newselect, sys_select) 281 + #define __NR_flock 143 282 + __SYSCALL(__NR_flock, sys_flock) 283 + #define __NR_msync 144 284 + __SYSCALL(__NR_msync, sys_msync) 285 + #define __NR_readv 145 286 + __SYSCALL(__NR_readv, sys_readv) 287 + #define __NR_writev 146 288 + __SYSCALL(__NR_writev, sys_writev) 289 + #define __NR_getsid 147 290 + __SYSCALL(__NR_getsid, sys_getsid) 291 + #define __NR_fdatasync 148 292 + __SYSCALL(__NR_fdatasync, sys_fdatasync) 293 + #define __NR__sysctl 149 294 + __SYSCALL(__NR__sysctl, sys_sysctl) 295 + #define __NR_mlock 150 296 + __SYSCALL(__NR_mlock, sys_mlock) 297 + #define __NR_munlock 151 298 + __SYSCALL(__NR_munlock, sys_munlock) 299 + #define __NR_mlockall 152 300 + __SYSCALL(__NR_mlockall, sys_mlockall) 301 + #define __NR_munlockall 153 302 + __SYSCALL(__NR_munlockall, sys_munlockall) 303 + #define __NR_sched_setparam 154 304 + __SYSCALL(__NR_sched_setparam, sys_sched_setparam) 305 + #define __NR_sched_getparam 155 306 + __SYSCALL(__NR_sched_getparam, sys_sched_getparam) 307 + #define __NR_sched_setscheduler 156 308 + __SYSCALL(__NR_sched_setscheduler, sys_sched_setscheduler) 309 + #define __NR_sched_getscheduler 157 310 + __SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler) 311 + #define __NR_sched_yield 158 312 + __SYSCALL(__NR_sched_yield, sys_sched_yield) 313 + #define __NR_sched_get_priority_max 159 314 + __SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max) 315 + #define __NR_sched_get_priority_min 160 316 + __SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min) 317 + #define __NR_sched_rr_get_interval 161 318 + __SYSCALL(__NR_sched_rr_get_interval, sys_sched_rr_get_interval) 319 + #define __NR_nanosleep 162 320 + __SYSCALL(__NR_nanosleep, sys_nanosleep) 321 + #define __NR_mremap 163 322 + __SYSCALL(__NR_mremap, sys_mremap) 323 + #define __NR_setresuid 164 324 + __SYSCALL(__NR_setresuid, sys_setresuid16) 325 + #define __NR_getresuid 165 326 + __SYSCALL(__NR_getresuid, sys_getresuid16) 327 + __SYSCALL(166, sys_ni_syscall) /* 166 was sys_vm86 */ 328 + __SYSCALL(167, sys_ni_syscall) /* 167 was sys_query_module */ 329 + #define __NR_poll 168 330 + __SYSCALL(__NR_poll, sys_poll) 331 + #define __NR_nfsservctl 169 332 + __SYSCALL(__NR_nfsservctl, sys_ni_syscall) 333 + #define __NR_setresgid 170 334 + __SYSCALL(__NR_setresgid, sys_setresgid16) 335 + #define __NR_getresgid 171 336 + __SYSCALL(__NR_getresgid, sys_getresgid16) 337 + #define __NR_prctl 172 338 + __SYSCALL(__NR_prctl, sys_prctl) 339 + #define __NR_rt_sigreturn 173 340 + __SYSCALL(__NR_rt_sigreturn, sys_rt_sigreturn) 341 + #define __NR_rt_sigaction 174 342 + __SYSCALL(__NR_rt_sigaction, sys_rt_sigaction) 343 + #define __NR_rt_sigprocmask 175 344 + __SYSCALL(__NR_rt_sigprocmask, sys_rt_sigprocmask) 345 + #define __NR_rt_sigpending 176 346 + __SYSCALL(__NR_rt_sigpending, sys_rt_sigpending) 347 + #define __NR_rt_sigtimedwait 177 348 + __SYSCALL(__NR_rt_sigtimedwait, sys_rt_sigtimedwait) 349 + #define __NR_rt_sigqueueinfo 178 350 + __SYSCALL(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo) 351 + #define __NR_rt_sigsuspend 179 352 + __SYSCALL(__NR_rt_sigsuspend, sys_rt_sigsuspend) 353 + #define __NR_pread64 180 354 + __SYSCALL(__NR_pread64, sys_pread64) 355 + #define __NR_pwrite64 181 356 + __SYSCALL(__NR_pwrite64, sys_pwrite64) 357 + #define __NR_chown 182 358 + __SYSCALL(__NR_chown, sys_chown16) 359 + #define __NR_getcwd 183 360 + __SYSCALL(__NR_getcwd, sys_getcwd) 361 + #define __NR_capget 184 362 + __SYSCALL(__NR_capget, sys_capget) 363 + #define __NR_capset 185 364 + __SYSCALL(__NR_capset, sys_capset) 365 + #define __NR_sigaltstack 186 366 + __SYSCALL(__NR_sigaltstack, sys_sigaltstack) 367 + #define __NR_sendfile 187 368 + __SYSCALL(__NR_sendfile, sys_sendfile) 369 + __SYSCALL(188, sys_ni_syscall) /* 188 reserved */ 370 + __SYSCALL(189, sys_ni_syscall) /* 189 reserved */ 371 + #define __NR_vfork 190 372 + __SYSCALL(__NR_vfork, sys_vfork) 373 + #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ 374 + __SYSCALL(__NR_ugetrlimit, sys_getrlimit) 375 + #define __NR_mmap2 192 376 + __SYSCALL(__NR_mmap2, sys_mmap2) 377 + #define __NR_truncate64 193 378 + __SYSCALL(__NR_truncate64, sys_truncate64) 379 + #define __NR_ftruncate64 194 380 + __SYSCALL(__NR_ftruncate64, sys_ftruncate64) 381 + #define __NR_stat64 195 382 + __SYSCALL(__NR_stat64, sys_stat64) 383 + #define __NR_lstat64 196 384 + __SYSCALL(__NR_lstat64, sys_lstat64) 385 + #define __NR_fstat64 197 386 + __SYSCALL(__NR_fstat64, sys_fstat64) 387 + #define __NR_lchown32 198 388 + __SYSCALL(__NR_lchown32, sys_lchown) 389 + #define __NR_getuid32 199 390 + __SYSCALL(__NR_getuid32, sys_getuid) 391 + #define __NR_getgid32 200 392 + __SYSCALL(__NR_getgid32, sys_getgid) 393 + #define __NR_geteuid32 201 394 + __SYSCALL(__NR_geteuid32, sys_geteuid) 395 + #define __NR_getegid32 202 396 + __SYSCALL(__NR_getegid32, sys_getegid) 397 + #define __NR_setreuid32 203 398 + __SYSCALL(__NR_setreuid32, sys_setreuid) 399 + #define __NR_setregid32 204 400 + __SYSCALL(__NR_setregid32, sys_setregid) 401 + #define __NR_getgroups32 205 402 + __SYSCALL(__NR_getgroups32, sys_getgroups) 403 + #define __NR_setgroups32 206 404 + __SYSCALL(__NR_setgroups32, sys_setgroups) 405 + #define __NR_fchown32 207 406 + __SYSCALL(__NR_fchown32, sys_fchown) 407 + #define __NR_setresuid32 208 408 + __SYSCALL(__NR_setresuid32, sys_setresuid) 409 + #define __NR_getresuid32 209 410 + __SYSCALL(__NR_getresuid32, sys_getresuid) 411 + #define __NR_setresgid32 210 412 + __SYSCALL(__NR_setresgid32, sys_setresgid) 413 + #define __NR_getresgid32 211 414 + __SYSCALL(__NR_getresgid32, sys_getresgid) 415 + #define __NR_chown32 212 416 + __SYSCALL(__NR_chown32, sys_chown) 417 + #define __NR_setuid32 213 418 + __SYSCALL(__NR_setuid32, sys_setuid) 419 + #define __NR_setgid32 214 420 + __SYSCALL(__NR_setgid32, sys_setgid) 421 + #define __NR_setfsuid32 215 422 + __SYSCALL(__NR_setfsuid32, sys_setfsuid) 423 + #define __NR_setfsgid32 216 424 + __SYSCALL(__NR_setfsgid32, sys_setfsgid) 425 + #define __NR_getdents64 217 426 + __SYSCALL(__NR_getdents64, sys_getdents64) 427 + #define __NR_pivot_root 218 428 + __SYSCALL(__NR_pivot_root, sys_pivot_root) 429 + #define __NR_mincore 219 430 + __SYSCALL(__NR_mincore, sys_mincore) 431 + #define __NR_madvise 220 432 + __SYSCALL(__NR_madvise, sys_madvise) 433 + #define __NR_fcntl64 221 434 + __SYSCALL(__NR_fcntl64, sys_fcntl64) 435 + __SYSCALL(222, sys_ni_syscall) /* 222 for tux */ 436 + __SYSCALL(223, sys_ni_syscall) /* 223 is unused */ 437 + #define __NR_gettid 224 438 + __SYSCALL(__NR_gettid, sys_gettid) 439 + #define __NR_readahead 225 440 + __SYSCALL(__NR_readahead, sys_readahead) 441 + #define __NR_setxattr 226 442 + __SYSCALL(__NR_setxattr, sys_setxattr) 443 + #define __NR_lsetxattr 227 444 + __SYSCALL(__NR_lsetxattr, sys_lsetxattr) 445 + #define __NR_fsetxattr 228 446 + __SYSCALL(__NR_fsetxattr, sys_fsetxattr) 447 + #define __NR_getxattr 229 448 + __SYSCALL(__NR_getxattr, sys_getxattr) 449 + #define __NR_lgetxattr 230 450 + __SYSCALL(__NR_lgetxattr, sys_lgetxattr) 451 + #define __NR_fgetxattr 231 452 + __SYSCALL(__NR_fgetxattr, sys_fgetxattr) 453 + #define __NR_listxattr 232 454 + __SYSCALL(__NR_listxattr, sys_listxattr) 455 + #define __NR_llistxattr 233 456 + __SYSCALL(__NR_llistxattr, sys_llistxattr) 457 + #define __NR_flistxattr 234 458 + __SYSCALL(__NR_flistxattr, sys_flistxattr) 459 + #define __NR_removexattr 235 460 + __SYSCALL(__NR_removexattr, sys_removexattr) 461 + #define __NR_lremovexattr 236 462 + __SYSCALL(__NR_lremovexattr, sys_lremovexattr) 463 + #define __NR_fremovexattr 237 464 + __SYSCALL(__NR_fremovexattr, sys_fremovexattr) 465 + #define __NR_tkill 238 466 + __SYSCALL(__NR_tkill, sys_tkill) 467 + #define __NR_sendfile64 239 468 + __SYSCALL(__NR_sendfile64, sys_sendfile64) 469 + #define __NR_futex 240 470 + __SYSCALL(__NR_futex, sys_futex) 471 + #define __NR_sched_setaffinity 241 472 + __SYSCALL(__NR_sched_setaffinity, sys_sched_setaffinity) 473 + #define __NR_sched_getaffinity 242 474 + __SYSCALL(__NR_sched_getaffinity, sys_sched_getaffinity) 475 + #define __NR_io_setup 243 476 + __SYSCALL(__NR_io_setup, sys_io_setup) 477 + #define __NR_io_destroy 244 478 + __SYSCALL(__NR_io_destroy, sys_io_destroy) 479 + #define __NR_io_getevents 245 480 + __SYSCALL(__NR_io_getevents, sys_io_getevents) 481 + #define __NR_io_submit 246 482 + __SYSCALL(__NR_io_submit, sys_io_submit) 483 + #define __NR_io_cancel 247 484 + __SYSCALL(__NR_io_cancel, sys_io_cancel) 485 + #define __NR_exit_group 248 486 + __SYSCALL(__NR_exit_group, sys_exit_group) 487 + #define __NR_lookup_dcookie 249 488 + __SYSCALL(__NR_lookup_dcookie, sys_lookup_dcookie) 489 + #define __NR_epoll_create 250 490 + __SYSCALL(__NR_epoll_create, sys_epoll_create) 491 + #define __NR_epoll_ctl 251 492 + __SYSCALL(__NR_epoll_ctl, sys_epoll_ctl) 493 + #define __NR_epoll_wait 252 494 + __SYSCALL(__NR_epoll_wait, sys_epoll_wait) 495 + #define __NR_remap_file_pages 253 496 + __SYSCALL(__NR_remap_file_pages, sys_remap_file_pages) 497 + __SYSCALL(254, sys_ni_syscall) /* 254 for set_thread_area */ 498 + __SYSCALL(255, sys_ni_syscall) /* 255 for get_thread_area */ 499 + #define __NR_set_tid_address 256 500 + __SYSCALL(__NR_set_tid_address, sys_set_tid_address) 501 + #define __NR_timer_create 257 502 + __SYSCALL(__NR_timer_create, sys_timer_create) 503 + #define __NR_timer_settime 258 504 + __SYSCALL(__NR_timer_settime, sys_timer_settime) 505 + #define __NR_timer_gettime 259 506 + __SYSCALL(__NR_timer_gettime, sys_timer_gettime) 507 + #define __NR_timer_getoverrun 260 508 + __SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun) 509 + #define __NR_timer_delete 261 510 + __SYSCALL(__NR_timer_delete, sys_timer_delete) 511 + #define __NR_clock_settime 262 512 + __SYSCALL(__NR_clock_settime, sys_clock_settime) 513 + #define __NR_clock_gettime 263 514 + __SYSCALL(__NR_clock_gettime, sys_clock_gettime) 515 + #define __NR_clock_getres 264 516 + __SYSCALL(__NR_clock_getres, sys_clock_getres) 517 + #define __NR_clock_nanosleep 265 518 + __SYSCALL(__NR_clock_nanosleep, sys_clock_nanosleep) 519 + #define __NR_statfs64 266 520 + __SYSCALL(__NR_statfs64, sys_statfs64) 521 + #define __NR_fstatfs64 267 522 + __SYSCALL(__NR_fstatfs64, sys_fstatfs64) 523 + #define __NR_tgkill 268 524 + __SYSCALL(__NR_tgkill, sys_tgkill) 525 + #define __NR_utimes 269 526 + __SYSCALL(__NR_utimes, sys_utimes) 527 + #define __NR_fadvise64 270 528 + __SYSCALL(__NR_fadvise64, sys_fadvise64_64) 529 + #define __NR_pciconfig_iobase 271 530 + __SYSCALL(__NR_pciconfig_iobase, sys_pciconfig_iobase) 531 + #define __NR_pciconfig_read 272 532 + __SYSCALL(__NR_pciconfig_read, sys_pciconfig_read) 533 + #define __NR_pciconfig_write 273 534 + __SYSCALL(__NR_pciconfig_write, sys_pciconfig_write) 535 + #define __NR_mq_open 274 536 + __SYSCALL(__NR_mq_open, sys_mq_open) 537 + #define __NR_mq_unlink 275 538 + __SYSCALL(__NR_mq_unlink, sys_mq_unlink) 539 + #define __NR_mq_timedsend 276 540 + __SYSCALL(__NR_mq_timedsend, sys_mq_timedsend) 541 + #define __NR_mq_timedreceive 277 542 + __SYSCALL(__NR_mq_timedreceive, sys_mq_timedreceive) 543 + #define __NR_mq_notify 278 544 + __SYSCALL(__NR_mq_notify, sys_mq_notify) 545 + #define __NR_mq_getsetattr 279 546 + __SYSCALL(__NR_mq_getsetattr, sys_mq_getsetattr) 547 + #define __NR_waitid 280 548 + __SYSCALL(__NR_waitid, sys_waitid) 549 + #define __NR_socket 281 550 + __SYSCALL(__NR_socket, sys_socket) 551 + #define __NR_bind 282 552 + __SYSCALL(__NR_bind, sys_bind) 553 + #define __NR_connect 283 554 + __SYSCALL(__NR_connect, sys_connect) 555 + #define __NR_listen 284 556 + __SYSCALL(__NR_listen, sys_listen) 557 + #define __NR_accept 285 558 + __SYSCALL(__NR_accept, sys_accept) 559 + #define __NR_getsockname 286 560 + __SYSCALL(__NR_getsockname, sys_getsockname) 561 + #define __NR_getpeername 287 562 + __SYSCALL(__NR_getpeername, sys_getpeername) 563 + #define __NR_socketpair 288 564 + __SYSCALL(__NR_socketpair, sys_socketpair) 565 + #define __NR_send 289 566 + __SYSCALL(__NR_send, sys_send) 567 + #define __NR_sendto 290 568 + __SYSCALL(__NR_sendto, sys_sendto) 569 + #define __NR_recv 291 570 + __SYSCALL(__NR_recv, sys_recv) 571 + #define __NR_recvfrom 292 572 + __SYSCALL(__NR_recvfrom, sys_recvfrom) 573 + #define __NR_shutdown 293 574 + __SYSCALL(__NR_shutdown, sys_shutdown) 575 + #define __NR_setsockopt 294 576 + __SYSCALL(__NR_setsockopt, sys_setsockopt) 577 + #define __NR_getsockopt 295 578 + __SYSCALL(__NR_getsockopt, sys_getsockopt) 579 + #define __NR_sendmsg 296 580 + __SYSCALL(__NR_sendmsg, sys_sendmsg) 581 + #define __NR_recvmsg 297 582 + __SYSCALL(__NR_recvmsg, sys_recvmsg) 583 + #define __NR_semop 298 584 + __SYSCALL(__NR_semop, sys_semop) 585 + #define __NR_semget 299 586 + __SYSCALL(__NR_semget, sys_semget) 587 + #define __NR_semctl 300 588 + __SYSCALL(__NR_semctl, sys_semctl) 589 + #define __NR_msgsnd 301 590 + __SYSCALL(__NR_msgsnd, sys_msgsnd) 591 + #define __NR_msgrcv 302 592 + __SYSCALL(__NR_msgrcv, sys_msgrcv) 593 + #define __NR_msgget 303 594 + __SYSCALL(__NR_msgget, sys_msgget) 595 + #define __NR_msgctl 304 596 + __SYSCALL(__NR_msgctl, sys_msgctl) 597 + #define __NR_shmat 305 598 + __SYSCALL(__NR_shmat, sys_shmat) 599 + #define __NR_shmdt 306 600 + __SYSCALL(__NR_shmdt, sys_shmdt) 601 + #define __NR_shmget 307 602 + __SYSCALL(__NR_shmget, sys_shmget) 603 + #define __NR_shmctl 308 604 + __SYSCALL(__NR_shmctl, sys_shmctl) 605 + #define __NR_add_key 309 606 + __SYSCALL(__NR_add_key, sys_add_key) 607 + #define __NR_request_key 310 608 + __SYSCALL(__NR_request_key, sys_request_key) 609 + #define __NR_keyctl 311 610 + __SYSCALL(__NR_keyctl, sys_keyctl) 611 + #define __NR_semtimedop 312 612 + __SYSCALL(__NR_semtimedop, sys_semtimedop) 613 + #define __NR_vserver 313 614 + __SYSCALL(__NR_vserver, sys_ni_syscall) 615 + #define __NR_ioprio_set 314 616 + __SYSCALL(__NR_ioprio_set, sys_ioprio_set) 617 + #define __NR_ioprio_get 315 618 + __SYSCALL(__NR_ioprio_get, sys_ioprio_get) 619 + #define __NR_inotify_init 316 620 + __SYSCALL(__NR_inotify_init, sys_inotify_init) 621 + #define __NR_inotify_add_watch 317 622 + __SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch) 623 + #define __NR_inotify_rm_watch 318 624 + __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch) 625 + #define __NR_mbind 319 626 + __SYSCALL(__NR_mbind, sys_mbind) 627 + #define __NR_get_mempolicy 320 628 + __SYSCALL(__NR_get_mempolicy, sys_get_mempolicy) 629 + #define __NR_set_mempolicy 321 630 + __SYSCALL(__NR_set_mempolicy, sys_set_mempolicy) 631 + #define __NR_openat 322 632 + __SYSCALL(__NR_openat, sys_openat) 633 + #define __NR_mkdirat 323 634 + __SYSCALL(__NR_mkdirat, sys_mkdirat) 635 + #define __NR_mknodat 324 636 + __SYSCALL(__NR_mknodat, sys_mknodat) 637 + #define __NR_fchownat 325 638 + __SYSCALL(__NR_fchownat, sys_fchownat) 639 + #define __NR_futimesat 326 640 + __SYSCALL(__NR_futimesat, sys_futimesat) 641 + #define __NR_fstatat64 327 642 + __SYSCALL(__NR_fstatat64, sys_fstatat64) 643 + #define __NR_unlinkat 328 644 + __SYSCALL(__NR_unlinkat, sys_unlinkat) 645 + #define __NR_renameat 329 646 + __SYSCALL(__NR_renameat, sys_renameat) 647 + #define __NR_linkat 330 648 + __SYSCALL(__NR_linkat, sys_linkat) 649 + #define __NR_symlinkat 331 650 + __SYSCALL(__NR_symlinkat, sys_symlinkat) 651 + #define __NR_readlinkat 332 652 + __SYSCALL(__NR_readlinkat, sys_readlinkat) 653 + #define __NR_fchmodat 333 654 + __SYSCALL(__NR_fchmodat, sys_fchmodat) 655 + #define __NR_faccessat 334 656 + __SYSCALL(__NR_faccessat, sys_faccessat) 657 + #define __NR_pselect6 335 658 + __SYSCALL(__NR_pselect6, sys_pselect6) 659 + #define __NR_ppoll 336 660 + __SYSCALL(__NR_ppoll, sys_ppoll) 661 + #define __NR_unshare 337 662 + __SYSCALL(__NR_unshare, sys_unshare) 663 + #define __NR_set_robust_list 338 664 + __SYSCALL(__NR_set_robust_list, sys_set_robust_list) 665 + #define __NR_get_robust_list 339 666 + __SYSCALL(__NR_get_robust_list, sys_get_robust_list) 667 + #define __NR_splice 340 668 + __SYSCALL(__NR_splice, sys_splice) 669 + #define __NR_sync_file_range2 341 670 + __SYSCALL(__NR_sync_file_range2, sys_sync_file_range2) 671 + #define __NR_tee 342 672 + __SYSCALL(__NR_tee, sys_tee) 673 + #define __NR_vmsplice 343 674 + __SYSCALL(__NR_vmsplice, sys_vmsplice) 675 + #define __NR_move_pages 344 676 + __SYSCALL(__NR_move_pages, sys_move_pages) 677 + #define __NR_getcpu 345 678 + __SYSCALL(__NR_getcpu, sys_getcpu) 679 + #define __NR_epoll_pwait 346 680 + __SYSCALL(__NR_epoll_pwait, sys_epoll_pwait) 681 + #define __NR_kexec_load 347 682 + __SYSCALL(__NR_kexec_load, sys_kexec_load) 683 + #define __NR_utimensat 348 684 + __SYSCALL(__NR_utimensat, sys_utimensat) 685 + #define __NR_signalfd 349 686 + __SYSCALL(__NR_signalfd, sys_signalfd) 687 + #define __NR_timerfd_create 350 688 + __SYSCALL(__NR_timerfd_create, sys_timerfd_create) 689 + #define __NR_eventfd 351 690 + __SYSCALL(__NR_eventfd, sys_eventfd) 691 + #define __NR_fallocate 352 692 + __SYSCALL(__NR_fallocate, sys_fallocate) 693 + #define __NR_timerfd_settime 353 694 + __SYSCALL(__NR_timerfd_settime, sys_timerfd_settime) 695 + #define __NR_timerfd_gettime 354 696 + __SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime) 697 + #define __NR_signalfd4 355 698 + __SYSCALL(__NR_signalfd4, sys_signalfd4) 699 + #define __NR_eventfd2 356 700 + __SYSCALL(__NR_eventfd2, sys_eventfd2) 701 + #define __NR_epoll_create1 357 702 + __SYSCALL(__NR_epoll_create1, sys_epoll_create1) 703 + #define __NR_dup3 358 704 + __SYSCALL(__NR_dup3, sys_dup3) 705 + #define __NR_pipe2 359 706 + __SYSCALL(__NR_pipe2, sys_pipe2) 707 + #define __NR_inotify_init1 360 708 + __SYSCALL(__NR_inotify_init1, sys_inotify_init1) 709 + #define __NR_preadv 361 710 + __SYSCALL(__NR_preadv, sys_preadv) 711 + #define __NR_pwritev 362 712 + __SYSCALL(__NR_pwritev, sys_pwritev) 713 + #define __NR_rt_tgsigqueueinfo 363 714 + __SYSCALL(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) 715 + #define __NR_perf_event_open 364 716 + __SYSCALL(__NR_perf_event_open, sys_perf_event_open) 717 + #define __NR_recvmmsg 365 718 + __SYSCALL(__NR_recvmmsg, sys_recvmmsg) 719 + #define __NR_accept4 366 720 + __SYSCALL(__NR_accept4, sys_accept4) 721 + #define __NR_fanotify_init 367 722 + __SYSCALL(__NR_fanotify_init, sys_fanotify_init) 723 + #define __NR_fanotify_mark 368 724 + __SYSCALL(__NR_fanotify_mark, sys_fanotify_mark) 725 + #define __NR_prlimit64 369 726 + __SYSCALL(__NR_prlimit64, sys_prlimit64) 727 + #define __NR_name_to_handle_at 370 728 + __SYSCALL(__NR_name_to_handle_at, sys_name_to_handle_at) 729 + #define __NR_open_by_handle_at 371 730 + __SYSCALL(__NR_open_by_handle_at, sys_open_by_handle_at) 731 + #define __NR_clock_adjtime 372 732 + __SYSCALL(__NR_clock_adjtime, sys_clock_adjtime) 733 + #define __NR_syncfs 373 734 + __SYSCALL(__NR_syncfs, sys_syncfs) 735 + 736 + /* 737 + * The following SVCs are ARM private. 738 + */ 739 + #define __ARM_NR_COMPAT_BASE 0x0f0000 740 + #define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2) 741 + #define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5) 742 + 743 + #endif /* __SYSCALL_COMPAT */ 744 + 745 + #define __NR_compat_syscalls 374 746 + 747 + #define __ARCH_WANT_COMPAT_IPC_PARSE_VERSION 748 + #define __ARCH_WANT_COMPAT_STAT64 749 + #define __ARCH_WANT_SYS_GETHOSTNAME 750 + #define __ARCH_WANT_SYS_PAUSE 751 + #define __ARCH_WANT_SYS_GETPGRP 752 + #define __ARCH_WANT_SYS_LLSEEK 753 + #define __ARCH_WANT_SYS_NICE 754 + #define __ARCH_WANT_SYS_SIGPENDING 755 + #define __ARCH_WANT_SYS_SIGPROCMASK 756 + #define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 757 + 758 + #endif /* __ASM_UNISTD32_H */
+77
arch/arm64/kernel/kuser32.S
··· 1 + /* 2 + * Low-level user helpers placed in the vectors page for AArch32. 3 + * Based on the kuser helpers in arch/arm/kernel/entry-armv.S. 4 + * 5 + * Copyright (C) 2005-2011 Nicolas Pitre <nico@fluxnic.net> 6 + * Copyright (C) 2012 ARM Ltd. 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + * 20 + * 21 + * AArch32 user helpers. 22 + * 23 + * Each segment is 32-byte aligned and will be moved to the top of the high 24 + * vector page. New segments (if ever needed) must be added in front of 25 + * existing ones. This mechanism should be used only for things that are 26 + * really small and justified, and not be abused freely. 27 + * 28 + * See Documentation/arm/kernel_user_helpers.txt for formal definitions. 29 + */ 30 + .align 5 31 + .globl __kuser_helper_start 32 + __kuser_helper_start: 33 + 34 + __kuser_cmpxchg64: // 0xffff0f60 35 + .inst 0xe92d00f0 // push {r4, r5, r6, r7} 36 + .inst 0xe1c040d0 // ldrd r4, r5, [r0] 37 + .inst 0xe1c160d0 // ldrd r6, r7, [r1] 38 + .inst 0xf57ff05f // dmb sy 39 + .inst 0xe1b20f9f // 1: ldrexd r0, r1, [r2] 40 + .inst 0xe0303004 // eors r3, r0, r4 41 + .inst 0x00313005 // eoreqs r3, r1, r5 42 + .inst 0x01a23f96 // strexdeq r3, r6, [r2] 43 + .inst 0x03330001 // teqeq r3, #1 44 + .inst 0x0afffff9 // beq 1b 45 + .inst 0xf57ff05f // dmb sy 46 + .inst 0xe2730000 // rsbs r0, r3, #0 47 + .inst 0xe8bd00f0 // pop {r4, r5, r6, r7} 48 + .inst 0xe12fff1e // bx lr 49 + 50 + .align 5 51 + __kuser_memory_barrier: // 0xffff0fa0 52 + .inst 0xf57ff05f // dmb sy 53 + .inst 0xe12fff1e // bx lr 54 + 55 + .align 5 56 + __kuser_cmpxchg: // 0xffff0fc0 57 + .inst 0xf57ff05f // dmb sy 58 + .inst 0xe1923f9f // 1: ldrex r3, [r2] 59 + .inst 0xe0533000 // subs r3, r3, r0 60 + .inst 0x01823f91 // strexeq r3, r1, [r2] 61 + .inst 0x03330001 // teqeq r3, #1 62 + .inst 0x0afffffa // beq 1b 63 + .inst 0xe2730000 // rsbs r0, r3, #0 64 + .inst 0xeaffffef // b <__kuser_memory_barrier> 65 + 66 + .align 5 67 + __kuser_get_tls: // 0xffff0fe0 68 + .inst 0xee1d0f70 // mrc p15, 0, r0, c13, c0, 3 69 + .inst 0xe12fff1e // bx lr 70 + .rep 5 71 + .word 0 72 + .endr 73 + 74 + __kuser_helper_version: // 0xffff0ffc 75 + .word ((__kuser_helper_end - __kuser_helper_start) >> 5) 76 + .globl __kuser_helper_end 77 + __kuser_helper_end:
+876
arch/arm64/kernel/signal32.c
··· 1 + /* 2 + * Based on arch/arm/kernel/signal.c 3 + * 4 + * Copyright (C) 1995-2009 Russell King 5 + * Copyright (C) 2012 ARM Ltd. 6 + * Modified by Will Deacon <will.deacon@arm.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + */ 20 + 21 + #define __SYSCALL_COMPAT 22 + 23 + #include <linux/compat.h> 24 + #include <linux/signal.h> 25 + #include <linux/syscalls.h> 26 + #include <linux/ratelimit.h> 27 + 28 + #include <asm/fpsimd.h> 29 + #include <asm/signal32.h> 30 + #include <asm/uaccess.h> 31 + #include <asm/unistd.h> 32 + 33 + typedef struct compat_siginfo { 34 + int si_signo; 35 + int si_errno; 36 + int si_code; 37 + 38 + union { 39 + /* The padding is the same size as AArch64. */ 40 + int _pad[SI_PAD_SIZE]; 41 + 42 + /* kill() */ 43 + struct { 44 + compat_pid_t _pid; /* sender's pid */ 45 + __compat_uid32_t _uid; /* sender's uid */ 46 + } _kill; 47 + 48 + /* POSIX.1b timers */ 49 + struct { 50 + compat_timer_t _tid; /* timer id */ 51 + int _overrun; /* overrun count */ 52 + compat_sigval_t _sigval; /* same as below */ 53 + int _sys_private; /* not to be passed to user */ 54 + } _timer; 55 + 56 + /* POSIX.1b signals */ 57 + struct { 58 + compat_pid_t _pid; /* sender's pid */ 59 + __compat_uid32_t _uid; /* sender's uid */ 60 + compat_sigval_t _sigval; 61 + } _rt; 62 + 63 + /* SIGCHLD */ 64 + struct { 65 + compat_pid_t _pid; /* which child */ 66 + __compat_uid32_t _uid; /* sender's uid */ 67 + int _status; /* exit code */ 68 + compat_clock_t _utime; 69 + compat_clock_t _stime; 70 + } _sigchld; 71 + 72 + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 73 + struct { 74 + compat_uptr_t _addr; /* faulting insn/memory ref. */ 75 + short _addr_lsb; /* LSB of the reported address */ 76 + } _sigfault; 77 + 78 + /* SIGPOLL */ 79 + struct { 80 + compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 81 + int _fd; 82 + } _sigpoll; 83 + } _sifields; 84 + } compat_siginfo_t; 85 + 86 + struct compat_sigaction { 87 + compat_uptr_t sa_handler; 88 + compat_ulong_t sa_flags; 89 + compat_uptr_t sa_restorer; 90 + compat_sigset_t sa_mask; 91 + }; 92 + 93 + struct compat_old_sigaction { 94 + compat_uptr_t sa_handler; 95 + compat_old_sigset_t sa_mask; 96 + compat_ulong_t sa_flags; 97 + compat_uptr_t sa_restorer; 98 + }; 99 + 100 + typedef struct compat_sigaltstack { 101 + compat_uptr_t ss_sp; 102 + int ss_flags; 103 + compat_size_t ss_size; 104 + } compat_stack_t; 105 + 106 + struct compat_sigcontext { 107 + /* We always set these two fields to 0 */ 108 + compat_ulong_t trap_no; 109 + compat_ulong_t error_code; 110 + 111 + compat_ulong_t oldmask; 112 + compat_ulong_t arm_r0; 113 + compat_ulong_t arm_r1; 114 + compat_ulong_t arm_r2; 115 + compat_ulong_t arm_r3; 116 + compat_ulong_t arm_r4; 117 + compat_ulong_t arm_r5; 118 + compat_ulong_t arm_r6; 119 + compat_ulong_t arm_r7; 120 + compat_ulong_t arm_r8; 121 + compat_ulong_t arm_r9; 122 + compat_ulong_t arm_r10; 123 + compat_ulong_t arm_fp; 124 + compat_ulong_t arm_ip; 125 + compat_ulong_t arm_sp; 126 + compat_ulong_t arm_lr; 127 + compat_ulong_t arm_pc; 128 + compat_ulong_t arm_cpsr; 129 + compat_ulong_t fault_address; 130 + }; 131 + 132 + struct compat_ucontext { 133 + compat_ulong_t uc_flags; 134 + struct compat_ucontext *uc_link; 135 + compat_stack_t uc_stack; 136 + struct compat_sigcontext uc_mcontext; 137 + compat_sigset_t uc_sigmask; 138 + int __unused[32 - (sizeof (compat_sigset_t) / sizeof (int))]; 139 + compat_ulong_t uc_regspace[128] __attribute__((__aligned__(8))); 140 + }; 141 + 142 + struct compat_vfp_sigframe { 143 + compat_ulong_t magic; 144 + compat_ulong_t size; 145 + struct compat_user_vfp { 146 + compat_u64 fpregs[32]; 147 + compat_ulong_t fpscr; 148 + } ufp; 149 + struct compat_user_vfp_exc { 150 + compat_ulong_t fpexc; 151 + compat_ulong_t fpinst; 152 + compat_ulong_t fpinst2; 153 + } ufp_exc; 154 + } __attribute__((__aligned__(8))); 155 + 156 + #define VFP_MAGIC 0x56465001 157 + #define VFP_STORAGE_SIZE sizeof(struct compat_vfp_sigframe) 158 + 159 + struct compat_aux_sigframe { 160 + struct compat_vfp_sigframe vfp; 161 + 162 + /* Something that isn't a valid magic number for any coprocessor. */ 163 + unsigned long end_magic; 164 + } __attribute__((__aligned__(8))); 165 + 166 + struct compat_sigframe { 167 + struct compat_ucontext uc; 168 + compat_ulong_t retcode[2]; 169 + }; 170 + 171 + struct compat_rt_sigframe { 172 + struct compat_siginfo info; 173 + struct compat_sigframe sig; 174 + }; 175 + 176 + #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 177 + 178 + /* 179 + * For ARM syscalls, the syscall number has to be loaded into r7. 180 + * We do not support an OABI userspace. 181 + */ 182 + #define MOV_R7_NR_SIGRETURN (0xe3a07000 | __NR_sigreturn) 183 + #define SVC_SYS_SIGRETURN (0xef000000 | __NR_sigreturn) 184 + #define MOV_R7_NR_RT_SIGRETURN (0xe3a07000 | __NR_rt_sigreturn) 185 + #define SVC_SYS_RT_SIGRETURN (0xef000000 | __NR_rt_sigreturn) 186 + 187 + /* 188 + * For Thumb syscalls, we also pass the syscall number via r7. We therefore 189 + * need two 16-bit instructions. 190 + */ 191 + #define SVC_THUMB_SIGRETURN (((0xdf00 | __NR_sigreturn) << 16) | \ 192 + 0x2700 | __NR_sigreturn) 193 + #define SVC_THUMB_RT_SIGRETURN (((0xdf00 | __NR_rt_sigreturn) << 16) | \ 194 + 0x2700 | __NR_rt_sigreturn) 195 + 196 + const compat_ulong_t aarch32_sigret_code[6] = { 197 + /* 198 + * AArch32 sigreturn code. 199 + * We don't construct an OABI SWI - instead we just set the imm24 field 200 + * to the EABI syscall number so that we create a sane disassembly. 201 + */ 202 + MOV_R7_NR_SIGRETURN, SVC_SYS_SIGRETURN, SVC_THUMB_SIGRETURN, 203 + MOV_R7_NR_RT_SIGRETURN, SVC_SYS_RT_SIGRETURN, SVC_THUMB_RT_SIGRETURN, 204 + }; 205 + 206 + static inline int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set) 207 + { 208 + compat_sigset_t cset; 209 + 210 + cset.sig[0] = set->sig[0] & 0xffffffffull; 211 + cset.sig[1] = set->sig[0] >> 32; 212 + 213 + return copy_to_user(uset, &cset, sizeof(*uset)); 214 + } 215 + 216 + static inline int get_sigset_t(sigset_t *set, 217 + const compat_sigset_t __user *uset) 218 + { 219 + compat_sigset_t s32; 220 + 221 + if (copy_from_user(&s32, uset, sizeof(*uset))) 222 + return -EFAULT; 223 + 224 + set->sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32); 225 + return 0; 226 + } 227 + 228 + int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) 229 + { 230 + int err; 231 + 232 + if (!access_ok(VERIFY_WRITE, to, sizeof(*to))) 233 + return -EFAULT; 234 + 235 + /* If you change siginfo_t structure, please be sure 236 + * this code is fixed accordingly. 237 + * It should never copy any pad contained in the structure 238 + * to avoid security leaks, but must copy the generic 239 + * 3 ints plus the relevant union member. 240 + * This routine must convert siginfo from 64bit to 32bit as well 241 + * at the same time. 242 + */ 243 + err = __put_user(from->si_signo, &to->si_signo); 244 + err |= __put_user(from->si_errno, &to->si_errno); 245 + err |= __put_user((short)from->si_code, &to->si_code); 246 + if (from->si_code < 0) 247 + err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, 248 + SI_PAD_SIZE); 249 + else switch (from->si_code & __SI_MASK) { 250 + case __SI_KILL: 251 + err |= __put_user(from->si_pid, &to->si_pid); 252 + err |= __put_user(from->si_uid, &to->si_uid); 253 + break; 254 + case __SI_TIMER: 255 + err |= __put_user(from->si_tid, &to->si_tid); 256 + err |= __put_user(from->si_overrun, &to->si_overrun); 257 + err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, 258 + &to->si_ptr); 259 + break; 260 + case __SI_POLL: 261 + err |= __put_user(from->si_band, &to->si_band); 262 + err |= __put_user(from->si_fd, &to->si_fd); 263 + break; 264 + case __SI_FAULT: 265 + err |= __put_user((compat_uptr_t)(unsigned long)from->si_addr, 266 + &to->si_addr); 267 + #ifdef BUS_MCEERR_AO 268 + /* 269 + * Other callers might not initialize the si_lsb field, 270 + * so check explicitely for the right codes here. 271 + */ 272 + if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO) 273 + err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); 274 + #endif 275 + break; 276 + case __SI_CHLD: 277 + err |= __put_user(from->si_pid, &to->si_pid); 278 + err |= __put_user(from->si_uid, &to->si_uid); 279 + err |= __put_user(from->si_status, &to->si_status); 280 + err |= __put_user(from->si_utime, &to->si_utime); 281 + err |= __put_user(from->si_stime, &to->si_stime); 282 + break; 283 + case __SI_RT: /* This is not generated by the kernel as of now. */ 284 + case __SI_MESGQ: /* But this is */ 285 + err |= __put_user(from->si_pid, &to->si_pid); 286 + err |= __put_user(from->si_uid, &to->si_uid); 287 + err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, &to->si_ptr); 288 + break; 289 + default: /* this is just in case for now ... */ 290 + err |= __put_user(from->si_pid, &to->si_pid); 291 + err |= __put_user(from->si_uid, &to->si_uid); 292 + break; 293 + } 294 + return err; 295 + } 296 + 297 + int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) 298 + { 299 + memset(to, 0, sizeof *to); 300 + 301 + if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) || 302 + copy_from_user(to->_sifields._pad, 303 + from->_sifields._pad, SI_PAD_SIZE)) 304 + return -EFAULT; 305 + 306 + return 0; 307 + } 308 + 309 + /* 310 + * VFP save/restore code. 311 + */ 312 + static int compat_preserve_vfp_context(struct compat_vfp_sigframe __user *frame) 313 + { 314 + struct fpsimd_state *fpsimd = &current->thread.fpsimd_state; 315 + compat_ulong_t magic = VFP_MAGIC; 316 + compat_ulong_t size = VFP_STORAGE_SIZE; 317 + compat_ulong_t fpscr, fpexc; 318 + int err = 0; 319 + 320 + /* 321 + * Save the hardware registers to the fpsimd_state structure. 322 + * Note that this also saves V16-31, which aren't visible 323 + * in AArch32. 324 + */ 325 + fpsimd_save_state(fpsimd); 326 + 327 + /* Place structure header on the stack */ 328 + __put_user_error(magic, &frame->magic, err); 329 + __put_user_error(size, &frame->size, err); 330 + 331 + /* 332 + * Now copy the FP registers. Since the registers are packed, 333 + * we can copy the prefix we want (V0-V15) as it is. 334 + * FIXME: Won't work if big endian. 335 + */ 336 + err |= __copy_to_user(&frame->ufp.fpregs, fpsimd->vregs, 337 + sizeof(frame->ufp.fpregs)); 338 + 339 + /* Create an AArch32 fpscr from the fpsr and the fpcr. */ 340 + fpscr = (fpsimd->fpsr & VFP_FPSCR_STAT_MASK) | 341 + (fpsimd->fpcr & VFP_FPSCR_CTRL_MASK); 342 + __put_user_error(fpscr, &frame->ufp.fpscr, err); 343 + 344 + /* 345 + * The exception register aren't available so we fake up a 346 + * basic FPEXC and zero everything else. 347 + */ 348 + fpexc = (1 << 30); 349 + __put_user_error(fpexc, &frame->ufp_exc.fpexc, err); 350 + __put_user_error(0, &frame->ufp_exc.fpinst, err); 351 + __put_user_error(0, &frame->ufp_exc.fpinst2, err); 352 + 353 + return err ? -EFAULT : 0; 354 + } 355 + 356 + static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame) 357 + { 358 + struct fpsimd_state fpsimd; 359 + compat_ulong_t magic = VFP_MAGIC; 360 + compat_ulong_t size = VFP_STORAGE_SIZE; 361 + compat_ulong_t fpscr; 362 + int err = 0; 363 + 364 + __get_user_error(magic, &frame->magic, err); 365 + __get_user_error(size, &frame->size, err); 366 + 367 + if (err) 368 + return -EFAULT; 369 + if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE) 370 + return -EINVAL; 371 + 372 + /* 373 + * Copy the FP registers into the start of the fpsimd_state. 374 + * FIXME: Won't work if big endian. 375 + */ 376 + err |= __copy_from_user(fpsimd.vregs, frame->ufp.fpregs, 377 + sizeof(frame->ufp.fpregs)); 378 + 379 + /* Extract the fpsr and the fpcr from the fpscr */ 380 + __get_user_error(fpscr, &frame->ufp.fpscr, err); 381 + fpsimd.fpsr = fpscr & VFP_FPSCR_STAT_MASK; 382 + fpsimd.fpcr = fpscr & VFP_FPSCR_CTRL_MASK; 383 + 384 + /* 385 + * We don't need to touch the exception register, so 386 + * reload the hardware state. 387 + */ 388 + if (!err) { 389 + preempt_disable(); 390 + fpsimd_load_state(&fpsimd); 391 + preempt_enable(); 392 + } 393 + 394 + return err ? -EFAULT : 0; 395 + } 396 + 397 + /* 398 + * atomically swap in the new signal mask, and wait for a signal. 399 + */ 400 + asmlinkage int compat_sys_sigsuspend(int restart, compat_ulong_t oldmask, 401 + compat_old_sigset_t mask) 402 + { 403 + sigset_t blocked; 404 + 405 + siginitset(&current->blocked, mask); 406 + return sigsuspend(&blocked); 407 + } 408 + 409 + asmlinkage int compat_sys_sigaction(int sig, 410 + const struct compat_old_sigaction __user *act, 411 + struct compat_old_sigaction __user *oact) 412 + { 413 + struct k_sigaction new_ka, old_ka; 414 + int ret; 415 + compat_old_sigset_t mask; 416 + compat_uptr_t handler, restorer; 417 + 418 + if (act) { 419 + if (!access_ok(VERIFY_READ, act, sizeof(*act)) || 420 + __get_user(handler, &act->sa_handler) || 421 + __get_user(restorer, &act->sa_restorer) || 422 + __get_user(new_ka.sa.sa_flags, &act->sa_flags) || 423 + __get_user(mask, &act->sa_mask)) 424 + return -EFAULT; 425 + 426 + new_ka.sa.sa_handler = compat_ptr(handler); 427 + new_ka.sa.sa_restorer = compat_ptr(restorer); 428 + siginitset(&new_ka.sa.sa_mask, mask); 429 + } 430 + 431 + ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); 432 + 433 + if (!ret && oact) { 434 + if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || 435 + __put_user(ptr_to_compat(old_ka.sa.sa_handler), 436 + &oact->sa_handler) || 437 + __put_user(ptr_to_compat(old_ka.sa.sa_restorer), 438 + &oact->sa_restorer) || 439 + __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || 440 + __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) 441 + return -EFAULT; 442 + } 443 + 444 + return ret; 445 + } 446 + 447 + asmlinkage int compat_sys_rt_sigaction(int sig, 448 + const struct compat_sigaction __user *act, 449 + struct compat_sigaction __user *oact, 450 + compat_size_t sigsetsize) 451 + { 452 + struct k_sigaction new_ka, old_ka; 453 + int ret; 454 + 455 + /* XXX: Don't preclude handling different sized sigset_t's. */ 456 + if (sigsetsize != sizeof(compat_sigset_t)) 457 + return -EINVAL; 458 + 459 + if (act) { 460 + compat_uptr_t handler, restorer; 461 + 462 + ret = get_user(handler, &act->sa_handler); 463 + new_ka.sa.sa_handler = compat_ptr(handler); 464 + ret |= get_user(restorer, &act->sa_restorer); 465 + new_ka.sa.sa_restorer = compat_ptr(restorer); 466 + ret |= get_sigset_t(&new_ka.sa.sa_mask, &act->sa_mask); 467 + ret |= __get_user(new_ka.sa.sa_flags, &act->sa_flags); 468 + if (ret) 469 + return -EFAULT; 470 + } 471 + 472 + ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); 473 + if (!ret && oact) { 474 + ret = put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler); 475 + ret |= put_sigset_t(&oact->sa_mask, &old_ka.sa.sa_mask); 476 + ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); 477 + } 478 + return ret; 479 + } 480 + 481 + int compat_do_sigaltstack(compat_uptr_t compat_uss, compat_uptr_t compat_uoss, 482 + compat_ulong_t sp) 483 + { 484 + compat_stack_t __user *newstack = compat_ptr(compat_uss); 485 + compat_stack_t __user *oldstack = compat_ptr(compat_uoss); 486 + compat_uptr_t ss_sp; 487 + int ret; 488 + mm_segment_t old_fs; 489 + stack_t uss, uoss; 490 + 491 + /* Marshall the compat new stack into a stack_t */ 492 + if (newstack) { 493 + if (get_user(ss_sp, &newstack->ss_sp) || 494 + __get_user(uss.ss_flags, &newstack->ss_flags) || 495 + __get_user(uss.ss_size, &newstack->ss_size)) 496 + return -EFAULT; 497 + uss.ss_sp = compat_ptr(ss_sp); 498 + } 499 + 500 + old_fs = get_fs(); 501 + set_fs(KERNEL_DS); 502 + /* The __user pointer casts are valid because of the set_fs() */ 503 + ret = do_sigaltstack( 504 + newstack ? (stack_t __user *) &uss : NULL, 505 + oldstack ? (stack_t __user *) &uoss : NULL, 506 + (unsigned long)sp); 507 + set_fs(old_fs); 508 + 509 + /* Convert the old stack_t into a compat stack. */ 510 + if (!ret && oldstack && 511 + (put_user(ptr_to_compat(uoss.ss_sp), &oldstack->ss_sp) || 512 + __put_user(uoss.ss_flags, &oldstack->ss_flags) || 513 + __put_user(uoss.ss_size, &oldstack->ss_size))) 514 + return -EFAULT; 515 + return ret; 516 + } 517 + 518 + static int compat_restore_sigframe(struct pt_regs *regs, 519 + struct compat_sigframe __user *sf) 520 + { 521 + int err; 522 + sigset_t set; 523 + struct compat_aux_sigframe __user *aux; 524 + 525 + err = get_sigset_t(&set, &sf->uc.uc_sigmask); 526 + if (err == 0) { 527 + sigdelsetmask(&set, ~_BLOCKABLE); 528 + set_current_blocked(&set); 529 + } 530 + 531 + __get_user_error(regs->regs[0], &sf->uc.uc_mcontext.arm_r0, err); 532 + __get_user_error(regs->regs[1], &sf->uc.uc_mcontext.arm_r1, err); 533 + __get_user_error(regs->regs[2], &sf->uc.uc_mcontext.arm_r2, err); 534 + __get_user_error(regs->regs[3], &sf->uc.uc_mcontext.arm_r3, err); 535 + __get_user_error(regs->regs[4], &sf->uc.uc_mcontext.arm_r4, err); 536 + __get_user_error(regs->regs[5], &sf->uc.uc_mcontext.arm_r5, err); 537 + __get_user_error(regs->regs[6], &sf->uc.uc_mcontext.arm_r6, err); 538 + __get_user_error(regs->regs[7], &sf->uc.uc_mcontext.arm_r7, err); 539 + __get_user_error(regs->regs[8], &sf->uc.uc_mcontext.arm_r8, err); 540 + __get_user_error(regs->regs[9], &sf->uc.uc_mcontext.arm_r9, err); 541 + __get_user_error(regs->regs[10], &sf->uc.uc_mcontext.arm_r10, err); 542 + __get_user_error(regs->regs[11], &sf->uc.uc_mcontext.arm_fp, err); 543 + __get_user_error(regs->regs[12], &sf->uc.uc_mcontext.arm_ip, err); 544 + __get_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err); 545 + __get_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err); 546 + __get_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err); 547 + __get_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err); 548 + 549 + /* 550 + * Avoid compat_sys_sigreturn() restarting. 551 + */ 552 + regs->syscallno = ~0UL; 553 + 554 + err |= !valid_user_regs(&regs->user_regs); 555 + 556 + aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace; 557 + if (err == 0) 558 + err |= compat_restore_vfp_context(&aux->vfp); 559 + 560 + return err; 561 + } 562 + 563 + asmlinkage int compat_sys_sigreturn(struct pt_regs *regs) 564 + { 565 + struct compat_sigframe __user *frame; 566 + 567 + /* Always make any pending restarted system calls return -EINTR */ 568 + current_thread_info()->restart_block.fn = do_no_restart_syscall; 569 + 570 + /* 571 + * Since we stacked the signal on a 64-bit boundary, 572 + * then 'sp' should be word aligned here. If it's 573 + * not, then the user is trying to mess with us. 574 + */ 575 + if (regs->compat_sp & 7) 576 + goto badframe; 577 + 578 + frame = (struct compat_sigframe __user *)regs->compat_sp; 579 + 580 + if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) 581 + goto badframe; 582 + 583 + if (compat_restore_sigframe(regs, frame)) 584 + goto badframe; 585 + 586 + return regs->regs[0]; 587 + 588 + badframe: 589 + if (show_unhandled_signals) 590 + pr_info_ratelimited("%s[%d]: bad frame in %s: pc=%08llx sp=%08llx\n", 591 + current->comm, task_pid_nr(current), __func__, 592 + regs->pc, regs->sp); 593 + force_sig(SIGSEGV, current); 594 + return 0; 595 + } 596 + 597 + asmlinkage int compat_sys_rt_sigreturn(struct pt_regs *regs) 598 + { 599 + struct compat_rt_sigframe __user *frame; 600 + 601 + /* Always make any pending restarted system calls return -EINTR */ 602 + current_thread_info()->restart_block.fn = do_no_restart_syscall; 603 + 604 + /* 605 + * Since we stacked the signal on a 64-bit boundary, 606 + * then 'sp' should be word aligned here. If it's 607 + * not, then the user is trying to mess with us. 608 + */ 609 + if (regs->compat_sp & 7) 610 + goto badframe; 611 + 612 + frame = (struct compat_rt_sigframe __user *)regs->compat_sp; 613 + 614 + if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) 615 + goto badframe; 616 + 617 + if (compat_restore_sigframe(regs, &frame->sig)) 618 + goto badframe; 619 + 620 + if (compat_do_sigaltstack(ptr_to_compat(&frame->sig.uc.uc_stack), 621 + ptr_to_compat((void __user *)NULL), 622 + regs->compat_sp) == -EFAULT) 623 + goto badframe; 624 + 625 + return regs->regs[0]; 626 + 627 + badframe: 628 + if (show_unhandled_signals) 629 + pr_info_ratelimited("%s[%d]: bad frame in %s: pc=%08llx sp=%08llx\n", 630 + current->comm, task_pid_nr(current), __func__, 631 + regs->pc, regs->sp); 632 + force_sig(SIGSEGV, current); 633 + return 0; 634 + } 635 + 636 + static inline void __user *compat_get_sigframe(struct k_sigaction *ka, 637 + struct pt_regs *regs, 638 + int framesize) 639 + { 640 + compat_ulong_t sp = regs->compat_sp; 641 + void __user *frame; 642 + 643 + /* 644 + * This is the X/Open sanctioned signal stack switching. 645 + */ 646 + if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) 647 + sp = current->sas_ss_sp + current->sas_ss_size; 648 + 649 + /* 650 + * ATPCS B01 mandates 8-byte alignment 651 + */ 652 + frame = compat_ptr((compat_uptr_t)((sp - framesize) & ~7)); 653 + 654 + /* 655 + * Check that we can actually write to the signal frame. 656 + */ 657 + if (!access_ok(VERIFY_WRITE, frame, framesize)) 658 + frame = NULL; 659 + 660 + return frame; 661 + } 662 + 663 + static int compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka, 664 + compat_ulong_t __user *rc, void __user *frame, 665 + int usig) 666 + { 667 + compat_ulong_t handler = ptr_to_compat(ka->sa.sa_handler); 668 + compat_ulong_t retcode; 669 + compat_ulong_t spsr = regs->pstate & ~PSR_f; 670 + int thumb; 671 + 672 + /* Check if the handler is written for ARM or Thumb */ 673 + thumb = handler & 1; 674 + 675 + if (thumb) { 676 + spsr |= COMPAT_PSR_T_BIT; 677 + spsr &= ~COMPAT_PSR_IT_MASK; 678 + } else { 679 + spsr &= ~COMPAT_PSR_T_BIT; 680 + } 681 + 682 + if (ka->sa.sa_flags & SA_RESTORER) { 683 + retcode = ptr_to_compat(ka->sa.sa_restorer); 684 + } else { 685 + /* Set up sigreturn pointer */ 686 + unsigned int idx = thumb << 1; 687 + 688 + if (ka->sa.sa_flags & SA_SIGINFO) 689 + idx += 3; 690 + 691 + retcode = AARCH32_VECTORS_BASE + 692 + AARCH32_KERN_SIGRET_CODE_OFFSET + 693 + (idx << 2) + thumb; 694 + } 695 + 696 + regs->regs[0] = usig; 697 + regs->compat_sp = ptr_to_compat(frame); 698 + regs->compat_lr = retcode; 699 + regs->pc = handler; 700 + regs->pstate = spsr; 701 + 702 + return 0; 703 + } 704 + 705 + static int compat_setup_sigframe(struct compat_sigframe __user *sf, 706 + struct pt_regs *regs, sigset_t *set) 707 + { 708 + struct compat_aux_sigframe __user *aux; 709 + int err = 0; 710 + 711 + __put_user_error(regs->regs[0], &sf->uc.uc_mcontext.arm_r0, err); 712 + __put_user_error(regs->regs[1], &sf->uc.uc_mcontext.arm_r1, err); 713 + __put_user_error(regs->regs[2], &sf->uc.uc_mcontext.arm_r2, err); 714 + __put_user_error(regs->regs[3], &sf->uc.uc_mcontext.arm_r3, err); 715 + __put_user_error(regs->regs[4], &sf->uc.uc_mcontext.arm_r4, err); 716 + __put_user_error(regs->regs[5], &sf->uc.uc_mcontext.arm_r5, err); 717 + __put_user_error(regs->regs[6], &sf->uc.uc_mcontext.arm_r6, err); 718 + __put_user_error(regs->regs[7], &sf->uc.uc_mcontext.arm_r7, err); 719 + __put_user_error(regs->regs[8], &sf->uc.uc_mcontext.arm_r8, err); 720 + __put_user_error(regs->regs[9], &sf->uc.uc_mcontext.arm_r9, err); 721 + __put_user_error(regs->regs[10], &sf->uc.uc_mcontext.arm_r10, err); 722 + __put_user_error(regs->regs[11], &sf->uc.uc_mcontext.arm_fp, err); 723 + __put_user_error(regs->regs[12], &sf->uc.uc_mcontext.arm_ip, err); 724 + __put_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err); 725 + __put_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err); 726 + __put_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err); 727 + __put_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err); 728 + 729 + __put_user_error((compat_ulong_t)0, &sf->uc.uc_mcontext.trap_no, err); 730 + __put_user_error((compat_ulong_t)0, &sf->uc.uc_mcontext.error_code, err); 731 + __put_user_error(current->thread.fault_address, &sf->uc.uc_mcontext.fault_address, err); 732 + __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err); 733 + 734 + err |= put_sigset_t(&sf->uc.uc_sigmask, set); 735 + 736 + aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace; 737 + 738 + if (err == 0) 739 + err |= compat_preserve_vfp_context(&aux->vfp); 740 + __put_user_error(0, &aux->end_magic, err); 741 + 742 + return err; 743 + } 744 + 745 + /* 746 + * 32-bit signal handling routines called from signal.c 747 + */ 748 + int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, 749 + sigset_t *set, struct pt_regs *regs) 750 + { 751 + struct compat_rt_sigframe __user *frame; 752 + compat_stack_t stack; 753 + int err = 0; 754 + 755 + frame = compat_get_sigframe(ka, regs, sizeof(*frame)); 756 + 757 + if (!frame) 758 + return 1; 759 + 760 + err |= copy_siginfo_to_user32(&frame->info, info); 761 + 762 + __put_user_error(0, &frame->sig.uc.uc_flags, err); 763 + __put_user_error(NULL, &frame->sig.uc.uc_link, err); 764 + 765 + memset(&stack, 0, sizeof(stack)); 766 + stack.ss_sp = (compat_uptr_t)current->sas_ss_sp; 767 + stack.ss_flags = sas_ss_flags(regs->compat_sp); 768 + stack.ss_size = current->sas_ss_size; 769 + err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack)); 770 + 771 + err |= compat_setup_sigframe(&frame->sig, regs, set); 772 + if (err == 0) 773 + err = compat_setup_return(regs, ka, frame->sig.retcode, frame, 774 + usig); 775 + 776 + if (err == 0) { 777 + regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info; 778 + regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc; 779 + } 780 + 781 + return err; 782 + } 783 + 784 + int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, 785 + struct pt_regs *regs) 786 + { 787 + struct compat_sigframe __user *frame; 788 + int err = 0; 789 + 790 + frame = compat_get_sigframe(ka, regs, sizeof(*frame)); 791 + 792 + if (!frame) 793 + return 1; 794 + 795 + __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err); 796 + 797 + err |= compat_setup_sigframe(frame, regs, set); 798 + if (err == 0) 799 + err = compat_setup_return(regs, ka, frame->retcode, frame, usig); 800 + 801 + return err; 802 + } 803 + 804 + /* 805 + * RT signals don't have generic compat wrappers. 806 + * See arch/powerpc/kernel/signal_32.c 807 + */ 808 + asmlinkage int compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set, 809 + compat_sigset_t __user *oset, 810 + compat_size_t sigsetsize) 811 + { 812 + sigset_t s; 813 + sigset_t __user *up; 814 + int ret; 815 + mm_segment_t old_fs = get_fs(); 816 + 817 + if (set) { 818 + if (get_sigset_t(&s, set)) 819 + return -EFAULT; 820 + } 821 + 822 + set_fs(KERNEL_DS); 823 + /* This is valid because of the set_fs() */ 824 + up = (sigset_t __user *) &s; 825 + ret = sys_rt_sigprocmask(how, set ? up : NULL, oset ? up : NULL, 826 + sigsetsize); 827 + set_fs(old_fs); 828 + if (ret) 829 + return ret; 830 + if (oset) { 831 + if (put_sigset_t(oset, &s)) 832 + return -EFAULT; 833 + } 834 + return 0; 835 + } 836 + 837 + asmlinkage int compat_sys_rt_sigpending(compat_sigset_t __user *set, 838 + compat_size_t sigsetsize) 839 + { 840 + sigset_t s; 841 + int ret; 842 + mm_segment_t old_fs = get_fs(); 843 + 844 + set_fs(KERNEL_DS); 845 + /* The __user pointer cast is valid because of the set_fs() */ 846 + ret = sys_rt_sigpending((sigset_t __user *) &s, sigsetsize); 847 + set_fs(old_fs); 848 + if (!ret) { 849 + if (put_sigset_t(set, &s)) 850 + return -EFAULT; 851 + } 852 + return ret; 853 + } 854 + 855 + asmlinkage int compat_sys_rt_sigqueueinfo(int pid, int sig, 856 + compat_siginfo_t __user *uinfo) 857 + { 858 + siginfo_t info; 859 + int ret; 860 + mm_segment_t old_fs = get_fs(); 861 + 862 + ret = copy_siginfo_from_user32(&info, uinfo); 863 + if (unlikely(ret)) 864 + return ret; 865 + 866 + set_fs (KERNEL_DS); 867 + /* The __user pointer cast is valid because of the set_fs() */ 868 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info); 869 + set_fs (old_fs); 870 + return ret; 871 + } 872 + 873 + void compat_setup_restart_syscall(struct pt_regs *regs) 874 + { 875 + regs->regs[7] = __NR_restart_syscall; 876 + }
+282
arch/arm64/kernel/sys32.S
··· 1 + /* 2 + * Compat system call wrappers 3 + * 4 + * Copyright (C) 2012 ARM Ltd. 5 + * Authors: Will Deacon <will.deacon@arm.com> 6 + * Catalin Marinas <catalin.marinas@arm.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + */ 20 + 21 + #include <linux/linkage.h> 22 + 23 + #include <asm/assembler.h> 24 + #include <asm/asm-offsets.h> 25 + 26 + /* 27 + * System call wrappers for the AArch32 compatibility layer. 28 + */ 29 + compat_sys_fork_wrapper: 30 + mov x0, sp 31 + b compat_sys_fork 32 + ENDPROC(compat_sys_fork_wrapper) 33 + 34 + compat_sys_vfork_wrapper: 35 + mov x0, sp 36 + b compat_sys_vfork 37 + ENDPROC(compat_sys_vfork_wrapper) 38 + 39 + compat_sys_execve_wrapper: 40 + mov x3, sp 41 + b compat_sys_execve 42 + ENDPROC(compat_sys_execve_wrapper) 43 + 44 + compat_sys_clone_wrapper: 45 + mov x5, sp 46 + b compat_sys_clone 47 + ENDPROC(compat_sys_clone_wrapper) 48 + 49 + compat_sys_sigreturn_wrapper: 50 + mov x0, sp 51 + mov x27, #0 // prevent syscall restart handling (why) 52 + b compat_sys_sigreturn 53 + ENDPROC(compat_sys_sigreturn_wrapper) 54 + 55 + compat_sys_rt_sigreturn_wrapper: 56 + mov x0, sp 57 + mov x27, #0 // prevent syscall restart handling (why) 58 + b compat_sys_rt_sigreturn 59 + ENDPROC(compat_sys_rt_sigreturn_wrapper) 60 + 61 + compat_sys_sigaltstack_wrapper: 62 + ldr x2, [sp, #S_COMPAT_SP] 63 + b compat_do_sigaltstack 64 + ENDPROC(compat_sys_sigaltstack_wrapper) 65 + 66 + compat_sys_statfs64_wrapper: 67 + mov w3, #84 68 + cmp w1, #88 69 + csel w1, w3, w1, eq 70 + b compat_sys_statfs64 71 + ENDPROC(compat_sys_statfs64_wrapper) 72 + 73 + compat_sys_fstatfs64_wrapper: 74 + mov w3, #84 75 + cmp w1, #88 76 + csel w1, w3, w1, eq 77 + b compat_sys_fstatfs64 78 + ENDPROC(compat_sys_fstatfs64_wrapper) 79 + 80 + /* 81 + * Wrappers for AArch32 syscalls that either take 64-bit parameters 82 + * in registers or that take 32-bit parameters which require sign 83 + * extension. 84 + */ 85 + compat_sys_lseek_wrapper: 86 + sxtw x1, w1 87 + b sys_lseek 88 + ENDPROC(compat_sys_lseek_wrapper) 89 + 90 + compat_sys_pread64_wrapper: 91 + orr x3, x4, x5, lsl #32 92 + b sys_pread64 93 + ENDPROC(compat_sys_pread64_wrapper) 94 + 95 + compat_sys_pwrite64_wrapper: 96 + orr x3, x4, x5, lsl #32 97 + b sys_pwrite64 98 + ENDPROC(compat_sys_pwrite64_wrapper) 99 + 100 + compat_sys_truncate64_wrapper: 101 + orr x1, x2, x3, lsl #32 102 + b sys_truncate 103 + ENDPROC(compat_sys_truncate64_wrapper) 104 + 105 + compat_sys_ftruncate64_wrapper: 106 + orr x1, x2, x3, lsl #32 107 + b sys_ftruncate 108 + ENDPROC(compat_sys_ftruncate64_wrapper) 109 + 110 + compat_sys_readahead_wrapper: 111 + orr x1, x2, x3, lsl #32 112 + mov w2, w4 113 + b sys_readahead 114 + ENDPROC(compat_sys_readahead_wrapper) 115 + 116 + compat_sys_lookup_dcookie: 117 + orr x0, x0, x1, lsl #32 118 + mov w1, w2 119 + mov w2, w3 120 + b sys_lookup_dcookie 121 + ENDPROC(compat_sys_lookup_dcookie) 122 + 123 + compat_sys_fadvise64_64_wrapper: 124 + mov w6, w1 125 + orr x1, x2, x3, lsl #32 126 + orr x2, x4, x5, lsl #32 127 + mov w3, w6 128 + b sys_fadvise64_64 129 + ENDPROC(compat_sys_fadvise64_64_wrapper) 130 + 131 + compat_sys_sync_file_range2_wrapper: 132 + orr x2, x2, x3, lsl #32 133 + orr x3, x4, x5, lsl #32 134 + b sys_sync_file_range2 135 + ENDPROC(compat_sys_sync_file_range2_wrapper) 136 + 137 + compat_sys_fallocate_wrapper: 138 + orr x2, x2, x3, lsl #32 139 + orr x3, x4, x5, lsl #32 140 + b sys_fallocate 141 + ENDPROC(compat_sys_fallocate_wrapper) 142 + 143 + compat_sys_fanotify_mark_wrapper: 144 + orr x2, x2, x3, lsl #32 145 + mov w3, w4 146 + mov w4, w5 147 + b sys_fanotify_mark 148 + ENDPROC(compat_sys_fanotify_mark_wrapper) 149 + 150 + /* 151 + * Use the compat system call wrappers. 152 + */ 153 + #define sys_fork compat_sys_fork_wrapper 154 + #define sys_open compat_sys_open 155 + #define sys_execve compat_sys_execve_wrapper 156 + #define sys_lseek compat_sys_lseek_wrapper 157 + #define sys_mount compat_sys_mount 158 + #define sys_ptrace compat_sys_ptrace 159 + #define sys_times compat_sys_times 160 + #define sys_ioctl compat_sys_ioctl 161 + #define sys_fcntl compat_sys_fcntl 162 + #define sys_ustat compat_sys_ustat 163 + #define sys_sigaction compat_sys_sigaction 164 + #define sys_sigsuspend compat_sys_sigsuspend 165 + #define sys_sigpending compat_sys_sigpending 166 + #define sys_setrlimit compat_sys_setrlimit 167 + #define sys_getrusage compat_sys_getrusage 168 + #define sys_gettimeofday compat_sys_gettimeofday 169 + #define sys_settimeofday compat_sys_settimeofday 170 + #define sys_statfs compat_sys_statfs 171 + #define sys_fstatfs compat_sys_fstatfs 172 + #define sys_setitimer compat_sys_setitimer 173 + #define sys_getitimer compat_sys_getitimer 174 + #define sys_newstat compat_sys_newstat 175 + #define sys_newlstat compat_sys_newlstat 176 + #define sys_newfstat compat_sys_newfstat 177 + #define sys_wait4 compat_sys_wait4 178 + #define sys_sysinfo compat_sys_sysinfo 179 + #define sys_sigreturn compat_sys_sigreturn_wrapper 180 + #define sys_clone compat_sys_clone_wrapper 181 + #define sys_adjtimex compat_sys_adjtimex 182 + #define sys_sigprocmask compat_sys_sigprocmask 183 + #define sys_getdents compat_sys_getdents 184 + #define sys_select compat_sys_select 185 + #define sys_readv compat_sys_readv 186 + #define sys_writev compat_sys_writev 187 + #define sys_sysctl compat_sys_sysctl 188 + #define sys_sched_rr_get_interval compat_sys_sched_rr_get_interval 189 + #define sys_nanosleep compat_sys_nanosleep 190 + #define sys_rt_sigreturn compat_sys_rt_sigreturn_wrapper 191 + #define sys_rt_sigaction compat_sys_rt_sigaction 192 + #define sys_rt_sigprocmask compat_sys_rt_sigprocmask 193 + #define sys_rt_sigpending compat_sys_rt_sigpending 194 + #define sys_rt_sigtimedwait compat_sys_rt_sigtimedwait 195 + #define sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo 196 + #define sys_rt_sigsuspend compat_sys_rt_sigsuspend 197 + #define sys_pread64 compat_sys_pread64_wrapper 198 + #define sys_pwrite64 compat_sys_pwrite64_wrapper 199 + #define sys_sigaltstack compat_sys_sigaltstack_wrapper 200 + #define sys_sendfile compat_sys_sendfile 201 + #define sys_vfork compat_sys_vfork_wrapper 202 + #define sys_getrlimit compat_sys_getrlimit 203 + #define sys_mmap2 sys_mmap_pgoff 204 + #define sys_truncate64 compat_sys_truncate64_wrapper 205 + #define sys_ftruncate64 compat_sys_ftruncate64_wrapper 206 + #define sys_getdents64 compat_sys_getdents64 207 + #define sys_fcntl64 compat_sys_fcntl64 208 + #define sys_readahead compat_sys_readahead_wrapper 209 + #define sys_futex compat_sys_futex 210 + #define sys_sched_setaffinity compat_sys_sched_setaffinity 211 + #define sys_sched_getaffinity compat_sys_sched_getaffinity 212 + #define sys_io_setup compat_sys_io_setup 213 + #define sys_io_getevents compat_sys_io_getevents 214 + #define sys_io_submit compat_sys_io_submit 215 + #define sys_lookup_dcookie compat_sys_lookup_dcookie 216 + #define sys_timer_create compat_sys_timer_create 217 + #define sys_timer_settime compat_sys_timer_settime 218 + #define sys_timer_gettime compat_sys_timer_gettime 219 + #define sys_clock_settime compat_sys_clock_settime 220 + #define sys_clock_gettime compat_sys_clock_gettime 221 + #define sys_clock_getres compat_sys_clock_getres 222 + #define sys_clock_nanosleep compat_sys_clock_nanosleep 223 + #define sys_statfs64 compat_sys_statfs64_wrapper 224 + #define sys_fstatfs64 compat_sys_fstatfs64_wrapper 225 + #define sys_utimes compat_sys_utimes 226 + #define sys_fadvise64_64 compat_sys_fadvise64_64_wrapper 227 + #define sys_mq_open compat_sys_mq_open 228 + #define sys_mq_timedsend compat_sys_mq_timedsend 229 + #define sys_mq_timedreceive compat_sys_mq_timedreceive 230 + #define sys_mq_notify compat_sys_mq_notify 231 + #define sys_mq_getsetattr compat_sys_mq_getsetattr 232 + #define sys_waitid compat_sys_waitid 233 + #define sys_recv compat_sys_recv 234 + #define sys_recvfrom compat_sys_recvfrom 235 + #define sys_setsockopt compat_sys_setsockopt 236 + #define sys_getsockopt compat_sys_getsockopt 237 + #define sys_sendmsg compat_sys_sendmsg 238 + #define sys_recvmsg compat_sys_recvmsg 239 + #define sys_semctl compat_sys_semctl 240 + #define sys_msgsnd compat_sys_msgsnd 241 + #define sys_msgrcv compat_sys_msgrcv 242 + #define sys_msgctl compat_sys_msgctl 243 + #define sys_shmat compat_sys_shmat 244 + #define sys_shmctl compat_sys_shmctl 245 + #define sys_keyctl compat_sys_keyctl 246 + #define sys_semtimedop compat_sys_semtimedop 247 + #define sys_mbind compat_sys_mbind 248 + #define sys_get_mempolicy compat_sys_get_mempolicy 249 + #define sys_set_mempolicy compat_sys_set_mempolicy 250 + #define sys_openat compat_sys_openat 251 + #define sys_futimesat compat_sys_futimesat 252 + #define sys_pselect6 compat_sys_pselect6 253 + #define sys_ppoll compat_sys_ppoll 254 + #define sys_set_robust_list compat_sys_set_robust_list 255 + #define sys_get_robust_list compat_sys_get_robust_list 256 + #define sys_sync_file_range2 compat_sys_sync_file_range2_wrapper 257 + #define sys_vmsplice compat_sys_vmsplice 258 + #define sys_move_pages compat_sys_move_pages 259 + #define sys_epoll_pwait compat_sys_epoll_pwait 260 + #define sys_kexec_load compat_sys_kexec_load 261 + #define sys_utimensat compat_sys_utimensat 262 + #define sys_signalfd compat_sys_signalfd 263 + #define sys_fallocate compat_sys_fallocate_wrapper 264 + #define sys_timerfd_settime compat_sys_timerfd_settime 265 + #define sys_timerfd_gettime compat_sys_timerfd_gettime 266 + #define sys_signalfd4 compat_sys_signalfd4 267 + #define sys_preadv compat_sys_preadv 268 + #define sys_pwritev compat_sys_pwritev 269 + #define sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo 270 + #define sys_recvmmsg compat_sys_recvmmsg 271 + #define sys_fanotify_mark compat_sys_fanotify_mark_wrapper 272 + 273 + #undef __SYSCALL 274 + #define __SYSCALL(x, y) .quad y // x 275 + #define __SYSCALL_COMPAT 276 + 277 + /* 278 + * The system calls table must be 4KB aligned. 279 + */ 280 + .align 12 281 + ENTRY(compat_sys_call_table) 282 + #include <asm/unistd.h>
+164
arch/arm64/kernel/sys_compat.c
··· 1 + /* 2 + * Based on arch/arm/kernel/sys_arm.c 3 + * 4 + * Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c 5 + * Copyright (C) 1995, 1996 Russell King. 6 + * Copyright (C) 2012 ARM Ltd. 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + */ 20 + 21 + #define __SYSCALL_COMPAT 22 + 23 + #include <linux/compat.h> 24 + #include <linux/personality.h> 25 + #include <linux/sched.h> 26 + #include <linux/slab.h> 27 + #include <linux/syscalls.h> 28 + #include <linux/uaccess.h> 29 + 30 + #include <asm/cacheflush.h> 31 + #include <asm/unistd.h> 32 + 33 + asmlinkage int compat_sys_fork(struct pt_regs *regs) 34 + { 35 + return do_fork(SIGCHLD, regs->compat_sp, regs, 0, NULL, NULL); 36 + } 37 + 38 + asmlinkage int compat_sys_clone(unsigned long clone_flags, unsigned long newsp, 39 + int __user *parent_tidptr, int tls_val, 40 + int __user *child_tidptr, struct pt_regs *regs) 41 + { 42 + if (!newsp) 43 + newsp = regs->compat_sp; 44 + 45 + return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr); 46 + } 47 + 48 + asmlinkage int compat_sys_vfork(struct pt_regs *regs) 49 + { 50 + return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->compat_sp, 51 + regs, 0, NULL, NULL); 52 + } 53 + 54 + asmlinkage int compat_sys_execve(const char __user *filenamei, 55 + compat_uptr_t argv, compat_uptr_t envp, 56 + struct pt_regs *regs) 57 + { 58 + int error; 59 + char * filename; 60 + 61 + filename = getname(filenamei); 62 + error = PTR_ERR(filename); 63 + if (IS_ERR(filename)) 64 + goto out; 65 + error = compat_do_execve(filename, compat_ptr(argv), compat_ptr(envp), 66 + regs); 67 + putname(filename); 68 + out: 69 + return error; 70 + } 71 + 72 + asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid, 73 + struct compat_timespec __user *interval) 74 + { 75 + struct timespec t; 76 + int ret; 77 + mm_segment_t old_fs = get_fs(); 78 + 79 + set_fs(KERNEL_DS); 80 + ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t); 81 + set_fs(old_fs); 82 + if (put_compat_timespec(&t, interval)) 83 + return -EFAULT; 84 + return ret; 85 + } 86 + 87 + asmlinkage int compat_sys_sendfile(int out_fd, int in_fd, 88 + compat_off_t __user *offset, s32 count) 89 + { 90 + mm_segment_t old_fs = get_fs(); 91 + int ret; 92 + off_t of; 93 + 94 + if (offset && get_user(of, offset)) 95 + return -EFAULT; 96 + 97 + set_fs(KERNEL_DS); 98 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, 99 + count); 100 + set_fs(old_fs); 101 + 102 + if (offset && put_user(of, offset)) 103 + return -EFAULT; 104 + return ret; 105 + } 106 + 107 + static inline void 108 + do_compat_cache_op(unsigned long start, unsigned long end, int flags) 109 + { 110 + struct mm_struct *mm = current->active_mm; 111 + struct vm_area_struct *vma; 112 + 113 + if (end < start || flags) 114 + return; 115 + 116 + down_read(&mm->mmap_sem); 117 + vma = find_vma(mm, start); 118 + if (vma && vma->vm_start < end) { 119 + if (start < vma->vm_start) 120 + start = vma->vm_start; 121 + if (end > vma->vm_end) 122 + end = vma->vm_end; 123 + up_read(&mm->mmap_sem); 124 + __flush_cache_user_range(start & PAGE_MASK, PAGE_ALIGN(end)); 125 + return; 126 + } 127 + up_read(&mm->mmap_sem); 128 + } 129 + 130 + /* 131 + * Handle all unrecognised system calls. 132 + */ 133 + long compat_arm_syscall(struct pt_regs *regs) 134 + { 135 + unsigned int no = regs->regs[7]; 136 + 137 + switch (no) { 138 + /* 139 + * Flush a region from virtual address 'r0' to virtual address 'r1' 140 + * _exclusive_. There is no alignment requirement on either address; 141 + * user space does not need to know the hardware cache layout. 142 + * 143 + * r2 contains flags. It should ALWAYS be passed as ZERO until it 144 + * is defined to be something else. For now we ignore it, but may 145 + * the fires of hell burn in your belly if you break this rule. ;) 146 + * 147 + * (at a later date, we may want to allow this call to not flush 148 + * various aspects of the cache. Passing '0' will guarantee that 149 + * everything necessary gets flushed to maintain consistency in 150 + * the specified region). 151 + */ 152 + case __ARM_NR_compat_cacheflush: 153 + do_compat_cache_op(regs->regs[0], regs->regs[1], regs->regs[2]); 154 + return 0; 155 + 156 + case __ARM_NR_compat_set_tls: 157 + current->thread.tp_value = regs->regs[0]; 158 + asm ("msr tpidrro_el0, %0" : : "r" (regs->regs[0])); 159 + return 0; 160 + 161 + default: 162 + return -ENOSYS; 163 + } 164 + }