qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] MIPS64 problem with ethernet
Date: Mon, 28 May 2007 01:07:37 +0200	[thread overview]
Message-ID: <20070527230736.GA28896@amd64.aurel32.net> (raw)
In-Reply-To: <46596BEC.1090006@windriver.com>

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

      reply	other threads:[~2007-05-27 23:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070527230736.GA28896@amd64.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).