patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / x86_64 / ia32 / sys_ia32.c
1 /*
2  * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on
3  *             sys_sparc32 
4  *
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) 
13  *
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. 
16  *
17  * This file assumes that there is a hole at the end of user address space.
18  * 
19  * Some of the functions are LE specific currently. These are hopefully all marked.
20  * This should be fixed.
21  */
22
23 #include <linux/config.h>
24 #include <linux/kernel.h>
25 #include <linux/sched.h>
26 #include <linux/fs.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>
38 #include <linux/mm.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/vs_cvirt.h>
65 #include <asm/mman.h>
66 #include <asm/types.h>
67 #include <asm/uaccess.h>
68 #include <asm/semaphore.h>
69 #include <asm/ipc.h>
70 #include <asm/atomic.h>
71 #include <asm/ldt.h>
72
73 #include <net/scm.h>
74 #include <net/sock.h>
75 #include <asm/ia32.h>
76
77 #define A(__x)          ((unsigned long)(__x))
78 #define AA(__x)         ((unsigned long)(__x))
79 #define ROUND_UP(x,a)   ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
80 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
81
82 int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
83 {
84         typeof(ubuf->st_uid) uid = 0;
85         typeof(ubuf->st_gid) gid = 0;
86         SET_UID(uid, kbuf->uid);
87         SET_GID(gid, kbuf->gid);
88         if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
89                 return -EOVERFLOW;
90         if (kbuf->size >= 0x7fffffff)
91                 return -EOVERFLOW;
92         if (verify_area(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
93             __put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
94             __put_user (kbuf->ino, &ubuf->st_ino) ||
95             __put_user (kbuf->mode, &ubuf->st_mode) ||
96             __put_user (kbuf->nlink, &ubuf->st_nlink) ||
97             __put_user (uid, &ubuf->st_uid) ||
98             __put_user (gid, &ubuf->st_gid) ||
99             __put_user (old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
100             __put_user (kbuf->size, &ubuf->st_size) ||
101             __put_user (kbuf->atime.tv_sec, &ubuf->st_atime) ||
102             __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
103             __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
104             __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
105             __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
106             __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
107             __put_user (kbuf->blksize, &ubuf->st_blksize) ||
108             __put_user (kbuf->blocks, &ubuf->st_blocks))
109                 return -EFAULT;
110         return 0;
111 }
112
113 asmlinkage long
114 sys32_truncate64(char __user * filename, unsigned long offset_low, unsigned long offset_high)
115 {
116        return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
117 }
118
119 asmlinkage long
120 sys32_ftruncate64(unsigned int fd, unsigned long offset_low, unsigned long offset_high)
121 {
122        return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
123 }
124
125 /* Another set for IA32/LFS -- x86_64 struct stat is different due to 
126    support for 64bit inode numbers. */
127
128 static int
129 cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
130 {
131         typeof(ubuf->st_uid) uid = 0;
132         typeof(ubuf->st_gid) gid = 0;
133         SET_UID(uid, stat->uid);
134         SET_GID(gid, stat->gid);
135         if (verify_area(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
136             __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) ||
137             __put_user (stat->ino, &ubuf->__st_ino) ||
138             __put_user (stat->ino, &ubuf->st_ino) ||
139             __put_user (stat->mode, &ubuf->st_mode) ||
140             __put_user (stat->nlink, &ubuf->st_nlink) ||
141             __put_user (uid, &ubuf->st_uid) ||
142             __put_user (gid, &ubuf->st_gid) ||
143             __put_user (huge_encode_dev(stat->rdev), &ubuf->st_rdev) ||
144             __put_user (stat->size, &ubuf->st_size) ||
145             __put_user (stat->atime.tv_sec, &ubuf->st_atime) ||
146             __put_user (stat->atime.tv_nsec, &ubuf->st_atime_nsec) ||
147             __put_user (stat->mtime.tv_sec, &ubuf->st_mtime) ||
148             __put_user (stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
149             __put_user (stat->ctime.tv_sec, &ubuf->st_ctime) ||
150             __put_user (stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
151             __put_user (stat->blksize, &ubuf->st_blksize) ||
152             __put_user (stat->blocks, &ubuf->st_blocks))
153                 return -EFAULT;
154         return 0;
155 }
156
157 asmlinkage long
158 sys32_stat64(char __user * filename, struct stat64 __user *statbuf)
159 {
160         struct kstat stat;
161         int ret = vfs_stat(filename, &stat);
162         if (!ret)
163                 ret = cp_stat64(statbuf, &stat);
164         return ret;
165 }
166
167 asmlinkage long
168 sys32_lstat64(char __user * filename, struct stat64 __user *statbuf)
169 {
170         struct kstat stat;
171         int ret = vfs_lstat(filename, &stat);
172         if (!ret)
173                 ret = cp_stat64(statbuf, &stat);
174         return ret;
175 }
176
177 asmlinkage long
178 sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
179 {
180         struct kstat stat;
181         int ret = vfs_fstat(fd, &stat);
182         if (!ret)
183                 ret = cp_stat64(statbuf, &stat);
184         return ret;
185 }
186
187 /*
188  * Linux/i386 didn't use to be able to handle more than
189  * 4 system call parameters, so these system calls used a memory
190  * block for parameter passing..
191  */
192
193 struct mmap_arg_struct {
194         unsigned int addr;
195         unsigned int len;
196         unsigned int prot;
197         unsigned int flags;
198         unsigned int fd;
199         unsigned int offset;
200 };
201
202 asmlinkage long
203 sys32_mmap(struct mmap_arg_struct __user *arg)
204 {
205         struct mmap_arg_struct a;
206         struct file *file = NULL;
207         unsigned long retval;
208         struct mm_struct *mm ;
209
210         if (copy_from_user(&a, arg, sizeof(a)))
211                 return -EFAULT;
212
213         if (a.offset & ~PAGE_MASK)
214                 return -EINVAL; 
215
216         if (!(a.flags & MAP_ANONYMOUS)) {
217                 file = fget(a.fd);
218                 if (!file)
219                         return -EBADF;
220         }
221         
222         if (a.prot & PROT_READ) 
223                 a.prot |= vm_force_exec32;
224
225         mm = current->mm; 
226         down_write(&mm->mmap_sem); 
227         retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, a.offset>>PAGE_SHIFT);
228         if (file)
229                 fput(file);
230
231         up_write(&mm->mmap_sem); 
232
233         return retval;
234 }
235
236 asmlinkage long 
237 sys32_mprotect(unsigned long start, size_t len, unsigned long prot)
238 {
239         if (prot & PROT_READ) 
240                 prot |= vm_force_exec32;
241         return sys_mprotect(start,len,prot); 
242 }
243
244 asmlinkage long
245 sys32_pipe(int __user *fd)
246 {
247         int retval;
248         int fds[2];
249
250         retval = do_pipe(fds);
251         if (retval)
252                 goto out;
253         if (copy_to_user(fd, fds, sizeof(fds)))
254                 retval = -EFAULT;
255   out:
256         return retval;
257 }
258
259 asmlinkage long
260 sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
261                    struct sigaction32 __user *oact,  unsigned int sigsetsize)
262 {
263         struct k_sigaction new_ka, old_ka;
264         int ret;
265         compat_sigset_t set32;
266
267         /* XXX: Don't preclude handling different sized sigset_t's.  */
268         if (sigsetsize != sizeof(compat_sigset_t))
269                 return -EINVAL;
270
271         if (act) {
272                 compat_uptr_t handler, restorer;
273
274                 if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
275                     __get_user(handler, &act->sa_handler) ||
276                     __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
277                     __get_user(restorer, &act->sa_restorer)||
278                     __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t)))
279                         return -EFAULT;
280                 new_ka.sa.sa_handler = compat_ptr(handler);
281                 new_ka.sa.sa_restorer = compat_ptr(restorer);
282                 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
283                 switch (_NSIG_WORDS) {
284                 case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
285                                 | (((long)set32.sig[7]) << 32);
286                 case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4]
287                                 | (((long)set32.sig[5]) << 32);
288                 case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2]
289                                 | (((long)set32.sig[3]) << 32);
290                 case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0]
291                                 | (((long)set32.sig[1]) << 32);
292                 }
293         }
294
295         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
296
297         if (!ret && oact) {
298                 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
299                 switch (_NSIG_WORDS) {
300                 case 4:
301                         set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);
302                         set32.sig[6] = old_ka.sa.sa_mask.sig[3];
303                 case 3:
304                         set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);
305                         set32.sig[4] = old_ka.sa.sa_mask.sig[2];
306                 case 2:
307                         set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);
308                         set32.sig[2] = old_ka.sa.sa_mask.sig[1];
309                 case 1:
310                         set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
311                         set32.sig[0] = old_ka.sa.sa_mask.sig[0];
312                 }
313                 if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
314                     __put_user((long)old_ka.sa.sa_handler, &oact->sa_handler) ||
315                     __put_user((long)old_ka.sa.sa_restorer, &oact->sa_restorer) ||
316                     __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
317                     __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t)))
318                         return -EFAULT;
319         }
320
321         return ret;
322 }
323
324 asmlinkage long
325 sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact)
326 {
327         struct k_sigaction new_ka, old_ka;
328         int ret;
329
330         if (act) {
331                 compat_old_sigset_t mask;
332                 compat_uptr_t handler, restorer;
333
334                 if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
335                     __get_user(handler, &act->sa_handler) ||
336                     __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
337                     __get_user(restorer, &act->sa_restorer) ||
338                     __get_user(mask, &act->sa_mask))
339                         return -EFAULT;
340
341                 new_ka.sa.sa_handler = compat_ptr(handler);
342                 new_ka.sa.sa_restorer = compat_ptr(restorer);
343
344                 siginitset(&new_ka.sa.sa_mask, mask);
345         }
346
347         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
348
349         if (!ret && oact) {
350                 if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
351                     __put_user((long)old_ka.sa.sa_handler, &oact->sa_handler) ||
352                     __put_user((long)old_ka.sa.sa_restorer, &oact->sa_restorer) ||
353                     __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
354                     __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
355                         return -EFAULT;
356         }
357
358         return ret;
359 }
360
361 asmlinkage long
362 sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
363                         compat_sigset_t __user *oset, unsigned int sigsetsize)
364 {
365         sigset_t s;
366         compat_sigset_t s32;
367         int ret;
368         mm_segment_t old_fs = get_fs();
369         
370         if (set) {
371                 if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
372                         return -EFAULT;
373                 switch (_NSIG_WORDS) {
374                 case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
375                 case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
376                 case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
377                 case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
378                 }
379         }
380         set_fs (KERNEL_DS);
381         ret = sys_rt_sigprocmask(how, set ? &s : NULL, oset ? &s : NULL,
382                                  sigsetsize); 
383         set_fs (old_fs);
384         if (ret) return ret;
385         if (oset) {
386                 switch (_NSIG_WORDS) {
387                 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
388                 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
389                 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
390                 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
391                 }
392                 if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
393                         return -EFAULT;
394         }
395         return 0;
396 }
397
398 static inline long
399 get_tv32(struct timeval *o, struct compat_timeval __user *i)
400 {
401         int err = -EFAULT; 
402         if (access_ok(VERIFY_READ, i, sizeof(*i))) { 
403                 err = __get_user(o->tv_sec, &i->tv_sec);
404                 err |= __get_user(o->tv_usec, &i->tv_usec);
405         }
406         return err; 
407 }
408
409 static inline long
410 put_tv32(struct compat_timeval __user *o, struct timeval *i)
411 {
412         int err = -EFAULT;
413         if (access_ok(VERIFY_WRITE, o, sizeof(*o))) { 
414                 err = __put_user(i->tv_sec, &o->tv_sec);
415                 err |= __put_user(i->tv_usec, &o->tv_usec);
416         } 
417         return err; 
418 }
419
420 extern int do_setitimer(int which, struct itimerval *, struct itimerval *);
421
422 asmlinkage long
423 sys32_alarm(unsigned int seconds)
424 {
425         struct itimerval it_new, it_old;
426         unsigned int oldalarm;
427
428         it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
429         it_new.it_value.tv_sec = seconds;
430         it_new.it_value.tv_usec = 0;
431         do_setitimer(ITIMER_REAL, &it_new, &it_old);
432         oldalarm = it_old.it_value.tv_sec;
433         /* ehhh.. We can't return 0 if we have an alarm pending.. */
434         /* And we'd better return too much than too little anyway */
435         if (it_old.it_value.tv_usec)
436                 oldalarm++;
437         return oldalarm;
438 }
439
440 /* Translations due to time_t size differences.  Which affects all
441    sorts of things, like timeval and itimerval.  */
442
443 extern struct timezone sys_tz;
444
445 asmlinkage long
446 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
447 {
448         if (tv) {
449                 struct timeval ktv;
450                 do_gettimeofday(&ktv);
451                 if (put_tv32(tv, &ktv))
452                         return -EFAULT;
453         }
454         if (tz) {
455                 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
456                         return -EFAULT;
457         }
458         return 0;
459 }
460
461 asmlinkage long
462 sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
463 {
464         struct timeval ktv;
465         struct timespec kts;
466         struct timezone ktz;
467
468         if (tv) {
469                 if (get_tv32(&ktv, tv))
470                         return -EFAULT;
471                 kts.tv_sec = ktv.tv_sec;
472                 kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC;
473         }
474         if (tz) {
475                 if (copy_from_user(&ktz, tz, sizeof(ktz)))
476                         return -EFAULT;
477         }
478
479         return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
480 }
481
482 struct linux32_dirent {
483         u32     d_ino;
484         u32     d_off;
485         u16     d_reclen;
486         char    d_name[1];
487 };
488
489 struct old_linux32_dirent {
490         u32     d_ino;
491         u32     d_offset;
492         u16     d_namlen;
493         char    d_name[1];
494 };
495
496 struct getdents32_callback {
497         struct linux32_dirent __user * current_dir;
498         struct linux32_dirent __user * previous;
499         int count;
500         int error;
501 };
502
503 struct readdir32_callback {
504         struct old_linux32_dirent __user * dirent;
505         int count;
506 };
507
508 static int
509 filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
510            unsigned int d_type)
511 {
512         struct linux32_dirent __user * dirent;
513         struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
514         int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2, 4);
515
516         buf->error = -EINVAL;   /* only used if we fail.. */
517         if (reclen > buf->count)
518                 return -EINVAL;
519         dirent = buf->previous;
520         if (dirent)
521                 put_user(offset, &dirent->d_off);
522         dirent = buf->current_dir;
523         buf->previous = dirent;
524         put_user(ino, &dirent->d_ino);
525         put_user(reclen, &dirent->d_reclen);
526         copy_to_user(dirent->d_name, name, namlen);
527         put_user(0, dirent->d_name + namlen);
528         put_user(d_type, (char __user *)dirent + reclen - 1); 
529         dirent = ((void __user *)dirent) + reclen;
530         buf->current_dir = dirent;
531         buf->count -= reclen;
532         return 0;
533 }
534
535 asmlinkage long
536 sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
537 {
538         struct file * file;
539         struct linux32_dirent __user * lastdirent;
540         struct getdents32_callback buf;
541         int error;
542
543         error = -EBADF;
544         file = fget(fd);
545         if (!file)
546                 goto out;
547
548         buf.current_dir = (struct linux32_dirent __user *) dirent;
549         buf.previous = NULL;
550         buf.count = count;
551         buf.error = 0;
552
553         error = vfs_readdir(file, filldir32, &buf);
554         if (error < 0)
555                 goto out_putf;
556         error = buf.error;
557         lastdirent = buf.previous;
558         if (lastdirent) {
559                 put_user(file->f_pos, &lastdirent->d_off);
560                 error = count - buf.count;
561         }
562
563 out_putf:
564         fput(file);
565 out:
566         return error;
567 }
568
569 static int
570 fillonedir32 (void * __buf, const char * name, int namlen, loff_t offset, ino_t ino, unsigned d_type)
571 {
572         struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
573         struct old_linux32_dirent __user * dirent;
574
575         if (buf->count)
576                 return -EINVAL;
577         buf->count++;
578         dirent = buf->dirent;
579         put_user(ino, &dirent->d_ino);
580         put_user(offset, &dirent->d_offset);
581         put_user(namlen, &dirent->d_namlen);
582         copy_to_user(dirent->d_name, name, namlen);
583         put_user(0, dirent->d_name + namlen);
584         return 0;
585 }
586
587 asmlinkage long
588 sys32_oldreaddir (unsigned int fd, void __user * dirent, unsigned int count)
589 {
590         int error;
591         struct file * file;
592         struct readdir32_callback buf;
593
594         error = -EBADF;
595         file = fget(fd);
596         if (!file)
597                 goto out;
598
599         buf.count = 0;
600         buf.dirent = dirent;
601
602         error = vfs_readdir(file, fillonedir32, &buf);
603         if (error >= 0)
604                 error = buf.count;
605         fput(file);
606 out:
607         return error;
608 }
609
610 struct sel_arg_struct {
611         unsigned int n;
612         unsigned int inp;
613         unsigned int outp;
614         unsigned int exp;
615         unsigned int tvp;
616 };
617
618 asmlinkage long
619 sys32_old_select(struct sel_arg_struct __user *arg)
620 {
621         struct sel_arg_struct a;
622
623         if (copy_from_user(&a, arg, sizeof(a)))
624                 return -EFAULT;
625         return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
626                                  compat_ptr(a.exp), compat_ptr(a.tvp));
627 }
628
629 /*
630  * sys_time() can be implemented in user-level using
631  * sys_gettimeofday().  x86-64 did this but i386 Linux did not
632  * so we have to implement this system call here.
633  */
634 asmlinkage long sys32_time(int __user * tloc)
635 {
636         int i;
637         struct timeval tv;
638
639         do_gettimeofday(&tv);
640         i = tv.tv_sec;
641
642         if (tloc) {
643                 if (put_user(i,tloc))
644                         i = -EFAULT;
645         }
646         return i;
647 }
648
649 extern asmlinkage long
650 compat_sys_wait4(compat_pid_t pid, compat_uint_t * stat_addr, int options,
651                  struct compat_rusage *ru);
652
653 asmlinkage long
654 sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
655 {
656         return compat_sys_wait4(pid, stat_addr, options, NULL);
657 }
658
659 int sys32_ni_syscall(int call)
660
661         struct task_struct *me = current;
662         static char lastcomm[8];
663         if (strcmp(lastcomm, me->comm)) {
664         printk(KERN_INFO "IA32 syscall %d from %s not implemented\n", call,
665                current->comm);
666                 strcpy(lastcomm, me->comm); 
667         } 
668         return -ENOSYS;        
669
670
671 /* 32-bit timeval and related flotsam.  */
672
673 asmlinkage long
674 sys32_sysfs(int option, u32 arg1, u32 arg2)
675 {
676         return sys_sysfs(option, arg1, arg2);
677 }
678
679 struct sysinfo32 {
680         s32 uptime;
681         u32 loads[3];
682         u32 totalram;
683         u32 freeram;
684         u32 sharedram;
685         u32 bufferram;
686         u32 totalswap;
687         u32 freeswap;
688         unsigned short procs;
689         unsigned short pad; 
690         u32 totalhigh;
691         u32 freehigh;
692         u32 mem_unit;
693         char _f[20-2*sizeof(u32)-sizeof(int)];
694 };
695
696 asmlinkage long
697 sys32_sysinfo(struct sysinfo32 __user *info)
698 {
699         struct sysinfo s;
700         int ret;
701         mm_segment_t old_fs = get_fs ();
702         int bitcount = 0;
703         
704         set_fs (KERNEL_DS);
705         ret = sys_sysinfo(&s);
706         set_fs (old_fs);
707
708         /* Check to see if any memory value is too large for 32-bit and scale
709          *  down if needed
710          */
711         if ((s.totalram >> 32) || (s.totalswap >> 32)) {
712                 while (s.mem_unit < PAGE_SIZE) {
713                         s.mem_unit <<= 1;
714                         bitcount++;
715                 }
716                 s.totalram >>= bitcount;
717                 s.freeram >>= bitcount;
718                 s.sharedram >>= bitcount;
719                 s.bufferram >>= bitcount;
720                 s.totalswap >>= bitcount;
721                 s.freeswap >>= bitcount;
722                 s.totalhigh >>= bitcount;
723                 s.freehigh >>= bitcount;
724         }
725
726         if (verify_area(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
727             __put_user (s.uptime, &info->uptime) ||
728             __put_user (s.loads[0], &info->loads[0]) ||
729             __put_user (s.loads[1], &info->loads[1]) ||
730             __put_user (s.loads[2], &info->loads[2]) ||
731             __put_user (s.totalram, &info->totalram) ||
732             __put_user (s.freeram, &info->freeram) ||
733             __put_user (s.sharedram, &info->sharedram) ||
734             __put_user (s.bufferram, &info->bufferram) ||
735             __put_user (s.totalswap, &info->totalswap) ||
736             __put_user (s.freeswap, &info->freeswap) ||
737             __put_user (s.procs, &info->procs) ||
738             __put_user (s.totalhigh, &info->totalhigh) || 
739             __put_user (s.freehigh, &info->freehigh) ||
740             __put_user (s.mem_unit, &info->mem_unit))
741                 return -EFAULT;
742         return 0;
743 }
744                 
745 asmlinkage long
746 sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
747 {
748         struct timespec t;
749         int ret;
750         mm_segment_t old_fs = get_fs ();
751         
752         set_fs (KERNEL_DS);
753         ret = sys_sched_rr_get_interval(pid, &t);
754         set_fs (old_fs);
755         if (put_compat_timespec(&t, interval))
756                 return -EFAULT;
757         return ret;
758 }
759
760 asmlinkage long
761 sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize)
762 {
763         sigset_t s;
764         compat_sigset_t s32;
765         int ret;
766         mm_segment_t old_fs = get_fs();
767                 
768         set_fs (KERNEL_DS);
769         ret = sys_rt_sigpending(&s, sigsetsize);
770         set_fs (old_fs);
771         if (!ret) {
772                 switch (_NSIG_WORDS) {
773                 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
774                 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
775                 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
776                 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
777                 }
778                 if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
779                         return -EFAULT;
780         }
781         return ret;
782 }
783
784
785 asmlinkage long
786 sys32_rt_sigtimedwait(compat_sigset_t __user *uthese, siginfo_t32 __user *uinfo,
787                       struct compat_timespec __user *uts, compat_size_t sigsetsize)
788 {
789         sigset_t s;
790         compat_sigset_t s32;
791         struct timespec t;
792         int ret;
793         mm_segment_t old_fs = get_fs();
794         siginfo_t info;
795                 
796         if (copy_from_user (&s32, uthese, sizeof(compat_sigset_t)))
797                 return -EFAULT;
798         switch (_NSIG_WORDS) {
799         case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
800         case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
801         case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
802         case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
803         }
804         if (uts && get_compat_timespec(&t, uts))
805                 return -EFAULT;
806         if (uinfo) {
807                 /* stop data leak to user space in case of structure fill mismatch
808                  * between sys_rt_sigtimedwait & ia32_copy_siginfo_to_user.
809                  */
810                 memset(&info, 0, sizeof(info));
811         }
812         set_fs (KERNEL_DS);
813         ret = sys_rt_sigtimedwait(&s, uinfo ? &info : NULL, uts ? &t : NULL,
814                         sigsetsize);
815         set_fs (old_fs);
816         if (ret >= 0 && uinfo) {
817                 if (ia32_copy_siginfo_to_user(uinfo, &info))
818                         return -EFAULT;
819         }
820         return ret;
821 }
822
823 asmlinkage long
824 sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 __user *uinfo)
825 {
826         siginfo_t info;
827         int ret;
828         mm_segment_t old_fs = get_fs();
829         
830         if (ia32_copy_siginfo_from_user(&info, uinfo))
831                 return -EFAULT;
832         set_fs (KERNEL_DS);
833         ret = sys_rt_sigqueueinfo(pid, sig, &info);
834         set_fs (old_fs);
835         return ret;
836 }
837
838 /* These are here just in case some old ia32 binary calls it. */
839 asmlinkage long
840 sys32_pause(void)
841 {
842         current->state = TASK_INTERRUPTIBLE;
843         schedule();
844         return -ERESTARTNOHAND;
845 }
846
847
848 struct sysctl_ia32 {
849         unsigned int    name;
850         int             nlen;
851         unsigned int    oldval;
852         unsigned int    oldlenp;
853         unsigned int    newval;
854         unsigned int    newlen;
855         unsigned int    __unused[4];
856 };
857
858
859 asmlinkage long
860 sys32_sysctl(struct sysctl_ia32 __user *args32)
861 {
862 #ifndef CONFIG_SYSCTL
863         return -ENOSYS; 
864 #else
865         struct sysctl_ia32 a32;
866         mm_segment_t old_fs = get_fs ();
867         void *oldvalp, *newvalp;
868         size_t oldlen;
869         int *namep;
870         long ret;
871         extern int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
872                      void *newval, size_t newlen);
873
874
875         if (copy_from_user(&a32, args32, sizeof (a32)))
876                 return -EFAULT;
877
878         /*
879          * We need to pre-validate these because we have to disable address checking
880          * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
881          * user specifying bad addresses here.  Well, since we're dealing with 32 bit
882          * addresses, we KNOW that access_ok() will always succeed, so this is an
883          * expensive NOP, but so what...
884          */
885         namep = (int *) A(a32.name);
886         oldvalp = (void *) A(a32.oldval);
887         newvalp = (void *) A(a32.newval);
888
889         if ((oldvalp && get_user(oldlen, (int *) A(a32.oldlenp)))
890             || !access_ok(VERIFY_WRITE, namep, 0)
891             || !access_ok(VERIFY_WRITE, oldvalp, 0)
892             || !access_ok(VERIFY_WRITE, newvalp, 0))
893                 return -EFAULT;
894
895         set_fs(KERNEL_DS);
896         lock_kernel();
897         ret = do_sysctl(namep, a32.nlen, oldvalp, &oldlen, newvalp, (size_t) a32.newlen);
898         unlock_kernel();
899         set_fs(old_fs);
900
901         if (oldvalp && put_user (oldlen, (int *) A(a32.oldlenp)))
902                 return -EFAULT;
903
904         return ret;
905 #endif
906 }
907
908 /* warning: next two assume little endian */ 
909 asmlinkage long
910 sys32_pread(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
911 {
912         return sys_pread64(fd, ubuf, count,
913                          ((loff_t)AA(poshi) << 32) | AA(poslo));
914 }
915
916 asmlinkage long
917 sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
918 {
919         return sys_pwrite64(fd, ubuf, count,
920                           ((loff_t)AA(poshi) << 32) | AA(poslo));
921 }
922
923
924 asmlinkage long
925 sys32_personality(unsigned long personality)
926 {
927         int ret;
928         if (personality(current->personality) == PER_LINUX32 && 
929                 personality == PER_LINUX)
930                 personality = PER_LINUX32;
931         ret = sys_personality(personality);
932         if (ret == PER_LINUX32)
933                 ret = PER_LINUX;
934         return ret;
935 }
936
937 asmlinkage long
938 sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
939 {
940         mm_segment_t old_fs = get_fs();
941         int ret;
942         off_t of;
943         
944         if (offset && get_user(of, offset))
945                 return -EFAULT;
946                 
947         set_fs(KERNEL_DS);
948         ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
949         set_fs(old_fs);
950         
951         if (!ret && offset && put_user(of, offset))
952                 return -EFAULT;
953                 
954         return ret;
955 }
956
957 /* Handle adjtimex compatibility. */
958
959 struct timex32 {
960         u32 modes;
961         s32 offset, freq, maxerror, esterror;
962         s32 status, constant, precision, tolerance;
963         struct compat_timeval time;
964         s32 tick;
965         s32 ppsfreq, jitter, shift, stabil;
966         s32 jitcnt, calcnt, errcnt, stbcnt;
967         s32  :32; s32  :32; s32  :32; s32  :32;
968         s32  :32; s32  :32; s32  :32; s32  :32;
969         s32  :32; s32  :32; s32  :32; s32  :32;
970 };
971
972 extern int do_adjtimex(struct timex *);
973
974 asmlinkage long
975 sys32_adjtimex(struct timex32 __user *utp)
976 {
977         struct timex txc;
978         int ret;
979
980         memset(&txc, 0, sizeof(struct timex));
981
982         if(verify_area(VERIFY_READ, utp, sizeof(struct timex32)) ||
983            __get_user(txc.modes, &utp->modes) ||
984            __get_user(txc.offset, &utp->offset) ||
985            __get_user(txc.freq, &utp->freq) ||
986            __get_user(txc.maxerror, &utp->maxerror) ||
987            __get_user(txc.esterror, &utp->esterror) ||
988            __get_user(txc.status, &utp->status) ||
989            __get_user(txc.constant, &utp->constant) ||
990            __get_user(txc.precision, &utp->precision) ||
991            __get_user(txc.tolerance, &utp->tolerance) ||
992            __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
993            __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
994            __get_user(txc.tick, &utp->tick) ||
995            __get_user(txc.ppsfreq, &utp->ppsfreq) ||
996            __get_user(txc.jitter, &utp->jitter) ||
997            __get_user(txc.shift, &utp->shift) ||
998            __get_user(txc.stabil, &utp->stabil) ||
999            __get_user(txc.jitcnt, &utp->jitcnt) ||
1000            __get_user(txc.calcnt, &utp->calcnt) ||
1001            __get_user(txc.errcnt, &utp->errcnt) ||
1002            __get_user(txc.stbcnt, &utp->stbcnt))
1003                 return -EFAULT;
1004
1005         ret = do_adjtimex(&txc);
1006
1007         if(verify_area(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
1008            __put_user(txc.modes, &utp->modes) ||
1009            __put_user(txc.offset, &utp->offset) ||
1010            __put_user(txc.freq, &utp->freq) ||
1011            __put_user(txc.maxerror, &utp->maxerror) ||
1012            __put_user(txc.esterror, &utp->esterror) ||
1013            __put_user(txc.status, &utp->status) ||
1014            __put_user(txc.constant, &utp->constant) ||
1015            __put_user(txc.precision, &utp->precision) ||
1016            __put_user(txc.tolerance, &utp->tolerance) ||
1017            __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
1018            __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
1019            __put_user(txc.tick, &utp->tick) ||
1020            __put_user(txc.ppsfreq, &utp->ppsfreq) ||
1021            __put_user(txc.jitter, &utp->jitter) ||
1022            __put_user(txc.shift, &utp->shift) ||
1023            __put_user(txc.stabil, &utp->stabil) ||
1024            __put_user(txc.jitcnt, &utp->jitcnt) ||
1025            __put_user(txc.calcnt, &utp->calcnt) ||
1026            __put_user(txc.errcnt, &utp->errcnt) ||
1027            __put_user(txc.stbcnt, &utp->stbcnt))
1028                 ret = -EFAULT;
1029
1030         return ret;
1031 }
1032
1033 asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
1034         unsigned long prot, unsigned long flags,
1035         unsigned long fd, unsigned long pgoff)
1036 {
1037         struct mm_struct *mm = current->mm;
1038         unsigned long error;
1039         struct file * file = NULL;
1040
1041         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1042         if (!(flags & MAP_ANONYMOUS)) {
1043                 file = fget(fd);
1044                 if (!file)
1045                         return -EBADF;
1046         }
1047
1048         if (prot & PROT_READ)
1049                 prot |= vm_force_exec32;
1050
1051         down_write(&mm->mmap_sem);
1052         error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1053         up_write(&mm->mmap_sem);
1054
1055         if (file)
1056                 fput(file);
1057         return error;
1058 }
1059
1060 asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
1061 {
1062         int error;
1063         struct new_utsname *ptr;
1064
1065         if (!name)
1066                 return -EFAULT;
1067         if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
1068                 return -EFAULT;
1069   
1070         down_read(&uts_sem);
1071         
1072         ptr = vx_new_utsname();
1073         error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
1074          __put_user(0,name->sysname+__OLD_UTS_LEN);
1075          __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
1076          __put_user(0,name->nodename+__OLD_UTS_LEN);
1077          __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
1078          __put_user(0,name->release+__OLD_UTS_LEN);
1079          __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
1080          __put_user(0,name->version+__OLD_UTS_LEN);
1081          { 
1082                  char *arch = "x86_64";
1083                  if (personality(current->personality) == PER_LINUX32)
1084                          arch = "i686";
1085                  
1086                  __copy_to_user(&name->machine,arch,strlen(arch)+1);
1087          }
1088         
1089          up_read(&uts_sem);
1090          
1091          error = error ? -EFAULT : 0;
1092          
1093          return error;
1094 }
1095
1096 long sys32_uname(struct old_utsname __user * name)
1097 {
1098         int err;
1099         if (!name)
1100                 return -EFAULT;
1101         down_read(&uts_sem);
1102         err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
1103         up_read(&uts_sem);
1104         if (personality(current->personality) == PER_LINUX32) 
1105                 err |= copy_to_user(&name->machine, "i686", 5);
1106         return err?-EFAULT:0;
1107 }
1108
1109 long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
1110 {
1111         struct ustat u;
1112         mm_segment_t seg;
1113         int ret;
1114         
1115         seg = get_fs(); 
1116         set_fs(KERNEL_DS); 
1117         ret = sys_ustat(dev,&u); 
1118         set_fs(seg);
1119         if (ret >= 0) { 
1120                 if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) || 
1121                     __put_user((__u32) u.f_tfree, &u32p->f_tfree) ||
1122                     __put_user((__u32) u.f_tinode, &u32p->f_tfree) ||
1123                     __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) ||
1124                     __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack)))
1125                         ret = -EFAULT;
1126         }
1127         return ret;
1128
1129
1130 asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
1131                              compat_uptr_t __user *envp, struct pt_regs regs)
1132 {
1133         long error;
1134         char * filename;
1135
1136         filename = getname(name);
1137         error = PTR_ERR(filename);
1138         if (IS_ERR(filename))
1139                 return error;
1140         error = compat_do_execve(filename, argv, envp, &regs);
1141         if (error == 0)
1142                 current->ptrace &= ~PT_DTRACE;
1143         putname(filename);
1144         return error;
1145 }
1146
1147 asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp, struct pt_regs regs)
1148 {
1149         void __user *parent_tid = (void __user *)regs.rdx;
1150         void __user *child_tid = (void __user *)regs.rdi; 
1151         if (!newsp)
1152                 newsp = regs.rsp;
1153         return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0, 
1154                     parent_tid, child_tid);
1155 }
1156
1157 /*
1158  * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
1159  */ 
1160
1161 long sys32_lseek (unsigned int fd, int offset, unsigned int whence)
1162 {
1163         return sys_lseek(fd, offset, whence);
1164 }
1165
1166 long sys32_kill(int pid, int sig)
1167 {
1168         return sys_kill(pid, sig);
1169 }
1170  
1171
1172 long sys32_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
1173
1174         long ret; 
1175         aio_context_t ctx64;
1176         mm_segment_t oldfs = get_fs();  
1177         set_fs(KERNEL_DS); 
1178         ret = sys_io_setup(nr_reqs, &ctx64); 
1179         set_fs(oldfs); 
1180         /* truncating is ok because it's a user address */
1181         if (!ret) 
1182                 ret = put_user((u32)ctx64, ctx32p);
1183         return ret;
1184
1185
1186 asmlinkage long sys32_io_submit(aio_context_t ctx_id, int nr,
1187                    compat_uptr_t __user *iocbpp)
1188 {
1189         struct kioctx *ctx;
1190         long ret = 0;
1191         int i;
1192         
1193         if (unlikely(nr < 0))
1194                 return -EINVAL;
1195
1196         if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))
1197                 return -EFAULT;
1198
1199         ctx = lookup_ioctx(ctx_id);
1200         if (unlikely(!ctx)) {
1201                 pr_debug("EINVAL: io_submit: invalid context id\n");
1202                 return -EINVAL; 
1203         } 
1204
1205         for (i=0; i<nr; i++) {
1206                 compat_uptr_t p32;
1207                 struct iocb __user *user_iocb;
1208                 struct iocb tmp;
1209
1210                 if (unlikely(__get_user(p32, iocbpp + i))) {
1211                         ret = -EFAULT;
1212                         break;
1213                 } 
1214                 user_iocb = compat_ptr(p32);
1215
1216                 if (unlikely(copy_from_user(&tmp, user_iocb, sizeof(tmp)))) {
1217                         ret = -EFAULT;
1218                         break;
1219                 }
1220
1221                 ret = io_submit_one(ctx, user_iocb, &tmp);
1222                 if (ret)
1223                         break;
1224         }
1225
1226         put_ioctx(ctx);
1227         return i ? i : ret;
1228 }
1229
1230
1231 asmlinkage long sys32_io_getevents(aio_context_t ctx_id,
1232                                  unsigned long min_nr,
1233                                  unsigned long nr,
1234                                  struct io_event __user *events,
1235                                  struct compat_timespec __user *timeout)
1236 {       
1237         long ret;
1238         mm_segment_t oldfs; 
1239         struct timespec t;
1240         /* Harden against bogus ptrace */
1241         if (nr >= 0xffffffff || 
1242             !access_ok(VERIFY_WRITE, events, nr * sizeof(struct io_event)))
1243                 return -EFAULT;
1244         if (timeout && get_compat_timespec(&t, timeout))
1245                 return -EFAULT; 
1246         oldfs = get_fs();
1247         set_fs(KERNEL_DS); 
1248         ret = sys_io_getevents(ctx_id,min_nr,nr,events,timeout ? &t : NULL); 
1249         set_fs(oldfs); 
1250         if (!ret && timeout && put_compat_timespec(&t, timeout))
1251                 return -EFAULT;                 
1252         return ret;
1253
1254
1255 asmlinkage long sys32_open(const char __user * filename, int flags, int mode)
1256 {
1257         char * tmp;
1258         int fd, error;
1259
1260         /* don't force O_LARGEFILE */
1261         tmp = getname(filename);
1262         fd = PTR_ERR(tmp);
1263         if (!IS_ERR(tmp)) {
1264                 fd = get_unused_fd();
1265                 if (fd >= 0) {
1266                         struct file *f = filp_open(tmp, flags, mode);
1267                         error = PTR_ERR(f);
1268                         if (unlikely(IS_ERR(f))) {
1269                                 put_unused_fd(fd); 
1270                                 fd = error;
1271                         } else
1272                                 fd_install(fd, f);
1273                 }
1274                 putname(tmp);
1275         }
1276         return fd;
1277 }
1278
1279 struct sigevent32 { 
1280         u32 sigev_value;
1281         u32 sigev_signo; 
1282         u32 sigev_notify; 
1283         u32 payload[(64 / 4) - 3]; 
1284 }; 
1285
1286 extern asmlinkage long
1287 sys_timer_create(clockid_t which_clock,
1288                  struct sigevent __user *timer_event_spec,
1289                  timer_t __user * created_timer_id);
1290
1291 long
1292 sys32_timer_create(u32 clock, struct sigevent32 __user *se32, timer_t __user *timer_id)
1293 {
1294         struct sigevent se;
1295         mm_segment_t oldfs;
1296         long err;
1297
1298         if (se32) { 
1299                 memset(&se, 0, sizeof(struct sigevent)); 
1300                 if (get_user(se.sigev_value.sival_int,  &se32->sigev_value) ||
1301                     __get_user(se.sigev_signo, &se32->sigev_signo) ||
1302                     __get_user(se.sigev_notify, &se32->sigev_notify) ||
1303                     __copy_from_user(&se._sigev_un._pad, &se32->payload, 
1304                                      sizeof(se32->payload)))
1305                         return -EFAULT;
1306         } 
1307         if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
1308                 return -EFAULT;
1309
1310         oldfs = get_fs();
1311         set_fs(KERNEL_DS);
1312         err = sys_timer_create(clock, se32 ? &se : NULL, timer_id);
1313         set_fs(oldfs); 
1314         
1315         return err; 
1316
1317
1318 long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, 
1319                         __u32 len_low, __u32 len_high, int advice)
1320
1321         return sys_fadvise64_64(fd,
1322                                (((u64)offset_high)<<32) | offset_low,
1323                                (((u64)len_high)<<32) | len_low,
1324                                advice); 
1325
1326
1327 long sys32_vm86_warning(void)
1328
1329         struct task_struct *me = current;
1330         static char lastcomm[8];
1331         if (strcmp(lastcomm, me->comm)) {
1332                 printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
1333                        me->comm);
1334                 strcpy(lastcomm, me->comm); 
1335         } 
1336         return -ENOSYS;
1337
1338
1339 long sys32_quotactl(void)
1340
1341         struct task_struct *me = current;
1342         static char lastcomm[8];
1343         if (strcmp(lastcomm, me->comm)) {
1344                 printk(KERN_INFO "%s: 32bit quotactl not supported on 64 bit kernel\n",
1345                        me->comm);
1346                 strcpy(lastcomm, me->comm); 
1347         } 
1348         return -ENOSYS;
1349
1350
1351 cond_syscall(sys32_ipc)
1352
1353 static int __init ia32_init (void)
1354 {
1355         printk("IA32 emulation $Id: sys_ia32.c,v 1.32 2002/03/24 13:02:28 ak Exp $\n");  
1356         return 0;
1357 }
1358
1359 __initcall(ia32_init);
1360
1361 extern unsigned long ia32_sys_call_table[];
1362 EXPORT_SYMBOL(ia32_sys_call_table);