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/systemcfg.h>
56 #include <asm/ppc-pci.h>
58 /* readdir & getdents */
59 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
60 #define ROUND_UP(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
62 struct old_linux_dirent32
{
65 unsigned short d_namlen
;
69 struct readdir_callback32
{
70 struct old_linux_dirent32 __user
* dirent
;
74 static int fillonedir(void * __buf
, const char * name
, int namlen
,
75 off_t offset
, ino_t ino
, unsigned int d_type
)
77 struct readdir_callback32
* buf
= (struct readdir_callback32
*) __buf
;
78 struct old_linux_dirent32 __user
* dirent
;
84 put_user(ino
, &dirent
->d_ino
);
85 put_user(offset
, &dirent
->d_offset
);
86 put_user(namlen
, &dirent
->d_namlen
);
87 copy_to_user(dirent
->d_name
, name
, namlen
);
88 put_user(0, dirent
->d_name
+ namlen
);
92 asmlinkage
int old32_readdir(unsigned int fd
, struct old_linux_dirent32 __user
*dirent
, unsigned int count
)
96 struct readdir_callback32 buf
;
105 error
= vfs_readdir(file
, (filldir_t
)fillonedir
, &buf
);
116 asmlinkage
long ppc32_select(u32 n
, compat_ulong_t __user
*inp
,
117 compat_ulong_t __user
*outp
, compat_ulong_t __user
*exp
,
121 return compat_sys_select((int)n
, inp
, outp
, exp
, compat_ptr(tvp_x
));
124 int cp_compat_stat(struct kstat
*stat
, struct compat_stat __user
*statbuf
)
128 if (stat
->size
> MAX_NON_LFS
|| !new_valid_dev(stat
->dev
) ||
129 !new_valid_dev(stat
->rdev
))
132 err
= access_ok(VERIFY_WRITE
, statbuf
, sizeof(*statbuf
)) ? 0 : -EFAULT
;
133 err
|= __put_user(new_encode_dev(stat
->dev
), &statbuf
->st_dev
);
134 err
|= __put_user(stat
->ino
, &statbuf
->st_ino
);
135 err
|= __put_user(stat
->mode
, &statbuf
->st_mode
);
136 err
|= __put_user(stat
->nlink
, &statbuf
->st_nlink
);
137 err
|= __put_user(stat
->uid
, &statbuf
->st_uid
);
138 err
|= __put_user(stat
->gid
, &statbuf
->st_gid
);
139 err
|= __put_user(new_encode_dev(stat
->rdev
), &statbuf
->st_rdev
);
140 err
|= __put_user(stat
->size
, &statbuf
->st_size
);
141 err
|= __put_user(stat
->atime
.tv_sec
, &statbuf
->st_atime
);
142 err
|= __put_user(stat
->atime
.tv_nsec
, &statbuf
->st_atime_nsec
);
143 err
|= __put_user(stat
->mtime
.tv_sec
, &statbuf
->st_mtime
);
144 err
|= __put_user(stat
->mtime
.tv_nsec
, &statbuf
->st_mtime_nsec
);
145 err
|= __put_user(stat
->ctime
.tv_sec
, &statbuf
->st_ctime
);
146 err
|= __put_user(stat
->ctime
.tv_nsec
, &statbuf
->st_ctime_nsec
);
147 err
|= __put_user(stat
->blksize
, &statbuf
->st_blksize
);
148 err
|= __put_user(stat
->blocks
, &statbuf
->st_blocks
);
149 err
|= __put_user(0, &statbuf
->__unused4
[0]);
150 err
|= __put_user(0, &statbuf
->__unused4
[1]);
155 /* Note: it is necessary to treat option as an unsigned int,
156 * with the corresponding cast to a signed int to insure that the
157 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
158 * and the register representation of a signed int (msr in 64-bit mode) is performed.
160 asmlinkage
long compat_sys_sysfs(u32 option
, u32 arg1
, u32 arg2
)
162 return sys_sysfs((int)option
, arg1
, arg2
);
165 /* Handle adjtimex compatibility. */
168 s32 offset
, freq
, maxerror
, esterror
;
169 s32 status
, constant
, precision
, tolerance
;
170 struct compat_timeval time
;
172 s32 ppsfreq
, jitter
, shift
, stabil
;
173 s32 jitcnt
, calcnt
, errcnt
, stbcnt
;
174 s32
:32; s32
:32; s32
:32; s32
:32;
175 s32
:32; s32
:32; s32
:32; s32
:32;
176 s32
:32; s32
:32; s32
:32; s32
:32;
179 extern int do_adjtimex(struct timex
*);
180 extern void ppc_adjtimex(void);
182 asmlinkage
long compat_sys_adjtimex(struct timex32 __user
*utp
)
187 memset(&txc
, 0, sizeof(struct timex
));
189 if(get_user(txc
.modes
, &utp
->modes
) ||
190 __get_user(txc
.offset
, &utp
->offset
) ||
191 __get_user(txc
.freq
, &utp
->freq
) ||
192 __get_user(txc
.maxerror
, &utp
->maxerror
) ||
193 __get_user(txc
.esterror
, &utp
->esterror
) ||
194 __get_user(txc
.status
, &utp
->status
) ||
195 __get_user(txc
.constant
, &utp
->constant
) ||
196 __get_user(txc
.precision
, &utp
->precision
) ||
197 __get_user(txc
.tolerance
, &utp
->tolerance
) ||
198 __get_user(txc
.time
.tv_sec
, &utp
->time
.tv_sec
) ||
199 __get_user(txc
.time
.tv_usec
, &utp
->time
.tv_usec
) ||
200 __get_user(txc
.tick
, &utp
->tick
) ||
201 __get_user(txc
.ppsfreq
, &utp
->ppsfreq
) ||
202 __get_user(txc
.jitter
, &utp
->jitter
) ||
203 __get_user(txc
.shift
, &utp
->shift
) ||
204 __get_user(txc
.stabil
, &utp
->stabil
) ||
205 __get_user(txc
.jitcnt
, &utp
->jitcnt
) ||
206 __get_user(txc
.calcnt
, &utp
->calcnt
) ||
207 __get_user(txc
.errcnt
, &utp
->errcnt
) ||
208 __get_user(txc
.stbcnt
, &utp
->stbcnt
))
211 ret
= do_adjtimex(&txc
);
213 /* adjust the conversion of TB to time of day to track adjtimex */
216 if(put_user(txc
.modes
, &utp
->modes
) ||
217 __put_user(txc
.offset
, &utp
->offset
) ||
218 __put_user(txc
.freq
, &utp
->freq
) ||
219 __put_user(txc
.maxerror
, &utp
->maxerror
) ||
220 __put_user(txc
.esterror
, &utp
->esterror
) ||
221 __put_user(txc
.status
, &utp
->status
) ||
222 __put_user(txc
.constant
, &utp
->constant
) ||
223 __put_user(txc
.precision
, &utp
->precision
) ||
224 __put_user(txc
.tolerance
, &utp
->tolerance
) ||
225 __put_user(txc
.time
.tv_sec
, &utp
->time
.tv_sec
) ||
226 __put_user(txc
.time
.tv_usec
, &utp
->time
.tv_usec
) ||
227 __put_user(txc
.tick
, &utp
->tick
) ||
228 __put_user(txc
.ppsfreq
, &utp
->ppsfreq
) ||
229 __put_user(txc
.jitter
, &utp
->jitter
) ||
230 __put_user(txc
.shift
, &utp
->shift
) ||
231 __put_user(txc
.stabil
, &utp
->stabil
) ||
232 __put_user(txc
.jitcnt
, &utp
->jitcnt
) ||
233 __put_user(txc
.calcnt
, &utp
->calcnt
) ||
234 __put_user(txc
.errcnt
, &utp
->errcnt
) ||
235 __put_user(txc
.stbcnt
, &utp
->stbcnt
))
241 asmlinkage
long compat_sys_pause(void)
243 current
->state
= TASK_INTERRUPTIBLE
;
246 return -ERESTARTNOHAND
;
249 static inline long get_ts32(struct timespec
*o
, struct compat_timeval __user
*i
)
253 if (!access_ok(VERIFY_READ
, i
, sizeof(*i
)))
255 if (__get_user(o
->tv_sec
, &i
->tv_sec
))
257 if (__get_user(usec
, &i
->tv_usec
))
259 o
->tv_nsec
= usec
* 1000;
263 static inline long put_tv32(struct compat_timeval __user
*o
, struct timeval
*i
)
265 return (!access_ok(VERIFY_WRITE
, o
, sizeof(*o
)) ||
266 (__put_user(i
->tv_sec
, &o
->tv_sec
) |
267 __put_user(i
->tv_usec
, &o
->tv_usec
)));
279 unsigned short procs
;
284 char _f
[20-2*sizeof(int)-sizeof(int)];
287 asmlinkage
long compat_sys_sysinfo(struct sysinfo32 __user
*info
)
292 mm_segment_t old_fs
= get_fs ();
294 /* The __user cast is valid due to set_fs() */
296 ret
= sys_sysinfo((struct sysinfo __user
*)&s
);
299 /* Check to see if any memory value is too large for 32-bit and
300 * scale down if needed.
302 if ((s
.totalram
>> 32) || (s
.totalswap
>> 32)) {
303 while (s
.mem_unit
< PAGE_SIZE
) {
307 s
.totalram
>>=bitcount
;
308 s
.freeram
>>= bitcount
;
309 s
.sharedram
>>= bitcount
;
310 s
.bufferram
>>= bitcount
;
311 s
.totalswap
>>= bitcount
;
312 s
.freeswap
>>= bitcount
;
313 s
.totalhigh
>>= bitcount
;
314 s
.freehigh
>>= bitcount
;
317 err
= put_user (s
.uptime
, &info
->uptime
);
318 err
|= __put_user (s
.loads
[0], &info
->loads
[0]);
319 err
|= __put_user (s
.loads
[1], &info
->loads
[1]);
320 err
|= __put_user (s
.loads
[2], &info
->loads
[2]);
321 err
|= __put_user (s
.totalram
, &info
->totalram
);
322 err
|= __put_user (s
.freeram
, &info
->freeram
);
323 err
|= __put_user (s
.sharedram
, &info
->sharedram
);
324 err
|= __put_user (s
.bufferram
, &info
->bufferram
);
325 err
|= __put_user (s
.totalswap
, &info
->totalswap
);
326 err
|= __put_user (s
.freeswap
, &info
->freeswap
);
327 err
|= __put_user (s
.procs
, &info
->procs
);
328 err
|= __put_user (s
.totalhigh
, &info
->totalhigh
);
329 err
|= __put_user (s
.freehigh
, &info
->freehigh
);
330 err
|= __put_user (s
.mem_unit
, &info
->mem_unit
);
340 /* Translations due to time_t size differences. Which affects all
341 sorts of things, like timeval and itimerval. */
342 extern struct timezone sys_tz
;
344 asmlinkage
long compat_sys_gettimeofday(struct compat_timeval __user
*tv
, struct timezone __user
*tz
)
348 do_gettimeofday(&ktv
);
349 if (put_tv32(tv
, &ktv
))
353 if (copy_to_user(tz
, &sys_tz
, sizeof(sys_tz
)))
362 asmlinkage
long compat_sys_settimeofday(struct compat_timeval __user
*tv
, struct timezone __user
*tz
)
368 if (get_ts32(&kts
, tv
))
372 if (copy_from_user(&ktz
, tz
, sizeof(ktz
)))
376 return do_sys_settimeofday(tv
? &kts
: NULL
, tz
? &ktz
: NULL
);
379 #ifdef CONFIG_SYSVIPC
380 long compat_sys_ipc(u32 call
, u32 first
, u32 second
, u32 third
, compat_uptr_t ptr
,
385 version
= call
>> 16; /* hack for backward compatibility */
392 /* sign extend semid */
393 return compat_sys_semtimedop((int)first
,
394 compat_ptr(ptr
), second
,
396 /* else fall through for normal semop() */
398 /* struct sembuf is the same on 32 and 64bit :)) */
399 /* sign extend semid */
400 return sys_semtimedop((int)first
, compat_ptr(ptr
), second
,
403 /* sign extend key, nsems */
404 return sys_semget((int)first
, (int)second
, third
);
406 /* sign extend semid, semnum */
407 return compat_sys_semctl((int)first
, (int)second
, third
,
411 /* sign extend msqid */
412 return compat_sys_msgsnd((int)first
, (int)second
, third
,
415 /* sign extend msqid, msgtyp */
416 return compat_sys_msgrcv((int)first
, second
, (int)fifth
,
417 third
, version
, compat_ptr(ptr
));
419 /* sign extend key */
420 return sys_msgget((int)first
, second
);
422 /* sign extend msqid */
423 return compat_sys_msgctl((int)first
, second
, compat_ptr(ptr
));
426 /* sign extend shmid */
427 return compat_sys_shmat((int)first
, second
, third
, version
,
430 return sys_shmdt(compat_ptr(ptr
));
432 /* sign extend key_t */
433 return sys_shmget((int)first
, second
, third
);
435 /* sign extend shmid */
436 return compat_sys_shmctl((int)first
, second
, compat_ptr(ptr
));
446 /* Note: it is necessary to treat out_fd and in_fd as unsigned ints,
447 * with the corresponding cast to a signed int to insure that the
448 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
449 * and the register representation of a signed int (msr in 64-bit mode) is performed.
451 asmlinkage
long compat_sys_sendfile(u32 out_fd
, u32 in_fd
, compat_off_t __user
* offset
, u32 count
)
453 mm_segment_t old_fs
= get_fs();
458 if (offset
&& get_user(of
, offset
))
461 /* The __user pointer cast is valid because of the set_fs() */
463 up
= offset
? (off_t __user
*) &of
: NULL
;
464 ret
= sys_sendfile((int)out_fd
, (int)in_fd
, up
, count
);
467 if (offset
&& put_user(of
, offset
))
473 asmlinkage
int compat_sys_sendfile64(int out_fd
, int in_fd
, compat_loff_t __user
*offset
, s32 count
)
475 mm_segment_t old_fs
= get_fs();
480 if (offset
&& get_user(lof
, offset
))
483 /* The __user pointer cast is valid because of the set_fs() */
485 up
= offset
? (loff_t __user
*) &lof
: NULL
;
486 ret
= sys_sendfile64(out_fd
, in_fd
, up
, count
);
489 if (offset
&& put_user(lof
, offset
))
495 long compat_sys_execve(unsigned long a0
, unsigned long a1
, unsigned long a2
,
496 unsigned long a3
, unsigned long a4
, unsigned long a5
,
497 struct pt_regs
*regs
)
502 filename
= getname((char __user
*) a0
);
503 error
= PTR_ERR(filename
);
504 if (IS_ERR(filename
))
506 flush_fp_to_thread(current
);
507 flush_altivec_to_thread(current
);
509 error
= compat_do_execve(filename
, compat_ptr(a1
), compat_ptr(a2
), regs
);
513 current
->ptrace
&= ~PT_DTRACE
;
514 task_unlock(current
);
522 /* Note: it is necessary to treat option as an unsigned int,
523 * with the corresponding cast to a signed int to insure that the
524 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
525 * and the register representation of a signed int (msr in 64-bit mode) is performed.
527 asmlinkage
long compat_sys_prctl(u32 option
, u32 arg2
, u32 arg3
, u32 arg4
, u32 arg5
)
529 return sys_prctl((int)option
,
530 (unsigned long) arg2
,
531 (unsigned long) arg3
,
532 (unsigned long) arg4
,
533 (unsigned long) arg5
);
536 /* Note: it is necessary to treat pid as an unsigned int,
537 * with the corresponding cast to a signed int to insure that the
538 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
539 * and the register representation of a signed int (msr in 64-bit mode) is performed.
541 asmlinkage
long compat_sys_sched_rr_get_interval(u32 pid
, struct compat_timespec __user
*interval
)
545 mm_segment_t old_fs
= get_fs ();
547 /* The __user pointer cast is valid because of the set_fs() */
549 ret
= sys_sched_rr_get_interval((int)pid
, (struct timespec __user
*) &t
);
551 if (put_compat_timespec(&t
, interval
))
556 asmlinkage
int compat_sys_pciconfig_read(u32 bus
, u32 dfn
, u32 off
, u32 len
, u32 ubuf
)
558 return sys_pciconfig_read((unsigned long) bus
,
565 asmlinkage
int compat_sys_pciconfig_write(u32 bus
, u32 dfn
, u32 off
, u32 len
, u32 ubuf
)
567 return sys_pciconfig_write((unsigned long) bus
,
574 asmlinkage
int compat_sys_pciconfig_iobase(u32 which
, u32 in_bus
, u32 in_devfn
)
576 return sys_pciconfig_iobase(which
, in_bus
, in_devfn
);
580 /* Note: it is necessary to treat mode as an unsigned int,
581 * with the corresponding cast to a signed int to insure that the
582 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
583 * and the register representation of a signed int (msr in 64-bit mode) is performed.
585 asmlinkage
long compat_sys_access(const char __user
* filename
, u32 mode
)
587 return sys_access(filename
, (int)mode
);
591 /* Note: it is necessary to treat mode as an unsigned int,
592 * with the corresponding cast to a signed int to insure that the
593 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
594 * and the register representation of a signed int (msr in 64-bit mode) is performed.
596 asmlinkage
long compat_sys_creat(const char __user
* pathname
, u32 mode
)
598 return sys_creat(pathname
, (int)mode
);
602 /* Note: it is necessary to treat pid and options as unsigned ints,
603 * with the corresponding cast to a signed int to insure that the
604 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
605 * and the register representation of a signed int (msr in 64-bit mode) is performed.
607 asmlinkage
long compat_sys_waitpid(u32 pid
, unsigned int __user
* stat_addr
, u32 options
)
609 return sys_waitpid((int)pid
, stat_addr
, (int)options
);
613 /* Note: it is necessary to treat gidsetsize as an unsigned int,
614 * with the corresponding cast to a signed int to insure that the
615 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
616 * and the register representation of a signed int (msr in 64-bit mode) is performed.
618 asmlinkage
long compat_sys_getgroups(u32 gidsetsize
, gid_t __user
*grouplist
)
620 return sys_getgroups((int)gidsetsize
, grouplist
);
624 /* Note: it is necessary to treat pid as an unsigned int,
625 * with the corresponding cast to a signed int to insure that the
626 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
627 * and the register representation of a signed int (msr in 64-bit mode) is performed.
629 asmlinkage
long compat_sys_getpgid(u32 pid
)
631 return sys_getpgid((int)pid
);
636 /* Note: it is necessary to treat pid as an unsigned int,
637 * with the corresponding cast to a signed int to insure that the
638 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
639 * and the register representation of a signed int (msr in 64-bit mode) is performed.
641 asmlinkage
long compat_sys_getsid(u32 pid
)
643 return sys_getsid((int)pid
);
647 /* Note: it is necessary to treat pid and sig as unsigned ints,
648 * with the corresponding cast to a signed int to insure that the
649 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
650 * and the register representation of a signed int (msr in 64-bit mode) is performed.
652 asmlinkage
long compat_sys_kill(u32 pid
, u32 sig
)
654 return sys_kill((int)pid
, (int)sig
);
658 /* Note: it is necessary to treat mode as an unsigned int,
659 * with the corresponding cast to a signed int to insure that the
660 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
661 * and the register representation of a signed int (msr in 64-bit mode) is performed.
663 asmlinkage
long compat_sys_mkdir(const char __user
* pathname
, u32 mode
)
665 return sys_mkdir(pathname
, (int)mode
);
668 long compat_sys_nice(u32 increment
)
670 /* sign extend increment */
671 return sys_nice((int)increment
);
674 off_t
ppc32_lseek(unsigned int fd
, u32 offset
, unsigned int origin
)
677 return sys_lseek(fd
, (int)offset
, origin
);
680 /* Note: it is necessary to treat bufsiz as an unsigned int,
681 * with the corresponding cast to a signed int to insure that the
682 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
683 * and the register representation of a signed int (msr in 64-bit mode) is performed.
685 asmlinkage
long compat_sys_readlink(const char __user
* path
, char __user
* buf
, u32 bufsiz
)
687 return sys_readlink(path
, buf
, (int)bufsiz
);
690 /* Note: it is necessary to treat option as an unsigned int,
691 * with the corresponding cast to a signed int to insure that the
692 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
693 * and the register representation of a signed int (msr in 64-bit mode) is performed.
695 asmlinkage
long compat_sys_sched_get_priority_max(u32 policy
)
697 return sys_sched_get_priority_max((int)policy
);
701 /* Note: it is necessary to treat policy as an unsigned int,
702 * with the corresponding cast to a signed int to insure that the
703 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
704 * and the register representation of a signed int (msr in 64-bit mode) is performed.
706 asmlinkage
long compat_sys_sched_get_priority_min(u32 policy
)
708 return sys_sched_get_priority_min((int)policy
);
712 /* Note: it is necessary to treat pid as an unsigned int,
713 * with the corresponding cast to a signed int to insure that the
714 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
715 * and the register representation of a signed int (msr in 64-bit mode) is performed.
717 asmlinkage
long compat_sys_sched_getparam(u32 pid
, struct sched_param __user
*param
)
719 return sys_sched_getparam((int)pid
, param
);
723 /* Note: it is necessary to treat pid as an unsigned int,
724 * with the corresponding cast to a signed int to insure that the
725 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
726 * and the register representation of a signed int (msr in 64-bit mode) is performed.
728 asmlinkage
long compat_sys_sched_getscheduler(u32 pid
)
730 return sys_sched_getscheduler((int)pid
);
734 /* Note: it is necessary to treat pid as an unsigned int,
735 * with the corresponding cast to a signed int to insure that the
736 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
737 * and the register representation of a signed int (msr in 64-bit mode) is performed.
739 asmlinkage
long compat_sys_sched_setparam(u32 pid
, struct sched_param __user
*param
)
741 return sys_sched_setparam((int)pid
, param
);
745 /* Note: it is necessary to treat pid and policy as unsigned ints,
746 * with the corresponding cast to a signed int to insure that the
747 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
748 * and the register representation of a signed int (msr in 64-bit mode) is performed.
750 asmlinkage
long compat_sys_sched_setscheduler(u32 pid
, u32 policy
, struct sched_param __user
*param
)
752 return sys_sched_setscheduler((int)pid
, (int)policy
, param
);
756 /* Note: it is necessary to treat len as an unsigned int,
757 * with the corresponding cast to a signed int to insure that the
758 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
759 * and the register representation of a signed int (msr in 64-bit mode) is performed.
761 asmlinkage
long compat_sys_setdomainname(char __user
*name
, u32 len
)
763 return sys_setdomainname(name
, (int)len
);
767 /* Note: it is necessary to treat gidsetsize as an unsigned int,
768 * with the corresponding cast to a signed int to insure that the
769 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
770 * and the register representation of a signed int (msr in 64-bit mode) is performed.
772 asmlinkage
long compat_sys_setgroups(u32 gidsetsize
, gid_t __user
*grouplist
)
774 return sys_setgroups((int)gidsetsize
, grouplist
);
778 asmlinkage
long compat_sys_sethostname(char __user
*name
, u32 len
)
780 /* sign extend len */
781 return sys_sethostname(name
, (int)len
);
785 /* Note: it is necessary to treat pid and pgid as unsigned ints,
786 * with the corresponding cast to a signed int to insure that the
787 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
788 * and the register representation of a signed int (msr in 64-bit mode) is performed.
790 asmlinkage
long compat_sys_setpgid(u32 pid
, u32 pgid
)
792 return sys_setpgid((int)pid
, (int)pgid
);
795 long compat_sys_getpriority(u32 which
, u32 who
)
797 /* sign extend which and who */
798 return sys_getpriority((int)which
, (int)who
);
801 long compat_sys_setpriority(u32 which
, u32 who
, u32 niceval
)
803 /* sign extend which, who and niceval */
804 return sys_setpriority((int)which
, (int)who
, (int)niceval
);
807 long compat_sys_ioprio_get(u32 which
, u32 who
)
809 /* sign extend which and who */
810 return sys_ioprio_get((int)which
, (int)who
);
813 long compat_sys_ioprio_set(u32 which
, u32 who
, u32 ioprio
)
815 /* sign extend which, who and ioprio */
816 return sys_ioprio_set((int)which
, (int)who
, (int)ioprio
);
819 /* Note: it is necessary to treat newmask as an unsigned int,
820 * with the corresponding cast to a signed int to insure that the
821 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
822 * and the register representation of a signed int (msr in 64-bit mode) is performed.
824 asmlinkage
long compat_sys_ssetmask(u32 newmask
)
826 return sys_ssetmask((int) newmask
);
829 asmlinkage
long compat_sys_syslog(u32 type
, char __user
* buf
, u32 len
)
831 /* sign extend len */
832 return sys_syslog(type
, buf
, (int)len
);
836 /* Note: it is necessary to treat mask as an unsigned int,
837 * with the corresponding cast to a signed int to insure that the
838 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
839 * and the register representation of a signed int (msr in 64-bit mode) is performed.
841 asmlinkage
long compat_sys_umask(u32 mask
)
843 return sys_umask((int)mask
);
847 struct __sysctl_args32
{
857 asmlinkage
long compat_sys_sysctl(struct __sysctl_args32 __user
*args
)
859 struct __sysctl_args32 tmp
;
862 size_t __user
*oldlenp
= NULL
;
863 unsigned long addr
= (((unsigned long)&args
->__unused
[0]) + 7) & ~7;
865 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
868 if (tmp
.oldval
&& tmp
.oldlenp
) {
869 /* Duh, this is ugly and might not work if sysctl_args
870 is in read-only memory, but do_sysctl does indirectly
871 a lot of uaccess in both directions and we'd have to
872 basically copy the whole sysctl.c here, and
873 glibc's __sysctl uses rw memory for the structure
875 oldlenp
= (size_t __user
*)addr
;
876 if (get_user(oldlen
, (compat_size_t __user
*)compat_ptr(tmp
.oldlenp
)) ||
877 put_user(oldlen
, oldlenp
))
882 error
= do_sysctl(compat_ptr(tmp
.name
), tmp
.nlen
,
883 compat_ptr(tmp
.oldval
), oldlenp
,
884 compat_ptr(tmp
.newval
), tmp
.newlen
);
888 if (get_user(oldlen
, oldlenp
) ||
889 put_user(oldlen
, (compat_size_t __user
*)compat_ptr(tmp
.oldlenp
)))
892 copy_to_user(args
->__unused
, tmp
.__unused
, sizeof(tmp
.__unused
));
898 unsigned long compat_sys_mmap2(unsigned long addr
, size_t len
,
899 unsigned long prot
, unsigned long flags
,
900 unsigned long fd
, unsigned long pgoff
)
902 /* This should remain 12 even if PAGE_SIZE changes */
903 return sys_mmap(addr
, len
, prot
, flags
, fd
, pgoff
<< 12);
906 long compat_sys_tgkill(u32 tgid
, u32 pid
, int sig
)
908 /* sign extend tgid, pid */
909 return sys_tgkill((int)tgid
, (int)pid
, sig
);
914 * The 32 bit ABI passes long longs in an odd even register pair.
917 compat_ssize_t
compat_sys_pread64(unsigned int fd
, char __user
*ubuf
, compat_size_t count
,
918 u32 reg6
, u32 poshi
, u32 poslo
)
920 return sys_pread64(fd
, ubuf
, count
, ((loff_t
)poshi
<< 32) | poslo
);
923 compat_ssize_t
compat_sys_pwrite64(unsigned int fd
, char __user
*ubuf
, compat_size_t count
,
924 u32 reg6
, u32 poshi
, u32 poslo
)
926 return sys_pwrite64(fd
, ubuf
, count
, ((loff_t
)poshi
<< 32) | poslo
);
929 compat_ssize_t
compat_sys_readahead(int fd
, u32 r4
, u32 offhi
, u32 offlo
, u32 count
)
931 return sys_readahead(fd
, ((loff_t
)offhi
<< 32) | offlo
, count
);
934 asmlinkage
int compat_sys_truncate64(const char __user
* path
, u32 reg4
,
935 unsigned long high
, unsigned long low
)
937 return sys_truncate(path
, (high
<< 32) | low
);
940 asmlinkage
int compat_sys_ftruncate64(unsigned int fd
, u32 reg4
, unsigned long high
,
943 return sys_ftruncate(fd
, (high
<< 32) | low
);
946 long ppc32_lookup_dcookie(u32 cookie_high
, u32 cookie_low
, char __user
*buf
,
949 return sys_lookup_dcookie((u64
)cookie_high
<< 32 | cookie_low
,
953 long ppc32_fadvise64(int fd
, u32 unused
, u32 offset_high
, u32 offset_low
,
954 size_t len
, int advice
)
956 return sys_fadvise64(fd
, (u64
)offset_high
<< 32 | offset_low
, len
,
960 long ppc32_timer_create(clockid_t clock
,
961 struct compat_sigevent __user
*ev32
,
962 timer_t __user
*timer_id
)
970 return sys_timer_create(clock
, NULL
, timer_id
);
972 if (get_compat_sigevent(&event
, ev32
))
975 if (!access_ok(VERIFY_WRITE
, timer_id
, sizeof(timer_t
)))
980 /* The __user pointer casts are valid due to the set_fs() */
981 err
= sys_timer_create(clock
,
982 (sigevent_t __user
*) &event
,
983 (timer_t __user
*) &t
);
987 err
= __put_user(t
, timer_id
);
992 asmlinkage
long compat_sys_add_key(const char __user
*_type
,
993 const char __user
*_description
,
994 const void __user
*_payload
,
998 return sys_add_key(_type
, _description
, _payload
, plen
, ringid
);
1001 asmlinkage
long compat_sys_request_key(const char __user
*_type
,
1002 const char __user
*_description
,
1003 const char __user
*_callout_info
,
1006 return sys_request_key(_type
, _description
, _callout_info
, destringid
);