18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * syscall_wrapper.h - arm64 specific wrappers to syscall definitions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Based on arch/x86/include/asm_syscall_wrapper.h 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __ASM_SYSCALL_WRAPPER_H 98c2ecf20Sopenharmony_ci#define __ASM_SYSCALL_WRAPPER_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define SC_ARM64_REGS_TO_ARGS(x, ...) \ 148c2ecf20Sopenharmony_ci __MAP(x,__SC_ARGS \ 158c2ecf20Sopenharmony_ci ,,regs->regs[0],,regs->regs[1],,regs->regs[2] \ 168c2ecf20Sopenharmony_ci ,,regs->regs[3],,regs->regs[4],,regs->regs[5]) 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ 218c2ecf20Sopenharmony_ci asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs); \ 228c2ecf20Sopenharmony_ci ALLOW_ERROR_INJECTION(__arm64_compat_sys##name, ERRNO); \ 238c2ecf20Sopenharmony_ci static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ 248c2ecf20Sopenharmony_ci static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 258c2ecf20Sopenharmony_ci asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs) \ 268c2ecf20Sopenharmony_ci { \ 278c2ecf20Sopenharmony_ci return __se_compat_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ 288c2ecf20Sopenharmony_ci } \ 298c2ecf20Sopenharmony_ci static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 308c2ecf20Sopenharmony_ci { \ 318c2ecf20Sopenharmony_ci return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ 328c2ecf20Sopenharmony_ci } \ 338c2ecf20Sopenharmony_ci static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE0(sname) \ 368c2ecf20Sopenharmony_ci asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \ 378c2ecf20Sopenharmony_ci ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \ 388c2ecf20Sopenharmony_ci asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define COND_SYSCALL_COMPAT(name) \ 418c2ecf20Sopenharmony_ci asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \ 428c2ecf20Sopenharmony_ci { \ 438c2ecf20Sopenharmony_ci return sys_ni_syscall(); \ 448c2ecf20Sopenharmony_ci } 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define COMPAT_SYS_NI(name) \ 478c2ecf20Sopenharmony_ci SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#endif /* CONFIG_COMPAT */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define __SYSCALL_DEFINEx(x, name, ...) \ 528c2ecf20Sopenharmony_ci asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \ 538c2ecf20Sopenharmony_ci ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \ 548c2ecf20Sopenharmony_ci static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ 558c2ecf20Sopenharmony_ci static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 568c2ecf20Sopenharmony_ci asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \ 578c2ecf20Sopenharmony_ci { \ 588c2ecf20Sopenharmony_ci return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ 598c2ecf20Sopenharmony_ci } \ 608c2ecf20Sopenharmony_ci static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 618c2ecf20Sopenharmony_ci { \ 628c2ecf20Sopenharmony_ci long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ 638c2ecf20Sopenharmony_ci __MAP(x,__SC_TEST,__VA_ARGS__); \ 648c2ecf20Sopenharmony_ci __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ 658c2ecf20Sopenharmony_ci return ret; \ 668c2ecf20Sopenharmony_ci } \ 678c2ecf20Sopenharmony_ci static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define SYSCALL_DEFINE0(sname) \ 708c2ecf20Sopenharmony_ci SYSCALL_METADATA(_##sname, 0); \ 718c2ecf20Sopenharmony_ci asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \ 728c2ecf20Sopenharmony_ci ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \ 738c2ecf20Sopenharmony_ci asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define COND_SYSCALL(name) \ 768c2ecf20Sopenharmony_ci asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \ 778c2ecf20Sopenharmony_ci { \ 788c2ecf20Sopenharmony_ci return sys_ni_syscall(); \ 798c2ecf20Sopenharmony_ci } 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define SYS_NI(name) SYSCALL_ALIAS(__arm64_sys_##name, sys_ni_posix_timers); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#endif /* __ASM_SYSCALL_WRAPPER_H */ 84