Run program without kernel. Possible? (part 2)
Hi,
First, let me apologise if this isn't the right place for asking this.
Yesterday I posted this thread (
http://qemu.dad-answers.com/viewtopic.php?t=1804) on the general help forum, but it seems I got no answer. This is kinda urgent and I'd really appreciate any help.
Again, sorry for being a stubborn
Thanks,
Luís Pureza
[sorry for posting this back to the list, but i'm too lazy to register for the forum]
Quoted 3 lines · Luis Pureza
Is it possible to run some program with qemu without a kernel attached?
I'm involved in a project to create an emulator for the leon2 processor (which is sparc-like). In order to estimate the kind of performance gains we can achieve using dynamic transalation, I'd like to run some small benchmarks without the overhead of the operative system.
If i understand you correctly, you want to try qemu-user. Beware that when benchmarking, qemu-user should probably be faster than qemu-system, as it doesn't have to emulate the os and hardware.
Marco
Hi,
Yes. To a certain extent: If you run x86 linux, and you want to execute a program for PPC linux, you can use the usermode emulation (-user).
Unfortunately, this is only possible if you run Linux _and_ the program is for Linux (on another CPU).
If you want to do this for Darwin, you might be lucky with the usermode emulation of darwine (which is not yet merged with mainstream QEmu, unfortunately).
Maybe you want to ask in a more precise fashion what you want to achieve?
Ciao,
Dscho
Hi,
I think you got it right. I compiled a small test program on linux/x86 using a cross compiler that generates sparc binaries.
Then I tried to emulate it (still on linux/x86) using
$ qemu-sparc -d in_asm program
and it starts emulating but then fails:
Unhandled trap: 0x2
pc: 40002bac npc: 40002bb0
General Registers:
%g0: 00000000 %g1: 40002bac %g2: 00000000 %g3: 00000000 %g4: 40002800 %g5: 00000000 %g6: 00000000 %g7: 00000000 Current Register Window: %o0: 00000000 %o1: 00000000 %o2: 00000000 %o3: 00000000 %o4: 00000000 %o5: 00000000 %o6: b7dbb2a0 %o7: 40002b00 %l0: 00000000 %l1: 00000000 %l2: 00000000 %l3: 00000000 %l4: 00000000 %l5: 00000000 %l6: 00000000 %l7: 00000000 %i0: 00000000 %i1: 00000000 %i2: 00000000 %i3: 00000000 %i4: 00000000 %i5: 00000000 %i6: 00000000 %i7: 00000000
Floating Point Registers:
<All 0>
psr: 0x04000000 -> ---- --- wim: 0x00000001
fsr: 0x00000000
According to the SPARC manual that is an illegal instruction trap. The log contains:
##########################################################
start end size prot
40000000-40004000 00004000 rwx
b7d76000-b7df6000 00080000 rw-
b7df6000-b7df7000 00001000 ---
start_brk 0x40003adc end_code 0x400038c4 start_code 0x40000000 end_data 0x400038c4
start_stack 0xb7df52e0
brk 0x40003adc
entry 0x40000000
--------------
IN:
0x40000000: mov %g0, %g4 0x40000004: sethi %hi(0x40002800), %g4 0x40000008: jmp %g4 + 0x2f8 ! 0x40002af8 0x4000000c: nop
--------------
IN:
0x40002af8: sethi %hi(0x40002800), %g1 0x40002afc: or %g1, 0x3ac, %g1 ! 0x40002bac 0x40002b00: call %g1 0x40002b04: nop
--------------
IN:0x40002bac: rd %psr, %l3
##########################################################
This last instruction seems to be completely legal, so I don't really know what's happening...
The source for the program is in attachment.
Thanks for your help.
Luís Pureza
P.S.: By the way, every time I tried qemu-i386 using examples from the official documentation, it failed with this error:
cannot set up thread-local storage: set_thread_area failed when setting up thread-local storage
Seems to be something related to my glibc. My problem?
Quoted 20 lines · Johannes Schindelin
Hi,
Yes. To a certain extent: If you run x86 linux, and you want to execute a program for PPC linux, you can use the usermode emulation (-user).
Unfortunately, this is only possible if you run Linux _and_ the program is for Linux (on another CPU).
If you want to do this for Darwin, you might be lucky with the usermode emulation of darwine (which is not yet merged with mainstream QEmu, unfortunately).
Maybe you want to ask in a more precise fashion what you want to achieve?
Ciao,
Dscho
Quoted 5 lines
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
int main(void)
{
int i;
i = 3 + 4;
return 0;
}Quoted 5 lines
IN:
0x40002bac: rd %psr, %l3
##########################################################
This last instruction seems to be completely legal, so I don't really know what's happening...
User mode emulator does not allow supervisor mode instructions at all. Try the system emulator (qemu-system-sparc) instead, or compile your program so that the startup code doesn't use any supervisor instructions.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/