2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/kernel/sys_arm.c
|
|
|
|
*
|
|
|
|
* Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c
|
|
|
|
* Copyright (C) 1995, 1996 Russell King.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This file contains various random system calls that
|
|
|
|
* have a non-standard calling sequence on the Linux/arm
|
|
|
|
* platform.
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/sem.h>
|
|
|
|
#include <linux/msg.h>
|
|
|
|
#include <linux/shm.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/mman.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/file.h>
|
2007-10-17 14:29:24 +08:00
|
|
|
#include <linux/ipc.h>
|
2008-09-06 18:35:55 +08:00
|
|
|
#include <linux/uaccess.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 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Fork a new task - this creates a new program thread.
|
|
|
|
* This is called indirectly via a small wrapper
|
|
|
|
*/
|
|
|
|
asmlinkage int sys_fork(struct pt_regs *regs)
|
|
|
|
{
|
2006-02-25 05:37:50 +08:00
|
|
|
#ifdef CONFIG_MMU
|
2005-04-17 06:20:36 +08:00
|
|
|
return do_fork(SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
|
2006-02-25 05:37:50 +08:00
|
|
|
#else
|
|
|
|
/* can not support in nommu mode */
|
|
|
|
return(-EINVAL);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clone a task - this clones the calling program thread.
|
|
|
|
* This is called indirectly via a small wrapper
|
|
|
|
*/
|
|
|
|
asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
|
|
|
|
int __user *parent_tidptr, int tls_val,
|
|
|
|
int __user *child_tidptr, struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
if (!newsp)
|
|
|
|
newsp = regs->ARM_sp;
|
|
|
|
|
|
|
|
return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage int sys_vfork(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sys_execve() executes a new program.
|
|
|
|
* This is called indirectly via a small wrapper
|
|
|
|
*/
|
2010-08-18 06:52:56 +08:00
|
|
|
asmlinkage int sys_execve(const char __user *filenamei,
|
|
|
|
const char __user *const __user *argv,
|
|
|
|
const char __user *const __user *envp, struct pt_regs *regs)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
char * filename;
|
|
|
|
|
|
|
|
filename = getname(filenamei);
|
|
|
|
error = PTR_ERR(filename);
|
|
|
|
if (IS_ERR(filename))
|
|
|
|
goto out;
|
|
|
|
error = do_execve(filename, argv, envp, regs);
|
|
|
|
putname(filename);
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-08-18 06:52:56 +08:00
|
|
|
int kernel_execve(const char *filename,
|
|
|
|
const char *const argv[],
|
|
|
|
const char *const envp[])
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct pt_regs regs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(®s, 0, sizeof(struct pt_regs));
|
2010-08-18 06:52:56 +08:00
|
|
|
ret = do_execve(filename,
|
|
|
|
(const char __user *const __user *)argv,
|
|
|
|
(const char __user *const __user *)envp, ®s);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save argc to the register structure for userspace.
|
|
|
|
*/
|
|
|
|
regs.ARM_r0 = ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We were successful. We won't be returning to our caller, but
|
|
|
|
* instead to user space by manipulating the kernel stack.
|
|
|
|
*/
|
|
|
|
asm( "add r0, %0, %1\n\t"
|
|
|
|
"mov r1, %2\n\t"
|
|
|
|
"mov r2, %3\n\t"
|
|
|
|
"bl memmove\n\t" /* copy regs to top of stack */
|
|
|
|
"mov r8, #0\n\t" /* not a syscall */
|
|
|
|
"mov r9, %0\n\t" /* thread structure */
|
|
|
|
"mov sp, r0\n\t" /* reposition stack pointer */
|
|
|
|
"b ret_to_user"
|
|
|
|
:
|
|
|
|
: "r" (current_thread_info()),
|
2005-05-05 20:11:00 +08:00
|
|
|
"Ir" (THREAD_START_SP - sizeof(regs)),
|
2005-04-17 06:20:36 +08:00
|
|
|
"r" (®s),
|
|
|
|
"Ir" (sizeof(regs))
|
2005-10-05 06:17:53 +08:00
|
|
|
: "r0", "r1", "r2", "r3", "ip", "lr", "memory");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
2006-10-02 17:18:31 +08:00
|
|
|
EXPORT_SYMBOL(kernel_execve);
|
2005-09-01 19:37:13 +08:00
|
|
|
|
|
|
|
/*
|
2007-05-12 03:40:30 +08:00
|
|
|
* Since loff_t is a 64 bit type we avoid a lot of ABI hassle
|
2005-09-01 19:37:13 +08:00
|
|
|
* with a different argument ordering.
|
|
|
|
*/
|
|
|
|
asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
|
|
|
|
loff_t offset, loff_t len)
|
|
|
|
{
|
|
|
|
return sys_fadvise64_64(fd, offset, len, advice);
|
|
|
|
}
|