mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
syscall_get_arguments() returns 'regs->orig_x0' for the first system call argument so as to avoid aliasing with the syscall return value in 'regs->regs[0]' on the return path, however the actual syscall invocation passes 'regs->regs[0]' as the first parameter. Although the two registers should be kept in sync during syscall entry for native tasks, pass 'regs->orig_x0' as the first syscall parameter for consistency with the syscall argument APIs. Compat tasks continue to use 'regs->regs[0]' for compatibility with the behaviour of the 32-bit kernel. Suggested-by: Jinjie Ruan <[email protected]> Signed-off-by: Will Deacon <[email protected]>
88 lines
3.3 KiB
C
88 lines
3.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* syscall_wrapper.h - arm64 specific wrappers to syscall definitions
|
|
*
|
|
* Based on arch/x86/include/asm_syscall_wrapper.h
|
|
*/
|
|
|
|
#ifndef __ASM_SYSCALL_WRAPPER_H
|
|
#define __ASM_SYSCALL_WRAPPER_H
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
#define COMPAT_SC_ARM64_REGS_TO_ARGS(x, ...) \
|
|
__MAP(x,__SC_ARGS \
|
|
,,regs->regs[0],,regs->regs[1],,regs->regs[2] \
|
|
,,regs->regs[3],,regs->regs[4],,regs->regs[5])
|
|
|
|
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
|
|
asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs); \
|
|
ALLOW_ERROR_INJECTION(__arm64_compat_sys##name, ERRNO); \
|
|
static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
|
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
|
|
asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs) \
|
|
{ \
|
|
return __se_compat_sys##name(COMPAT_SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \
|
|
} \
|
|
static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
|
{ \
|
|
return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
|
|
} \
|
|
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
|
|
|
#define COMPAT_SYSCALL_DEFINE0(sname) \
|
|
asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \
|
|
ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
|
|
asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused)
|
|
|
|
#define COND_SYSCALL_COMPAT(name) \
|
|
asmlinkage long __arm64_compat_sys_##name(const struct pt_regs *regs); \
|
|
asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \
|
|
{ \
|
|
return sys_ni_syscall(); \
|
|
}
|
|
|
|
#endif /* CONFIG_COMPAT */
|
|
|
|
#define SC_ARM64_REGS_TO_ARGS(x, ...) \
|
|
__MAP(x,__SC_ARGS \
|
|
,,regs->orig_x0,,regs->regs[1],,regs->regs[2] \
|
|
,,regs->regs[3],,regs->regs[4],,regs->regs[5])
|
|
|
|
#define __SYSCALL_DEFINEx(x, name, ...) \
|
|
asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \
|
|
ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \
|
|
static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
|
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
|
|
asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \
|
|
{ \
|
|
return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \
|
|
} \
|
|
static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
|
{ \
|
|
long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
|
|
__MAP(x,__SC_TEST,__VA_ARGS__); \
|
|
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
|
|
return ret; \
|
|
} \
|
|
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
|
|
|
#define SYSCALL_DEFINE0(sname) \
|
|
SYSCALL_METADATA(_##sname, 0); \
|
|
asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \
|
|
ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
|
|
asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused)
|
|
|
|
#define COND_SYSCALL(name) \
|
|
asmlinkage long __arm64_sys_##name(const struct pt_regs *regs); \
|
|
asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
|
|
{ \
|
|
return sys_ni_syscall(); \
|
|
}
|
|
|
|
asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused);
|
|
|
|
#endif /* __ASM_SYSCALL_WRAPPER_H */
|