sys_parisc32.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * sys_parisc32.c: Conversion between 32bit and 64bit native syscalls.
  3. *
  4. * Copyright (C) 2000-2001 Hewlett Packard Company
  5. * Copyright (C) 2000 John Marvin
  6. * Copyright (C) 2001 Matthew Wilcox
  7. *
  8. * These routines maintain argument size conversion between 32bit and 64bit
  9. * environment. Based heavily on sys_ia32.c and sys_sparc32.c.
  10. */
  11. #include <linux/compat.h>
  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/time.h>
  21. #include <linux/smp.h>
  22. #include <linux/sem.h>
  23. #include <linux/msg.h>
  24. #include <linux/shm.h>
  25. #include <linux/slab.h>
  26. #include <linux/uio.h>
  27. #include <linux/ncp_fs.h>
  28. #include <linux/poll.h>
  29. #include <linux/personality.h>
  30. #include <linux/stat.h>
  31. #include <linux/highmem.h>
  32. #include <linux/highuid.h>
  33. #include <linux/mman.h>
  34. #include <linux/binfmts.h>
  35. #include <linux/namei.h>
  36. #include <linux/vfs.h>
  37. #include <linux/ptrace.h>
  38. #include <linux/swap.h>
  39. #include <linux/syscalls.h>
  40. #include <asm/types.h>
  41. #include <asm/uaccess.h>
  42. #include <asm/mmu_context.h>
  43. #include "sys32.h"
  44. #undef DEBUG
  45. #ifdef DEBUG
  46. #define DBG(x) printk x
  47. #else
  48. #define DBG(x)
  49. #endif
  50. asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,
  51. int r22, int r21, int r20)
  52. {
  53. printk(KERN_ERR "%s(%d): Unimplemented 32 on 64 syscall #%d!\n",
  54. current->comm, current->pid, r20);
  55. return -ENOSYS;
  56. }
  57. struct msgbuf32 {
  58. int mtype;
  59. char mtext[1];
  60. };
  61. asmlinkage long sys32_msgsnd(int msqid,
  62. struct msgbuf32 __user *umsgp32,
  63. size_t msgsz, int msgflg)
  64. {
  65. struct msgbuf *mb;
  66. struct msgbuf32 mb32;
  67. int err;
  68. if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)
  69. return -ENOMEM;
  70. err = get_user(mb32.mtype, &umsgp32->mtype);
  71. mb->mtype = mb32.mtype;
  72. err |= copy_from_user(mb->mtext, &umsgp32->mtext, msgsz);
  73. if (err)
  74. err = -EFAULT;
  75. else
  76. KERNEL_SYSCALL(err, sys_msgsnd, msqid, (struct msgbuf __user *)mb, msgsz, msgflg);
  77. kfree(mb);
  78. return err;
  79. }
  80. asmlinkage long sys32_msgrcv(int msqid,
  81. struct msgbuf32 __user *umsgp32,
  82. size_t msgsz, long msgtyp, int msgflg)
  83. {
  84. struct msgbuf *mb;
  85. struct msgbuf32 mb32;
  86. int err, len;
  87. if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)
  88. return -ENOMEM;
  89. KERNEL_SYSCALL(err, sys_msgrcv, msqid, (struct msgbuf __user *)mb, msgsz, msgtyp, msgflg);
  90. if (err >= 0) {
  91. len = err;
  92. mb32.mtype = mb->mtype;
  93. err = put_user(mb32.mtype, &umsgp32->mtype);
  94. err |= copy_to_user(&umsgp32->mtext, mb->mtext, len);
  95. if (err)
  96. err = -EFAULT;
  97. else
  98. err = len;
  99. }
  100. kfree(mb);
  101. return err;
  102. }
  103. asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
  104. {
  105. mm_segment_t old_fs = get_fs();
  106. int ret;
  107. off_t of;
  108. if (offset && get_user(of, offset))
  109. return -EFAULT;
  110. set_fs(KERNEL_DS);
  111. ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count);
  112. set_fs(old_fs);
  113. if (offset && put_user(of, offset))
  114. return -EFAULT;
  115. return ret;
  116. }
  117. asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
  118. {
  119. mm_segment_t old_fs = get_fs();
  120. int ret;
  121. loff_t lof;
  122. if (offset && get_user(lof, offset))
  123. return -EFAULT;
  124. set_fs(KERNEL_DS);
  125. ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count);
  126. set_fs(old_fs);
  127. if (offset && put_user(lof, offset))
  128. return -EFAULT;
  129. return ret;
  130. }
  131. /* lseek() needs a wrapper because 'offset' can be negative, but the top
  132. * half of the argument has been zeroed by syscall.S.
  133. */
  134. asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin)
  135. {
  136. return sys_lseek(fd, offset, origin);
  137. }
  138. asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg)
  139. {
  140. union semun u;
  141. if (cmd == SETVAL) {
  142. /* Ugh. arg is a union of int,ptr,ptr,ptr, so is 8 bytes.
  143. * The int should be in the first 4, but our argument
  144. * frobbing has left it in the last 4.
  145. */
  146. u.val = *((int *)&arg + 1);
  147. return sys_semctl (semid, semnum, cmd, u);
  148. }
  149. return sys_semctl (semid, semnum, cmd, arg);
  150. }
  151. long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
  152. size_t len)
  153. {
  154. return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
  155. buf, len);
  156. }
  157. asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
  158. u32 lenhi, u32 lenlo)
  159. {
  160. return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
  161. ((loff_t)lenhi << 32) | lenlo);
  162. }
  163. asmlinkage long compat_sys_fanotify_mark(int fan_fd, int flags, u32 mask_hi,
  164. u32 mask_lo, int fd,
  165. const char __user *pathname)
  166. {
  167. return sys_fanotify_mark(fan_fd, flags, ((u64)mask_hi << 32) | mask_lo,
  168. fd, pathname);
  169. }