2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
15 #include <sys/ptrace.h>
16 #include <linux/ptrace.h>
19 #include <asm/ptrace.h>
20 #include <asm/unistd.h>
22 #include "user_util.h"
23 #include "kern_util.h"
25 #include "signal_kern.h"
26 #include "signal_user.h"
27 #include "sysdep/ptrace.h"
28 #include "sysdep/sigcontext.h"
30 #include "ptrace_user.h"
31 #include "time_user.h"
34 #include "uml-config.h"
35 #include "choose-mode.h"
39 int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
44 err = os_protect_memory((void *) addr, len, r, w, x);
47 panic("protect failed, err = %d", -err);
54 *-------------------------
55 * only for tt mode (will be deleted in future...)
56 *-------------------------
62 unsigned long temp_stack;
67 /* See above for why sigkill is here */
69 int sigkill = SIGKILL;
71 int outer_tramp(void *arg)
77 t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2,
78 t->flags, t->tramp_data);
79 if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
80 kill(os_getpid(), sig);
84 int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
85 int clone_flags, int (*tramp)(void *))
89 int new_pid, status, err;
91 /* The trampoline will run on the temporary stack */
92 sp = stack_sp(temp_stack);
94 clone_flags |= CLONE_FILES | SIGCHLD;
97 arg.tramp_data = thread_arg;
98 arg.temp_stack = temp_stack;
99 arg.flags = clone_flags;
101 /* Start the process and wait for it to kill itself */
102 new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
106 CATCH_EINTR(err = waitpid(new_pid, &status, 0));
108 panic("Waiting for outer trampoline failed - errno = %d",
111 if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
112 panic("outer trampoline didn't exit with SIGKILL, "
113 "status = %d", status);
118 void forward_pending_sigio(int target)
122 if(sigpending(&sigs))
123 panic("forward_pending_sigio : sigpending failed");
124 if(sigismember(&sigs, SIGIO))