BSD user emulator
RFC PATCH 1/1 BSD user emulator
Hi,
This is a preliminary implementation of BSD user emulator. Some files inside bsd-user contain a lot of unwanted cruft copied from linux-user and ldscript is not used. But it can already run a handcrafted Sparc64 helloworld file (on OpenBSD/Sparc64 host):
LD_BIND_NOW=y ./qemu-sparc64 -d in_asm -strace ../helloworld.sparc64_obsd write(1,0x2001f8,13)Hello World!
= 13
exit(13)
cat /tmp/qemu.log
start end size prot
00100000-00102000 00002000 r-x
00200000-00202000 00002000 r--
00300000-00302000 00002000 rw-
00700000-00702000 00002000 rw-
40000000-40080000 00080000 rw-
40080000-40082000 00002000 ---
40d32000-40d3a000 00008000 ---
418e8000-418f0000 00008000 ---
41b84000-41b8c000 00008000 ---
4325a000-43262000 00008000 ---
4357c000-4357e000 00002000 ---
436ca000-436d2000 00008000 ---
43758000-43760000 00008000 ---
44202000-4420a000 00008000 ---
44dce000-44dd6000 00008000 ---
4643e000-46448000 0000a000 ---
466da000-466e2000 00008000 ---
467d0000-467d8000 00008000 ---
48492000-4849a000 00008000 ---
487b0000-487b8000 00008000 ---
48e8a000-48e92000 00008000 ---
49136000-4913e000 00008000 ---
4941a000-49422000 00008000 ---
494ec000-494ee000 00002000 ---
498b4000-498bc000 00008000 ---
4a950000-4a958000 00008000 ---
4ade4000-4adec000 00008000 ---
4bae8000-4baf0000 00008000 ---
4bb86000-4bb88000 00002000 ---
4d542000-4d55c000 0001a000 ---
4df92000-4df9a000 00008000 ---
4e10a000-4e112000 00008000 ---
4e212000-4e21a000 00008000 ---
4eaca000-4ead2000 00008000 ---
4f392000-4f39a000 00008000 ---
4f4ae000-4f4b6000 00008000 ---
4f6da000-4f6e2000 00008000 ---
500ba000-544bc000 04402000 ---
start_brk 0x0000000000700208 end_code 0x00000000001001f8 start_code 0x0000000000100000 start_data 0x0000000000700208 end_data 0x0000000000700208
start_stack 0x000000004007fb70
brk 0x0000000000700208
entry 0x00000000001001c8
--------------
IN:
0x00000000001001c8: mov 0xd, %o2 0x00000000001001cc: sethi %hi(0), %o0 0x00000000001001d0: sethi %hi(0x200000), %o1 0x00000000001001d4: mov %o0, %o0 0x00000000001001d8: or %o1, 0x1f8, %o1 0x00000000001001dc: sllx %o0, 0x20, %o0 0x00000000001001e0: or %o1, %o0, %o1 0x00000000001001e4: mov 1, %o0 0x00000000001001e8: mov 4, %g1 0x00000000001001ec: ta 0
--------------
IN:0x00000000001001f0: mov 1, %g10x00000000001001f4: ta 0
I think in BSD (at least OpenBSD), system call numbers, system call parameters, ioctls, and signal numbers are shared across architectures, maybe even between *BSDs. If it's true, it should make the emulator much simpler than Linux one.
In message: <[email protected]>
"Blue Swirl" <[email protected]> writes:
: I think in BSD (at least OpenBSD), system call numbers, system call : parameters, ioctls, and signal numbers are shared across
: architectures, maybe even between *BSDs. If it's true, it should make : the emulator much simpler than Linux one.
Yes. FreeBSD, DragonFlyBSD and NetBSD all share this trait. There's some minor ioctl variances between architectures, however, since the size of the data of the ioctl is encoded in the ioctl request number/#define. Error numbers are also the same.
The only time that system call numbers are translated is for the different emulation layers that the BSDs implement. So for doing OSF/1 emulation something different than Linux emulation is done. However, for each of the emulators, the system calls, signals, etc is consistent across architectures for everything except Linux...
And before I forget, way way way cool!
Warner
Hi,
Am 25.08.2008 um 20:45 schrieb Blue Swirl:
Quoted 4 lines
This is a preliminary implementation of BSD user emulator. Some files inside bsd-user contain a lot of unwanted cruft copied from linux-user and ldscript is not used. But it can already run a handcrafted Sparc64 helloworld file (on OpenBSD/Sparc64 host)
[...]
Quoted 4 lines
I think in BSD (at least OpenBSD), system call numbers, system call parameters, ioctls, and signal numbers are shared across architectures, maybe even between *BSDs. If it's true, it should make the emulator much simpler than Linux one.
Recently I had investigated the idea of a Haiku user emulator. Looking at your patch, I see a lot of similarities with what I saw in the linux-user dir, but your patch is not an svn diff and marks all files as fully new against /dev/null, so it's hard to spot the actual differences to linux-user...
In light of getting more userland emulations, do you see possibilities to move shared stuff to a new "user" dir rather than copying them to each *-user dir? The ELF loading for instance?
Andreas
Quoted 24 lines · Andreas Färber
Hi,
Am 25.08.2008 um 20:45 schrieb Blue Swirl:
Quoted 5 lines
This is a preliminary implementation of BSD user emulator. Some files inside bsd-user contain a lot of unwanted cruft copied from linux-user and ldscript is not used. But it can already run a handcrafted Sparc64 helloworld file (on OpenBSD/Sparc64 host)
[...]
Quoted 5 lines
I think in BSD (at least OpenBSD), system call numbers, system call parameters, ioctls, and signal numbers are shared across architectures, maybe even between *BSDs. If it's true, it should make the emulator much simpler than Linux one.
Recently I had investigated the idea of a Haiku user emulator. Looking at
your patch, I see a lot of similarities with what I saw in the linux-user dir, but your patch is not an svn diff and marks all files as fully new against/dev/null, so it's hard to spot the actual differences to linux-user...
Quoted 3 lines
In light of getting more userland emulations, do you see possibilities to
move shared stuff to a new "user" dir rather than copying them to each *-user dir? The ELF loading for instance?
I don't think so, Fabrice was strongly against such merges:
http://article.gmane.org/gmane.comp.emulators.qemu/20864