qemu-sparc64 broken
Here is the result of running Debian's busybox-static for sparc64:
$ sparc64-linux-user/qemu-sparc64 /usr/gnemul/qemu-sparc64/bin/busybox ls -l block.c ?rwxr-x--T 1 stefan root 1378329541 Jan 1 1970 block.c
It's obviously wrong. All other user emulations return the correct result:
$ busybox ls -l block.c -rw-r--r-- 1 stefan stefan 131462 Sep 3 21:13 block.c
In a first analysis of this, I noticed that it is impossible to run qemu-sparc64
under gdb (raised fatal signal). I was also surprised to see that target_stat64
is unused.
Regards,
Stefan
Quoted 7 lines · Stefan Weil
Here is the result of running Debian's busybox-static for sparc64:
$ sparc64-linux-user/qemu-sparc64 /usr/gnemul/qemu-sparc64/bin/busybox ls -l block.c ?rwxr-x--T 1 stefan root 1378329541 Jan 1 1970 block.cIt's obviously wrong. All other user emulations return the correct result:
SPARC linux-user emulation has been pretty badly broken and obviously unused (except probably for being able to run gcc test suite code) for some time (if it ever worked at all); I fixed a pretty obvious problem in commit 82f05b69e6 which meant bash couldn't run any programs, for instance.
Quoted 2 lines
$ busybox ls -l block.c -rw-r--r-- 1 stefan stefan 131462 Sep 3 21:13 block.c
Try checking the target_stat and target_stat64 struct definitions in linux-user/syscall_defs.h against the kernel's versions; there's probably a mismatch.
http://lxr.linux.no/#linux+v3.11/arch/sparc/include/uapi/asm/stat.h#L8
The most obvious error is that st_nlink should be a short, not an int. One of the others must be wrong too, though, because alignment padding would cancel that out. You need to chase typedefs (and watch out for possible arch-specific overrides of generic type choices)...
Quoted 3 lines
In a first analysis of this, I noticed that it is impossible to run qemu-sparc64
under gdb (raised fatal signal).
You probably just need to let the signals go through to the target... I noticed that it had a tendency to do lots of (presumably safely handled) segfaulting while running; didn't look at why this happens.
Quoted 2 lines
I was also surprised to see that
target_stat64is unused.
sparc64 provides a stat64 syscall (probably for backward compatibility), but any sensibly compiled libc should just use stat, since with 64 bit longs the fields are all sensible sizes anyway.
-- PMM
Am 05.09.2013 23:32, schrieb Peter Maydell:
Quoted 8 lines · Stefan Weil
Quoted 3 lines
In a first analysis of this, I noticed that it is impossible to run qemu-sparc64
under gdb (raised fatal signal).You probably just need to let the signals go through to the target... I noticed that it had a tendency to do lots of (presumably safely handled) segfaulting while running; didn't look at why this happens.
After lots of SIGSEGV, the program indeed finishes successfully, so my report was wrong - SIGSEGV is not a fatal signal for sparc64. That's interesting - thank you for this information.
Now I can debug. I'll send a patch when it's fixed.
Regards,
Stefan
Quoted 5 lines · Stefan Weil
Am 05.09.2013 23:32, schrieb Peter Maydell:
Quoted 4 lines · Stefan Weil
Quoted 3 lines
In a first analysis of this, I noticed that it is impossible to run qemu-sparc64
under gdb (raised fatal signal).
Quoted 8 lines
Quoted 4 lines
You probably just need to let the signals go through to the target... I noticed that it had a tendency to do lots of (presumably safely handled) segfaulting while running; didn't look at why this happens.
After lots of SIGSEGV, the program indeed finishes successfully, so my report was wrong - SIGSEGV is not a fatal signal for sparc64. That's interesting - thank you for this information.
It's not just sparc64.
That's changed page detection, for determining when to invalidate translation blocks. For self-modifying code, and more.
r~
Quoted 9 lines · Richard Henderson
Quoted 3 lines · Stefan Weil
After lots of SIGSEGV, the program indeed finishes successfully, so my report was wrong - SIGSEGV is not a fatal signal for sparc64. That's interesting - thank you for this information.
It's not just sparc64.
That's changed page detection, for determining when to invalidate translation blocks. For self-modifying code, and more.
Yeah, but in practice sparc64 does this a huge number of times on simple binaries in a way that other linux-user guests I looked at just don't. Presumably it's just that gcc has for some reason put writable data next to code for that target.
-- PMM
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Richard Henderson
Quoted 3 lines · Stefan Weil
After lots of SIGSEGV, the program indeed finishes successfully, so my report was wrong - SIGSEGV is not a fatal signal for sparc64. That's interesting - thank you for this information.
It's not just sparc64.
Quoted 8 lines
Quoted 2 lines
That's changed page detection, for determining when to invalidate translation blocks. For self-modifying code, and more.
Yeah, but in practice sparc64 does this a huge number of times on simple binaries in a way that other linux-user guests I looked at just don't. Presumably it's just that gcc has for some reason put writable data next to code for that target.
It's the (old?) PLT scheme for sparc -- it modifies code on linking. If you use LD_BIND_NOW=1 it can help speed things up when debugging.
r~