Commit b9232fc4 authored by Paolo \'Blaisorblade\' Giarrusso's avatar Paolo \'Blaisorblade\' Giarrusso Committed by Linus Torvalds

[PATCH] uml: fix sysemu test at startup

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
      Bodo Stroesser <bodo.stroesser@fujitsu-siemens.com>
      Jeff Dike <jdike@addtoit.com>

Currently, the test for the SYSEMU support on the host is completely wrong, as
Bodo noticed.  We should change the syscall result (inserting the host pid)
and check if it is received correctly by the guest.  What we actually do,
without this patch, is to overwrite the syscall number.

This went unnoticed because we only check that the getpid() syscall from the
child does not return its pid.  We don't check that it returns the correct
value.

Also, override the result portably, using the PT_SYSCALL_RET_OFFSET macro
which abstract away the host stack frame layout (took from Jeff Dike code).
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 974789a5
...@@ -214,8 +214,6 @@ static void __init check_sysemu(void) ...@@ -214,8 +214,6 @@ static void __init check_sysemu(void)
sysemu_supported = 0; sysemu_supported = 0;
pid = start_ptraced_child(&stack); pid = start_ptraced_child(&stack);
if(ptrace(PTRACE_SYSEMU, pid, 0, 0) >= 0) { if(ptrace(PTRACE_SYSEMU, pid, 0, 0) >= 0) {
struct user_regs_struct regs;
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
if (n < 0) if (n < 0)
panic("check_ptrace : wait failed, errno = %d", errno); panic("check_ptrace : wait failed, errno = %d", errno);
...@@ -223,18 +221,16 @@ static void __init check_sysemu(void) ...@@ -223,18 +221,16 @@ static void __init check_sysemu(void)
panic("check_ptrace : expected SIGTRAP, " panic("check_ptrace : expected SIGTRAP, "
"got status = %d", status); "got status = %d", status);
if (ptrace(PTRACE_GETREGS, pid, 0, &regs) < 0) n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET,
panic("check_ptrace : failed to read child " os_getpid());
"registers, errno = %d", errno); if(n < 0)
regs.orig_eax = pid; panic("check_ptrace : failed to modify system "
if (ptrace(PTRACE_SETREGS, pid, 0, &regs) < 0) "call return, errno = %d", errno);
panic("check_ptrace : failed to modify child "
"registers, errno = %d", errno);
stop_ptraced_child(pid, stack, 0); stop_ptraced_child(pid, stack, 0);
sysemu_supported = 1; sysemu_supported = 1;
printk("found\n"); printk("OK\n");
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment