diff options
Diffstat (limited to 'arch/um/kernel/skas/clone.c')
-rw-r--r-- | arch/um/kernel/skas/clone.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/um/kernel/skas/clone.c b/arch/um/kernel/skas/clone.c new file mode 100644 index 000000000000..4dc55f10cd18 --- /dev/null +++ b/arch/um/kernel/skas/clone.c | |||
@@ -0,0 +1,44 @@ | |||
1 | #include <sched.h> | ||
2 | #include <signal.h> | ||
3 | #include <sys/mman.h> | ||
4 | #include <sys/time.h> | ||
5 | #include <asm/unistd.h> | ||
6 | #include <asm/page.h> | ||
7 | #include "ptrace_user.h" | ||
8 | #include "skas.h" | ||
9 | #include "stub-data.h" | ||
10 | #include "uml-config.h" | ||
11 | #include "sysdep/stub.h" | ||
12 | |||
13 | /* This is in a separate file because it needs to be compiled with any | ||
14 | * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled | ||
15 | */ | ||
16 | void __attribute__ ((__section__ (".__syscall_stub"))) | ||
17 | stub_clone_handler(void) | ||
18 | { | ||
19 | long err; | ||
20 | struct stub_data *from = (struct stub_data *) UML_CONFIG_STUB_DATA; | ||
21 | |||
22 | err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD, | ||
23 | UML_CONFIG_STUB_DATA + PAGE_SIZE / 2 - | ||
24 | sizeof(void *)); | ||
25 | if(err != 0) | ||
26 | goto out; | ||
27 | |||
28 | err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0); | ||
29 | if(err) | ||
30 | goto out; | ||
31 | |||
32 | err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL, | ||
33 | (long) &from->timer, 0); | ||
34 | if(err) | ||
35 | goto out; | ||
36 | |||
37 | err = stub_syscall6(STUB_MMAP_NR, UML_CONFIG_STUB_DATA, PAGE_SIZE, | ||
38 | PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, | ||
39 | from->fd, from->offset); | ||
40 | out: | ||
41 | /* save current result. Parent: pid; child: retcode of mmap */ | ||
42 | from->err = err; | ||
43 | trap_myself(); | ||
44 | } | ||