Package: qemu
Version: 0.7.0-2
Tags: patch upstream

On PowerPC, the do_fork function zeroes out r7-r31 in the new CPU state
structure after a clone, which it should not do, as the child's
registers should match the parent; it also does not zero register r3,
which holds the return value and should be zero in the child.  As a
result, programs which call clone() with the CLONE_VM flag set, or
threaded programs using clone()-based threads, will segfault in the
child process after the clone().  I've prepared and attached a patch
which fixes this problem; I have already reported this problem to the
upstream qemu-devel list and supplied the patch on that list.  Credit
goes to pbrook on OFTC #qemu for some extremely helpful debugging
assistance and insight when tracking down the problem.

- Josh Triplett
diff -Naur qemu-0.7.0.orig/linux-user/syscall.c qemu-0.7.0/linux-user/syscall.c
--- qemu-0.7.0.orig/linux-user/syscall.c	2005-10-21 19:56:04.000000000 -0700
+++ qemu-0.7.0/linux-user/syscall.c	2005-10-21 20:02:20.000000000 -0700
@@ -1560,11 +1560,7 @@
         if (!newsp)
             newsp = env->gpr[1];
         new_env->gpr[1] = newsp;
-        { 
-            int i;
-            for (i = 7; i < 32; i++)
-                new_env->gpr[i] = 0;
-        }
+        new_env->gpr[3] = 0;
 #else
 #error unsupported target CPU
 #endif

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to