aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorBodo Stroesser <bstroesser@fujitsu-siemens.com>2005-09-03 18:57:51 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:06:24 -0400
commitf9dfefe423a7633d81310c7b06c5566c74f9167b (patch)
tree268a3b4389621aa31e82808c7223484808758046 /arch/um
parentd9838d86536fe17e76d19bf3e737100fae618396 (diff)
[PATCH] uml: fix advanced sysemu check
cleanup and fix the check for advanced sysemu (PTRACE_SYSEMU_SINGLESTEP option) Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/os-Linux/start_up.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index a8b5b9d9c6ee..040cc1472bc7 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -161,7 +161,7 @@ __uml_setup("nosysemu", nosysemu_cmd_param,
161static void __init check_sysemu(void) 161static void __init check_sysemu(void)
162{ 162{
163 void *stack; 163 void *stack;
164 int pid, syscall, n, status, count=0; 164 int pid, n, status, count=0;
165 165
166 printk("Checking syscall emulation patch for ptrace..."); 166 printk("Checking syscall emulation patch for ptrace...");
167 sysemu_supported = 0; 167 sysemu_supported = 0;
@@ -192,6 +192,12 @@ static void __init check_sysemu(void)
192 192
193 printk("Checking advanced syscall emulation patch for ptrace..."); 193 printk("Checking advanced syscall emulation patch for ptrace...");
194 pid = start_ptraced_child(&stack); 194 pid = start_ptraced_child(&stack);
195
196 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
197 (void *) PTRACE_O_TRACESYSGOOD) < 0)
198 panic("check_ptrace: PTRACE_OLDSETOPTIONS failed, errno = %d",
199 errno);
200
195 while(1){ 201 while(1){
196 count++; 202 count++;
197 if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) 203 if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
@@ -199,15 +205,10 @@ static void __init check_sysemu(void)
199 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); 205 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
200 if(n < 0) 206 if(n < 0)
201 panic("check_ptrace : wait failed, errno = %d", errno); 207 panic("check_ptrace : wait failed, errno = %d", errno);
202 if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP)) 208 if(WIFSTOPPED(status) && (WSTOPSIG(status) == (SIGTRAP|0x80))){
203 panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), "
204 "got status = %d", status);
205
206 syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
207 0);
208 if(syscall == __NR_getpid){
209 if (!count) 209 if (!count)
210 panic("check_ptrace : SYSEMU_SINGLESTEP doesn't singlestep"); 210 panic("check_ptrace : SYSEMU_SINGLESTEP "
211 "doesn't singlestep");
211 n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, 212 n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
212 os_getpid()); 213 os_getpid());
213 if(n < 0) 214 if(n < 0)
@@ -215,6 +216,11 @@ static void __init check_sysemu(void)
215 "call return, errno = %d", errno); 216 "call return, errno = %d", errno);
216 break; 217 break;
217 } 218 }
219 else if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
220 count++;
221 else
222 panic("check_ptrace : expected SIGTRAP or "
223 "(SIGTRAP|0x80), got status = %d", status);
218 } 224 }
219 if (stop_ptraced_child(pid, stack, 0, 0) < 0) 225 if (stop_ptraced_child(pid, stack, 0, 0) < 0)
220 goto fail_stopped; 226 goto fail_stopped;
@@ -250,8 +256,8 @@ static void __init check_ptrace(void)
250 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); 256 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
251 if(n < 0) 257 if(n < 0)
252 panic("check_ptrace : wait failed, errno = %d", errno); 258 panic("check_ptrace : wait failed, errno = %d", errno);
253 if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP + 0x80)) 259 if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|0x80)))
254 panic("check_ptrace : expected SIGTRAP + 0x80, " 260 panic("check_ptrace : expected (SIGTRAP|0x80), "
255 "got status = %d", status); 261 "got status = %d", status);
256 262
257 syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, 263 syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,