sys_parisc32.c 5.6 KB

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