syscall.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Access to user system call parameters and results
  4. *
  5. * Copyright (C) 2008 Intel Corp. Shaohua Li <[email protected]>
  6. *
  7. * See asm-generic/syscall.h for descriptions of what we must do here.
  8. */
  9. #ifndef _ASM_SYSCALL_H
  10. #define _ASM_SYSCALL_H 1
  11. #include <uapi/linux/audit.h>
  12. #include <linux/sched.h>
  13. #include <linux/err.h>
  14. static inline long syscall_get_nr(struct task_struct *task,
  15. struct pt_regs *regs)
  16. {
  17. if ((long)regs->cr_ifs < 0) /* Not a syscall */
  18. return -1;
  19. return regs->r15;
  20. }
  21. static inline void syscall_rollback(struct task_struct *task,
  22. struct pt_regs *regs)
  23. {
  24. /* do nothing */
  25. }
  26. static inline long syscall_get_error(struct task_struct *task,
  27. struct pt_regs *regs)
  28. {
  29. return regs->r10 == -1 ? -regs->r8:0;
  30. }
  31. static inline long syscall_get_return_value(struct task_struct *task,
  32. struct pt_regs *regs)
  33. {
  34. return regs->r8;
  35. }
  36. static inline void syscall_set_return_value(struct task_struct *task,
  37. struct pt_regs *regs,
  38. int error, long val)
  39. {
  40. if (error) {
  41. /* error < 0, but ia64 uses > 0 return value */
  42. regs->r8 = -error;
  43. regs->r10 = -1;
  44. } else {
  45. regs->r8 = val;
  46. regs->r10 = 0;
  47. }
  48. }
  49. extern void syscall_get_arguments(struct task_struct *task,
  50. struct pt_regs *regs, unsigned long *args);
  51. static inline int syscall_get_arch(struct task_struct *task)
  52. {
  53. return AUDIT_ARCH_IA64;
  54. }
  55. #endif /* _ASM_SYSCALL_H */