2 * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on
5 * Copyright (C) 2000 VA Linux Co
6 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
7 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
8 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
9 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
10 * Copyright (C) 2000 Hewlett-Packard Co.
11 * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
12 * Copyright (C) 2000,2001,2002 Andi Kleen, SuSE Labs (x86-64 port)
14 * These routines maintain argument size conversion between 32bit and 64bit
15 * environment. In 2.5 most of this should be moved to a generic directory.
17 * This file assumes that there is a hole at the end of user address space.
19 * Some of the functions are LE specific currently. These are hopefully all marked.
20 * This should be fixed.
23 #include <linux/config.h>
24 #include <linux/kernel.h>
25 #include <linux/sched.h>
27 #include <linux/file.h>
28 #include <linux/signal.h>
29 #include <linux/syscalls.h>
30 #include <linux/resource.h>
31 #include <linux/times.h>
32 #include <linux/utsname.h>
33 #include <linux/timex.h>
34 #include <linux/smp.h>
35 #include <linux/smp_lock.h>
36 #include <linux/sem.h>
37 #include <linux/msg.h>
39 #include <linux/shm.h>
40 #include <linux/slab.h>
41 #include <linux/uio.h>
42 #include <linux/nfs_fs.h>
43 #include <linux/quota.h>
44 #include <linux/module.h>
45 #include <linux/sunrpc/svc.h>
46 #include <linux/nfsd/nfsd.h>
47 #include <linux/nfsd/cache.h>
48 #include <linux/nfsd/xdr.h>
49 #include <linux/nfsd/syscall.h>
50 #include <linux/poll.h>
51 #include <linux/personality.h>
52 #include <linux/stat.h>
53 #include <linux/ipc.h>
54 #include <linux/rwsem.h>
55 #include <linux/binfmts.h>
56 #include <linux/init.h>
57 #include <linux/aio_abi.h>
58 #include <linux/aio.h>
59 #include <linux/compat.h>
60 #include <linux/vfs.h>
61 #include <linux/ptrace.h>
62 #include <linux/highuid.h>
63 #include <linux/vmalloc.h>
64 #include <linux/fsnotify.h>
65 #include <linux/vs_cvirt.h>
67 #include <asm/types.h>
68 #include <asm/uaccess.h>
69 #include <asm/semaphore.h>
70 #include <asm/atomic.h>
77 #define AA(__x) ((unsigned long)(__x))
79 int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
81 typeof(ubuf->st_uid) uid = 0;
82 typeof(ubuf->st_gid) gid = 0;
83 SET_UID(uid, kbuf->uid);
84 SET_GID(gid, kbuf->gid);
85 if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
87 if (kbuf->size >= 0x7fffffff)
89 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
90 __put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
91 __put_user (kbuf->ino, &ubuf->st_ino) ||
92 __put_user (kbuf->mode, &ubuf->st_mode) ||
93 __put_user (kbuf->nlink, &ubuf->st_nlink) ||
94 __put_user (uid, &ubuf->st_uid) ||
95 __put_user (gid, &ubuf->st_gid) ||
96 __put_user (old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
97 __put_user (kbuf->size, &ubuf->st_size) ||
98 __put_user (kbuf->atime.tv_sec, &ubuf->st_atime) ||
99 __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
100 __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
101 __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
102 __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
103 __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
104 __put_user (kbuf->blksize, &ubuf->st_blksize) ||
105 __put_user (kbuf->blocks, &ubuf->st_blocks))
111 sys32_truncate64(char __user * filename, unsigned long offset_low, unsigned long offset_high)
113 return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
117 sys32_ftruncate64(unsigned int fd, unsigned long offset_low, unsigned long offset_high)
119 return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
122 /* Another set for IA32/LFS -- x86_64 struct stat is different due to
123 support for 64bit inode numbers. */
126 cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
128 typeof(ubuf->st_uid) uid = 0;
129 typeof(ubuf->st_gid) gid = 0;
130 SET_UID(uid, stat->uid);
131 SET_GID(gid, stat->gid);
132 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
133 __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) ||
134 __put_user (stat->ino, &ubuf->__st_ino) ||
135 __put_user (stat->ino, &ubuf->st_ino) ||
136 __put_user (stat->mode, &ubuf->st_mode) ||
137 __put_user (stat->nlink, &ubuf->st_nlink) ||
138 __put_user (uid, &ubuf->st_uid) ||
139 __put_user (gid, &ubuf->st_gid) ||
140 __put_user (huge_encode_dev(stat->rdev), &ubuf->st_rdev) ||
141 __put_user (stat->size, &ubuf->st_size) ||
142 __put_user (stat->atime.tv_sec, &ubuf->st_atime) ||
143 __put_user (stat->atime.tv_nsec, &ubuf->st_atime_nsec) ||
144 __put_user (stat->mtime.tv_sec, &ubuf->st_mtime) ||
145 __put_user (stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
146 __put_user (stat->ctime.tv_sec, &ubuf->st_ctime) ||
147 __put_user (stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
148 __put_user (stat->blksize, &ubuf->st_blksize) ||
149 __put_user (stat->blocks, &ubuf->st_blocks))
155 sys32_stat64(char __user * filename, struct stat64 __user *statbuf)
158 int ret = vfs_stat(filename, &stat);
160 ret = cp_stat64(statbuf, &stat);
165 sys32_lstat64(char __user * filename, struct stat64 __user *statbuf)
168 int ret = vfs_lstat(filename, &stat);
170 ret = cp_stat64(statbuf, &stat);
175 sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
178 int ret = vfs_fstat(fd, &stat);
180 ret = cp_stat64(statbuf, &stat);
185 sys32_fstatat(unsigned int dfd, char __user *filename,
186 struct stat64 __user* statbuf, int flag)
191 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
194 if (flag & AT_SYMLINK_NOFOLLOW)
195 error = vfs_lstat_fd(dfd, filename, &stat);
197 error = vfs_stat_fd(dfd, filename, &stat);
200 error = cp_stat64(statbuf, &stat);
207 * Linux/i386 didn't use to be able to handle more than
208 * 4 system call parameters, so these system calls used a memory
209 * block for parameter passing..
212 struct mmap_arg_struct {
222 sys32_mmap(struct mmap_arg_struct __user *arg)
224 struct mmap_arg_struct a;
225 struct file *file = NULL;
226 unsigned long retval;
227 struct mm_struct *mm ;
229 if (copy_from_user(&a, arg, sizeof(a)))
232 if (a.offset & ~PAGE_MASK)
235 if (!(a.flags & MAP_ANONYMOUS)) {
242 down_write(&mm->mmap_sem);
243 retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, a.offset>>PAGE_SHIFT);
247 up_write(&mm->mmap_sem);
253 sys32_mprotect(unsigned long start, size_t len, unsigned long prot)
255 return sys_mprotect(start,len,prot);
259 sys32_pipe(int __user *fd)
264 retval = do_pipe(fds);
267 if (copy_to_user(fd, fds, sizeof(fds)))
274 sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
275 struct sigaction32 __user *oact, unsigned int sigsetsize)
277 struct k_sigaction new_ka, old_ka;
279 compat_sigset_t set32;
281 /* XXX: Don't preclude handling different sized sigset_t's. */
282 if (sigsetsize != sizeof(compat_sigset_t))
286 compat_uptr_t handler, restorer;
288 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
289 __get_user(handler, &act->sa_handler) ||
290 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
291 __get_user(restorer, &act->sa_restorer)||
292 __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t)))
294 new_ka.sa.sa_handler = compat_ptr(handler);
295 new_ka.sa.sa_restorer = compat_ptr(restorer);
296 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
297 switch (_NSIG_WORDS) {
298 case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
299 | (((long)set32.sig[7]) << 32);
300 case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4]
301 | (((long)set32.sig[5]) << 32);
302 case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2]
303 | (((long)set32.sig[3]) << 32);
304 case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0]
305 | (((long)set32.sig[1]) << 32);
309 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
312 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
313 switch (_NSIG_WORDS) {
315 set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);
316 set32.sig[6] = old_ka.sa.sa_mask.sig[3];
318 set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);
319 set32.sig[4] = old_ka.sa.sa_mask.sig[2];
321 set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);
322 set32.sig[2] = old_ka.sa.sa_mask.sig[1];
324 set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
325 set32.sig[0] = old_ka.sa.sa_mask.sig[0];
327 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
328 __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
329 __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
330 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
331 __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t)))
339 sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact)
341 struct k_sigaction new_ka, old_ka;
345 compat_old_sigset_t mask;
346 compat_uptr_t handler, restorer;
348 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
349 __get_user(handler, &act->sa_handler) ||
350 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
351 __get_user(restorer, &act->sa_restorer) ||
352 __get_user(mask, &act->sa_mask))
355 new_ka.sa.sa_handler = compat_ptr(handler);
356 new_ka.sa.sa_restorer = compat_ptr(restorer);
358 siginitset(&new_ka.sa.sa_mask, mask);
361 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
364 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
365 __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
366 __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
367 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
368 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
376 sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
377 compat_sigset_t __user *oset, unsigned int sigsetsize)
382 mm_segment_t old_fs = get_fs();
385 if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
387 switch (_NSIG_WORDS) {
388 case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
389 case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
390 case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
391 case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
395 ret = sys_rt_sigprocmask(how, set ? &s : NULL, oset ? &s : NULL,
400 switch (_NSIG_WORDS) {
401 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
402 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
403 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
404 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
406 if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
413 get_tv32(struct timeval *o, struct compat_timeval __user *i)
416 if (access_ok(VERIFY_READ, i, sizeof(*i))) {
417 err = __get_user(o->tv_sec, &i->tv_sec);
418 err |= __get_user(o->tv_usec, &i->tv_usec);
424 put_tv32(struct compat_timeval __user *o, struct timeval *i)
427 if (access_ok(VERIFY_WRITE, o, sizeof(*o))) {
428 err = __put_user(i->tv_sec, &o->tv_sec);
429 err |= __put_user(i->tv_usec, &o->tv_usec);
434 extern int do_setitimer(int which, struct itimerval *, struct itimerval *);
437 sys32_alarm(unsigned int seconds)
439 struct itimerval it_new, it_old;
440 unsigned int oldalarm;
442 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
443 it_new.it_value.tv_sec = seconds;
444 it_new.it_value.tv_usec = 0;
445 do_setitimer(ITIMER_REAL, &it_new, &it_old);
446 oldalarm = it_old.it_value.tv_sec;
447 /* ehhh.. We can't return 0 if we have an alarm pending.. */
448 /* And we'd better return too much than too little anyway */
449 if (it_old.it_value.tv_usec)
454 /* Translations due to time_t size differences. Which affects all
455 sorts of things, like timeval and itimerval. */
457 extern struct timezone sys_tz;
460 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
464 do_gettimeofday(&ktv);
465 if (put_tv32(tv, &ktv))
469 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
476 sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
483 if (get_tv32(&ktv, tv))
485 kts.tv_sec = ktv.tv_sec;
486 kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC;
489 if (copy_from_user(&ktz, tz, sizeof(ktz)))
493 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
496 struct sel_arg_struct {
505 sys32_old_select(struct sel_arg_struct __user *arg)
507 struct sel_arg_struct a;
509 if (copy_from_user(&a, arg, sizeof(a)))
511 return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
512 compat_ptr(a.exp), compat_ptr(a.tvp));
515 extern asmlinkage long
516 compat_sys_wait4(compat_pid_t pid, compat_uint_t * stat_addr, int options,
517 struct compat_rusage *ru);
520 sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
522 return compat_sys_wait4(pid, stat_addr, options, NULL);
525 int sys32_ni_syscall(int call)
527 struct task_struct *me = current;
528 static char lastcomm[sizeof(me->comm)];
530 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
531 printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
533 strncpy(lastcomm, me->comm, sizeof(lastcomm));
538 /* 32-bit timeval and related flotsam. */
541 sys32_sysfs(int option, u32 arg1, u32 arg2)
543 return sys_sysfs(option, arg1, arg2);
555 unsigned short procs;
560 char _f[20-2*sizeof(u32)-sizeof(int)];
564 sys32_sysinfo(struct sysinfo32 __user *info)
568 mm_segment_t old_fs = get_fs ();
572 ret = sys_sysinfo(&s);
575 /* Check to see if any memory value is too large for 32-bit and scale
578 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
579 while (s.mem_unit < PAGE_SIZE) {
583 s.totalram >>= bitcount;
584 s.freeram >>= bitcount;
585 s.sharedram >>= bitcount;
586 s.bufferram >>= bitcount;
587 s.totalswap >>= bitcount;
588 s.freeswap >>= bitcount;
589 s.totalhigh >>= bitcount;
590 s.freehigh >>= bitcount;
593 if (!access_ok(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
594 __put_user (s.uptime, &info->uptime) ||
595 __put_user (s.loads[0], &info->loads[0]) ||
596 __put_user (s.loads[1], &info->loads[1]) ||
597 __put_user (s.loads[2], &info->loads[2]) ||
598 __put_user (s.totalram, &info->totalram) ||
599 __put_user (s.freeram, &info->freeram) ||
600 __put_user (s.sharedram, &info->sharedram) ||
601 __put_user (s.bufferram, &info->bufferram) ||
602 __put_user (s.totalswap, &info->totalswap) ||
603 __put_user (s.freeswap, &info->freeswap) ||
604 __put_user (s.procs, &info->procs) ||
605 __put_user (s.totalhigh, &info->totalhigh) ||
606 __put_user (s.freehigh, &info->freehigh) ||
607 __put_user (s.mem_unit, &info->mem_unit))
613 sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
617 mm_segment_t old_fs = get_fs ();
620 ret = sys_sched_rr_get_interval(pid, &t);
622 if (put_compat_timespec(&t, interval))
628 sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize)
633 mm_segment_t old_fs = get_fs();
636 ret = sys_rt_sigpending(&s, sigsetsize);
639 switch (_NSIG_WORDS) {
640 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
641 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
642 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
643 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
645 if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
652 sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
656 mm_segment_t old_fs = get_fs();
658 if (copy_siginfo_from_user32(&info, uinfo))
661 ret = sys_rt_sigqueueinfo(pid, sig, &info);
666 /* These are here just in case some old ia32 binary calls it. */
670 current->state = TASK_INTERRUPTIBLE;
672 return -ERESTARTNOHAND;
681 unsigned int oldlenp;
684 unsigned int __unused[4];
689 sys32_sysctl(struct sysctl_ia32 __user *args32)
691 struct sysctl_ia32 a32;
692 mm_segment_t old_fs = get_fs ();
693 void __user *oldvalp, *newvalp;
697 extern int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
698 void *newval, size_t newlen);
701 if (copy_from_user(&a32, args32, sizeof (a32)))
705 * We need to pre-validate these because we have to disable address checking
706 * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
707 * user specifying bad addresses here. Well, since we're dealing with 32 bit
708 * addresses, we KNOW that access_ok() will always succeed, so this is an
709 * expensive NOP, but so what...
711 namep = compat_ptr(a32.name);
712 oldvalp = compat_ptr(a32.oldval);
713 newvalp = compat_ptr(a32.newval);
715 if ((oldvalp && get_user(oldlen, (int __user *)compat_ptr(a32.oldlenp)))
716 || !access_ok(VERIFY_WRITE, namep, 0)
717 || !access_ok(VERIFY_WRITE, oldvalp, 0)
718 || !access_ok(VERIFY_WRITE, newvalp, 0))
723 ret = do_sysctl(namep, a32.nlen, oldvalp, &oldlen, newvalp, (size_t) a32.newlen);
727 if (oldvalp && put_user (oldlen, (int __user *)compat_ptr(a32.oldlenp)))
734 /* warning: next two assume little endian */
736 sys32_pread(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
738 return sys_pread64(fd, ubuf, count,
739 ((loff_t)AA(poshi) << 32) | AA(poslo));
743 sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
745 return sys_pwrite64(fd, ubuf, count,
746 ((loff_t)AA(poshi) << 32) | AA(poslo));
751 sys32_personality(unsigned long personality)
754 if (personality(current->personality) == PER_LINUX32 &&
755 personality == PER_LINUX)
756 personality = PER_LINUX32;
757 ret = sys_personality(personality);
758 if (ret == PER_LINUX32)
764 sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
766 mm_segment_t old_fs = get_fs();
770 if (offset && get_user(of, offset))
774 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
777 if (offset && put_user(of, offset))
783 /* Handle adjtimex compatibility. */
787 s32 offset, freq, maxerror, esterror;
788 s32 status, constant, precision, tolerance;
789 struct compat_timeval time;
791 s32 ppsfreq, jitter, shift, stabil;
792 s32 jitcnt, calcnt, errcnt, stbcnt;
793 s32 :32; s32 :32; s32 :32; s32 :32;
794 s32 :32; s32 :32; s32 :32; s32 :32;
795 s32 :32; s32 :32; s32 :32; s32 :32;
798 extern int do_adjtimex(struct timex *);
801 sys32_adjtimex(struct timex32 __user *utp)
806 memset(&txc, 0, sizeof(struct timex));
808 if (!access_ok(VERIFY_READ, utp, sizeof(struct timex32)) ||
809 __get_user(txc.modes, &utp->modes) ||
810 __get_user(txc.offset, &utp->offset) ||
811 __get_user(txc.freq, &utp->freq) ||
812 __get_user(txc.maxerror, &utp->maxerror) ||
813 __get_user(txc.esterror, &utp->esterror) ||
814 __get_user(txc.status, &utp->status) ||
815 __get_user(txc.constant, &utp->constant) ||
816 __get_user(txc.precision, &utp->precision) ||
817 __get_user(txc.tolerance, &utp->tolerance) ||
818 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
819 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
820 __get_user(txc.tick, &utp->tick) ||
821 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
822 __get_user(txc.jitter, &utp->jitter) ||
823 __get_user(txc.shift, &utp->shift) ||
824 __get_user(txc.stabil, &utp->stabil) ||
825 __get_user(txc.jitcnt, &utp->jitcnt) ||
826 __get_user(txc.calcnt, &utp->calcnt) ||
827 __get_user(txc.errcnt, &utp->errcnt) ||
828 __get_user(txc.stbcnt, &utp->stbcnt))
831 ret = do_adjtimex(&txc);
833 if (!access_ok(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
834 __put_user(txc.modes, &utp->modes) ||
835 __put_user(txc.offset, &utp->offset) ||
836 __put_user(txc.freq, &utp->freq) ||
837 __put_user(txc.maxerror, &utp->maxerror) ||
838 __put_user(txc.esterror, &utp->esterror) ||
839 __put_user(txc.status, &utp->status) ||
840 __put_user(txc.constant, &utp->constant) ||
841 __put_user(txc.precision, &utp->precision) ||
842 __put_user(txc.tolerance, &utp->tolerance) ||
843 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
844 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
845 __put_user(txc.tick, &utp->tick) ||
846 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
847 __put_user(txc.jitter, &utp->jitter) ||
848 __put_user(txc.shift, &utp->shift) ||
849 __put_user(txc.stabil, &utp->stabil) ||
850 __put_user(txc.jitcnt, &utp->jitcnt) ||
851 __put_user(txc.calcnt, &utp->calcnt) ||
852 __put_user(txc.errcnt, &utp->errcnt) ||
853 __put_user(txc.stbcnt, &utp->stbcnt))
859 asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
860 unsigned long prot, unsigned long flags,
861 unsigned long fd, unsigned long pgoff)
863 struct mm_struct *mm = current->mm;
865 struct file * file = NULL;
867 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
868 if (!(flags & MAP_ANONYMOUS)) {
874 down_write(&mm->mmap_sem);
875 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
876 up_write(&mm->mmap_sem);
883 asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
886 struct new_utsname *ptr;
890 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
895 ptr = vx_new_utsname();
896 error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
897 __put_user(0,name->sysname+__OLD_UTS_LEN);
898 __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
899 __put_user(0,name->nodename+__OLD_UTS_LEN);
900 __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
901 __put_user(0,name->release+__OLD_UTS_LEN);
902 __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
903 __put_user(0,name->version+__OLD_UTS_LEN);
905 char *arch = "x86_64";
906 if (personality(current->personality) == PER_LINUX32)
909 __copy_to_user(&name->machine,arch,strlen(arch)+1);
914 error = error ? -EFAULT : 0;
919 long sys32_uname(struct old_utsname __user * name)
925 err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
927 if (personality(current->personality) == PER_LINUX32)
928 err |= copy_to_user(&name->machine, "i686", 5);
929 return err?-EFAULT:0;
932 long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
940 ret = sys_ustat(dev,&u);
943 if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) ||
944 __put_user((__u32) u.f_tfree, &u32p->f_tfree) ||
945 __put_user((__u32) u.f_tinode, &u32p->f_tfree) ||
946 __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) ||
947 __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack)))
953 asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
954 compat_uptr_t __user *envp, struct pt_regs *regs)
959 filename = getname(name);
960 error = PTR_ERR(filename);
961 if (IS_ERR(filename))
963 error = compat_do_execve(filename, argv, envp, regs);
966 current->ptrace &= ~PT_DTRACE;
967 task_unlock(current);
973 asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
974 struct pt_regs *regs)
976 void __user *parent_tid = (void __user *)regs->rdx;
977 void __user *child_tid = (void __user *)regs->rdi;
980 return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
984 * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
987 long sys32_lseek (unsigned int fd, int offset, unsigned int whence)
989 return sys_lseek(fd, offset, whence);
992 long sys32_kill(int pid, int sig)
994 return sys_kill(pid, sig);
997 long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
998 __u32 len_low, __u32 len_high, int advice)
1000 return sys_fadvise64_64(fd,
1001 (((u64)offset_high)<<32) | offset_low,
1002 (((u64)len_high)<<32) | len_low,
1006 long sys32_vm86_warning(void)
1008 struct task_struct *me = current;
1009 static char lastcomm[sizeof(me->comm)];
1010 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
1011 printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
1013 strncpy(lastcomm, me->comm, sizeof(lastcomm));
1018 long sys32_lookup_dcookie(u32 addr_low, u32 addr_high,
1019 char __user * buf, size_t len)
1021 return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len);
1024 static int __init ia32_init (void)
1026 printk("IA32 emulation $Id: sys_ia32.c,v 1.32 2002/03/24 13:02:28 ak Exp $\n");
1030 __initcall(ia32_init);
1032 extern unsigned long ia32_sys_call_table[];
1033 EXPORT_SYMBOL(ia32_sys_call_table);