Skip to contentSkip to conversation

Is mips-user broken on 64bit host?

Qemu-devel Michael Tokarev 4 participants 6 messages Dec 18, 2012 – Dec 21, 2012

lore
Share & tools
lore
#0 lore raw

Since at least 1.1 version of qemu, I can't run any mips binary using statically linked qemu-mips on x86_64 host. It immediately fails with SIGSEGV:

# chroot mipsroot /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

mipsroot/bin/bash: ELF 32-bit MSB executable, MIPS, MIPS-II version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xeb1a3595d733e28f4f081beabb1f135bc5bf7527,
with unknown capability 0x41000000 = 0xf676e75,
with unknown capability 0x10000 = 0x70401,
stripped

(this is current Debian install of mips architecture).

At the same time, 32bit qemu-mips works just fine:

# cp -p /usr/bin/qemu-mips-static-32 mipsroot/usr/bin/
# chroot mipsroot /bin/bash
I have no name!@gandalf:/# ls
bin   dev  home  lib64	proc  run   selinux  tmp  var
boot  etc  lib	 mnt	root  sbin  sys      usr
I have no name!@gandalf:/# uname -a
Linux gandalf 3.2.0-amd64 #3.2.30 SMP Thu Sep 20 18:50:45 MSK 2012 mips GNU/Linux

Current qemu git behaves the same - it also segfaults when trying to run a 32bit mips binary from x86_64 host qemu-mips binary.

There are numerous bugreports about this issue on Debian as well.

Is it just Debian, or is something really broken there? I'd think that running 32bit mips code on x86_64 host is quite common, no?

