Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HsRpy-0000E8-JJ for qemu-devel@nongnu.org; Sun, 27 May 2007 19:07:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HsRpv-0000Aw-PU for qemu-devel@nongnu.org; Sun, 27 May 2007 19:07:45 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HsRpv-0000AR-J2 for qemu-devel@nongnu.org; Sun, 27 May 2007 19:07:43 -0400 Received: from farad.aurel32.net ([82.232.2.251] helo=mail.aurel32.net) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HsRpv-0005br-2f for qemu-devel@nongnu.org; Sun, 27 May 2007 19:07:43 -0400 Received: from amd64.aurel32.net ([2001:618:400:fc13:216:3eff:fe00:1009]) by mail.aurel32.net with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1HsRpp-00052K-LY for qemu-devel@nongnu.org; Mon, 28 May 2007 01:07:37 +0200 Received: from aurel32 by amd64.aurel32.net with local (Exim 4.67) (envelope-from ) id 1HsRpp-0007ry-At for qemu-devel@nongnu.org; Mon, 28 May 2007 01:07:37 +0200 Date: Mon, 28 May 2007 01:07:37 +0200 From: Aurelien Jarno Subject: Re: [Qemu-devel] MIPS64 problem with ethernet Message-ID: <20070527230736.GA28896@amd64.aurel32.net> References: <4651B40F.3000704@windriver.com> <4651BD4D.9020008@aurel32.net> <4651BF78.3000000@windriver.com> <20070526211844.GB18476@amd64.aurel32.net> <46596BEC.1090006@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <46596BEC.1090006@windriver.com> 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 On Sun, May 27, 2007 at 06:30:52AM -0500, Jason Wessel wrote: > Aurelien Jarno wrote: > >As discussed on IRC, the problem is only present on 32-bit hosts. It is > >due to the do_ddivu which is falsely implemented using lldiv and then by > >casting the result. The patch below uses / and % as on the 64-bit host > >code. It is maybe slower than lldiv, but at least it gives the correct > >result. This probably involves some libgcc code, so it is better to keep > >it in op_helper.c for 32-bit hosts. > > > > > > With your change the ethernet does come up but it seems there is a > further problem, perhaps with ddivu. My host is a 32bit host, and this > does seem to work on a 64bit host or the real hardware. Doing something > like an ls /proc does not work in the emulated target. The reason is > that the compatibility syscalls are 32bit and there is some sign > extension problem somewhere. > > I put the following code in kernel/main/init.c as an illustration of the > problem. > { > unsigned long v1 = 0xffffffff80731111; > unsigned int v2 = v1 + 1; > printk("v1 %lx v2 %08x\n", v1, v2); > } > > On the real hw it prints correctly as: > v1 ffffffff80731111 v2 80731112 > > On the emulated 64 bit + 64bit kernel on a 32 bit host it prints as: > v1 ffffffff80731111 v2 ffffffff80731112 > > This might be due to the ddivu in printk, but it could be elsewhere... > The problem is actually not specific to 32-bit hosts. It is a bug in the lwu instruction, which should not sign extend the loaded byte. Please find below a patch to fix that. Index: target-mips/op_mem.c =================================================================== RCS file: /sources/qemu/qemu/target-mips/op_mem.c,v retrieving revision 1.10 diff -u -d -p -r1.10 op_mem.c --- target-mips/op_mem.c 20 May 2007 01:36:28 -0000 1.10 +++ target-mips/op_mem.c 27 May 2007 22:59:13 -0000 @@ -63,7 +63,7 @@ void glue(op_lw, MEMSUFFIX) (void) void glue(op_lwu, MEMSUFFIX) (void) { - T0 = glue(ldl, MEMSUFFIX)(T0); + T0 = (uint32_t) glue(ldl, MEMSUFFIX)(T0); RETURN(); } -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net