2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* sys_ppc32.c: Conversion between 32bit and 64bit native syscalls.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 IBM
|
|
|
|
* Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
* Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
*
|
|
|
|
* These routines maintain argument size conversion between 32bit and 64bit
|
|
|
|
* environment.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/resource.h>
|
|
|
|
#include <linux/times.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/sem.h>
|
|
|
|
#include <linux/msg.h>
|
|
|
|
#include <linux/shm.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/personality.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/mman.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/sysctl.h>
|
|
|
|
#include <linux/binfmts.h>
|
|
|
|
#include <linux/security.h>
|
|
|
|
#include <linux/compat.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/elf.h>
|
2007-10-16 23:29:24 -07:00
|
|
|
#include <linux/ipc.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 01:04:11 -07:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/unistd.h>
|
|
|
|
#include <asm/time.h>
|
|
|
|
#include <asm/mmu_context.h>
|
2005-09-27 09:50:25 -07:00
|
|
|
#include <asm/ppc-pci.h>
|
2006-11-27 11:18:59 -07:00
|
|
|
#include <asm/syscalls.h>
|
2012-03-28 10:30:02 -07:00
|
|
|
#include <asm/switch_to.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
asmlinkage long ppc32_select(u32 n, compat_ulong_t __user *inp,
|
|
|
|
compat_ulong_t __user *outp, compat_ulong_t __user *exp,
|
|
|
|
compat_uptr_t tvp_x)
|
|
|
|
{
|
|
|
|
/* sign extend n */
|
|
|
|
return compat_sys_select((int)n, inp, outp, exp, compat_ptr(tvp_x));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat option as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sysfs(u32 option, u32 arg1, u32 arg2)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sysfs((int)option, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYSVIPC
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 fifth)
|
|
|
|
{
|
|
|
|
int version;
|
|
|
|
|
|
|
|
version = call >> 16; /* hack for backward compatibility */
|
|
|
|
call &= 0xffff;
|
|
|
|
|
|
|
|
switch (call) {
|
|
|
|
|
|
|
|
case SEMTIMEDOP:
|
|
|
|
if (fifth)
|
|
|
|
/* sign extend semid */
|
|
|
|
return compat_sys_semtimedop((int)first,
|
|
|
|
compat_ptr(ptr), second,
|
|
|
|
compat_ptr(fifth));
|
|
|
|
/* else fall through for normal semop() */
|
|
|
|
case SEMOP:
|
|
|
|
/* struct sembuf is the same on 32 and 64bit :)) */
|
|
|
|
/* sign extend semid */
|
|
|
|
return sys_semtimedop((int)first, compat_ptr(ptr), second,
|
|
|
|
NULL);
|
|
|
|
case SEMGET:
|
|
|
|
/* sign extend key, nsems */
|
|
|
|
return sys_semget((int)first, (int)second, third);
|
|
|
|
case SEMCTL:
|
|
|
|
/* sign extend semid, semnum */
|
|
|
|
return compat_sys_semctl((int)first, (int)second, third,
|
|
|
|
compat_ptr(ptr));
|
|
|
|
|
|
|
|
case MSGSND:
|
|
|
|
/* sign extend msqid */
|
|
|
|
return compat_sys_msgsnd((int)first, (int)second, third,
|
|
|
|
compat_ptr(ptr));
|
|
|
|
case MSGRCV:
|
|
|
|
/* sign extend msqid, msgtyp */
|
|
|
|
return compat_sys_msgrcv((int)first, second, (int)fifth,
|
|
|
|
third, version, compat_ptr(ptr));
|
|
|
|
case MSGGET:
|
|
|
|
/* sign extend key */
|
|
|
|
return sys_msgget((int)first, second);
|
|
|
|
case MSGCTL:
|
|
|
|
/* sign extend msqid */
|
|
|
|
return compat_sys_msgctl((int)first, second, compat_ptr(ptr));
|
|
|
|
|
|
|
|
case SHMAT:
|
|
|
|
/* sign extend shmid */
|
|
|
|
return compat_sys_shmat((int)first, second, third, version,
|
|
|
|
compat_ptr(ptr));
|
|
|
|
case SHMDT:
|
|
|
|
return sys_shmdt(compat_ptr(ptr));
|
|
|
|
case SHMGET:
|
|
|
|
/* sign extend key_t */
|
|
|
|
return sys_shmget((int)first, second, third);
|
|
|
|
case SHMCTL:
|
|
|
|
/* sign extend shmid */
|
|
|
|
return compat_sys_shmctl((int)first, second, compat_ptr(ptr));
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat out_fd and in_fd as unsigned ints,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sendfile(u32 out_fd, u32 in_fd, compat_off_t __user * offset, u32 count)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
mm_segment_t old_fs = get_fs();
|
|
|
|
int ret;
|
|
|
|
off_t of;
|
|
|
|
off_t __user *up;
|
|
|
|
|
|
|
|
if (offset && get_user(of, offset))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
/* The __user pointer cast is valid because of the set_fs() */
|
|
|
|
set_fs(KERNEL_DS);
|
|
|
|
up = offset ? (off_t __user *) &of : NULL;
|
|
|
|
ret = sys_sendfile((int)out_fd, (int)in_fd, up, count);
|
|
|
|
set_fs(old_fs);
|
|
|
|
|
|
|
|
if (offset && put_user(of, offset))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
mm_segment_t old_fs = get_fs();
|
|
|
|
int ret;
|
|
|
|
loff_t lof;
|
|
|
|
loff_t __user *up;
|
|
|
|
|
|
|
|
if (offset && get_user(lof, offset))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
/* The __user pointer cast is valid because of the set_fs() */
|
|
|
|
set_fs(KERNEL_DS);
|
|
|
|
up = offset ? (loff_t __user *) &lof : NULL;
|
|
|
|
ret = sys_sendfile64(out_fd, in_fd, up, count);
|
|
|
|
set_fs(old_fs);
|
|
|
|
|
|
|
|
if (offset && put_user(lof, offset))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long a3, unsigned long a4, unsigned long a5,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
char * filename;
|
|
|
|
|
|
|
|
filename = getname((char __user *) a0);
|
|
|
|
error = PTR_ERR(filename);
|
|
|
|
if (IS_ERR(filename))
|
|
|
|
goto out;
|
|
|
|
flush_fp_to_thread(current);
|
|
|
|
flush_altivec_to_thread(current);
|
|
|
|
|
|
|
|
error = compat_do_execve(filename, compat_ptr(a1), compat_ptr(a2), regs);
|
|
|
|
|
|
|
|
putname(filename);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat option as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_prctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_prctl((int)option,
|
|
|
|
(unsigned long) arg2,
|
|
|
|
(unsigned long) arg3,
|
|
|
|
(unsigned long) arg4,
|
|
|
|
(unsigned long) arg5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec __user *interval)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct timespec t;
|
|
|
|
int ret;
|
|
|
|
mm_segment_t old_fs = get_fs ();
|
|
|
|
|
|
|
|
/* The __user pointer cast is valid because of the set_fs() */
|
|
|
|
set_fs (KERNEL_DS);
|
|
|
|
ret = sys_sched_rr_get_interval((int)pid, (struct timespec __user *) &t);
|
|
|
|
set_fs (old_fs);
|
|
|
|
if (put_compat_timespec(&t, interval))
|
|
|
|
return -EFAULT;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat mode as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_access(const char __user * filename, u32 mode)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_access(filename, (int)mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat mode as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_creat(const char __user * pathname, u32 mode)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_creat(pathname, (int)mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid and options as unsigned ints,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_waitpid(u32 pid, unsigned int __user * stat_addr, u32 options)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_waitpid((int)pid, stat_addr, (int)options);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat gidsetsize as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_getgroups(u32 gidsetsize, gid_t __user *grouplist)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_getgroups((int)gidsetsize, grouplist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_getpgid(u32 pid)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_getpgid((int)pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_getsid(u32 pid)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_getsid((int)pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid and sig as unsigned ints,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_kill(u32 pid, u32 sig)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_kill((int)pid, (int)sig);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat mode as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_mkdir(const char __user * pathname, u32 mode)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_mkdir(pathname, (int)mode);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_nice(u32 increment)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
/* sign extend increment */
|
|
|
|
return sys_nice((int)increment);
|
|
|
|
}
|
|
|
|
|
|
|
|
off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
|
|
|
|
{
|
|
|
|
/* sign extend n */
|
|
|
|
return sys_lseek(fd, (int)offset, origin);
|
|
|
|
}
|
|
|
|
|
2009-07-27 18:54:32 -07:00
|
|
|
long compat_sys_truncate(const char __user * path, u32 length)
|
|
|
|
{
|
|
|
|
/* sign extend length */
|
|
|
|
return sys_truncate(path, (int)length);
|
|
|
|
}
|
|
|
|
|
|
|
|
long compat_sys_ftruncate(int fd, u32 length)
|
|
|
|
{
|
|
|
|
/* sign extend length */
|
|
|
|
return sys_ftruncate(fd, (int)length);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Note: it is necessary to treat bufsiz as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_readlink(const char __user * path, char __user * buf, u32 bufsiz)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_readlink(path, buf, (int)bufsiz);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat option as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_get_priority_max(u32 policy)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sched_get_priority_max((int)policy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat policy as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_get_priority_min(u32 policy)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sched_get_priority_min((int)policy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_getparam(u32 pid, struct sched_param __user *param)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sched_getparam((int)pid, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_getscheduler(u32 pid)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sched_getscheduler((int)pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_setparam(u32 pid, struct sched_param __user *param)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sched_setparam((int)pid, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid and policy as unsigned ints,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sched_setscheduler(u32 pid, u32 policy, struct sched_param __user *param)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_sched_setscheduler((int)pid, (int)policy, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat len as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_setdomainname(char __user *name, u32 len)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_setdomainname(name, (int)len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat gidsetsize as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_setgroups(u32 gidsetsize, gid_t __user *grouplist)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_setgroups((int)gidsetsize, grouplist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_sethostname(char __user *name, u32 len)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
/* sign extend len */
|
|
|
|
return sys_sethostname(name, (int)len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat pid and pgid as unsigned ints,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_setpgid(u32 pid, u32 pgid)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_setpgid((int)pid, (int)pgid);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_getpriority(u32 which, u32 who)
|
2005-07-07 17:56:15 -07:00
|
|
|
{
|
|
|
|
/* sign extend which and who */
|
|
|
|
return sys_getpriority((int)which, (int)who);
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_setpriority(u32 which, u32 who, u32 niceval)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
/* sign extend which, who and niceval */
|
|
|
|
return sys_setpriority((int)which, (int)who, (int)niceval);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_ioprio_get(u32 which, u32 who)
|
2005-07-07 17:56:15 -07:00
|
|
|
{
|
|
|
|
/* sign extend which and who */
|
|
|
|
return sys_ioprio_get((int)which, (int)who);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_ioprio_set(u32 which, u32 who, u32 ioprio)
|
2005-07-07 17:56:15 -07:00
|
|
|
{
|
|
|
|
/* sign extend which, who and ioprio */
|
|
|
|
return sys_ioprio_set((int)which, (int)who, (int)ioprio);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Note: it is necessary to treat newmask as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_ssetmask(u32 newmask)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_ssetmask((int) newmask);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_syslog(u32 type, char __user * buf, u32 len)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
/* sign extend len */
|
|
|
|
return sys_syslog(type, buf, (int)len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: it is necessary to treat mask as an unsigned int,
|
|
|
|
* with the corresponding cast to a signed int to insure that the
|
|
|
|
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
|
|
|
|
* and the register representation of a signed int (msr in 64-bit mode) is performed.
|
|
|
|
*/
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_umask(u32 mask)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_umask((int)mask);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long prot, unsigned long flags,
|
|
|
|
unsigned long fd, unsigned long pgoff)
|
|
|
|
{
|
|
|
|
/* This should remain 12 even if PAGE_SIZE changes */
|
|
|
|
return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
long compat_sys_tgkill(u32 tgid, u32 pid, int sig)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
/* sign extend tgid, pid */
|
|
|
|
return sys_tgkill((int)tgid, (int)pid, sig);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* long long munging:
|
|
|
|
* The 32 bit ABI passes long longs in an odd even register pair.
|
|
|
|
*/
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 reg6, u32 poshi, u32 poslo)
|
|
|
|
{
|
|
|
|
return sys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
|
|
|
|
}
|
|
|
|
|
2010-08-11 03:26:22 -07:00
|
|
|
compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count,
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 reg6, u32 poshi, u32 poslo)
|
|
|
|
{
|
|
|
|
return sys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return sys_readahead(fd, ((loff_t)offhi << 32) | offlo, count);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long high, unsigned long low)
|
|
|
|
{
|
|
|
|
return sys_truncate(path, (high << 32) | low);
|
|
|
|
}
|
|
|
|
|
sys_fallocate() implementation on i386, x86_64 and powerpc
fallocate() is a new system call being proposed here which will allow
applications to preallocate space to any file(s) in a file system.
Each file system implementation that wants to use this feature will need
to support an inode operation called ->fallocate().
Applications can use this feature to avoid fragmentation to certain
level and thus get faster access speed. With preallocation, applications
also get a guarantee of space for particular file(s) - even if later the
the system becomes full.
Currently, glibc provides an interface called posix_fallocate() which
can be used for similar cause. Though this has the advantage of working
on all file systems, but it is quite slow (since it writes zeroes to
each block that has to be preallocated). Without a doubt, file systems
can do this more efficiently within the kernel, by implementing
the proposed fallocate() system call. It is expected that
posix_fallocate() will be modified to call this new system call first
and incase the kernel/filesystem does not implement it, it should fall
back to the current implementation of writing zeroes to the new blocks.
ToDos:
1. Implementation on other architectures (other than i386, x86_64,
and ppc). Patches for s390(x) and ia64 are already available from
previous posts, but it was decided that they should be added later
once fallocate is in the mainline. Hence not including those patches
in this take.
2. Changes to glibc,
a) to support fallocate() system call
b) to make posix_fallocate() and posix_fallocate64() call fallocate()
Signed-off-by: Amit Arora <aarora@in.ibm.com>
2007-07-17 18:42:44 -07:00
|
|
|
asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
|
|
|
|
u32 lenhi, u32 lenlo)
|
|
|
|
{
|
|
|
|
return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
|
|
|
|
((loff_t)lenhi << 32) | lenlo);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long low)
|
|
|
|
{
|
|
|
|
return sys_ftruncate(fd, (high << 32) | low);
|
|
|
|
}
|
|
|
|
|
|
|
|
long ppc32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
|
|
|
|
size_t len)
|
|
|
|
{
|
|
|
|
return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
|
|
|
|
buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
|
|
|
|
size_t len, int advice)
|
|
|
|
{
|
|
|
|
return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len,
|
|
|
|
advice);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_add_key(const char __user *_type,
|
2005-04-16 15:20:36 -07:00
|
|
|
const char __user *_description,
|
|
|
|
const void __user *_payload,
|
|
|
|
u32 plen,
|
|
|
|
u32 ringid)
|
|
|
|
{
|
|
|
|
return sys_add_key(_type, _description, _payload, plen, ringid);
|
|
|
|
}
|
|
|
|
|
2005-10-17 21:51:57 -07:00
|
|
|
asmlinkage long compat_sys_request_key(const char __user *_type,
|
2005-04-16 15:20:36 -07:00
|
|
|
const char __user *_description,
|
|
|
|
const char __user *_callout_info,
|
|
|
|
u32 destringid)
|
|
|
|
{
|
|
|
|
return sys_request_key(_type, _description, _callout_info, destringid);
|
|
|
|
}
|
|
|
|
|
Introduce fixed sys_sync_file_range2() syscall, implement on PowerPC and ARM
Not all the world is an i386. Many architectures need 64-bit arguments to be
aligned in suitable pairs of registers, and the original
sys_sync_file_range(int, loff_t, loff_t, int) was therefore wasting an
argument register for padding after the first integer. Since we don't
normally have more than 6 arguments for system calls, that left no room for
the final argument on some architectures.
Fix this by introducing sys_sync_file_range2(int, int, loff_t, loff_t) which
all fits nicely. In fact, ARM already had that, but called it
sys_arm_sync_file_range. Move it to fs/sync.c and rename it, then implement
the needed compatibility routine. And stop the missing syscall check from
bitching about the absence of sys_sync_file_range() if we've implemented
sys_sync_file_range2() instead.
Tested on PPC32 and with 32-bit and 64-bit userspace on PPC64.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-06-27 14:10:09 -07:00
|
|
|
asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,
|
|
|
|
unsigned offset_hi, unsigned offset_lo,
|
|
|
|
unsigned nbytes_hi, unsigned nbytes_lo)
|
|
|
|
{
|
|
|
|
loff_t offset = ((loff_t)offset_hi << 32) | offset_lo;
|
|
|
|
loff_t nbytes = ((loff_t)nbytes_hi << 32) | nbytes_lo;
|
|
|
|
|
|
|
|
return sys_sync_file_range(fd, offset, nbytes, flags);
|
|
|
|
}
|
2010-08-18 22:15:37 -07:00
|
|
|
|
|
|
|
asmlinkage long compat_sys_fanotify_mark(int fanotify_fd, unsigned int flags,
|
|
|
|
unsigned mask_hi, unsigned mask_lo,
|
|
|
|
int dfd, const char __user *pathname)
|
|
|
|
{
|
|
|
|
u64 mask = ((u64)mask_hi << 32) | mask_lo;
|
|
|
|
return sys_fanotify_mark(fanotify_fd, flags, mask, dfd, pathname);
|
|
|
|
}
|