Skip to content

Commit 27d83e6

Browse files
mrutland-armwildea01
authored andcommitted
arm64: introduce syscall_fn_t
In preparation for invoking arbitrary syscalls from C code, let's define a type for an arbitrary syscall, matching the parameter passing rules of the AAPCS. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 3085e16 commit 27d83e6

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎arch/arm64/include/asm/syscall.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
#include <linux/compat.h>
2121
#include <linux/err.h>
2222

23-
extern const void *sys_call_table[];
23+
typedef long (*syscall_fn_t)(unsigned long, unsigned long,
24+
unsigned long, unsigned long,
25+
unsigned long, unsigned long);
26+
27+
extern const syscall_fn_t sys_call_table[];
2428

2529
static inline int syscall_get_nr(struct task_struct *task,
2630
struct pt_regs *regs)

‎arch/arm64/kernel/sys.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
#include <linux/sched.h>
2626
#include <linux/slab.h>
2727
#include <linux/syscalls.h>
28+
2829
#include <asm/cpufeature.h>
30+
#include <asm/syscall.h>
2931

3032
asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
3133
unsigned long prot, unsigned long flags,
@@ -52,13 +54,13 @@ asmlinkage long sys_rt_sigreturn(void);
5254
#define sys_personality sys_arm64_personality
5355

5456
#undef __SYSCALL
55-
#define __SYSCALL(nr, sym) [nr] = sym,
57+
#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)sym,
5658

5759
/*
5860
* The sys_call_table array must be 4K aligned to be accessible from
5961
* kernel/entry.S.
6062
*/
61-
void * const sys_call_table[__NR_syscalls] __aligned(4096) = {
62-
[0 ... __NR_syscalls - 1] = sys_ni_syscall,
63+
const syscall_fn_t sys_call_table[__NR_syscalls] __aligned(4096) = {
64+
[0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
6365
#include <asm/unistd.h>
6466
};

‎arch/arm64/kernel/sys32.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <linux/compiler.h>
2626
#include <linux/syscalls.h>
2727

28+
#include <asm/syscall.h>
29+
2830
asmlinkage long compat_sys_sigreturn(void);
2931
asmlinkage long compat_sys_rt_sigreturn(void);
3032
asmlinkage long compat_sys_statfs64_wrapper(void);
@@ -40,13 +42,13 @@ asmlinkage long compat_sys_fallocate_wrapper(void);
4042
asmlinkage long compat_sys_mmap2_wrapper(void);
4143

4244
#undef __SYSCALL
43-
#define __SYSCALL(nr, sym) [nr] = sym,
45+
#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)sym,
4446

4547
/*
4648
* The sys_call_table array must be 4K aligned to be accessible from
4749
* kernel/entry.S.
4850
*/
49-
void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
50-
[0 ... __NR_compat_syscalls - 1] = sys_ni_syscall,
51+
const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
52+
[0 ... __NR_compat_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
5153
#include <asm/unistd32.h>
5254
};

0 commit comments

Comments
 (0)