syscall.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Access to user system call parameters and results
  4. *
  5. * See asm-generic/syscall.h for descriptions of what we must do here.
  6. */
  7. #ifndef _ASM_ARM_SYSCALL_H
  8. #define _ASM_ARM_SYSCALL_H
  9. #include <uapi/linux/audit.h> /* for AUDIT_ARCH_* */
  10. #include <linux/elf.h> /* for ELF_EM */
  11. #include <linux/err.h>
  12. #include <linux/sched.h>
  13. #include <asm/unistd.h>
  14. #define NR_syscalls (__NR_syscalls)
  15. extern const unsigned long sys_call_table[];
  16. static inline int syscall_get_nr(struct task_struct *task,
  17. struct pt_regs *regs)
  18. {
  19. if (IS_ENABLED(CONFIG_AEABI) && !IS_ENABLED(CONFIG_OABI_COMPAT))
  20. return task_thread_info(task)->abi_syscall;
  21. if (task_thread_info(task)->abi_syscall == -1)
  22. return -1;
  23. return task_thread_info(task)->abi_syscall & __NR_SYSCALL_MASK;
  24. }
  25. static inline bool __in_oabi_syscall(struct task_struct *task)
  26. {
  27. return IS_ENABLED(CONFIG_OABI_COMPAT) &&
  28. (task_thread_info(task)->abi_syscall & __NR_OABI_SYSCALL_BASE);
  29. }
  30. static inline bool in_oabi_syscall(void)
  31. {
  32. return __in_oabi_syscall(current);
  33. }
  34. static inline void syscall_rollback(struct task_struct *task,
  35. struct pt_regs *regs)
  36. {
  37. regs->ARM_r0 = regs->ARM_ORIG_r0;
  38. }
  39. static inline long syscall_get_error(struct task_struct *task,
  40. struct pt_regs *regs)
  41. {
  42. unsigned long error = regs->ARM_r0;
  43. return IS_ERR_VALUE(error) ? error : 0;
  44. }
  45. static inline long syscall_get_return_value(struct task_struct *task,
  46. struct pt_regs *regs)
  47. {
  48. return regs->ARM_r0;
  49. }
  50. static inline void syscall_set_return_value(struct task_struct *task,
  51. struct pt_regs *regs,
  52. int error, long val)
  53. {
  54. regs->ARM_r0 = (long) error ? error : val;
  55. }
  56. #define SYSCALL_MAX_ARGS 7
  57. static inline void syscall_get_arguments(struct task_struct *task,
  58. struct pt_regs *regs,
  59. unsigned long *args)
  60. {
  61. args[0] = regs->ARM_ORIG_r0;
  62. args++;
  63. memcpy(args, &regs->ARM_r0 + 1, 5 * sizeof(args[0]));
  64. }
  65. static inline int syscall_get_arch(struct task_struct *task)
  66. {
  67. /* ARM tasks don't change audit architectures on the fly. */
  68. return AUDIT_ARCH_ARM;
  69. }
  70. #endif /* _ASM_ARM_SYSCALL_H */