sys_parisc32.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. /*
  51. * sys32_execve() executes a new program.
  52. */
  53. asmlinkage int sys32_execve(struct pt_regs *regs)
  54. {
  55. int error;
  56. char *filename;
  57. DBG(("sys32_execve(%p) r26 = 0x%lx\n", regs, regs->gr[26]));
  58. filename = getname((const char __user *) regs->gr[26]);
  59. error = PTR_ERR(filename);
  60. if (IS_ERR(filename))
  61. goto out;
  62. error = compat_do_execve(filename, compat_ptr(regs->gr[25]),
  63. compat_ptr(regs->gr[24]), regs);
  64. putname(filename);
  65. out:
  66. return error;
  67. }
  68. asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,
  69. int r22, int r21, int r20)
  70. {
  71. printk(KERN_ERR "%s(%d): Unimplemented 32 on 64 syscall #%d!\n",
  72. current->comm, current->pid, r20);
  73. return -ENOSYS;
  74. }
  75. asmlinkage long sys32_sched_rr_get_interval(pid_t pid,
  76. struct compat_timespec __user *interval)
  77. {
  78. struct timespec t;
  79. int ret;
  80. KERNEL_SYSCALL(ret, sys_sched_rr_get_interval, pid, (struct timespec __user *)&t);
  81. if (put_compat_timespec(&t, interval))
  82. return -EFAULT;
  83. return ret;
  84. }
  85. struct msgbuf32 {
  86. int mtype;
  87. char mtext[1];
  88. };
  89. asmlinkage long sys32_msgsnd(int msqid,
  90. struct msgbuf32 __user *umsgp32,
  91. size_t msgsz, int msgflg)
  92. {
  93. struct msgbuf *mb;
  94. struct msgbuf32 mb32;
  95. int err;
  96. if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)
  97. return -ENOMEM;
  98. err = get_user(mb32.mtype, &umsgp32->mtype);
  99. mb->mtype = mb32.mtype;
  100. err |= copy_from_user(mb->mtext, &umsgp32->mtext, msgsz);
  101. if (err)
  102. err = -EFAULT;
  103. else
  104. KERNEL_SYSCALL(err, sys_msgsnd, msqid, (struct msgbuf __user *)mb, msgsz, msgflg);
  105. kfree(mb);
  106. return err;
  107. }
  108. asmlinkage long sys32_msgrcv(int msqid,
  109. struct msgbuf32 __user *umsgp32,
  110. size_t msgsz, long msgtyp, int msgflg)
  111. {
  112. struct msgbuf *mb;
  113. struct msgbuf32 mb32;
  114. int err, len;
  115. if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)
  116. return -ENOMEM;
  117. KERNEL_SYSCALL(err, sys_msgrcv, msqid, (struct msgbuf __user *)mb, msgsz, msgtyp, msgflg);
  118. if (err >= 0) {
  119. len = err;
  120. mb32.mtype = mb->mtype;
  121. err = put_user(mb32.mtype, &umsgp32->mtype);
  122. err |= copy_to_user(&umsgp32->mtext, mb->mtext, len);
  123. if (err)
  124. err = -EFAULT;
  125. else
  126. err = len;
  127. }
  128. kfree(mb);
  129. return err;
  130. }
  131. asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
  132. {
  133. mm_segment_t old_fs = get_fs();
  134. int ret;
  135. off_t of;
  136. if (offset && get_user(of, offset))
  137. return -EFAULT;
  138. set_fs(KERNEL_DS);
  139. ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count);
  140. set_fs(old_fs);
  141. if (offset && put_user(of, offset))
  142. return -EFAULT;
  143. return ret;
  144. }
  145. asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
  146. {
  147. mm_segment_t old_fs = get_fs();
  148. int ret;
  149. loff_t lof;
  150. if (offset && get_user(lof, offset))
  151. return -EFAULT;
  152. set_fs(KERNEL_DS);
  153. ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count);
  154. set_fs(old_fs);
  155. if (offset && put_user(lof, offset))
  156. return -EFAULT;
  157. return ret;
  158. }
  159. /* lseek() needs a wrapper because 'offset' can be negative, but the top
  160. * half of the argument has been zeroed by syscall.S.
  161. */
  162. asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin)
  163. {
  164. return sys_lseek(fd, offset, origin);
  165. }
  166. asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg)
  167. {
  168. union semun u;
  169. if (cmd == SETVAL) {
  170. /* Ugh. arg is a union of int,ptr,ptr,ptr, so is 8 bytes.
  171. * The int should be in the first 4, but our argument
  172. * frobbing has left it in the last 4.
  173. */
  174. u.val = *((int *)&arg + 1);
  175. return sys_semctl (semid, semnum, cmd, u);
  176. }
  177. return sys_semctl (semid, semnum, cmd, arg);
  178. }
  179. long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
  180. size_t len)
  181. {
  182. return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
  183. buf, len);
  184. }
  185. asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
  186. u32 lenhi, u32 lenlo)
  187. {
  188. return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
  189. ((loff_t)lenhi << 32) | lenlo);
  190. }
  191. asmlinkage long compat_sys_fanotify_mark(int fan_fd, int flags, u32 mask_hi,
  192. u32 mask_lo, int fd,
  193. const char __user *pathname)
  194. {
  195. return sys_fanotify_mark(fan_fd, flags, ((u64)mask_hi << 32) | mask_lo,
  196. fd, pathname);
  197. }