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
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/config.h>
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
22 #include <linux/file.h>
23 #include <linux/signal.h>
24 #include <linux/resource.h>
25 #include <linux/times.h>
26 #include <linux/utsname.h>
27 #include <linux/timex.h>
28 #include <linux/smp.h>
29 #include <linux/smp_lock.h>
30 #include <linux/sem.h>
31 #include <linux/msg.h>
32 #include <linux/shm.h>
33 #include <linux/poll.h>
34 #include <linux/personality.h>
35 #include <linux/stat.h>
36 #include <linux/mman.h>
38 #include <linux/syscalls.h>
39 #include <linux/unistd.h>
40 #include <linux/sysctl.h>
41 #include <linux/binfmts.h>
42 #include <linux/security.h>
43 #include <linux/compat.h>
44 #include <linux/ptrace.h>
45 #include <linux/elf.h>
47 #include <asm/ptrace.h>
48 #include <asm/types.h>
50 #include <asm/uaccess.h>
51 #include <asm/unistd.h>
52 #include <asm/semaphore.h>
54 #include <asm/mmu_context.h>
55 #include <asm/ppc-pci.h>
57 /* readdir & getdents */
58 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
59 #define ROUND_UP(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
61 struct old_linux_dirent32
{
64 unsigned short d_namlen
;
68 struct readdir_callback32
{
69 struct old_linux_dirent32 __user
* dirent
;
73 static int fillonedir(void * __buf
, const char * name
, int namlen
,
74 off_t offset
, ino_t ino
, unsigned int d_type
)
76 struct readdir_callback32
* buf
= (struct readdir_callback32
*) __buf
;
77 struct old_linux_dirent32 __user
* dirent
;
83 put_user(ino
, &dirent
->d_ino
);
84 put_user(offset
, &dirent
->d_offset
);
85 put_user(namlen
, &dirent
->d_namlen
);
86 copy_to_user(dirent
->d_name
, name
, namlen
);
87 put_user(0, dirent
->d_name
+ namlen
);
91 asmlinkage
int old32_readdir(unsigned int fd
, struct old_linux_dirent32 __user
*dirent
, unsigned int count
)
95 struct readdir_callback32 buf
;
104 error
= vfs_readdir(file
, (filldir_t
)fillonedir
, &buf
);
115 asmlinkage
long ppc32_select(u32 n
, compat_ulong_t __user
*inp
,
116 compat_ulong_t __user
*outp
, compat_ulong_t __user
*exp
,
120 return compat_sys_select((int)n
, inp
, outp
, exp
, compat_ptr(tvp_x
));
123 int cp_compat_stat(struct kstat
*stat
, struct compat_stat __user
*statbuf
)
127 if (stat
->size
> MAX_NON_LFS
|| !new_valid_dev(stat
->dev
) ||
128 !new_valid_dev(stat
->rdev
))
131 err
= access_ok(VERIFY_WRITE
, statbuf
, sizeof(*statbuf
)) ? 0 : -EFAULT
;
132 err
|= __put_user(new_encode_dev(stat
->dev
), &statbuf
->st_dev
);
133 err
|= __put_user(stat
->ino
, &statbuf
->st_ino
);
134 err
|= __put_user(stat
->mode
, &statbuf
->st_mode
);
135 err
|= __put_user(stat
->nlink
, &statbuf
->st_nlink
);
136 err
|= __put_user(stat
->uid
, &statbuf
->st_uid
);
137 err
|= __put_user(stat
->gid
, &statbuf
->st_gid
);
138 err
|= __put_user(new_encode_dev(stat
->rdev
), &statbuf
->st_rdev
);
139 err
|= __put_user(stat
->size
, &statbuf
->st_size
);
140 err
|= __put_user(stat
->atime
.tv_sec
, &statbuf
->st_atime
);
141 err
|= __put_user(stat
->atime
.tv_nsec
, &statbuf
->st_atime_nsec
);
142 err
|= __put_user(stat
->mtime
.tv_sec
, &statbuf
->st_mtime
);
143 err
|= __put_user(stat
->mtime
.tv_nsec
, &statbuf
->st_mtime_nsec
);
144 err
|= __put_user(stat
->ctime
.tv_sec
, &statbuf
->st_ctime
);
145 err
|= __put_user(stat
->ctime
.tv_nsec
, &statbuf
->st_ctime_nsec
);
146 err
|= __put_user(stat
->blksize
, &statbuf
->st_blksize
);
147 err
|= __put_user(stat
->blocks
, &statbuf
->st_blocks
);
148 err
|= __put_user(0, &statbuf
->__unused4
[0]);
149 err
|= __put_user(0, &statbuf
->__unused4
[1]);
154 /* Note: it is necessary to treat option as an unsigned int,
155 * with the corresponding cast to a signed int to insure that the
156 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
157 * and the register representation of a signed int (msr in 64-bit mode) is performed.
159 asmlinkage
long compat_sys_sysfs(u32 option
, u32 arg1
, u32 arg2
)
161 return sys_sysfs((int)option
, arg1
, arg2
);
164 /* Handle adjtimex compatibility. */
167 s32 offset
, freq
, maxerror
, esterror
;
168 s32 status
, constant
, precision
, tolerance
;
169 struct compat_timeval time
;
171 s32 ppsfreq
, jitter
, shift
, stabil
;
172 s32 jitcnt
, calcnt
, errcnt
, stbcnt
;
173 s32
:32; s32
:32; s32
:32; s32
:32;
174 s32
:32; s32
:32; s32
:32; s32
:32;
175 s32
:32; s32
:32; s32
:32; s32
:32;
178 extern int do_adjtimex(struct timex
*);
179 extern void ppc_adjtimex(void);
181 asmlinkage
long compat_sys_adjtimex(struct timex32 __user
*utp
)
186 memset(&txc
, 0, sizeof(struct timex
));
188 if(get_user(txc
.modes
, &utp
->modes
) ||
189 __get_user(txc
.offset
, &utp
->offset
) ||
190 __get_user(txc
.freq
, &utp
->freq
) ||
191 __get_user(txc
.maxerror
, &utp
->maxerror
) ||
192 __get_user(txc
.esterror
, &utp
->esterror
) ||
193 __get_user(txc
.status
, &utp
->status
) ||
194 __get_user(txc
.constant
, &utp
->constant
) ||
195 __get_user(txc
.precision
, &utp
->precision
) ||
196 __get_user(txc
.tolerance
, &utp
->tolerance
) ||
197 __get_user(txc
.time
.tv_sec
, &utp
->time
.tv_sec
) ||
198 __get_user(txc
.time
.tv_usec
, &utp
->time
.tv_usec
) ||
199 __get_user(txc
.tick
, &utp
->tick
) ||
200 __get_user(txc
.ppsfreq
, &utp
->ppsfreq
) ||
201 __get_user(txc
.jitter
, &utp
->jitter
) ||
202 __get_user(txc
.shift
, &utp
->shift
) ||
203 __get_user(txc
.stabil
, &utp
->stabil
) ||
204 __get_user(txc
.jitcnt
, &utp
->jitcnt
) ||
205 __get_user(txc
.calcnt
, &utp
->calcnt
) ||
206 __get_user(txc
.errcnt
, &utp
->errcnt
) ||
207 __get_user(txc
.stbcnt
, &utp
->stbcnt
))
210 ret
= do_adjtimex(&txc
);
212 /* adjust the conversion of TB to time of day to track adjtimex */
215 if(put_user(txc
.modes
, &utp
->modes
) ||
216 __put_user(txc
.offset
, &utp
->offset
) ||
217 __put_user(txc
.freq
, &utp
->freq
) ||
218 __put_user(txc
.maxerror
, &utp
->maxerror
) ||
219 __put_user(txc
.esterror
, &utp
->esterror
) ||
220 __put_user(txc
.status
, &utp
->status
) ||
221 __put_user(txc
.constant
, &utp
->constant
) ||
222 __put_user(txc
.precision
, &utp
->precision
) ||
223 __put_user(txc
.tolerance
, &utp
->tolerance
) ||
224 __put_user(txc
.time
.tv_sec
, &utp
->time
.tv_sec
) ||
225 __put_user(txc
.time
.tv_usec
, &utp
->time
.tv_usec
) ||
226 __put_user(txc
.tick
, &utp
->tick
) ||
227 __put_user(txc
.ppsfreq
, &utp
->ppsfreq
) ||
228 __put_user(txc
.jitter
, &utp
->jitter
) ||
229 __put_user(txc
.shift
, &utp
->shift
) ||
230 __put_user(txc
.stabil
, &utp
->stabil
) ||
231 __put_user(txc
.jitcnt
, &utp
->jitcnt
) ||
232 __put_user(txc
.calcnt
, &utp
->calcnt
) ||
233 __put_user(txc
.errcnt
, &utp
->errcnt
) ||
234 __put_user(txc
.stbcnt
, &utp
->stbcnt
))
240 asmlinkage
long compat_sys_pause(void)
242 current
->state
= TASK_INTERRUPTIBLE
;
245 return -ERESTARTNOHAND
;
248 static inline long get_ts32(struct timespec
*o
, struct compat_timeval __user
*i
)
252 if (!access_ok(VERIFY_READ
, i
, sizeof(*i
)))
254 if (__get_user(o
->tv_sec
, &i
->tv_sec
))
256 if (__get_user(usec
, &i
->tv_usec
))
258 o
->tv_nsec
= usec
* 1000;
262 static inline long put_tv32(struct compat_timeval __user
*o
, struct timeval
*i
)
264 return (!access_ok(VERIFY_WRITE
, o
, sizeof(*o
)) ||
265 (__put_user(i
->tv_sec
, &o
->tv_sec
) |
266 __put_user(i
->tv_usec
, &o
->tv_usec
)));
278 unsigned short procs
;
283 char _f
[20-2*sizeof(int)-sizeof(int)];
286 asmlinkage
long compat_sys_sysinfo(struct sysinfo32 __user
*info
)
291 mm_segment_t old_fs
= get_fs ();
293 /* The __user cast is valid due to set_fs() */
295 ret
= sys_sysinfo((struct sysinfo __user
*)&s
);
298 /* Check to see if any memory value is too large for 32-bit and
299 * scale down if needed.
301 if ((s
.totalram
>> 32) || (s
.totalswap
>> 32)) {
302 while (s
.mem_unit
< PAGE_SIZE
) {
306 s
.totalram
>>=bitcount
;
307 s
.freeram
>>= bitcount
;
308 s
.sharedram
>>= bitcount
;
309 s
.bufferram
>>= bitcount
;
310 s
.totalswap
>>= bitcount
;
311 s
.freeswap
>>= bitcount
;
312 s
.totalhigh
>>= bitcount
;
313 s
.freehigh
>>= bitcount
;
316 err
= put_user (s
.uptime
, &info
->uptime
);
317 err
|= __put_user (s
.loads
[0], &info
->loads
[0]);
318 err
|= __put_user (s
.loads
[1], &info
->loads
[1]);
319 err
|= __put_user (s
.loads
[2], &info
->loads
[2]);
320 err
|= __put_user (s
.totalram
, &info
->totalram
);
321 err
|= __put_user (s
.freeram
, &info
->freeram
);
322 err
|= __put_user (s
.sharedram
, &info
->sharedram
);
323 err
|= __put_user (s
.bufferram
, &info
->bufferram
);
324 err
|= __put_user (s
.totalswap
, &info
->totalswap
);
325 err
|= __put_user (s
.freeswap
, &info
->freeswap
);
326 err
|= __put_user (s
.procs
, &info
->procs
);
327 err
|= __put_user (s
.totalhigh
, &info
->totalhigh
);
328 err
|= __put_user (s
.freehigh
, &info
->freehigh
);
329 err
|= __put_user (s
.mem_unit
, &info
->mem_unit
);
339 /* Translations due to time_t size differences. Which affects all
340 sorts of things, like timeval and itimerval. */
341 extern struct timezone sys_tz
;
343 asmlinkage
long compat_sys_gettimeofday(struct compat_timeval __user
*tv
, struct timezone __user
*tz
)
347 do_gettimeofday(&ktv
);
348 if (put_tv32(tv
, &ktv
))
352 if (copy_to_user(tz
, &sys_tz
, sizeof(sys_tz
)))
361 asmlinkage
long compat_sys_settimeofday(struct compat_timeval __user
*tv
, struct timezone __user
*tz
)
367 if (get_ts32(&kts
, tv
))
371 if (copy_from_user(&ktz
, tz
, sizeof(ktz
)))
375 return do_sys_settimeofday(tv
? &kts
: NULL
, tz
? &ktz
: NULL
);
378 #ifdef CONFIG_SYSVIPC
379 long compat_sys_ipc(u32 call
, u32 first
, u32 second
, u32 third
, compat_uptr_t ptr
,
384 version
= call
>> 16; /* hack for backward compatibility */
391 /* sign extend semid */
392 return compat_sys_semtimedop((int)first
,
393 compat_ptr(ptr
), second
,
395 /* else fall through for normal semop() */
397 /* struct sembuf is the same on 32 and 64bit :)) */
398 /* sign extend semid */
399 return sys_semtimedop((int)first
, compat_ptr(ptr
), second
,
402 /* sign extend key, nsems */
403 return sys_semget((int)first
, (int)second
, third
);
405 /* sign extend semid, semnum */
406 return compat_sys_semctl((int)first
, (int)second
, third
,
410 /* sign extend msqid */
411 return compat_sys_msgsnd((int)first
, (int)second
, third
,
414 /* sign extend msqid, msgtyp */
415 return compat_sys_msgrcv((int)first
, second
, (int)fifth
,
416 third
, version
, compat_ptr(ptr
));
418 /* sign extend key */
419 return sys_msgget((int)first
, second
);
421 /* sign extend msqid */
422 return compat_sys_msgctl((int)first
, second
, compat_ptr(ptr
));
425 /* sign extend shmid */
426 return compat_sys_shmat((int)first
, second
, third
, version
,
429 return sys_shmdt(compat_ptr(ptr
));
431 /* sign extend key_t */
432 return sys_shmget((int)first
, second
, third
);
434 /* sign extend shmid */
435 return compat_sys_shmctl((int)first
, second
, compat_ptr(ptr
));
445 /* Note: it is necessary to treat out_fd and in_fd as unsigned ints,
446 * with the corresponding cast to a signed int to insure that the
447 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
448 * and the register representation of a signed int (msr in 64-bit mode) is performed.
450 asmlinkage
long compat_sys_sendfile(u32 out_fd
, u32 in_fd
, compat_off_t __user
* offset
, u32 count
)
452 mm_segment_t old_fs
= get_fs();
457 if (offset
&& get_user(of
, offset
))
460 /* The __user pointer cast is valid because of the set_fs() */
462 up
= offset
? (off_t __user
*) &of
: NULL
;
463 ret
= sys_sendfile((int)out_fd
, (int)in_fd
, up
, count
);
466 if (offset
&& put_user(of
, offset
))
472 asmlinkage
int compat_sys_sendfile64(int out_fd
, int in_fd
, compat_loff_t __user
*offset
, s32 count
)
474 mm_segment_t old_fs
= get_fs();
479 if (offset
&& get_user(lof
, offset
))
482 /* The __user pointer cast is valid because of the set_fs() */
484 up
= offset
? (loff_t __user
*) &lof
: NULL
;
485 ret
= sys_sendfile64(out_fd
, in_fd
, up
, count
);
488 if (offset
&& put_user(lof
, offset
))
494 long compat_sys_execve(unsigned long a0
, unsigned long a1
, unsigned long a2
,
495 unsigned long a3
, unsigned long a4
, unsigned long a5
,
496 struct pt_regs
*regs
)
501 filename
= getname((char __user
*) a0
);
502 error
= PTR_ERR(filename
);
503 if (IS_ERR(filename
))
505 flush_fp_to_thread(current
);
506 flush_altivec_to_thread(current
);
508 error
= compat_do_execve(filename
, compat_ptr(a1
), compat_ptr(a2
), regs
);
512 current
->ptrace
&= ~PT_DTRACE
;
513 task_unlock(current
);
521 /* Note: it is necessary to treat option 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_prctl(u32 option
, u32 arg2
, u32 arg3
, u32 arg4
, u32 arg5
)
528 return sys_prctl((int)option
,
529 (unsigned long) arg2
,
530 (unsigned long) arg3
,
531 (unsigned long) arg4
,
532 (unsigned long) arg5
);
535 /* Note: it is necessary to treat pid as an unsigned int,
536 * with the corresponding cast to a signed int to insure that the
537 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
538 * and the register representation of a signed int (msr in 64-bit mode) is performed.
540 asmlinkage
long compat_sys_sched_rr_get_interval(u32 pid
, struct compat_timespec __user
*interval
)
544 mm_segment_t old_fs
= get_fs ();
546 /* The __user pointer cast is valid because of the set_fs() */
548 ret
= sys_sched_rr_get_interval((int)pid
, (struct timespec __user
*) &t
);
550 if (put_compat_timespec(&t
, interval
))
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_access(const char __user
* filename
, u32 mode
)
562 return sys_access(filename
, (int)mode
);
566 /* Note: it is necessary to treat mode as an unsigned int,
567 * with the corresponding cast to a signed int to insure that the
568 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
569 * and the register representation of a signed int (msr in 64-bit mode) is performed.
571 asmlinkage
long compat_sys_creat(const char __user
* pathname
, u32 mode
)
573 return sys_creat(pathname
, (int)mode
);
577 /* Note: it is necessary to treat pid and options as unsigned ints,
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_waitpid(u32 pid
, unsigned int __user
* stat_addr
, u32 options
)
584 return sys_waitpid((int)pid
, stat_addr
, (int)options
);
588 /* Note: it is necessary to treat gidsetsize as an unsigned int,
589 * with the corresponding cast to a signed int to insure that the
590 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
591 * and the register representation of a signed int (msr in 64-bit mode) is performed.
593 asmlinkage
long compat_sys_getgroups(u32 gidsetsize
, gid_t __user
*grouplist
)
595 return sys_getgroups((int)gidsetsize
, grouplist
);
599 /* Note: it is necessary to treat pid as an unsigned int,
600 * with the corresponding cast to a signed int to insure that the
601 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
602 * and the register representation of a signed int (msr in 64-bit mode) is performed.
604 asmlinkage
long compat_sys_getpgid(u32 pid
)
606 return sys_getpgid((int)pid
);
611 /* Note: it is necessary to treat pid as an unsigned int,
612 * with the corresponding cast to a signed int to insure that the
613 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
614 * and the register representation of a signed int (msr in 64-bit mode) is performed.
616 asmlinkage
long compat_sys_getsid(u32 pid
)
618 return sys_getsid((int)pid
);
622 /* Note: it is necessary to treat pid and sig as unsigned ints,
623 * with the corresponding cast to a signed int to insure that the
624 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
625 * and the register representation of a signed int (msr in 64-bit mode) is performed.
627 asmlinkage
long compat_sys_kill(u32 pid
, u32 sig
)
629 return sys_kill((int)pid
, (int)sig
);
633 /* Note: it is necessary to treat mode as an unsigned int,
634 * with the corresponding cast to a signed int to insure that the
635 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
636 * and the register representation of a signed int (msr in 64-bit mode) is performed.
638 asmlinkage
long compat_sys_mkdir(const char __user
* pathname
, u32 mode
)
640 return sys_mkdir(pathname
, (int)mode
);
643 long compat_sys_nice(u32 increment
)
645 /* sign extend increment */
646 return sys_nice((int)increment
);
649 off_t
ppc32_lseek(unsigned int fd
, u32 offset
, unsigned int origin
)
652 return sys_lseek(fd
, (int)offset
, origin
);
655 /* Note: it is necessary to treat bufsiz as an unsigned int,
656 * with the corresponding cast to a signed int to insure that the
657 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
658 * and the register representation of a signed int (msr in 64-bit mode) is performed.
660 asmlinkage
long compat_sys_readlink(const char __user
* path
, char __user
* buf
, u32 bufsiz
)
662 return sys_readlink(path
, buf
, (int)bufsiz
);
665 /* Note: it is necessary to treat option as an unsigned int,
666 * with the corresponding cast to a signed int to insure that the
667 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
668 * and the register representation of a signed int (msr in 64-bit mode) is performed.
670 asmlinkage
long compat_sys_sched_get_priority_max(u32 policy
)
672 return sys_sched_get_priority_max((int)policy
);
676 /* Note: it is necessary to treat policy as an unsigned int,
677 * with the corresponding cast to a signed int to insure that the
678 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
679 * and the register representation of a signed int (msr in 64-bit mode) is performed.
681 asmlinkage
long compat_sys_sched_get_priority_min(u32 policy
)
683 return sys_sched_get_priority_min((int)policy
);
687 /* Note: it is necessary to treat pid as an unsigned int,
688 * with the corresponding cast to a signed int to insure that the
689 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
690 * and the register representation of a signed int (msr in 64-bit mode) is performed.
692 asmlinkage
long compat_sys_sched_getparam(u32 pid
, struct sched_param __user
*param
)
694 return sys_sched_getparam((int)pid
, param
);
698 /* Note: it is necessary to treat pid as an unsigned int,
699 * with the corresponding cast to a signed int to insure that the
700 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
701 * and the register representation of a signed int (msr in 64-bit mode) is performed.
703 asmlinkage
long compat_sys_sched_getscheduler(u32 pid
)
705 return sys_sched_getscheduler((int)pid
);
709 /* Note: it is necessary to treat pid as an unsigned int,
710 * with the corresponding cast to a signed int to insure that the
711 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
712 * and the register representation of a signed int (msr in 64-bit mode) is performed.
714 asmlinkage
long compat_sys_sched_setparam(u32 pid
, struct sched_param __user
*param
)
716 return sys_sched_setparam((int)pid
, param
);
720 /* Note: it is necessary to treat pid and policy as unsigned ints,
721 * with the corresponding cast to a signed int to insure that the
722 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
723 * and the register representation of a signed int (msr in 64-bit mode) is performed.
725 asmlinkage
long compat_sys_sched_setscheduler(u32 pid
, u32 policy
, struct sched_param __user
*param
)
727 return sys_sched_setscheduler((int)pid
, (int)policy
, param
);
731 /* Note: it is necessary to treat len as an unsigned int,
732 * with the corresponding cast to a signed int to insure that the
733 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
734 * and the register representation of a signed int (msr in 64-bit mode) is performed.
736 asmlinkage
long compat_sys_setdomainname(char __user
*name
, u32 len
)
738 return sys_setdomainname(name
, (int)len
);
742 /* Note: it is necessary to treat gidsetsize as an unsigned int,
743 * with the corresponding cast to a signed int to insure that the
744 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
745 * and the register representation of a signed int (msr in 64-bit mode) is performed.
747 asmlinkage
long compat_sys_setgroups(u32 gidsetsize
, gid_t __user
*grouplist
)
749 return sys_setgroups((int)gidsetsize
, grouplist
);
753 asmlinkage
long compat_sys_sethostname(char __user
*name
, u32 len
)
755 /* sign extend len */
756 return sys_sethostname(name
, (int)len
);
760 /* Note: it is necessary to treat pid and pgid as unsigned ints,
761 * with the corresponding cast to a signed int to insure that the
762 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
763 * and the register representation of a signed int (msr in 64-bit mode) is performed.
765 asmlinkage
long compat_sys_setpgid(u32 pid
, u32 pgid
)
767 return sys_setpgid((int)pid
, (int)pgid
);
770 long compat_sys_getpriority(u32 which
, u32 who
)
772 /* sign extend which and who */
773 return sys_getpriority((int)which
, (int)who
);
776 long compat_sys_setpriority(u32 which
, u32 who
, u32 niceval
)
778 /* sign extend which, who and niceval */
779 return sys_setpriority((int)which
, (int)who
, (int)niceval
);
782 long compat_sys_ioprio_get(u32 which
, u32 who
)
784 /* sign extend which and who */
785 return sys_ioprio_get((int)which
, (int)who
);
788 long compat_sys_ioprio_set(u32 which
, u32 who
, u32 ioprio
)
790 /* sign extend which, who and ioprio */
791 return sys_ioprio_set((int)which
, (int)who
, (int)ioprio
);
794 /* Note: it is necessary to treat newmask as an unsigned int,
795 * with the corresponding cast to a signed int to insure that the
796 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
797 * and the register representation of a signed int (msr in 64-bit mode) is performed.
799 asmlinkage
long compat_sys_ssetmask(u32 newmask
)
801 return sys_ssetmask((int) newmask
);
804 asmlinkage
long compat_sys_syslog(u32 type
, char __user
* buf
, u32 len
)
806 /* sign extend len */
807 return sys_syslog(type
, buf
, (int)len
);
811 /* Note: it is necessary to treat mask as an unsigned int,
812 * with the corresponding cast to a signed int to insure that the
813 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
814 * and the register representation of a signed int (msr in 64-bit mode) is performed.
816 asmlinkage
long compat_sys_umask(u32 mask
)
818 return sys_umask((int)mask
);
822 struct __sysctl_args32
{
832 asmlinkage
long compat_sys_sysctl(struct __sysctl_args32 __user
*args
)
834 struct __sysctl_args32 tmp
;
837 size_t __user
*oldlenp
= NULL
;
838 unsigned long addr
= (((unsigned long)&args
->__unused
[0]) + 7) & ~7;
840 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
843 if (tmp
.oldval
&& tmp
.oldlenp
) {
844 /* Duh, this is ugly and might not work if sysctl_args
845 is in read-only memory, but do_sysctl does indirectly
846 a lot of uaccess in both directions and we'd have to
847 basically copy the whole sysctl.c here, and
848 glibc's __sysctl uses rw memory for the structure
850 oldlenp
= (size_t __user
*)addr
;
851 if (get_user(oldlen
, (compat_size_t __user
*)compat_ptr(tmp
.oldlenp
)) ||
852 put_user(oldlen
, oldlenp
))
857 error
= do_sysctl(compat_ptr(tmp
.name
), tmp
.nlen
,
858 compat_ptr(tmp
.oldval
), oldlenp
,
859 compat_ptr(tmp
.newval
), tmp
.newlen
);
863 if (get_user(oldlen
, oldlenp
) ||
864 put_user(oldlen
, (compat_size_t __user
*)compat_ptr(tmp
.oldlenp
)))
867 copy_to_user(args
->__unused
, tmp
.__unused
, sizeof(tmp
.__unused
));
873 unsigned long compat_sys_mmap2(unsigned long addr
, size_t len
,
874 unsigned long prot
, unsigned long flags
,
875 unsigned long fd
, unsigned long pgoff
)
877 /* This should remain 12 even if PAGE_SIZE changes */
878 return sys_mmap(addr
, len
, prot
, flags
, fd
, pgoff
<< 12);
881 long compat_sys_tgkill(u32 tgid
, u32 pid
, int sig
)
883 /* sign extend tgid, pid */
884 return sys_tgkill((int)tgid
, (int)pid
, sig
);
889 * The 32 bit ABI passes long longs in an odd even register pair.
892 compat_ssize_t
compat_sys_pread64(unsigned int fd
, char __user
*ubuf
, compat_size_t count
,
893 u32 reg6
, u32 poshi
, u32 poslo
)
895 return sys_pread64(fd
, ubuf
, count
, ((loff_t
)poshi
<< 32) | poslo
);
898 compat_ssize_t
compat_sys_pwrite64(unsigned int fd
, char __user
*ubuf
, compat_size_t count
,
899 u32 reg6
, u32 poshi
, u32 poslo
)
901 return sys_pwrite64(fd
, ubuf
, count
, ((loff_t
)poshi
<< 32) | poslo
);
904 compat_ssize_t
compat_sys_readahead(int fd
, u32 r4
, u32 offhi
, u32 offlo
, u32 count
)
906 return sys_readahead(fd
, ((loff_t
)offhi
<< 32) | offlo
, count
);
909 asmlinkage
int compat_sys_truncate64(const char __user
* path
, u32 reg4
,
910 unsigned long high
, unsigned long low
)
912 return sys_truncate(path
, (high
<< 32) | low
);
915 asmlinkage
int compat_sys_ftruncate64(unsigned int fd
, u32 reg4
, unsigned long high
,
918 return sys_ftruncate(fd
, (high
<< 32) | low
);
921 long ppc32_lookup_dcookie(u32 cookie_high
, u32 cookie_low
, char __user
*buf
,
924 return sys_lookup_dcookie((u64
)cookie_high
<< 32 | cookie_low
,
928 long ppc32_fadvise64(int fd
, u32 unused
, u32 offset_high
, u32 offset_low
,
929 size_t len
, int advice
)
931 return sys_fadvise64(fd
, (u64
)offset_high
<< 32 | offset_low
, len
,
935 asmlinkage
long compat_sys_add_key(const char __user
*_type
,
936 const char __user
*_description
,
937 const void __user
*_payload
,
941 return sys_add_key(_type
, _description
, _payload
, plen
, ringid
);
944 asmlinkage
long compat_sys_request_key(const char __user
*_type
,
945 const char __user
*_description
,
946 const char __user
*_callout_info
,
949 return sys_request_key(_type
, _description
, _callout_info
, destringid
);