Bug 3143

Summary: qemu-mips segfault on mips x86_64 gmae-toolchain
Product: [Build System, Metadata & Runtime] OE-Core Reporter: liang li <liang.li2>
Component: devtools / tool chainAssignee: Laurentiu Palcu <laurentiu.palcu>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: jessica.zhang, laurentiu.serban, meta.mr.watcher, meta.watcher, poky.adt.watcher, poky.watcher, yi.zhao
Version: unspecified   
Target Milestone: 1.3 M5   
Hardware: x86   
OS: Multiple   
Whiteboard: (merged)
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description liang li 2012-09-20 10:24:09 UTC
toolchain from below:
http://autobuilder.yoctoproject.org/pub/nightly/20120919-2/toolchain/x86_64/poky-eglibc-x86_64-mips-toolchain-gmae-1.2+snapshot-20120919.sh

steps below:
1.install toolchain to "/opt/poky/1.2+snapshot".
2.run "source /opt/poky/1.2+snapshot/environment-setup-mips32-poky-linux".
3.run "${CC} -o test test.c -lm"
4.run "qemu-mips /opt/poky/1.2+snapshot/sysroots/mips32-poky-linux/lib/ld.so.1 --library-path /opt/poky/1.2+snapshot/sysroots/mips32-poky-linux/lib:/opt/poky/1.2+snapshot/sysroots/mips32-poky-linux/usr/lib ./test"

errors below:
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)

run "file ./test",output below:
./test: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70401, not stripped

test.c below:
#include <stdio.h>
#include <math.h>
double convert(long long l)
{
return (double)l;// or double(l)
}

int main(int argc, char * argv[])
{
long long l = 10;
double f;
f = convert(l);
printf("convert: %lld => %f\n", l, f);
f = 1234.67;
printf("floorf(%f) = %f\n", f, floorf(f));
return 0;
}


test env :
host :ubuntu 12.04 x86_64

git info:52850f0fc6f801298413ee779834b346ef7f48d6
git branch: poky/1.3_M5
Comment 1 Laurentiu Palcu 2012-09-24 13:08:26 UTC
Do you happen to know if this is a regression? Did it work previously?
Comment 2 Laurentiu Palcu 2012-09-24 13:10:38 UTC
It looks like it's enough for the test.c file to contain an empty main() function and it still segfaults...
Comment 3 liang li 2012-09-25 02:18:25 UTC
(In reply to comment #1)
> Do you happen to know if this is a regression? Did it work previously?

not regression,such error not met before.
Comment 4 liang li 2012-09-26 07:32:08 UTC
error still exists in 1.3 M5 RC2 from:
http://autobuilder.pokylinux.org/nightly/20120926-1/toolchain/x86_64/poky-eglibc-x86_64-mips-toolchain-gmae-1.2+snapshot-20120926.sh
git info: 718eb85806e080d0b165344b272e531ef19421eb
git branch:  poky/1.3_M5
Comment 5 Laurentiu Palcu 2012-09-26 15:51:09 UTC
I isolated the issue doing a bisect on qemu repository and found that this issue was introduced by this commit: "linux-user: reserve 4GB of vmem for 32-on-64". Reverting it will make qemu-mips work again.
Comment 6 Laurentiu Palcu 2012-09-28 15:03:28 UTC
After some investigations, it looks like the problem is in the translated code and a MMU fault is generated in the virtual CPU. Somehow, a kernel address is accessed from user/supervisor mode or supervisor address from user mode and a MMU fault is triggered. Everything works fine however if the guest virtual address space is limited to 2GB...
Comment 7 Laurentiu Palcu 2012-10-03 10:59:18 UTC
Patch on the mailing list.
Comment 9 liang li 2012-10-08 03:43:21 UTC
no such error to nightly build 20121003-4:
http://autobuilder.yoctoproject.org/pub/nightly/20121003-4/toolchain/x86_64/poky-eglibc-x86_64-mips-toolchain-gmae-1.3.sh
git info:86c9aa8081f107420cd3763d0566d779daddc2b1
git branch:poky/danny