3 Linuxemu is a program that can execute Linux/i386 ELF binaries on
4 Plan9. It was started by Russ Cox and development was continued by
5 me. Its opensource, I dont care what you are doing with it, but maybe
6 Russ does, i don't know :-)
8 If you found some bugs or have some other improvements/ideas send a
11 cinap_lenrek AT gmx DOT de
16 linuxemu is available on sources. On Plan9 do:
19 % cp /n/sources/contrib/cinap_lenrek/linuxemu3.tgz .
21 Another source is my server on the web:
23 % hget http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz >linuxemu3.tgz
28 documentation is provided in the doc directory:
36 % tar xzf linuxemu3.tgz
48 You need a linux rootfilesystem packed in a tarball. Go!
49 get some linux rootfs:
51 http://9hal.ath.cx/usr/cinap_lenrek/mroot.tbz
52 http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz
54 the -linuxemu version contains no symlinks and can be extracted with
55 plain plan9 tools bunzip/tar so you can skip the BOOTSTRAP section.
58 You can create your own with debootstrap on debian linux... or help
59 me write a installer that unpacks and installs slackware on plan9...
60 In any case, linuxemu is not hardwared to any linux distribution!
62 Extract your linux rootfilesystem with the static linked gnutar from
63 the bootstrap directory. (This will create all the fake symlinks for
66 % 8.out bootstrap/tar xf /tmp/mroot.tar
71 Then you can use the linux script to "chroot" into your linux
72 rootfs. the linux script is neccesary because for linux programs
73 to run shared libraries from your linux root have to appear at /lib
74 and /usr/lib and configuration files are expected to be in /etc.
75 the script will build a private namespace and bind the linuxroot
76 over the plan9 root. the original plan9 namespace is mounted to /9.
78 % linux -r ./mroot /bin/bash -i
80 if you omit the -r option, the linuxroot defaults to /sys/lib/linux. you
81 may put your linux root there or add a bind to your $home/lib/profile.
83 You should change /etc/resolv.conf to match your network nameserver
84 setup. Also, you may want to edit /etc/apt/sources.list to change the
90 If linuxemu crashes, use acid to figure out whats going on:
93 % acid -l linuxemu.acid <pid>
95 then you can issue the following commands:
97 ustk() dump a (userspace) stacktrace for the current thread
98 umem(Current()) dump the memory mappings
99 ufds(Current()) dump the filedescriptor table
100 utrace(Current()) dump the internal tracebuffer (enabled by -d option)
102 use xasm()/xcasm() for disassembly for linux code.
104 You can also enable full trace logging:
106 % linux -r ./mroot -dd /bin/bash -i >[2]/tmp/linuxemu.log
108 This slows linuxemu down. In case of race conditions, it often
109 happens that the bug disapears when doing full trace logging!
112 NPTL/thread-local storage
114 If you get one of these errors:
116 "cannot set up thread-local storage: cannot set up LDT for thread-local storage"
118 this is glibc/libpthread complaining! the problem is the following:
119 glibc on i386 decided at some point to use the extra segment registers
120 GS and FS as an indirection pointer for thread local storage. the
121 operating system kernel therfor must have a mechanism to let userspace
122 change descriptor table entries and swap them in/out on context
125 to make it work here are several options:
127 1) recompile and link the program with a pre NPTL version of glibc.
129 2) on some distributions, a non-tls version of libc/libpthread is available.
130 in my debian mroot, the NPTL version is in /lib/tls, the older version
131 is in /lib. by renaming /lib/tls to /lib/_tls_disabled_ the loader will
132 use the non-tls version.
134 3) i made a kernel patch that adds support for per process descriptors to
136 /n/sources/contrib/cinap_lenrek/segdescpatch
137 http://9hal.ath.cx/usr/cinap_lenrek/segdescpatch.tgz
138 it will add the files gdt and ldt to devarch (#P).