[IPV6]: SNMPv2 "ipv6IfStatsInAddrErrors" counter error
[linux-2.6/zen-sources.git] / arch / powerpc / kernel / sys_ppc32.c
blob2e292863e982acac45b743248300d2820d73cbb7
1 /*
2 * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls.
4 * Copyright (C) 2001 IBM
5 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
8 * These routines maintain argument size conversion between 32bit and 64bit
9 * environment.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/fs.h>
20 #include <linux/mm.h>
21 #include <linux/file.h>
22 #include <linux/signal.h>
23 #include <linux/resource.h>
24 #include <linux/times.h>
25 #include <linux/utsname.h>
26 #include <linux/smp.h>
27 #include <linux/smp_lock.h>
28 #include <linux/sem.h>
29 #include <linux/msg.h>
30 #include <linux/shm.h>
31 #include <linux/poll.h>
32 #include <linux/personality.h>
33 #include <linux/stat.h>
34 #include <linux/mman.h>
35 #include <linux/in.h>
36 #include <linux/syscalls.h>
37 #include <linux/unistd.h>
38 #include <linux/sysctl.h>
39 #include <linux/binfmts.h>
40 #include <linux/security.h>
41 #include <linux/compat.h>
42 #include <linux/ptrace.h>
43 #include <linux/elf.h>
45 #include <asm/ptrace.h>
46 #include <asm/types.h>
47 #include <asm/ipc.h>
48 #include <asm/uaccess.h>
49 #include <asm/unistd.h>
50 #include <asm/semaphore.h>
51 #include <asm/time.h>
52 #include <asm/mmu_context.h>
53 #include <asm/ppc-pci.h>
55 /* readdir & getdents */
56 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
57 #define ROUND_UP(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
59 struct old_linux_dirent32 {
60 u32 d_ino;
61 u32 d_offset;
62 unsigned short d_namlen;
63 char d_name[1];
66 struct readdir_callback32 {
67 struct old_linux_dirent32 __user * dirent;
68 int count;
71 static int fillonedir(void * __buf, const char * name, int namlen,
72 off_t offset, ino_t ino, unsigned int d_type)
74 struct readdir_callback32 * buf = (struct readdir_callback32 *) __buf;
75 struct old_linux_dirent32 __user * dirent;
77 if (buf->count)
78 return -EINVAL;
79 buf->count++;
80 dirent = buf->dirent;
81 put_user(ino, &dirent->d_ino);
82 put_user(offset, &dirent->d_offset);
83 put_user(namlen, &dirent->d_namlen);
84 copy_to_user(dirent->d_name, name, namlen);
85 put_user(0, dirent->d_name + namlen);
86 return 0;
89 asmlinkage int old32_readdir(unsigned int fd, struct old_linux_dirent32 __user *dirent, unsigned int count)
91 int error = -EBADF;
92 struct file * file;
93 struct readdir_callback32 buf;
95 file = fget(fd);
96 if (!file)
97 goto out;
99 buf.count = 0;
100 buf.dirent = dirent;
102 error = vfs_readdir(file, (filldir_t)fillonedir, &buf);
103 if (error < 0)
104 goto out_putf;
105 error = buf.count;
107 out_putf:
108 fput(file);
109 out:
110 return error;
113 asmlinkage long ppc32_select(u32 n, compat_ulong_t __user *inp,
114 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
115 compat_uptr_t tvp_x)
117 /* sign extend n */
118 return compat_sys_select((int)n, inp, outp, exp, compat_ptr(tvp_x));
121 int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
123 long err;
125 if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
126 !new_valid_dev(stat->rdev))
127 return -EOVERFLOW;
129 err = access_ok(VERIFY_WRITE, statbuf, sizeof(*statbuf)) ? 0 : -EFAULT;
130 err |= __put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
131 err |= __put_user(stat->ino, &statbuf->st_ino);
132 err |= __put_user(stat->mode, &statbuf->st_mode);
133 err |= __put_user(stat->nlink, &statbuf->st_nlink);
134 err |= __put_user(stat->uid, &statbuf->st_uid);
135 err |= __put_user(stat->gid, &statbuf->st_gid);
136 err |= __put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
137 err |= __put_user(stat->size, &statbuf->st_size);
138 err |= __put_user(stat->atime.tv_sec, &statbuf->st_atime);
139 err |= __put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
140 err |= __put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
141 err |= __put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
142 err |= __put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
143 err |= __put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
144 err |= __put_user(stat->blksize, &statbuf->st_blksize);
145 err |= __put_user(stat->blocks, &statbuf->st_blocks);
146 err |= __put_user(0, &statbuf->__unused4[0]);
147 err |= __put_user(0, &statbuf->__unused4[1]);
149 return err;
152 /* Note: it is necessary to treat option as an unsigned int,
153 * with the corresponding cast to a signed int to insure that the
154 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
155 * and the register representation of a signed int (msr in 64-bit mode) is performed.
157 asmlinkage long compat_sys_sysfs(u32 option, u32 arg1, u32 arg2)
159 return sys_sysfs((int)option, arg1, arg2);
162 asmlinkage long compat_sys_pause(void)
164 current->state = TASK_INTERRUPTIBLE;
165 schedule();
167 return -ERESTARTNOHAND;
170 static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
172 long usec;
174 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
175 return -EFAULT;
176 if (__get_user(o->tv_sec, &i->tv_sec))
177 return -EFAULT;
178 if (__get_user(usec, &i->tv_usec))
179 return -EFAULT;
180 o->tv_nsec = usec * 1000;
181 return 0;
184 static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
186 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
187 (__put_user(i->tv_sec, &o->tv_sec) |
188 __put_user(i->tv_usec, &o->tv_usec)));
191 struct sysinfo32 {
192 s32 uptime;
193 u32 loads[3];
194 u32 totalram;
195 u32 freeram;
196 u32 sharedram;
197 u32 bufferram;
198 u32 totalswap;
199 u32 freeswap;
200 unsigned short procs;
201 unsigned short pad;
202 u32 totalhigh;
203 u32 freehigh;
204 u32 mem_unit;
205 char _f[20-2*sizeof(int)-sizeof(int)];
208 asmlinkage long compat_sys_sysinfo(struct sysinfo32 __user *info)
210 struct sysinfo s;
211 int ret, err;
212 int bitcount=0;
213 mm_segment_t old_fs = get_fs ();
215 /* The __user cast is valid due to set_fs() */
216 set_fs (KERNEL_DS);
217 ret = sys_sysinfo((struct sysinfo __user *)&s);
218 set_fs (old_fs);
220 /* Check to see if any memory value is too large for 32-bit and
221 * scale down if needed.
223 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
224 while (s.mem_unit < PAGE_SIZE) {
225 s.mem_unit <<= 1;
226 bitcount++;
228 s.totalram >>=bitcount;
229 s.freeram >>= bitcount;
230 s.sharedram >>= bitcount;
231 s.bufferram >>= bitcount;
232 s.totalswap >>= bitcount;
233 s.freeswap >>= bitcount;
234 s.totalhigh >>= bitcount;
235 s.freehigh >>= bitcount;
238 err = put_user (s.uptime, &info->uptime);
239 err |= __put_user (s.loads[0], &info->loads[0]);
240 err |= __put_user (s.loads[1], &info->loads[1]);
241 err |= __put_user (s.loads[2], &info->loads[2]);
242 err |= __put_user (s.totalram, &info->totalram);
243 err |= __put_user (s.freeram, &info->freeram);
244 err |= __put_user (s.sharedram, &info->sharedram);
245 err |= __put_user (s.bufferram, &info->bufferram);
246 err |= __put_user (s.totalswap, &info->totalswap);
247 err |= __put_user (s.freeswap, &info->freeswap);
248 err |= __put_user (s.procs, &info->procs);
249 err |= __put_user (s.totalhigh, &info->totalhigh);
250 err |= __put_user (s.freehigh, &info->freehigh);
251 err |= __put_user (s.mem_unit, &info->mem_unit);
252 if (err)
253 return -EFAULT;
255 return ret;
261 /* Translations due to time_t size differences. Which affects all
262 sorts of things, like timeval and itimerval. */
263 extern struct timezone sys_tz;
265 asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
267 if (tv) {
268 struct timeval ktv;
269 do_gettimeofday(&ktv);
270 if (put_tv32(tv, &ktv))
271 return -EFAULT;
273 if (tz) {
274 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
275 return -EFAULT;
278 return 0;
283 asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
285 struct timespec kts;
286 struct timezone ktz;
288 if (tv) {
289 if (get_ts32(&kts, tv))
290 return -EFAULT;
292 if (tz) {
293 if (copy_from_user(&ktz, tz, sizeof(ktz)))
294 return -EFAULT;
297 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
300 #ifdef CONFIG_SYSVIPC
301 long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
302 u32 fifth)
304 int version;
306 version = call >> 16; /* hack for backward compatibility */
307 call &= 0xffff;
309 switch (call) {
311 case SEMTIMEDOP:
312 if (fifth)
313 /* sign extend semid */
314 return compat_sys_semtimedop((int)first,
315 compat_ptr(ptr), second,
316 compat_ptr(fifth));
317 /* else fall through for normal semop() */
318 case SEMOP:
319 /* struct sembuf is the same on 32 and 64bit :)) */
320 /* sign extend semid */
321 return sys_semtimedop((int)first, compat_ptr(ptr), second,
322 NULL);
323 case SEMGET:
324 /* sign extend key, nsems */
325 return sys_semget((int)first, (int)second, third);
326 case SEMCTL:
327 /* sign extend semid, semnum */
328 return compat_sys_semctl((int)first, (int)second, third,
329 compat_ptr(ptr));
331 case MSGSND:
332 /* sign extend msqid */
333 return compat_sys_msgsnd((int)first, (int)second, third,
334 compat_ptr(ptr));
335 case MSGRCV:
336 /* sign extend msqid, msgtyp */
337 return compat_sys_msgrcv((int)first, second, (int)fifth,
338 third, version, compat_ptr(ptr));
339 case MSGGET:
340 /* sign extend key */
341 return sys_msgget((int)first, second);
342 case MSGCTL:
343 /* sign extend msqid */
344 return compat_sys_msgctl((int)first, second, compat_ptr(ptr));
346 case SHMAT:
347 /* sign extend shmid */
348 return compat_sys_shmat((int)first, second, third, version,
349 compat_ptr(ptr));
350 case SHMDT:
351 return sys_shmdt(compat_ptr(ptr));
352 case SHMGET:
353 /* sign extend key_t */
354 return sys_shmget((int)first, second, third);
355 case SHMCTL:
356 /* sign extend shmid */
357 return compat_sys_shmctl((int)first, second, compat_ptr(ptr));
359 default:
360 return -ENOSYS;
363 return -ENOSYS;
365 #endif
367 /* Note: it is necessary to treat out_fd and in_fd as unsigned ints,
368 * with the corresponding cast to a signed int to insure that the
369 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
370 * and the register representation of a signed int (msr in 64-bit mode) is performed.
372 asmlinkage long compat_sys_sendfile(u32 out_fd, u32 in_fd, compat_off_t __user * offset, u32 count)
374 mm_segment_t old_fs = get_fs();
375 int ret;
376 off_t of;
377 off_t __user *up;
379 if (offset && get_user(of, offset))
380 return -EFAULT;
382 /* The __user pointer cast is valid because of the set_fs() */
383 set_fs(KERNEL_DS);
384 up = offset ? (off_t __user *) &of : NULL;
385 ret = sys_sendfile((int)out_fd, (int)in_fd, up, count);
386 set_fs(old_fs);
388 if (offset && put_user(of, offset))
389 return -EFAULT;
391 return ret;
394 asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
396 mm_segment_t old_fs = get_fs();
397 int ret;
398 loff_t lof;
399 loff_t __user *up;
401 if (offset && get_user(lof, offset))
402 return -EFAULT;
404 /* The __user pointer cast is valid because of the set_fs() */
405 set_fs(KERNEL_DS);
406 up = offset ? (loff_t __user *) &lof : NULL;
407 ret = sys_sendfile64(out_fd, in_fd, up, count);
408 set_fs(old_fs);
410 if (offset && put_user(lof, offset))
411 return -EFAULT;
413 return ret;
416 long compat_sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
417 unsigned long a3, unsigned long a4, unsigned long a5,
418 struct pt_regs *regs)
420 int error;
421 char * filename;
423 filename = getname((char __user *) a0);
424 error = PTR_ERR(filename);
425 if (IS_ERR(filename))
426 goto out;
427 flush_fp_to_thread(current);
428 flush_altivec_to_thread(current);
430 error = compat_do_execve(filename, compat_ptr(a1), compat_ptr(a2), regs);
432 if (error == 0) {
433 task_lock(current);
434 current->ptrace &= ~PT_DTRACE;
435 task_unlock(current);
437 putname(filename);
439 out:
440 return error;
443 /* Note: it is necessary to treat option as an unsigned int,
444 * with the corresponding cast to a signed int to insure that the
445 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
446 * and the register representation of a signed int (msr in 64-bit mode) is performed.
448 asmlinkage long compat_sys_prctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
450 return sys_prctl((int)option,
451 (unsigned long) arg2,
452 (unsigned long) arg3,
453 (unsigned long) arg4,
454 (unsigned long) arg5);
457 /* Note: it is necessary to treat pid as an unsigned int,
458 * with the corresponding cast to a signed int to insure that the
459 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
460 * and the register representation of a signed int (msr in 64-bit mode) is performed.
462 asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec __user *interval)
464 struct timespec t;
465 int ret;
466 mm_segment_t old_fs = get_fs ();
468 /* The __user pointer cast is valid because of the set_fs() */
469 set_fs (KERNEL_DS);
470 ret = sys_sched_rr_get_interval((int)pid, (struct timespec __user *) &t);
471 set_fs (old_fs);
472 if (put_compat_timespec(&t, interval))
473 return -EFAULT;
474 return ret;
477 /* Note: it is necessary to treat mode as an unsigned int,
478 * with the corresponding cast to a signed int to insure that the
479 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
480 * and the register representation of a signed int (msr in 64-bit mode) is performed.
482 asmlinkage long compat_sys_access(const char __user * filename, u32 mode)
484 return sys_access(filename, (int)mode);
488 /* Note: it is necessary to treat mode as an unsigned int,
489 * with the corresponding cast to a signed int to insure that the
490 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
491 * and the register representation of a signed int (msr in 64-bit mode) is performed.
493 asmlinkage long compat_sys_creat(const char __user * pathname, u32 mode)
495 return sys_creat(pathname, (int)mode);
499 /* Note: it is necessary to treat pid and options as unsigned ints,
500 * with the corresponding cast to a signed int to insure that the
501 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
502 * and the register representation of a signed int (msr in 64-bit mode) is performed.
504 asmlinkage long compat_sys_waitpid(u32 pid, unsigned int __user * stat_addr, u32 options)
506 return sys_waitpid((int)pid, stat_addr, (int)options);
510 /* Note: it is necessary to treat gidsetsize as an unsigned int,
511 * with the corresponding cast to a signed int to insure that the
512 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
513 * and the register representation of a signed int (msr in 64-bit mode) is performed.
515 asmlinkage long compat_sys_getgroups(u32 gidsetsize, gid_t __user *grouplist)
517 return sys_getgroups((int)gidsetsize, grouplist);
521 /* Note: it is necessary to treat pid as an unsigned int,
522 * with the corresponding cast to a signed int to insure that the
523 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
524 * and the register representation of a signed int (msr in 64-bit mode) is performed.
526 asmlinkage long compat_sys_getpgid(u32 pid)
528 return sys_getpgid((int)pid);
533 /* Note: it is necessary to treat pid as an unsigned int,
534 * with the corresponding cast to a signed int to insure that the
535 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
536 * and the register representation of a signed int (msr in 64-bit mode) is performed.
538 asmlinkage long compat_sys_getsid(u32 pid)
540 return sys_getsid((int)pid);
544 /* Note: it is necessary to treat pid and sig as unsigned ints,
545 * with the corresponding cast to a signed int to insure that the
546 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
547 * and the register representation of a signed int (msr in 64-bit mode) is performed.
549 asmlinkage long compat_sys_kill(u32 pid, u32 sig)
551 return sys_kill((int)pid, (int)sig);
555 /* Note: it is necessary to treat mode as an unsigned int,
556 * with the corresponding cast to a signed int to insure that the
557 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
558 * and the register representation of a signed int (msr in 64-bit mode) is performed.
560 asmlinkage long compat_sys_mkdir(const char __user * pathname, u32 mode)
562 return sys_mkdir(pathname, (int)mode);
565 long compat_sys_nice(u32 increment)
567 /* sign extend increment */
568 return sys_nice((int)increment);
571 off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
573 /* sign extend n */
574 return sys_lseek(fd, (int)offset, origin);
577 /* Note: it is necessary to treat bufsiz as an unsigned int,
578 * with the corresponding cast to a signed int to insure that the
579 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
580 * and the register representation of a signed int (msr in 64-bit mode) is performed.
582 asmlinkage long compat_sys_readlink(const char __user * path, char __user * buf, u32 bufsiz)
584 return sys_readlink(path, buf, (int)bufsiz);
587 /* Note: it is necessary to treat option as an unsigned int,
588 * with the corresponding cast to a signed int to insure that the
589 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
590 * and the register representation of a signed int (msr in 64-bit mode) is performed.
592 asmlinkage long compat_sys_sched_get_priority_max(u32 policy)
594 return sys_sched_get_priority_max((int)policy);
598 /* Note: it is necessary to treat policy as an unsigned int,
599 * with the corresponding cast to a signed int to insure that the
600 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
601 * and the register representation of a signed int (msr in 64-bit mode) is performed.
603 asmlinkage long compat_sys_sched_get_priority_min(u32 policy)
605 return sys_sched_get_priority_min((int)policy);
609 /* Note: it is necessary to treat pid as an unsigned int,
610 * with the corresponding cast to a signed int to insure that the
611 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
612 * and the register representation of a signed int (msr in 64-bit mode) is performed.
614 asmlinkage long compat_sys_sched_getparam(u32 pid, struct sched_param __user *param)
616 return sys_sched_getparam((int)pid, param);
620 /* Note: it is necessary to treat pid as an unsigned int,
621 * with the corresponding cast to a signed int to insure that the
622 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
623 * and the register representation of a signed int (msr in 64-bit mode) is performed.
625 asmlinkage long compat_sys_sched_getscheduler(u32 pid)
627 return sys_sched_getscheduler((int)pid);
631 /* Note: it is necessary to treat pid as an unsigned int,
632 * with the corresponding cast to a signed int to insure that the
633 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
634 * and the register representation of a signed int (msr in 64-bit mode) is performed.
636 asmlinkage long compat_sys_sched_setparam(u32 pid, struct sched_param __user *param)
638 return sys_sched_setparam((int)pid, param);
642 /* Note: it is necessary to treat pid and policy as unsigned ints,
643 * with the corresponding cast to a signed int to insure that the
644 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
645 * and the register representation of a signed int (msr in 64-bit mode) is performed.
647 asmlinkage long compat_sys_sched_setscheduler(u32 pid, u32 policy, struct sched_param __user *param)
649 return sys_sched_setscheduler((int)pid, (int)policy, param);
653 /* Note: it is necessary to treat len as an unsigned int,
654 * with the corresponding cast to a signed int to insure that the
655 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
656 * and the register representation of a signed int (msr in 64-bit mode) is performed.
658 asmlinkage long compat_sys_setdomainname(char __user *name, u32 len)
660 return sys_setdomainname(name, (int)len);
664 /* Note: it is necessary to treat gidsetsize as an unsigned int,
665 * with the corresponding cast to a signed int to insure that the
666 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
667 * and the register representation of a signed int (msr in 64-bit mode) is performed.
669 asmlinkage long compat_sys_setgroups(u32 gidsetsize, gid_t __user *grouplist)
671 return sys_setgroups((int)gidsetsize, grouplist);
675 asmlinkage long compat_sys_sethostname(char __user *name, u32 len)
677 /* sign extend len */
678 return sys_sethostname(name, (int)len);
682 /* Note: it is necessary to treat pid and pgid as unsigned ints,
683 * with the corresponding cast to a signed int to insure that the
684 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
685 * and the register representation of a signed int (msr in 64-bit mode) is performed.
687 asmlinkage long compat_sys_setpgid(u32 pid, u32 pgid)
689 return sys_setpgid((int)pid, (int)pgid);
692 long compat_sys_getpriority(u32 which, u32 who)
694 /* sign extend which and who */
695 return sys_getpriority((int)which, (int)who);
698 long compat_sys_setpriority(u32 which, u32 who, u32 niceval)
700 /* sign extend which, who and niceval */
701 return sys_setpriority((int)which, (int)who, (int)niceval);
704 long compat_sys_ioprio_get(u32 which, u32 who)
706 /* sign extend which and who */
707 return sys_ioprio_get((int)which, (int)who);
710 long compat_sys_ioprio_set(u32 which, u32 who, u32 ioprio)
712 /* sign extend which, who and ioprio */
713 return sys_ioprio_set((int)which, (int)who, (int)ioprio);
716 /* Note: it is necessary to treat newmask as an unsigned int,
717 * with the corresponding cast to a signed int to insure that the
718 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
719 * and the register representation of a signed int (msr in 64-bit mode) is performed.
721 asmlinkage long compat_sys_ssetmask(u32 newmask)
723 return sys_ssetmask((int) newmask);
726 asmlinkage long compat_sys_syslog(u32 type, char __user * buf, u32 len)
728 /* sign extend len */
729 return sys_syslog(type, buf, (int)len);
733 /* Note: it is necessary to treat mask as an unsigned int,
734 * with the corresponding cast to a signed int to insure that the
735 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
736 * and the register representation of a signed int (msr in 64-bit mode) is performed.
738 asmlinkage long compat_sys_umask(u32 mask)
740 return sys_umask((int)mask);
743 #ifdef CONFIG_SYSCTL
744 struct __sysctl_args32 {
745 u32 name;
746 int nlen;
747 u32 oldval;
748 u32 oldlenp;
749 u32 newval;
750 u32 newlen;
751 u32 __unused[4];
754 asmlinkage long compat_sys_sysctl(struct __sysctl_args32 __user *args)
756 struct __sysctl_args32 tmp;
757 int error;
758 size_t oldlen;
759 size_t __user *oldlenp = NULL;
760 unsigned long addr = (((unsigned long)&args->__unused[0]) + 7) & ~7;
762 if (copy_from_user(&tmp, args, sizeof(tmp)))
763 return -EFAULT;
765 if (tmp.oldval && tmp.oldlenp) {
766 /* Duh, this is ugly and might not work if sysctl_args
767 is in read-only memory, but do_sysctl does indirectly
768 a lot of uaccess in both directions and we'd have to
769 basically copy the whole sysctl.c here, and
770 glibc's __sysctl uses rw memory for the structure
771 anyway. */
772 oldlenp = (size_t __user *)addr;
773 if (get_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)) ||
774 put_user(oldlen, oldlenp))
775 return -EFAULT;
778 lock_kernel();
779 error = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
780 compat_ptr(tmp.oldval), oldlenp,
781 compat_ptr(tmp.newval), tmp.newlen);
782 unlock_kernel();
783 if (oldlenp) {
784 if (!error) {
785 if (get_user(oldlen, oldlenp) ||
786 put_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)))
787 error = -EFAULT;
789 copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused));
791 return error;
793 #endif
795 unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
796 unsigned long prot, unsigned long flags,
797 unsigned long fd, unsigned long pgoff)
799 /* This should remain 12 even if PAGE_SIZE changes */
800 return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
803 long compat_sys_tgkill(u32 tgid, u32 pid, int sig)
805 /* sign extend tgid, pid */
806 return sys_tgkill((int)tgid, (int)pid, sig);
810 * long long munging:
811 * The 32 bit ABI passes long longs in an odd even register pair.
814 compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
815 u32 reg6, u32 poshi, u32 poslo)
817 return sys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
820 compat_ssize_t compat_sys_pwrite64(unsigned int fd, char __user *ubuf, compat_size_t count,
821 u32 reg6, u32 poshi, u32 poslo)
823 return sys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
826 compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count)
828 return sys_readahead(fd, ((loff_t)offhi << 32) | offlo, count);
831 asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
832 unsigned long high, unsigned long low)
834 return sys_truncate(path, (high << 32) | low);
837 asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
838 unsigned long low)
840 return sys_ftruncate(fd, (high << 32) | low);
843 long ppc32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
844 size_t len)
846 return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
847 buf, len);
850 long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
851 size_t len, int advice)
853 return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len,
854 advice);
857 asmlinkage long compat_sys_add_key(const char __user *_type,
858 const char __user *_description,
859 const void __user *_payload,
860 u32 plen,
861 u32 ringid)
863 return sys_add_key(_type, _description, _payload, plen, ringid);
866 asmlinkage long compat_sys_request_key(const char __user *_type,
867 const char __user *_description,
868 const char __user *_callout_info,
869 u32 destringid)
871 return sys_request_key(_type, _description, _callout_info, destringid);