2 * arch/arm64/kernel/sys32.c
4 * Copyright (C) 2015 ARM Ltd.
6 * This program is free software(void); you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http(void);//www.gnu.org/licenses/>.
20 * Needed to avoid conflicting __NR_* macros between uapi/asm/unistd.h and
23 #define __COMPAT_SYSCALL_NR
25 #include <linux/compat.h>
26 #include <linux/compiler.h>
27 #include <linux/syscalls.h>
29 #include <asm/syscall.h>
31 asmlinkage
long compat_sys_sigreturn(void);
32 asmlinkage
long compat_sys_rt_sigreturn(void);
34 COMPAT_SYSCALL_DEFINE3(aarch32_statfs64
, const char __user
*, pathname
,
35 compat_size_t
, sz
, struct compat_statfs64 __user
*, buf
)
38 * 32-bit ARM applies an OABI compatibility fixup to statfs64 and
39 * fstatfs64 regardless of whether OABI is in use, and therefore
40 * arbitrary binaries may rely upon it, so we must do the same.
41 * For more details, see commit:
43 * 713c481519f19df9 ("[ARM] 3108/2: old ABI compat: statfs64 and
49 return kcompat_sys_statfs64(pathname
, sz
, buf
);
52 COMPAT_SYSCALL_DEFINE3(aarch32_fstatfs64
, unsigned int, fd
, compat_size_t
, sz
,
53 struct compat_statfs64 __user
*, buf
)
55 /* see aarch32_statfs64 */
59 return kcompat_sys_fstatfs64(fd
, sz
, buf
);
63 * Note: off_4k is always in units of 4K. If we can't do the
64 * requested offset because it is not page-aligned, we return -EINVAL.
66 COMPAT_SYSCALL_DEFINE6(aarch32_mmap2
, unsigned long, addr
, unsigned long, len
,
67 unsigned long, prot
, unsigned long, flags
,
68 unsigned long, fd
, unsigned long, off_4k
)
70 if (off_4k
& (~PAGE_MASK
>> 12))
73 off_4k
>>= (PAGE_SHIFT
- 12);
75 return ksys_mmap_pgoff(addr
, len
, prot
, flags
, fd
, off_4k
);
78 #ifdef CONFIG_CPU_BIG_ENDIAN
79 #define arg_u32p(name) u32, name##_hi, u32, name##_lo
81 #define arg_u32p(name) u32, name##_lo, u32, name##_hi
84 #define arg_u64(name) (((u64)name##_hi << 32) | name##_lo)
86 COMPAT_SYSCALL_DEFINE6(aarch32_pread64
, unsigned int, fd
, char __user
*, buf
,
87 size_t, count
, u32
, __pad
, arg_u32p(pos
))
89 return ksys_pread64(fd
, buf
, count
, arg_u64(pos
));
92 COMPAT_SYSCALL_DEFINE6(aarch32_pwrite64
, unsigned int, fd
,
93 const char __user
*, buf
, size_t, count
, u32
, __pad
,
96 return ksys_pwrite64(fd
, buf
, count
, arg_u64(pos
));
99 COMPAT_SYSCALL_DEFINE4(aarch32_truncate64
, const char __user
*, pathname
,
100 u32
, __pad
, arg_u32p(length
))
102 return ksys_truncate(pathname
, arg_u64(length
));
105 COMPAT_SYSCALL_DEFINE4(aarch32_ftruncate64
, unsigned int, fd
, u32
, __pad
,
108 return ksys_ftruncate(fd
, arg_u64(length
));
111 COMPAT_SYSCALL_DEFINE5(aarch32_readahead
, int, fd
, u32
, __pad
,
112 arg_u32p(offset
), size_t, count
)
114 return ksys_readahead(fd
, arg_u64(offset
), count
);
117 COMPAT_SYSCALL_DEFINE6(aarch32_fadvise64_64
, int, fd
, int, advice
,
118 arg_u32p(offset
), arg_u32p(len
))
120 return ksys_fadvise64_64(fd
, arg_u64(offset
), arg_u64(len
), advice
);
123 COMPAT_SYSCALL_DEFINE6(aarch32_sync_file_range2
, int, fd
, unsigned int, flags
,
124 arg_u32p(offset
), arg_u32p(nbytes
))
126 return ksys_sync_file_range(fd
, arg_u64(offset
), arg_u64(nbytes
),
130 COMPAT_SYSCALL_DEFINE6(aarch32_fallocate
, int, fd
, int, mode
,
131 arg_u32p(offset
), arg_u32p(len
))
133 return ksys_fallocate(fd
, mode
, arg_u64(offset
), arg_u64(len
));
137 #define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
138 #include <asm/unistd32.h>
141 #define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
143 const syscall_fn_t compat_sys_call_table
[__NR_compat_syscalls
] = {
144 [0 ... __NR_compat_syscalls
- 1] = __arm64_sys_ni_syscall
,
145 #include <asm/unistd32.h>