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 "sysdep/ptrace.h"
27 #include "sysdep/sigcontext.h"
29 #include "ptrace_user.h"
30 #include "time_user.h"
33 #include "uml-config.h"
34 #include "choose-mode.h"
38 int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
43 err = os_protect_memory((void *) addr, len, r, w, x);
46 panic("protect failed, err = %d", -err);
53 *-------------------------
54 * only for tt mode (will be deleted in future...)
55 *-------------------------
61 unsigned long temp_stack;
66 /* See above for why sigkill is here */
68 int sigkill = SIGKILL;
70 int outer_tramp(void *arg)
76 t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2,
77 t->flags, t->tramp_data);
78 if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
79 kill(os_getpid(), sig);
83 int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
84 int clone_flags, int (*tramp)(void *))
88 int new_pid, status, err;
90 /* The trampoline will run on the temporary stack */
91 sp = stack_sp(temp_stack);
93 clone_flags |= CLONE_FILES | SIGCHLD;
96 arg.tramp_data = thread_arg;
97 arg.temp_stack = temp_stack;
98 arg.flags = clone_flags;
100 /* Start the process and wait for it to kill itself */
101 new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
105 CATCH_EINTR(err = waitpid(new_pid, &status, 0));
107 panic("Waiting for outer trampoline failed - errno = %d",
110 if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
111 panic("outer trampoline didn't exit with SIGKILL, "
112 "status = %d", status);
117 void forward_pending_sigio(int target)
121 if(sigpending(&sigs))
122 panic("forward_pending_sigio : sigpending failed");
123 if(sigismember(&sigs, SIGIO))