From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ETDH5-0006Dc-6y for qemu-devel@nongnu.org; Sat, 22 Oct 2005 02:54:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ETDH3-0006D3-K8 for qemu-devel@nongnu.org; Sat, 22 Oct 2005 02:54:38 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ETDH3-0006Cx-6s for qemu-devel@nongnu.org; Sat, 22 Oct 2005 02:54:37 -0400 Received: from [206.46.252.42] (helo=vms042pub.verizon.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ETDH3-00030l-BS for qemu-devel@nongnu.org; Sat, 22 Oct 2005 02:54:37 -0400 Received: from [192.168.1.10] ([71.111.51.16]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IOR001H71UYSLM2@vms042.mailsrvcs.net> for qemu-devel@nongnu.org; Sat, 22 Oct 2005 01:54:36 -0500 (CDT) Date: Fri, 21 Oct 2005 23:54:34 -0700 From: Josh Triplett In-reply-to: <43599151.90802@psas.pdx.edu> Message-id: <4359E22A.2090904@psas.pdx.edu> MIME-version: 1.0 Content-type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary=------------enigA26FCC4DE255D83DFCF7922C References: <43599151.90802@psas.pdx.edu> Subject: [Qemu-devel] Re: qemu-ppc fails to run clone with CLONE_VM, threaded programs, non-static programs Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA26FCC4DE255D83DFCF7922C Content-Type: multipart/mixed; boundary="------------070408090109000805030809" This is a multi-part message in MIME format. --------------070408090109000805030809 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Josh Triplett wrote: > I'm attempting to run cross-compiled programs with qemu-ppc. Basic > statically-linked programs work perfectly. However, if I attempt to run > non-static programs or threaded programs, or if I attempt to call > clone() with the CLONE_VM flag set, I get an invalid data memory access. > > Threaded programs get an error when calling pthread_create, with an > invalid data memory access at 0x00000018. A simple test program using > clone with CLONE_VM gets an invalid data memory access at 0x00000008. > Non-static programs get an invalid data memory access at various > addresses around 0x0de00000, before ever reaching main(). I worked with pbrook on #qemu to debug this issue. The problem turns out to be that qemu's do_fork function on PowerPC 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. I've prepared and attached a patch which should solve this problem. - Josh Triplett --------------070408090109000805030809 Content-Type: text/x-patch; name="qemu-powerpc-clone.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-powerpc-clone.patch" 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 --------------070408090109000805030809-- --------------enigA26FCC4DE255D83DFCF7922C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Debian - http://enigmail.mozdev.org iD8DBQFDWeIqGJuZRtD+evsRAm0UAJ9x7j6m8dR0s5T+Nw1czH/3/+BaTwCgkiQy 2n6ZOdB4+f0jRJds6aNY4Fo= =CPzq -----END PGP SIGNATURE----- --------------enigA26FCC4DE255D83DFCF7922C--