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>
66 #include <asm/types.h>
67 #include <asm/uaccess.h>
68 #include <asm/semaphore.h>
69 #include <asm/atomic.h>
76 #define AA(__x) ((unsigned long)(__x))
78 int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
80 typeof(ubuf->st_uid) uid = 0;
81 typeof(ubuf->st_gid) gid = 0;
82 SET_UID(uid, kbuf->uid);
83 SET_GID(gid, kbuf->gid);
84 if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
86 if (kbuf->size >= 0x7fffffff)
88 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
89 __put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
90 __put_user (kbuf->ino, &ubuf->st_ino) ||
91 __put_user (kbuf->mode, &ubuf->st_mode) ||
92 __put_user (kbuf->nlink, &ubuf->st_nlink) ||
93 __put_user (uid, &ubuf->st_uid) ||
94 __put_user (gid, &ubuf->st_gid) ||
95 __put_user (old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
96 __put_user (kbuf->size, &ubuf->st_size) ||
97 __put_user (kbuf->atime.tv_sec, &ubuf->st_atime) ||
98 __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
99 __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
100 __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
101 __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
102 __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
103 __put_user (kbuf->blksize, &ubuf->st_blksize) ||
104 __put_user (kbuf->blocks, &ubuf->st_blocks))
110 sys32_truncate64(char __user * filename, unsigned long offset_low, unsigned long offset_high)
112 return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
116 sys32_ftruncate64(unsigned int fd, unsigned long offset_low, unsigned long offset_high)
118 return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
121 /* Another set for IA32/LFS -- x86_64 struct stat is different due to
122 support for 64bit inode numbers. */
125 cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
127 typeof(ubuf->st_uid) uid = 0;
128 typeof(ubuf->st_gid) gid = 0;
129 SET_UID(uid, stat->uid);
130 SET_GID(gid, stat->gid);
131 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
132 __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) ||
133 __put_user (stat->ino, &ubuf->__st_ino) ||
134 __put_user (stat->ino, &ubuf->st_ino) ||
135 __put_user (stat->mode, &ubuf->st_mode) ||
136 __put_user (stat->nlink, &ubuf->st_nlink) ||
137 __put_user (uid, &ubuf->st_uid) ||
138 __put_user (gid, &ubuf->st_gid) ||
139 __put_user (huge_encode_dev(stat->rdev), &ubuf->st_rdev) ||
140 __put_user (stat->size, &ubuf->st_size) ||
141 __put_user (stat->atime.tv_sec, &ubuf->st_atime) ||
142 __put_user (stat->atime.tv_nsec, &ubuf->st_atime_nsec) ||
143 __put_user (stat->mtime.tv_sec, &ubuf->st_mtime) ||
144 __put_user (stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
145 __put_user (stat->ctime.tv_sec, &ubuf->st_ctime) ||
146 __put_user (stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
147 __put_user (stat->blksize, &ubuf->st_blksize) ||
148 __put_user (stat->blocks, &ubuf->st_blocks))
154 sys32_stat64(char __user * filename, struct stat64 __user *statbuf)
157 int ret = vfs_stat(filename, &stat);
159 ret = cp_stat64(statbuf, &stat);
164 sys32_lstat64(char __user * filename, struct stat64 __user *statbuf)
167 int ret = vfs_lstat(filename, &stat);
169 ret = cp_stat64(statbuf, &stat);
174 sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
177 int ret = vfs_fstat(fd, &stat);
179 ret = cp_stat64(statbuf, &stat);
184 sys32_fstatat(unsigned int dfd, char __user *filename,
185 struct stat64 __user* statbuf, int flag)
190 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
193 if (flag & AT_SYMLINK_NOFOLLOW)
194 error = vfs_lstat_fd(dfd, filename, &stat);
196 error = vfs_stat_fd(dfd, filename, &stat);
199 error = cp_stat64(statbuf, &stat);
206 * Linux/i386 didn't use to be able to handle more than
207 * 4 system call parameters, so these system calls used a memory
208 * block for parameter passing..
211 struct mmap_arg_struct {
221 sys32_mmap(struct mmap_arg_struct __user *arg)
223 struct mmap_arg_struct a;
224 struct file *file = NULL;
225 unsigned long retval;
226 struct mm_struct *mm ;
228 if (copy_from_user(&a, arg, sizeof(a)))
231 if (a.offset & ~PAGE_MASK)
234 if (!(a.flags & MAP_ANONYMOUS)) {
241 down_write(&mm->mmap_sem);
242 retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, a.offset>>PAGE_SHIFT);
246 up_write(&mm->mmap_sem);
252 sys32_mprotect(unsigned long start, size_t len, unsigned long prot)
254 return sys_mprotect(start,len,prot);
258 sys32_pipe(int __user *fd)
263 retval = do_pipe(fds);
266 if (copy_to_user(fd, fds, sizeof(fds)))
273 sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
274 struct sigaction32 __user *oact, unsigned int sigsetsize)
276 struct k_sigaction new_ka, old_ka;
278 compat_sigset_t set32;
280 /* XXX: Don't preclude handling different sized sigset_t's. */
281 if (sigsetsize != sizeof(compat_sigset_t))
285 compat_uptr_t handler, restorer;
287 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
288 __get_user(handler, &act->sa_handler) ||
289 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
290 __get_user(restorer, &act->sa_restorer)||
291 __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t)))
293 new_ka.sa.sa_handler = compat_ptr(handler);
294 new_ka.sa.sa_restorer = compat_ptr(restorer);
295 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
296 switch (_NSIG_WORDS) {
297 case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
298 | (((long)set32.sig[7]) << 32);
299 case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4]
300 | (((long)set32.sig[5]) << 32);
301 case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2]
302 | (((long)set32.sig[3]) << 32);
303 case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0]
304 | (((long)set32.sig[1]) << 32);
308 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
311 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
312 switch (_NSIG_WORDS) {
314 set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);
315 set32.sig[6] = old_ka.sa.sa_mask.sig[3];
317 set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);
318 set32.sig[4] = old_ka.sa.sa_mask.sig[2];
320 set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);
321 set32.sig[2] = old_ka.sa.sa_mask.sig[1];
323 set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
324 set32.sig[0] = old_ka.sa.sa_mask.sig[0];
326 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
327 __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
328 __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
329 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
330 __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t)))
338 sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact)
340 struct k_sigaction new_ka, old_ka;
344 compat_old_sigset_t mask;
345 compat_uptr_t handler, restorer;
347 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
348 __get_user(handler, &act->sa_handler) ||
349 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
350 __get_user(restorer, &act->sa_restorer) ||
351 __get_user(mask, &act->sa_mask))
354 new_ka.sa.sa_handler = compat_ptr(handler);
355 new_ka.sa.sa_restorer = compat_ptr(restorer);
357 siginitset(&new_ka.sa.sa_mask, mask);
360 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
363 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
364 __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
365 __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
366 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
367 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
375 sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
376 compat_sigset_t __user *oset, unsigned int sigsetsize)
381 mm_segment_t old_fs = get_fs();
384 if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
386 switch (_NSIG_WORDS) {
387 case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
388 case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
389 case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
390 case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
394 ret = sys_rt_sigprocmask(how, set ? &s : NULL, oset ? &s : NULL,
399 switch (_NSIG_WORDS) {
400 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
401 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
402 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
403 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
405 if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
412 get_tv32(struct timeval *o, struct compat_timeval __user *i)
415 if (access_ok(VERIFY_READ, i, sizeof(*i))) {
416 err = __get_user(o->tv_sec, &i->tv_sec);
417 err |= __get_user(o->tv_usec, &i->tv_usec);
423 put_tv32(struct compat_timeval __user *o, struct timeval *i)
426 if (access_ok(VERIFY_WRITE, o, sizeof(*o))) {
427 err = __put_user(i->tv_sec, &o->tv_sec);
428 err |= __put_user(i->tv_usec, &o->tv_usec);
433 extern unsigned int alarm_setitimer(unsigned int seconds);
436 sys32_alarm(unsigned int seconds)
438 return alarm_setitimer(seconds);
441 /* Translations due to time_t size differences. Which affects all
442 sorts of things, like timeval and itimerval. */
444 extern struct timezone sys_tz;
447 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
451 do_gettimeofday(&ktv);
452 if (put_tv32(tv, &ktv))
456 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
463 sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
470 if (get_tv32(&ktv, tv))
472 kts.tv_sec = ktv.tv_sec;
473 kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC;
476 if (copy_from_user(&ktz, tz, sizeof(ktz)))
480 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
483 struct sel_arg_struct {
492 sys32_old_select(struct sel_arg_struct __user *arg)
494 struct sel_arg_struct a;
496 if (copy_from_user(&a, arg, sizeof(a)))
498 return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
499 compat_ptr(a.exp), compat_ptr(a.tvp));
502 extern asmlinkage long
503 compat_sys_wait4(compat_pid_t pid, compat_uint_t * stat_addr, int options,
504 struct compat_rusage *ru);
507 sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
509 return compat_sys_wait4(pid, stat_addr, options, NULL);
512 int sys32_ni_syscall(int call)
514 struct task_struct *me = current;
515 static char lastcomm[sizeof(me->comm)];
517 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
518 printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
520 strncpy(lastcomm, me->comm, sizeof(lastcomm));
525 /* 32-bit timeval and related flotsam. */
528 sys32_sysfs(int option, u32 arg1, u32 arg2)
530 return sys_sysfs(option, arg1, arg2);
542 unsigned short procs;
547 char _f[20-2*sizeof(u32)-sizeof(int)];
551 sys32_sysinfo(struct sysinfo32 __user *info)
555 mm_segment_t old_fs = get_fs ();
559 ret = sys_sysinfo(&s);
562 /* Check to see if any memory value is too large for 32-bit and scale
565 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
566 while (s.mem_unit < PAGE_SIZE) {
570 s.totalram >>= bitcount;
571 s.freeram >>= bitcount;
572 s.sharedram >>= bitcount;
573 s.bufferram >>= bitcount;
574 s.totalswap >>= bitcount;
575 s.freeswap >>= bitcount;
576 s.totalhigh >>= bitcount;
577 s.freehigh >>= bitcount;
580 if (!access_ok(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
581 __put_user (s.uptime, &info->uptime) ||
582 __put_user (s.loads[0], &info->loads[0]) ||
583 __put_user (s.loads[1], &info->loads[1]) ||
584 __put_user (s.loads[2], &info->loads[2]) ||
585 __put_user (s.totalram, &info->totalram) ||
586 __put_user (s.freeram, &info->freeram) ||
587 __put_user (s.sharedram, &info->sharedram) ||
588 __put_user (s.bufferram, &info->bufferram) ||
589 __put_user (s.totalswap, &info->totalswap) ||
590 __put_user (s.freeswap, &info->freeswap) ||
591 __put_user (s.procs, &info->procs) ||
592 __put_user (s.totalhigh, &info->totalhigh) ||
593 __put_user (s.freehigh, &info->freehigh) ||
594 __put_user (s.mem_unit, &info->mem_unit))
600 sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
604 mm_segment_t old_fs = get_fs ();
607 ret = sys_sched_rr_get_interval(pid, &t);
609 if (put_compat_timespec(&t, interval))
615 sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize)
620 mm_segment_t old_fs = get_fs();
623 ret = sys_rt_sigpending(&s, sigsetsize);
626 switch (_NSIG_WORDS) {
627 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
628 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
629 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
630 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
632 if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
639 sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
643 mm_segment_t old_fs = get_fs();
645 if (copy_siginfo_from_user32(&info, uinfo))
648 ret = sys_rt_sigqueueinfo(pid, sig, &info);
653 /* These are here just in case some old ia32 binary calls it. */
657 current->state = TASK_INTERRUPTIBLE;
659 return -ERESTARTNOHAND;
668 unsigned int oldlenp;
671 unsigned int __unused[4];
676 sys32_sysctl(struct sysctl_ia32 __user *args32)
678 struct sysctl_ia32 a32;
679 mm_segment_t old_fs = get_fs ();
680 void __user *oldvalp, *newvalp;
684 extern int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
685 void *newval, size_t newlen);
688 if (copy_from_user(&a32, args32, sizeof (a32)))
692 * We need to pre-validate these because we have to disable address checking
693 * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
694 * user specifying bad addresses here. Well, since we're dealing with 32 bit
695 * addresses, we KNOW that access_ok() will always succeed, so this is an
696 * expensive NOP, but so what...
698 namep = compat_ptr(a32.name);
699 oldvalp = compat_ptr(a32.oldval);
700 newvalp = compat_ptr(a32.newval);
702 if ((oldvalp && get_user(oldlen, (int __user *)compat_ptr(a32.oldlenp)))
703 || !access_ok(VERIFY_WRITE, namep, 0)
704 || !access_ok(VERIFY_WRITE, oldvalp, 0)
705 || !access_ok(VERIFY_WRITE, newvalp, 0))
710 ret = do_sysctl(namep, a32.nlen, oldvalp, &oldlen, newvalp, (size_t) a32.newlen);
714 if (oldvalp && put_user (oldlen, (int __user *)compat_ptr(a32.oldlenp)))
721 /* warning: next two assume little endian */
723 sys32_pread(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
725 return sys_pread64(fd, ubuf, count,
726 ((loff_t)AA(poshi) << 32) | AA(poslo));
730 sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
732 return sys_pwrite64(fd, ubuf, count,
733 ((loff_t)AA(poshi) << 32) | AA(poslo));
738 sys32_personality(unsigned long personality)
741 if (personality(current->personality) == PER_LINUX32 &&
742 personality == PER_LINUX)
743 personality = PER_LINUX32;
744 ret = sys_personality(personality);
745 if (ret == PER_LINUX32)
751 sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
753 mm_segment_t old_fs = get_fs();
757 if (offset && get_user(of, offset))
761 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
764 if (offset && put_user(of, offset))
770 /* Handle adjtimex compatibility. */
774 s32 offset, freq, maxerror, esterror;
775 s32 status, constant, precision, tolerance;
776 struct compat_timeval time;
778 s32 ppsfreq, jitter, shift, stabil;
779 s32 jitcnt, calcnt, errcnt, stbcnt;
780 s32 :32; s32 :32; s32 :32; s32 :32;
781 s32 :32; s32 :32; s32 :32; s32 :32;
782 s32 :32; s32 :32; s32 :32; s32 :32;
785 extern int do_adjtimex(struct timex *);
788 sys32_adjtimex(struct timex32 __user *utp)
793 memset(&txc, 0, sizeof(struct timex));
795 if (!access_ok(VERIFY_READ, utp, sizeof(struct timex32)) ||
796 __get_user(txc.modes, &utp->modes) ||
797 __get_user(txc.offset, &utp->offset) ||
798 __get_user(txc.freq, &utp->freq) ||
799 __get_user(txc.maxerror, &utp->maxerror) ||
800 __get_user(txc.esterror, &utp->esterror) ||
801 __get_user(txc.status, &utp->status) ||
802 __get_user(txc.constant, &utp->constant) ||
803 __get_user(txc.precision, &utp->precision) ||
804 __get_user(txc.tolerance, &utp->tolerance) ||
805 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
806 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
807 __get_user(txc.tick, &utp->tick) ||
808 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
809 __get_user(txc.jitter, &utp->jitter) ||
810 __get_user(txc.shift, &utp->shift) ||
811 __get_user(txc.stabil, &utp->stabil) ||
812 __get_user(txc.jitcnt, &utp->jitcnt) ||
813 __get_user(txc.calcnt, &utp->calcnt) ||
814 __get_user(txc.errcnt, &utp->errcnt) ||
815 __get_user(txc.stbcnt, &utp->stbcnt))
818 ret = do_adjtimex(&txc);
820 if (!access_ok(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
821 __put_user(txc.modes, &utp->modes) ||
822 __put_user(txc.offset, &utp->offset) ||
823 __put_user(txc.freq, &utp->freq) ||
824 __put_user(txc.maxerror, &utp->maxerror) ||
825 __put_user(txc.esterror, &utp->esterror) ||
826 __put_user(txc.status, &utp->status) ||
827 __put_user(txc.constant, &utp->constant) ||
828 __put_user(txc.precision, &utp->precision) ||
829 __put_user(txc.tolerance, &utp->tolerance) ||
830 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
831 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
832 __put_user(txc.tick, &utp->tick) ||
833 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
834 __put_user(txc.jitter, &utp->jitter) ||
835 __put_user(txc.shift, &utp->shift) ||
836 __put_user(txc.stabil, &utp->stabil) ||
837 __put_user(txc.jitcnt, &utp->jitcnt) ||
838 __put_user(txc.calcnt, &utp->calcnt) ||
839 __put_user(txc.errcnt, &utp->errcnt) ||
840 __put_user(txc.stbcnt, &utp->stbcnt))
846 asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
847 unsigned long prot, unsigned long flags,
848 unsigned long fd, unsigned long pgoff)
850 struct mm_struct *mm = current->mm;
852 struct file * file = NULL;
854 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
855 if (!(flags & MAP_ANONYMOUS)) {
861 down_write(&mm->mmap_sem);
862 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
863 up_write(&mm->mmap_sem);
870 asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
876 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
881 error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
882 __put_user(0,name->sysname+__OLD_UTS_LEN);
883 __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
884 __put_user(0,name->nodename+__OLD_UTS_LEN);
885 __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
886 __put_user(0,name->release+__OLD_UTS_LEN);
887 __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
888 __put_user(0,name->version+__OLD_UTS_LEN);
890 char *arch = "x86_64";
891 if (personality(current->personality) == PER_LINUX32)
894 __copy_to_user(&name->machine,arch,strlen(arch)+1);
899 error = error ? -EFAULT : 0;
904 long sys32_uname(struct old_utsname __user * name)
910 err=copy_to_user(name, &system_utsname, sizeof (*name));
912 if (personality(current->personality) == PER_LINUX32)
913 err |= copy_to_user(&name->machine, "i686", 5);
914 return err?-EFAULT:0;
917 long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
925 ret = sys_ustat(dev,&u);
928 if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) ||
929 __put_user((__u32) u.f_tfree, &u32p->f_tfree) ||
930 __put_user((__u32) u.f_tinode, &u32p->f_tfree) ||
931 __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) ||
932 __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack)))
938 asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
939 compat_uptr_t __user *envp, struct pt_regs *regs)
944 filename = getname(name);
945 error = PTR_ERR(filename);
946 if (IS_ERR(filename))
948 error = compat_do_execve(filename, argv, envp, regs);
951 current->ptrace &= ~PT_DTRACE;
952 task_unlock(current);
958 asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
959 struct pt_regs *regs)
961 void __user *parent_tid = (void __user *)regs->rdx;
962 void __user *child_tid = (void __user *)regs->rdi;
965 return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
969 * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
972 long sys32_lseek (unsigned int fd, int offset, unsigned int whence)
974 return sys_lseek(fd, offset, whence);
977 long sys32_kill(int pid, int sig)
979 return sys_kill(pid, sig);
982 long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
983 __u32 len_low, __u32 len_high, int advice)
985 return sys_fadvise64_64(fd,
986 (((u64)offset_high)<<32) | offset_low,
987 (((u64)len_high)<<32) | len_low,
991 long sys32_vm86_warning(void)
993 struct task_struct *me = current;
994 static char lastcomm[sizeof(me->comm)];
995 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
996 printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
998 strncpy(lastcomm, me->comm, sizeof(lastcomm));
1003 long sys32_lookup_dcookie(u32 addr_low, u32 addr_high,
1004 char __user * buf, size_t len)
1006 return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len);
1009 static int __init ia32_init (void)
1011 printk("IA32 emulation $Id: sys_ia32.c,v 1.32 2002/03/24 13:02:28 ak Exp $\n");
1015 __initcall(ia32_init);
1017 extern unsigned long ia32_sys_call_table[];
1018 EXPORT_SYMBOL(ia32_sys_call_table);