mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
7fe33e9f66
This is a straight conversion from the old asm/unistd32.h into the format used by 32-bit arm and most other architectures, calling scripts to generate the asm/unistd32.h header and a new asm/syscalls32.h headers. I used a semi-automated text replacement method to do the conversion, and then used 'vimdiff' to synchronize the whitespace and the (unused) names of the non-compat syscalls with the arm version. There are two differences between the generated syscalls names and the old version: - the old asm/unistd32.h contained only a __NR_sync_file_range2 entry, while the arm32 version also defines __NR_arm_sync_file_range with the same number. I added this duplicate back in asm/unistd32.h. - __NR__sysctl was removed from the arm64 file a while ago, but all the tables still contain it. This should probably get removed everywhere but I added it here for consistency. On top of that, the arm64 version does not contain any references to the 32-bit OABI syscalls that are not supported by arm64. If we ever want to share the file between arm32 and arm64, it would not be hard to add support for both in one file. Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
132 lines
3.6 KiB
C
132 lines
3.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* arch/arm64/kernel/sys32.c
|
|
*
|
|
* Copyright (C) 2015 ARM Ltd.
|
|
*/
|
|
|
|
#include <linux/compat.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <asm/syscall.h>
|
|
#include <asm/unistd_compat_32.h>
|
|
|
|
asmlinkage long compat_sys_sigreturn(void);
|
|
asmlinkage long compat_sys_rt_sigreturn(void);
|
|
|
|
COMPAT_SYSCALL_DEFINE3(aarch32_statfs64, const char __user *, pathname,
|
|
compat_size_t, sz, struct compat_statfs64 __user *, buf)
|
|
{
|
|
/*
|
|
* 32-bit ARM applies an OABI compatibility fixup to statfs64 and
|
|
* fstatfs64 regardless of whether OABI is in use, and therefore
|
|
* arbitrary binaries may rely upon it, so we must do the same.
|
|
* For more details, see commit:
|
|
*
|
|
* 713c481519f19df9 ("[ARM] 3108/2: old ABI compat: statfs64 and
|
|
* fstatfs64")
|
|
*/
|
|
if (sz == 88)
|
|
sz = 84;
|
|
|
|
return kcompat_sys_statfs64(pathname, sz, buf);
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE3(aarch32_fstatfs64, unsigned int, fd, compat_size_t, sz,
|
|
struct compat_statfs64 __user *, buf)
|
|
{
|
|
/* see aarch32_statfs64 */
|
|
if (sz == 88)
|
|
sz = 84;
|
|
|
|
return kcompat_sys_fstatfs64(fd, sz, buf);
|
|
}
|
|
|
|
/*
|
|
* Note: off_4k is always in units of 4K. If we can't do the
|
|
* requested offset because it is not page-aligned, we return -EINVAL.
|
|
*/
|
|
COMPAT_SYSCALL_DEFINE6(aarch32_mmap2, unsigned long, addr, unsigned long, len,
|
|
unsigned long, prot, unsigned long, flags,
|
|
unsigned long, fd, unsigned long, off_4k)
|
|
{
|
|
if (off_4k & (~PAGE_MASK >> 12))
|
|
return -EINVAL;
|
|
|
|
off_4k >>= (PAGE_SHIFT - 12);
|
|
|
|
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off_4k);
|
|
}
|
|
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
#define arg_u32p(name) u32, name##_hi, u32, name##_lo
|
|
#else
|
|
#define arg_u32p(name) u32, name##_lo, u32, name##_hi
|
|
#endif
|
|
|
|
#define arg_u64(name) (((u64)name##_hi << 32) | name##_lo)
|
|
|
|
COMPAT_SYSCALL_DEFINE6(aarch32_pread64, unsigned int, fd, char __user *, buf,
|
|
size_t, count, u32, __pad, arg_u32p(pos))
|
|
{
|
|
return ksys_pread64(fd, buf, count, arg_u64(pos));
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE6(aarch32_pwrite64, unsigned int, fd,
|
|
const char __user *, buf, size_t, count, u32, __pad,
|
|
arg_u32p(pos))
|
|
{
|
|
return ksys_pwrite64(fd, buf, count, arg_u64(pos));
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE4(aarch32_truncate64, const char __user *, pathname,
|
|
u32, __pad, arg_u32p(length))
|
|
{
|
|
return ksys_truncate(pathname, arg_u64(length));
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE4(aarch32_ftruncate64, unsigned int, fd, u32, __pad,
|
|
arg_u32p(length))
|
|
{
|
|
return ksys_ftruncate(fd, arg_u64(length));
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE5(aarch32_readahead, int, fd, u32, __pad,
|
|
arg_u32p(offset), size_t, count)
|
|
{
|
|
return ksys_readahead(fd, arg_u64(offset), count);
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE6(aarch32_fadvise64_64, int, fd, int, advice,
|
|
arg_u32p(offset), arg_u32p(len))
|
|
{
|
|
return ksys_fadvise64_64(fd, arg_u64(offset), arg_u64(len), advice);
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE6(aarch32_sync_file_range2, int, fd, unsigned int, flags,
|
|
arg_u32p(offset), arg_u32p(nbytes))
|
|
{
|
|
return ksys_sync_file_range(fd, arg_u64(offset), arg_u64(nbytes),
|
|
flags);
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode,
|
|
arg_u32p(offset), arg_u32p(len))
|
|
{
|
|
return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
|
|
}
|
|
|
|
#define __SYSCALL_WITH_COMPAT(nr, sym, compat) __SYSCALL(nr, compat)
|
|
|
|
#undef __SYSCALL
|
|
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
|
|
#include <asm/syscall_table_32.h>
|
|
|
|
#undef __SYSCALL
|
|
#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
|
|
|
|
const syscall_fn_t compat_sys_call_table[__NR_compat32_syscalls] = {
|
|
[0 ... __NR_compat32_syscalls - 1] = __arm64_sys_ni_syscall,
|
|
#include <asm/syscall_table_32.h>
|
|
};
|