(Cc'ing Aurelien for this one)

Thanks,

/mjt

#1 lore raw

[Qemu-devel] (bisected): Is mips-user broken on 64bit host since v1.1?

Quoted 31 lines · Michael Tokarev

Since at least 1.1 version of qemu, I can't run any mips binary using statically linked qemu-mips on x86_64 host. It immediately fails with SIGSEGV:

# chroot mipsroot /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

mipsroot/bin/bash: ELF 32-bit MSB executable, MIPS, MIPS-II version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xeb1a3595d733e28f4f081beabb1f135bc5bf7527,
with unknown capability 0x41000000 = 0xf676e75,
with unknown capability 0x10000 = 0x70401,
stripped

(this is current Debian install of mips architecture).

At the same time, 32bit qemu-mips works just fine:

# cp -p /usr/bin/qemu-mips-static-32 mipsroot/usr/bin/
# chroot mipsroot /bin/bash
I have no name!@gandalf:/# ls
bin   dev  home  lib64	proc  run   selinux  tmp  var
boot  etc  lib	 mnt	root  sbin  sys      usr
I have no name!@gandalf:/# uname -a
Linux gandalf 3.2.0-amd64 #3.2.30 SMP Thu Sep 20 18:50:45 MSK 2012 mips GNU/Linux

Current qemu git behaves the same - it also segfaults when trying to run a 32bit mips binary from x86_64 host qemu-mips binary.

Quoted 6 lines

There are numerous bugreports about this issue on Debian as well.

Is it just Debian, or is something really broken there? I'd think that running 32bit mips code on x86_64 host is quite common, no?

This is broken (bisected to) since

commit 288e65b9eea0c9b3cbe21be46f3e24e4e8b2a090

Author: Alexander Graf <[email protected]>
Date:   Wed Dec 14 00:33:28 2011 +0100

linux-user: reserve 4GB of vmem for 32-on-64

When running 32-on-64 bit guests, we should always reserve as much virtual memory as we possibly can for the guest process, so it can never overlap with QEMU address space.

Fortunately we already have the infrastructure for that. All that's missing is some sane default value to also make use of it!

(Cc'ing).

Reverting this commit on top of qemu-1.1, 1.2 or 1.3 makes it work again.

This commit has been applied in the middle between 1.0 and 1.1 versions of qemu. It is interesting that no one noticed this before now, when 1.3 is out already. Oh well.

Thanks,

/mjt

#2 lore raw

Re: [Qemu-devel] (bisected): Is mips-user broken on 64bit host since v1.1?

Am 18.12.2012 20:05, schrieb Michael Tokarev:

Quoted 62 lines · Michael Tokarev
Quoted 31 lines

Since at least 1.1 version of qemu, I can't run any mips binary using statically linked qemu-mips on x86_64 host. It immediately fails with SIGSEGV:

# chroot mipsroot /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

mipsroot/bin/bash: ELF 32-bit MSB executable, MIPS, MIPS-II version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xeb1a3595d733e28f4f081beabb1f135bc5bf7527,
with unknown capability 0x41000000 = 0xf676e75,
with unknown capability 0x10000 = 0x70401,
stripped

(this is current Debian install of mips architecture).

At the same time, 32bit qemu-mips works just fine:

# cp -p /usr/bin/qemu-mips-static-32 mipsroot/usr/bin/
# chroot mipsroot /bin/bash
I have no name!@gandalf:/# ls
bin   dev  home  lib64	proc  run   selinux  tmp  var
boot  etc  lib	 mnt	root  sbin  sys      usr
I have no name!@gandalf:/# uname -a
Linux gandalf 3.2.0-amd64 #3.2.30 SMP Thu Sep 20 18:50:45 MSK 2012 mips GNU/Linux

Current qemu git behaves the same - it also segfaults when trying to run a 32bit mips binary from x86_64 host qemu-mips binary.

Quoted 6 lines

There are numerous bugreports about this issue on Debian as well.

Is it just Debian, or is something really broken there? I'd think that running 32bit mips code on x86_64 host is quite common, no?

This is broken (bisected to) since

commit 288e65b9eea0c9b3cbe21be46f3e24e4e8b2a090

Author: Alexander Graf<[email protected]>
Date:   Wed Dec 14 00:33:28 2011 +0100

linux-user: reserve 4GB of vmem for 32-on-64

When running 32-on-64 bit guests, we should always reserve as much virtual memory as we possibly can for the guest process, so it can never overlap with QEMU address space.

Fortunately we already have the infrastructure for that. All that's missing is some sane default value to also make use of it!

(Cc'ing).

Reverting this commit on top of qemu-1.1, 1.2 or 1.3 makes it work again.

Quoted 7 lines

This commit has been applied in the middle between 1.0 and 1.1 versions of qemu. It is interesting that no one noticed this before now, when 1.3 is out already. Oh well.

Thanks,

/mjt

I'm afraid that the main focus of most testers is system emulation and must admit that I run user emulation very rarely.

Nevertheless it should be possible to add some statically linked binaries for each architecture to the buildbot machines and add tests which run these binaries.

Regards,

Stefan Weil

#3 lore raw

Re: [Qemu-devel] (bisected): Is mips-user broken on 64bit host since v1.1?

In reply to Michael Tokarev
Quoted 54 lines · Michael Tokarev
Quoted 31 lines · Michael Tokarev

Since at least 1.1 version of qemu, I can't run any mips binary using statically linked qemu-mips on x86_64 host. It immediately fails with SIGSEGV:

# chroot mipsroot /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

mipsroot/bin/bash: ELF 32-bit MSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xeb1a3595d733e28f4f081beabb1f135bc5bf7527,
with unknown capability 0x41000000 = 0xf676e75,
with unknown capability 0x10000 = 0x70401,
stripped

(this is current Debian install of mips architecture).

At the same time, 32bit qemu-mips works just fine:

# cp -p /usr/bin/qemu-mips-static-32 mipsroot/usr/bin/
# chroot mipsroot /bin/bash
I have no name!@gandalf:/# ls
bin   dev  home  lib64	proc  run   selinux  tmp  var
boot  etc  lib	 mnt	root  sbin  sys      usr
I have no name!@gandalf:/# uname -a
Linux gandalf 3.2.0-amd64 #3.2.30 SMP Thu Sep 20 18:50:45 MSK 2012 mips GNU/Linux

Current qemu git behaves the same - it also segfaults when trying to run a 32bit mips binary from x86_64 host qemu-mips binary.

Quoted 6 lines

There are numerous bugreports about this issue on Debian as well.

Is it just Debian, or is something really broken there? I'd think that running 32bit mips code on x86_64 host is quite common, no?

This is broken (bisected to) since

commit 288e65b9eea0c9b3cbe21be46f3e24e4e8b2a090

Author: Alexander Graf <[email protected]>
Date:   Wed Dec 14 00:33:28 2011 +0100

linux-user: reserve 4GB of vmem for 32-on-64

When running 32-on-64 bit guests, we should always reserve as much virtual memory as we possibly can for the guest process, so it can never overlap with QEMU address space.

Fortunately we already have the infrastructure for that. All that's missing is some sane default value to also make use of it!

Quoted 7 lines

(Cc'ing).

Reverting this commit on top of qemu-1.1, 1.2 or 1.3 makes it work again.

Do you know exactly why it breaks mips?

Alex

Quoted 8 lines

This commit has been applied in the middle between 1.0 and 1.1 versions of qemu. It is interesting that no one noticed this before now, when 1.3 is out already. Oh well.

Thanks,

/mjt

#4 lore raw

Re: [Qemu-devel] (bisected): Is mips-user broken on 64bit host since v1.1?

Quoted 5 lines · Alexander Graf
Quoted 2 lines · Michael Tokarev
Quoted 2 lines
# chroot mipsroot /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Quoted 7 lines
Quoted 5 lines

commit 288e65b9eea0c9b3cbe21be46f3e24e4e8b2a090

Author: Alexander Graf <[email protected]>
Date:   Wed Dec 14 00:33:28 2011 +0100

linux-user: reserve 4GB of vmem for 32-on-64

Do you know exactly why it breaks mips?

Guess what? Yesterday was the first day I "met" mips in general and qemu-user in particular... ;)

That's why I Cc'ed Aurelien in the first place ;)

Thanks,

/mjt

#5 lore raw
In reply to Michael Tokarev
Quoted 1 line · Michael Tokarev

Is it just Debian, or is something really broken there?

Something's broken. But it's tricky.

For instance, running with -R 2G works, but -R 3G does not.

Now, I'll also note for the record that 2G is the most that a mips32 userland application ought to be able to reference anyway -- anything with the high-bit set is by definition kernel space.

So while I have yet to track down exactly what went wrong, I have a suspicion that it might actually be related to the incorrect placement of the objects in the address space.

r~