sys_ppc32.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls.
  4. *
  5. * Copyright (C) 2001 IBM
  6. * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  8. *
  9. * These routines maintain argument size conversion between 32bit and 64bit
  10. * environment.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/fs.h>
  15. #include <linux/mm.h>
  16. #include <linux/file.h>
  17. #include <linux/signal.h>
  18. #include <linux/resource.h>
  19. #include <linux/times.h>
  20. #include <linux/smp.h>
  21. #include <linux/sem.h>
  22. #include <linux/msg.h>
  23. #include <linux/shm.h>
  24. #include <linux/poll.h>
  25. #include <linux/personality.h>
  26. #include <linux/stat.h>
  27. #include <linux/mman.h>
  28. #include <linux/in.h>
  29. #include <linux/syscalls.h>
  30. #include <linux/unistd.h>
  31. #include <linux/sysctl.h>
  32. #include <linux/binfmts.h>
  33. #include <linux/security.h>
  34. #include <linux/compat.h>
  35. #include <linux/ptrace.h>
  36. #include <linux/elf.h>
  37. #include <linux/ipc.h>
  38. #include <linux/slab.h>
  39. #include <asm/ptrace.h>
  40. #include <asm/types.h>
  41. #include <linux/uaccess.h>
  42. #include <asm/unistd.h>
  43. #include <asm/time.h>
  44. #include <asm/mmu_context.h>
  45. #include <asm/ppc-pci.h>
  46. #include <asm/syscalls.h>
  47. #include <asm/switch_to.h>
  48. unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
  49. unsigned long prot, unsigned long flags,
  50. unsigned long fd, unsigned long pgoff)
  51. {
  52. /* This should remain 12 even if PAGE_SIZE changes */
  53. return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
  54. }
  55. /*
  56. * long long munging:
  57. * The 32 bit ABI passes long longs in an odd even register pair.
  58. */
  59. compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
  60. u32 reg6, u32 poshi, u32 poslo)
  61. {
  62. return ksys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
  63. }
  64. compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count,
  65. u32 reg6, u32 poshi, u32 poslo)
  66. {
  67. return ksys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
  68. }
  69. compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count)
  70. {
  71. return ksys_readahead(fd, ((loff_t)offhi << 32) | offlo, count);
  72. }
  73. asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
  74. unsigned long high, unsigned long low)
  75. {
  76. return ksys_truncate(path, (high << 32) | low);
  77. }
  78. asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
  79. u32 lenhi, u32 lenlo)
  80. {
  81. return ksys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
  82. ((loff_t)lenhi << 32) | lenlo);
  83. }
  84. asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
  85. unsigned long low)
  86. {
  87. return ksys_ftruncate(fd, (high << 32) | low);
  88. }
  89. long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
  90. size_t len, int advice)
  91. {
  92. return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low, len,
  93. advice);
  94. }
  95. asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,
  96. unsigned offset_hi, unsigned offset_lo,
  97. unsigned nbytes_hi, unsigned nbytes_lo)
  98. {
  99. loff_t offset = ((loff_t)offset_hi << 32) | offset_lo;
  100. loff_t nbytes = ((loff_t)nbytes_hi << 32) | nbytes_lo;
  101. return ksys_sync_file_range(fd, offset, nbytes, flags);
  102. }