qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH, RFC] BSD user emulator
@ 2008-08-25 18:45 Blue Swirl
  2008-08-25 19:03 ` M. Warner Losh
  2008-08-27 19:38 ` Andreas Färber
  0 siblings, 2 replies; 13+ messages in thread
From: Blue Swirl @ 2008-08-25 18:45 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2569 bytes --]

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, %g1
0x00000000001001f4:  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.

[-- Attachment #2: bsd_user_emu.diff.bz2 --]
[-- Type: application/x-bzip2, Size: 43852 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH, RFC] BSD user emulator
@ 2008-08-30  8:31 Blue Swirl
  2008-09-01  8:58 ` Alexander Graf
  0 siblings, 1 reply; 13+ messages in thread
From: Blue Swirl @ 2008-08-30  8:31 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

Hi,

This version can actually execute some programs, for example:

./sparc64-bsd-user/qemu-sparc64 -d in_asm /bin/cat /etc/motd
OpenBSD 4.4 (GENERIC) #1715: Mon Aug 11 17:55:10 MDT 2008

Welcome to OpenBSD: The proactively secure Unix-like operating system.

Please use the sendbug(1) utility to report bugs in the system.
Before reporting a bug, please try to reproduce it with the latest
version of the code.  With bug reports, please try to ensure that
enough information to reproduce the problem is enclosed, and if a
known fix for it exists, include that as well.

Something is not correct with errno handling, it could also be a bug
in CPU emulation:
/sparc64-bsd-user/qemu-sparc64 -d in_asm /bin/cat /foobar
cat: /foobar: Undefined error: 0

Some other programs just fail:
./sparc64-bsd-user/qemu-sparc64 -d in_asm /bin/ls
ls: Cannot allocate memory
./sparc64-bsd-user/qemu-sparc64 -d in_asm /bin/ksh
ksh in malloc(): error: chunk overflow
./sparc64-bsd-user/qemu-sparc64 -d in_asm /usr/bin/id
Segmentation fault
./sparc64-bsd-user/qemu-sparc64 -d in_asm /sbin/ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 0¸
ifconfig: getifgroups: Cannot allocate memory

I've cleaned up the patch a bit. Signals, ioctls and structure
conversions are still unimplemented and as usual, no docs.

I think this is getting ready to be committed pretty soon. Any
comments, objections?

[-- Attachment #2: bsd_user_emu.diff.bz2 --]
[-- Type: application/x-bzip2, Size: 31630 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-09-02 17:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-25 18:45 [Qemu-devel] [PATCH, RFC] BSD user emulator Blue Swirl
2008-08-25 19:03 ` M. Warner Losh
2008-08-27 19:38 ` Andreas Färber
2008-08-28 15:49   ` Blue Swirl
  -- strict thread matches above, loose matches on Subject: below --
2008-08-30  8:31 Blue Swirl
2008-09-01  8:58 ` Alexander Graf
2008-09-01  9:19   ` Andreas Färber
2008-09-01 16:25   ` M. Warner Losh
2008-09-01 16:44     ` Alexander Graf
2008-09-01 17:55       ` M. Warner Losh
2008-09-01 18:21         ` Blue Swirl
2008-09-01 19:13           ` M. Warner Losh
2008-09-02 17:13             ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).