sys_ppc32.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * sys_ppc32.c: 32-bit system calls with complex calling conventions.
  4. *
  5. * Copyright (C) 2001 IBM
  6. * Copyright (C) 1997,1998 Jakub Jelinek ([email protected])
  7. * Copyright (C) 1997 David S. Miller ([email protected])
  8. *
  9. * 32-bit system calls with 64-bit arguments pass those in register pairs.
  10. * This must be specially dealt with on 64-bit kernels. The compat_arg_u64_dual
  11. * in generic compat syscalls is not always usable because the register
  12. * pairing is constrained depending on preceding arguments.
  13. *
  14. * An analogous problem exists on 32-bit kernels with ARCH_HAS_SYSCALL_WRAPPER,
  15. * the defined system call functions take the pt_regs as an argument, and there
  16. * is a mapping macro which maps registers to arguments
  17. * (SC_POWERPC_REGS_TO_ARGS) which also does not deal with these 64-bit
  18. * arguments.
  19. *
  20. * This file contains these system calls.
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/sched.h>
  24. #include <linux/fs.h>
  25. #include <linux/mm.h>
  26. #include <linux/file.h>
  27. #include <linux/signal.h>
  28. #include <linux/resource.h>
  29. #include <linux/times.h>
  30. #include <linux/smp.h>
  31. #include <linux/sem.h>
  32. #include <linux/msg.h>
  33. #include <linux/shm.h>
  34. #include <linux/poll.h>
  35. #include <linux/personality.h>
  36. #include <linux/stat.h>
  37. #include <linux/in.h>
  38. #include <linux/syscalls.h>
  39. #include <linux/unistd.h>
  40. #include <linux/sysctl.h>
  41. #include <linux/binfmts.h>
  42. #include <linux/security.h>
  43. #include <linux/compat.h>
  44. #include <linux/ptrace.h>
  45. #include <linux/elf.h>
  46. #include <linux/ipc.h>
  47. #include <linux/slab.h>
  48. #include <asm/ptrace.h>
  49. #include <asm/types.h>
  50. #include <linux/uaccess.h>
  51. #include <asm/unistd.h>
  52. #include <asm/time.h>
  53. #include <asm/mmu_context.h>
  54. #include <asm/ppc-pci.h>
  55. #include <asm/syscalls.h>
  56. #include <asm/switch_to.h>
  57. #ifdef CONFIG_PPC32
  58. #define PPC32_SYSCALL_DEFINE4 SYSCALL_DEFINE4
  59. #define PPC32_SYSCALL_DEFINE5 SYSCALL_DEFINE5
  60. #define PPC32_SYSCALL_DEFINE6 SYSCALL_DEFINE6
  61. #else
  62. #define PPC32_SYSCALL_DEFINE4 COMPAT_SYSCALL_DEFINE4
  63. #define PPC32_SYSCALL_DEFINE5 COMPAT_SYSCALL_DEFINE5
  64. #define PPC32_SYSCALL_DEFINE6 COMPAT_SYSCALL_DEFINE6
  65. #endif
  66. PPC32_SYSCALL_DEFINE6(ppc_pread64,
  67. unsigned int, fd,
  68. char __user *, ubuf, compat_size_t, count,
  69. u32, reg6, u32, pos1, u32, pos2)
  70. {
  71. return ksys_pread64(fd, ubuf, count, merge_64(pos1, pos2));
  72. }
  73. PPC32_SYSCALL_DEFINE6(ppc_pwrite64,
  74. unsigned int, fd,
  75. const char __user *, ubuf, compat_size_t, count,
  76. u32, reg6, u32, pos1, u32, pos2)
  77. {
  78. return ksys_pwrite64(fd, ubuf, count, merge_64(pos1, pos2));
  79. }
  80. PPC32_SYSCALL_DEFINE5(ppc_readahead,
  81. int, fd, u32, r4,
  82. u32, offset1, u32, offset2, u32, count)
  83. {
  84. return ksys_readahead(fd, merge_64(offset1, offset2), count);
  85. }
  86. PPC32_SYSCALL_DEFINE4(ppc_truncate64,
  87. const char __user *, path, u32, reg4,
  88. unsigned long, len1, unsigned long, len2)
  89. {
  90. return ksys_truncate(path, merge_64(len1, len2));
  91. }
  92. PPC32_SYSCALL_DEFINE4(ppc_ftruncate64,
  93. unsigned int, fd, u32, reg4,
  94. unsigned long, len1, unsigned long, len2)
  95. {
  96. return ksys_ftruncate(fd, merge_64(len1, len2));
  97. }
  98. PPC32_SYSCALL_DEFINE6(ppc32_fadvise64,
  99. int, fd, u32, unused, u32, offset1, u32, offset2,
  100. size_t, len, int, advice)
  101. {
  102. return ksys_fadvise64_64(fd, merge_64(offset1, offset2), len,
  103. advice);
  104. }
  105. PPC32_SYSCALL_DEFINE6(ppc_sync_file_range2,
  106. int, fd, unsigned int, flags,
  107. unsigned int, offset1, unsigned int, offset2,
  108. unsigned int, nbytes1, unsigned int, nbytes2)
  109. {
  110. loff_t offset = merge_64(offset1, offset2);
  111. loff_t nbytes = merge_64(nbytes1, nbytes2);
  112. return ksys_sync_file_range(fd, offset, nbytes, flags);
  113. }
  114. #ifdef CONFIG_PPC32
  115. SYSCALL_DEFINE6(ppc_fallocate,
  116. int, fd, int, mode,
  117. u32, offset1, u32, offset2, u32, len1, u32, len2)
  118. {
  119. return ksys_fallocate(fd, mode,
  120. merge_64(offset1, offset2),
  121. merge_64(len1, len2));
  122. }
  123. #endif