* [Qemu-devel] MIPS64 problem with ethernet @ 2007-05-21 15:00 Jason Wessel 2007-05-21 15:39 ` Aurelien Jarno 0 siblings, 1 reply; 6+ messages in thread From: Jason Wessel @ 2007-05-21 15:00 UTC (permalink / raw) To: qemu-devel The ethernet device does not come up correctly on a 64 MIPS target with a 64 bit kernel. I narrowed it down a bit, so I thought I might mention it. If I add to the kernel the line: printk("\nTest ~0UL == %lx\n", (~0UL)); It will print correctly on the real HW: Test ~0UL == ffffffffffffffff In qemu-system-mips64 it will only print: Test ~0UL == The ethernet fails due to the failure of the computing of the test kcalloc() found in slab.h. if (n != 0 && size > ULONG_MAX / n) Where n == 16, size == 8, and ULONG_MAX == (~0UL). I suspect some low level debugging of which op code translation is at fault would be next... Jason. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] MIPS64 problem with ethernet 2007-05-21 15:00 [Qemu-devel] MIPS64 problem with ethernet Jason Wessel @ 2007-05-21 15:39 ` Aurelien Jarno 2007-05-21 15:49 ` Jason Wessel 0 siblings, 1 reply; 6+ messages in thread From: Aurelien Jarno @ 2007-05-21 15:39 UTC (permalink / raw) To: qemu-devel Jason Wessel a écrit : > The ethernet device does not come up correctly on a 64 MIPS target with > a 64 bit kernel. Which Ethernet card are you using? The pcnet one is working correctly here. I am using a 2.6.21.1 kernel. -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] MIPS64 problem with ethernet 2007-05-21 15:39 ` Aurelien Jarno @ 2007-05-21 15:49 ` Jason Wessel 2007-05-26 21:18 ` Aurelien Jarno 0 siblings, 1 reply; 6+ messages in thread From: Jason Wessel @ 2007-05-21 15:49 UTC (permalink / raw) To: qemu-devel Aurelien Jarno wrote: > Jason Wessel a écrit : > >> The ethernet device does not come up correctly on a 64 MIPS target with >> a 64 bit kernel. >> > > Which Ethernet card are you using? The pcnet one is working correctly > here. I am using a 2.6.21.1 kernel. > > It works perfectly fine if I boot a 32bit kernel on the 64bit mips qemu with the pcnet32. It is when I boot the 64bit kernel on the 64bit mips qemu that I see the issue. The only difference I can see is the math operations in the kcalloc() inline because the sizes are different in 32 vs 64 of course. I too was using a 2.6.21.1 kernel with mips.org patches. Likely that I am using a different compiler though. Keeping in mind that the same kernel 32bit and 64bit kernels works fine on real hardware. Jason. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] MIPS64 problem with ethernet 2007-05-21 15:49 ` Jason Wessel @ 2007-05-26 21:18 ` Aurelien Jarno 2007-05-27 11:30 ` Jason Wessel 0 siblings, 1 reply; 6+ messages in thread From: Aurelien Jarno @ 2007-05-26 21:18 UTC (permalink / raw) To: qemu-devel On Mon, May 21, 2007 at 10:49:12AM -0500, Jason Wessel wrote: > Aurelien Jarno wrote: > >Jason Wessel a écrit : > > > >>The ethernet device does not come up correctly on a 64 MIPS target with > >>a 64 bit kernel. > >> > > > >Which Ethernet card are you using? The pcnet one is working correctly > >here. I am using a 2.6.21.1 kernel. > > > > > It works perfectly fine if I boot a 32bit kernel on the 64bit mips qemu > with the pcnet32. It is when I boot the 64bit kernel on the 64bit mips > qemu that I see the issue. The only difference I can see is the math > operations in the kcalloc() inline because the sizes are different in 32 > vs 64 of course. I too was using a 2.6.21.1 kernel with mips.org > patches. Likely that I am using a different compiler though. Keeping > in mind that the same kernel 32bit and 64bit kernels works fine on real > hardware. > 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. Index: target-mips/op_helper.c =================================================================== RCS file: /sources/qemu/qemu/target-mips/op_helper.c,v retrieving revision 1.49 diff -u -d -p -r1.49 op_helper.c --- target-mips/op_helper.c 20 May 2007 13:27:58 -0000 1.49 +++ target-mips/op_helper.c 25 May 2007 14:57:23 -0000 @@ -240,10 +240,8 @@ void do_ddiv (void) void do_ddivu (void) { if (T1 != 0) { - /* XXX: lldivu? */ - lldiv_t res = lldiv(T0, T1); - env->LO = (uint64_t)res.quot; - env->HI = (uint64_t)res.rem; + env->LO = T0 / T1; + env->HI = T0 % T1; } } #endif -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] MIPS64 problem with ethernet 2007-05-26 21:18 ` Aurelien Jarno @ 2007-05-27 11:30 ` Jason Wessel 2007-05-27 23:07 ` Aurelien Jarno 0 siblings, 1 reply; 6+ messages in thread From: Jason Wessel @ 2007-05-27 11:30 UTC (permalink / raw) To: qemu-devel 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... Jason. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] MIPS64 problem with ethernet 2007-05-27 11:30 ` Jason Wessel @ 2007-05-27 23:07 ` Aurelien Jarno 0 siblings, 0 replies; 6+ messages in thread From: Aurelien Jarno @ 2007-05-27 23:07 UTC (permalink / raw) To: qemu-devel 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-05-27 23:07 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-05-21 15:00 [Qemu-devel] MIPS64 problem with ethernet Jason Wessel 2007-05-21 15:39 ` Aurelien Jarno 2007-05-21 15:49 ` Jason Wessel 2007-05-26 21:18 ` Aurelien Jarno 2007-05-27 11:30 ` Jason Wessel 2007-05-27 23:07 ` Aurelien Jarno
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).