~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/include/asm/syscall_wrapper.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * syscall_wrapper.h - riscv specific wrappers to syscall definitions
  4  *
  5  * Based on arch/arm64/include/syscall_wrapper.h
  6  */
  7 
  8 #ifndef __ASM_SYSCALL_WRAPPER_H
  9 #define __ASM_SYSCALL_WRAPPER_H
 10 
 11 #include <asm/ptrace.h>
 12 
 13 asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *);
 14 
 15 #ifdef CONFIG_64BIT
 16 
 17 #define __SYSCALL_SE_DEFINEx(x, prefix, name, ...)                                      \
 18         static long __se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__));                \
 19         static long __se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
 20 
 21 #define SC_RISCV_REGS_TO_ARGS(x, ...)                                                   \
 22         __MAP(x,__SC_ARGS                                                               \
 23               ,,regs->orig_a0,,regs->a1,,regs->a2                                       \
 24               ,,regs->a3,,regs->a4,,regs->a5,,regs->a6)
 25 
 26 #else
 27 /*
 28  * Use type aliasing to ensure registers a0-a6 are correctly passed to the syscall
 29  * implementation when >word-size arguments are used.
 30  */
 31 #define __SYSCALL_SE_DEFINEx(x, prefix, name, ...)                                      \
 32         __diag_push();                                                                  \
 33         __diag_ignore(GCC, 8, "-Wattribute-alias",                                      \
 34                         "Type aliasing is used to sanitize syscall arguments");         \
 35         static long __se_##prefix##name(ulong, ulong, ulong, ulong, ulong, ulong,       \
 36                                         ulong)                                          \
 37                         __attribute__((alias(__stringify(___se_##prefix##name))));      \
 38         __diag_pop();                                                                   \
 39         static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))       \
 40                         __used;                                                         \
 41         static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
 42 
 43 #define SC_RISCV_REGS_TO_ARGS(x, ...) \
 44         regs->orig_a0,regs->a1,regs->a2,regs->a3,regs->a4,regs->a5,regs->a6
 45 
 46 #endif /* CONFIG_64BIT */
 47 
 48 #ifdef CONFIG_COMPAT
 49 
 50 #define COMPAT_SYSCALL_DEFINEx(x, name, ...)                                            \
 51         asmlinkage long __riscv_compat_sys##name(const struct pt_regs *regs);           \
 52         ALLOW_ERROR_INJECTION(__riscv_compat_sys##name, ERRNO);                         \
 53         static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));       \
 54         __SYSCALL_SE_DEFINEx(x, compat_sys, name, __VA_ARGS__)                          \
 55         {                                                                               \
 56                 return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));        \
 57         }                                                                               \
 58         asmlinkage long __riscv_compat_sys##name(const struct pt_regs *regs)            \
 59         {                                                                               \
 60                 return __se_compat_sys##name(SC_RISCV_REGS_TO_ARGS(x,__VA_ARGS__));     \
 61         }                                                                               \
 62         static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
 63 
 64 #define COMPAT_SYSCALL_DEFINE0(sname)                                                   \
 65         asmlinkage long __riscv_compat_sys_##sname(const struct pt_regs *__unused);     \
 66         ALLOW_ERROR_INJECTION(__riscv_compat_sys_##sname, ERRNO);                       \
 67         asmlinkage long __riscv_compat_sys_##sname(const struct pt_regs *__unused)
 68 
 69 #define COND_SYSCALL_COMPAT(name)                                                       \
 70         asmlinkage long __weak __riscv_compat_sys_##name(const struct pt_regs *regs);   \
 71         asmlinkage long __weak __riscv_compat_sys_##name(const struct pt_regs *regs)    \
 72         {                                                                               \
 73                 return sys_ni_syscall();                                                \
 74         }
 75 
 76 #endif /* CONFIG_COMPAT */
 77 
 78 #define __SYSCALL_DEFINEx(x, name, ...)                                         \
 79         asmlinkage long __riscv_sys##name(const struct pt_regs *regs);          \
 80         ALLOW_ERROR_INJECTION(__riscv_sys##name, ERRNO);                        \
 81         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));      \
 82         __SYSCALL_SE_DEFINEx(x, sys, name, __VA_ARGS__)                         \
 83         {                                                                       \
 84                 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));      \
 85                 __MAP(x,__SC_TEST,__VA_ARGS__);                                 \
 86                 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__));               \
 87                 return ret;                                                     \
 88         }                                                                       \
 89         asmlinkage long __riscv_sys##name(const struct pt_regs *regs)           \
 90         {                                                                       \
 91                 return __se_sys##name(SC_RISCV_REGS_TO_ARGS(x,__VA_ARGS__));    \
 92         }                                                                       \
 93         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
 94 
 95 #define SYSCALL_DEFINE0(sname)                                                  \
 96         SYSCALL_METADATA(_##sname, 0);                                          \
 97         asmlinkage long __riscv_sys_##sname(const struct pt_regs *__unused);    \
 98         ALLOW_ERROR_INJECTION(__riscv_sys_##sname, ERRNO);                      \
 99         asmlinkage long __riscv_sys_##sname(const struct pt_regs *__unused)
100 
101 #define COND_SYSCALL(name)                                                      \
102         asmlinkage long __weak __riscv_sys_##name(const struct pt_regs *regs);  \
103         asmlinkage long __weak __riscv_sys_##name(const struct pt_regs *regs)   \
104         {                                                                       \
105                 return sys_ni_syscall();                                        \
106         }
107 
108 #endif /* __ASM_SYSCALL_WRAPPER_H */
109 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php