Commit b16c8a68 authored by Yury Norov's avatar Yury Norov Committed by Jinjie Ruan
Browse files

arm64: ilp32: introduce syscall table for ILP32

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8JVJ3
CVE: NA

Reference: https://github.com/norov/linux/commits/ilp32-5.2



--------------------------------

Depending on the personality of the task, syscalls has to be dispatched
to either aarch64, aarch32 or aarch64/ilp32 syscall handlers. We add
the support of ILP32 mode in this series, therefore introduce
corresponding syscall table.

Some system calls are wired to aarch32 syscall handlers, as listed in
arch/arm64/kernel/sys_ilp32.c.

For aarch64/ilp32, top halves of syscall arguments are meaningless
anthough not zeroed by hardware. Do that in the delouse_pt_regs()
routine to avoid passing garbage by userspace.

Signed-off-by: default avatarYury Norov <ynorov@caviumnetworks.com>
Signed-off-by: default avatarYury Norov <ynorov@marvell.com>
Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Signed-off-by: default avatarChen Jiahao <chenjiahao16@huawei.com>

Conflicts:
	arch/arm64/kernel/Makefile
	arch/arm64/kernel/syscall.c

Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
parent 50692114
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@ extern const syscall_fn_t sys_call_table[];
extern const syscall_fn_t a32_sys_call_table[];
#endif

#ifdef CONFIG_ARM64_ILP32
extern const syscall_fn_t ilp32_sys_call_table[];
#endif

static inline int syscall_get_nr(struct task_struct *task,
				 struct pt_regs *regs)
{
+6 −1
Original line number Diff line number Diff line
@@ -2,9 +2,14 @@
/*
 * Copyright (C) 2012 ARM Ltd.
 */
#ifdef CONFIG_AARCH32_EL0

#ifdef CONFIG_COMPAT
#define __ARCH_WANT_COMPAT_STAT
#define __ARCH_WANT_COMPAT_STAT64
#define __ARCH_WANT_SYS_LLSEEK
#endif

#ifdef CONFIG_AARCH32_EL0
#define __ARCH_WANT_SYS_GETHOSTNAME
#define __ARCH_WANT_SYS_PAUSE
#define __ARCH_WANT_SYS_GETPGRP
+14 −1
Original line number Diff line number Diff line
@@ -15,9 +15,22 @@
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * AARCH32 interface for ILP32 syscalls.
 */
#if defined(__ILP32__) || defined(__SYSCALL_COMPAT)
#define __ARCH_WANT_SYNC_FILE_RANGE2
#endif

/*
 * AARCH64/ILP32 is introduced after the following syscalls were deprecated.
 */
#if !(defined(__ILP32__) || defined(__SYSCALL_COMPAT))
#define __ARCH_WANT_RENAMEAT
#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_SET_GET_RLIMIT
#endif

#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_TIME32_SYSCALLS
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_MEMFD_SECRET
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ obj-$(CONFIG_AARCH32_EL0) += binfmt_elf32.o sys32.o signal32.o \
obj-$(CONFIG_AARCH32_EL0)		+= sigreturn32.o
obj-$(CONFIG_COMPAT_ALIGNMENT_FIXUPS)	+= compat_alignment.o
obj-$(CONFIG_KUSER_HELPERS)		+= kuser32.o
obj-$(CONFIG_ARM64_ILP32)		+= binfmt_ilp32.o
obj-$(CONFIG_ARM64_ILP32)		+= binfmt_ilp32.o sys_ilp32.o
obj-$(CONFIG_COMPAT)			+= sys32_common.o
obj-$(CONFIG_FUNCTION_TRACER)		+= ftrace.o entry-ftrace.o
obj-$(CONFIG_MODULES)			+= module.o module-plts.o
+76 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

/*
 * AArch64- ILP32 specific system calls implementation
 * Copyright (C) 2018 Marvell.
 */

#define __SYSCALL_COMPAT

#include <linux/compat.h>
#include <linux/compiler.h>
#include <linux/syscalls.h>

#include <asm/syscall.h>

/*
 * AARCH32 requires 4-page alignment for shared memory,
 * but AARCH64 - only 1 page. This is the only difference
 * between compat and native sys_shmat(). So ILP32 just pick
 * AARCH64 version.
 */
#define __arm64_compat_sys_shmat		__arm64_sys_shmat

/*
 * ILP32 needs special handling for some ptrace requests.
 */
#define __arm64_sys_ptrace			__arm64_compat_sys_ptrace

/*
 * Using AARCH32 interface for syscalls that take 64-bit
 * parameters in registers.
 */
#define __arm64_compat_sys_fadvise64_64		__arm64_compat_sys_aarch32_fadvise64_64
#define __arm64_compat_sys_fallocate		__arm64_compat_sys_aarch32_fallocate
#define __arm64_compat_sys_ftruncate64		__arm64_compat_sys_aarch32_ftruncate64
#define __arm64_compat_sys_pread64		__arm64_compat_sys_aarch32_pread64
#define __arm64_compat_sys_pwrite64		__arm64_compat_sys_aarch32_pwrite64
#define __arm64_compat_sys_readahead		__arm64_compat_sys_aarch32_readahead
#define __arm64_compat_sys_sync_file_range2	__arm64_compat_sys_aarch32_sync_file_range2
#define __arm64_compat_sys_truncate64		__arm64_compat_sys_aarch32_truncate64
#define __arm64_sys_mmap2			__arm64_compat_sys_aarch32_mmap2

/*
 * Using AARCH32 interface for syscalls that take the size of
 * struct statfs as an argument, as it's calculated differently
 * in kernel and user spaces.
 */
#define __arm64_compat_sys_fstatfs64		__arm64_compat_sys_aarch32_fstatfs64
#define __arm64_compat_sys_statfs64		__arm64_compat_sys_aarch32_statfs64

/*
 * Using old interface for IPC syscalls that should handle IPC_64 flag.
 */
#define __arm64_compat_sys_semctl		__arm64_compat_sys_old_semctl
#define __arm64_compat_sys_msgctl		__arm64_compat_sys_old_msgctl
#define __arm64_compat_sys_shmctl		__arm64_compat_sys_old_shmctl

/*
 * Wrappers to pass the pt_regs argument.
 */
#define sys_personality		sys_arm64_personality

asmlinkage long sys_ni_syscall(const struct pt_regs *);
#define __arm64_sys_ni_syscall	sys_ni_syscall

#undef __SYSCALL
#define __SYSCALL(nr, sym)	asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd.h>

#undef __SYSCALL
#define __SYSCALL(nr, sym)	[nr] = (syscall_fn_t)__arm64_##sym,

const syscall_fn_t ilp32_sys_call_table[__NR_syscalls] = {
	[0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall,
#include <asm/unistd.h>
};
Loading