syscall-generic.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Access to user system call parameters and results
  4. *
  5. * See asm-generic/syscall.h for function descriptions.
  6. *
  7. * Copyright (C) 2015 Mickaël Salaün <[email protected]>
  8. */
  9. #ifndef __UM_SYSCALL_GENERIC_H
  10. #define __UM_SYSCALL_GENERIC_H
  11. #include <asm/ptrace.h>
  12. #include <linux/err.h>
  13. #include <linux/sched.h>
  14. #include <sysdep/ptrace.h>
  15. static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
  16. {
  17. return PT_REGS_SYSCALL_NR(regs);
  18. }
  19. static inline void syscall_rollback(struct task_struct *task,
  20. struct pt_regs *regs)
  21. {
  22. /* do nothing */
  23. }
  24. static inline long syscall_get_error(struct task_struct *task,
  25. struct pt_regs *regs)
  26. {
  27. const long error = regs_return_value(regs);
  28. return IS_ERR_VALUE(error) ? error : 0;
  29. }
  30. static inline long syscall_get_return_value(struct task_struct *task,
  31. struct pt_regs *regs)
  32. {
  33. return regs_return_value(regs);
  34. }
  35. static inline void syscall_set_return_value(struct task_struct *task,
  36. struct pt_regs *regs,
  37. int error, long val)
  38. {
  39. PT_REGS_SET_SYSCALL_RETURN(regs, (long) error ?: val);
  40. }
  41. static inline void syscall_get_arguments(struct task_struct *task,
  42. struct pt_regs *regs,
  43. unsigned long *args)
  44. {
  45. const struct uml_pt_regs *r = &regs->regs;
  46. *args++ = UPT_SYSCALL_ARG1(r);
  47. *args++ = UPT_SYSCALL_ARG2(r);
  48. *args++ = UPT_SYSCALL_ARG3(r);
  49. *args++ = UPT_SYSCALL_ARG4(r);
  50. *args++ = UPT_SYSCALL_ARG5(r);
  51. *args = UPT_SYSCALL_ARG6(r);
  52. }
  53. /* See arch/x86/um/asm/syscall.h for syscall_get_arch() definition. */
  54. #endif /* __UM_SYSCALL_GENERIC_H */