Building and booting K42 on Mambo
Edgar A. Leon
Computer Science Department
University of New Mexico
Building K42 on an x86 debian-like machine
These instructions can be applied to a debian-like machine. In particular, a system capable of installing packages using apt-get.
- Install the cross-compilation tools:
Add to sources.list
deb http://www.cs.unm.edu/~k42/pub/k42-devkit/ ./
Install the k42-devkit package
apt-get install k42-devkit
This will create directories:
/u/kitchawa/k42 (file system image) /home/kitchawa/k42 (cross-compile tools)
Add cross-compile tools path to environment variable PATH
export PATH=/home/kitchawa/k42/bin:$PATH
- Get K42 source code (see http://www.research.ibm.com/K42/ for more details):
export CVSROOT=cvs@kcvs:/u/kitchawa/cvsroot export CVS_RSH=ssh cvs co kitchsrc
- Build K42
Edit file kitchsrc/MakePaths.proto to create your site definitions (see 'watson' as an example) and set your site as the default. In this example, we create 'unm' site:
... export K42_SITE=unm ... ifeq "$(K42_SITE)" "unm" export K42_PACKAGES:=/u/kitchawa/k42-packages export K42_PKGROOTPATH := $(K42_PACKAGES) export LINUXSRCROOT = $(K42_PACKAGES)/src-cvs/linux-$(LINUXVER) export K42_KFS_DISKPATH= $(K42_PACKAGES) # machine hosting 'k42-packages' export K42_PKGHOST:=127.0.0.1 # set up the system wide configuration files export K42_CONFIG:=/home/leon/cs591/k42/k42-config export K42_USER_CONFIG:=~/cs591/k42/k42-config export K42_PKGVER := 4 endif
Most likely you only need to modify K42_PKGHOST and K42_CONFIG. K42_CONFIG contains system-wide configuration files such as:
group hosts k42nfs passwd resolv.conf shadow
Define and export the K42 directory (parent directory of kitchsrc):
export MKANCHOR=/home/leon/cs591/k42
To build K42 you need the following packages:
gcc-3.3 g++-3.3
or the following fedora packages
compat-gcc-34 compat-gcc-34-c++
Compile:
cd $MKANCHOR/kitchsrc
# if default gcc and g++ are version 3.3 make SEQ=1 full_snapshot 2>&1 | tee dumpfile.make
# or point to where the 3.3 compilers are GCC3_EXEC=gcc-3.3 GXX3_EXEC=g++-3.3 make SEQ=1 full_snapshot 2>&1 | tee dumpfile.make
# if using fedora's 3.4 packages WARN_IS_ERR=0 GCC3_EXEC=gcc34 GXX3_EXEC=g++34 make SEQ=1 full_snapshot
If successful, two new directories are created: install and powerpc.
Booting K42 on Mambo
- Get the full system simulator for IBM PowerPC 970 from alphaworks:
http://alphaworks.ibm.com/tech/systemsim970
Assume simulator is installed in /home/leon/ibmsim directory.
- Create victim's configuration. Victim is the machine that runs K42.
Create file install/tools/lib/unm.conf (see generic_hw.conf as an example). This file is included in install/tools/lib/victims.conf.
The file unm.conf:
site.name =unm #unm_mambo.HW_IMGLOC =/homes/kitch0/kitchawa/tftpboot #unm_mambo.HW_INSTALL =hw_install #unm_mambo.K42_SPEC_PKG =/u/kitchawa/k42-packages/powerpc.elf/057.sdet/specdata/benchspec #unm_mambo.MAMBO_GARB_FNAME =/u/kitchawa/local/bfbf unm_mambo.K42_IOSOCKET_TRANSPORT =wire unm_mambo.K42_IP_NETMASK =255.255.255.0 unm_mambo.K42_PACKAGES =/u/kitchawa/k42-packages #unm_mambo.K42_LINUXSRCROOT =$(K42_PACKAGES)/src-cvs/linux-$(K42_LINUXVER) unm_mambo.K42_PKGHOST =spider unm_mambo.K42_PKGVER =4 unm_mambo.K42_REREAD_PARAM_FROM_THINWIRE =true unm_mambo.MAMBO_EXTRA_OPTS =-n -q unm_mambo.MAMBO_MEM =256 unm_mambo.MAMBO_TYPE =gpul # Make sure rlwrap is installed in your victim # if enabling this option, otherwise mambo won't start unm_mambo.MAMBO_RLWRAP =1 unm_mambo.MAMBO_DIR =/home/leon/ibmsim/simulators/systemsim-gpul-release unm_mambo.async_cmd =run_simip,thinwire_mambo unm_mambo.fg_cmd =run_systemsim unm_mambo.kserial =localhost unm_mambo.mambo_type =gpul unm_mambo.site =simulator unm_mambo.sync_cmd =/bin/true unm_mambo.victim_type =mambo mambo.inherit =unm_mambo
- Associate a port range with your user id.
Modify install/tools/Linux_i686/powerpc/kuservalues:
...
<myuserid>)
kuser_port=44900;
;;
...
- Export file system over NFS
Some files have to be exported to the victim machine:
# File on NFS server # Mountpoint on K42 /u/kitchawa/k42-packages/partDeb.Img.4 / /u/kitchawa/k42-packages/partDeb.Img.4 /nfs $MKANCHOR/install/powerpc/partDeb/kitchroot /knfs # powerpc-linux-objdump /home/kitchawa # Extra NFS mounts specified in /knfs/ketc/k42nfs # For example my home directory: # File on NFS server # Mountpoint on K42 $LEONET/k42/home /home/leon
Your exports file (/etc/exports) may look like:
/u/kitchawa/k42-packages/partDeb.Img.4 <victim>(rw,sync,insecure,no_subtree_check) $MKANCHOR/install/powerpc/partDeb/kitchroot <victim>(rw,sync,insecure,no_subtree_check) /home/kitchawa <victim>(rw,sync,insecure,no_subtree_check) $LEONET/k42/home <victim>(rw,sync,insecure,no_subtree_check)
To test that the NFS server daemon is up:
leon@server:new> rpcinfo -p
program vers proto port 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 100003 2 udp 2049 nfs 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100021 1 udp 32776 nlockmgr 100021 3 udp 32776 nlockmgr 100021 4 udp 32776 nlockmgr 100003 2 tcp 2049 nfs 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100021 1 tcp 49606 nlockmgr 100021 3 tcp 49606 nlockmgr 100021 4 tcp 49606 nlockmgr 100005 1 udp 669 mountd 100005 1 tcp 672 mountd 100005 2 udp 669 mountd 100005 2 tcp 672 mountd 100005 3 udp 669 mountd 100005 3 tcp 672 mountd 100024 1 udp 763 status 100024 1 tcp 766 status
To test that the k42 victim can mount (nfs client package):
leon@s1:~> rpcinfo -p
program vers proto port 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 100024 1 udp 32768 status 100024 1 tcp 36947 status 100021 1 tcp 60990 nlockmgr 100021 3 tcp 60990 nlockmgr 100021 4 tcp 60990 nlockmgr
- Boot K42 on Mambo
You may need the tcl/tk libraries to run mambo depending on your mambo binary. I use tcl8.4 (libtcl8.4.so) and tk8.4 (libtk8.4.so).
Add k42console and mambo-xxxxxx.tcl to your path
PATH=$MKANCHOR/install/tools/Linux_i686/powerpc:$PATH
Use the k42console command to boot K42:
K42_PKGHOST=spider K42_PACKAGES=/u/kitchawa/k42-packages \ MAMBO_RLWRAP=1 MAMBO_TCL_STAMP=-090805 MAMBO_TYPE=gpul \ MAMBO_DIR=/home/leon/ibmsim/simulators/systemsim-gpul-release \ k42console -m mambo
If you don't set the MAMBO_TCL_STAMP variable to -090805, k42 may not boot with this version of Mambo. If you want to use the latest mambo-xxxxxx.tcl file (i.e. use the default value for MAMBO_TCL_STAMP), then comment the line:
mysim debugger listen
in file:
install/tools/lib/mambo-111105.tcl
About the environment variables:
# host that contains and exports K42_PACKAGES K42_PKGHOST=spider K42_PACKAGES=/u/kitchawa/k42-packages # host that contains K42's root directory K42_NFS_HOST=spider # readline feature command line wrapper in mambo console # make sure you have rlwrap installed, otherwise mambo # won't start MAMBO_RLWRAP=1 # type of mambo machine MAMBO_TYPE=gpul # dir that holds the simulator binary directory MAMBO_DIR=/home/leon/ibmsim/simulators/systemsim-gpul-release # HW_VERBOSE=1
A more extensive list of variables can be found in:
install/tools/lib/k42_env_desc.txt
If successful, the k42 console shows:
Writing kparm.data.11950 to /home/leon/k42/new/powerpc/partDeb/os/mamboboot.tok at offset 156964 dd bs=1 if=kparm.data.11950 of=/home/leon/k42/new/powerpc/partDeb/os/mamboboot.tok seek=156964 conv=notrunc 662+0 records in 662+0 records out 662 bytes (662 B) copied, 0.00298559 seconds, 222 kB/s thinwire3: IO Channel 1 listening on port 44902 for stream 1. thinwire3: IO Channel 2 listening on port 44903 for stream 2. thinwire3: IO Channel 3 listening on port 44904 for stream 3. thinwire3: IO Channel 4 listening on port 44905 for stream 4. thinwire3: IO Channel 5 listening on port 44909 for stream 8. thinwire3: IO Channel 6 listening on port 44910 for stream 9. thinwire3: IO Channel 7 listening on port 44917 for stream 16. thinwire3: IO Channel 8 listening on port 44918 for stream 17. thinwire3: connecting to victim (host "localhost", port 44900). simip localhost:44903 localhost:44905 simip: connecting to host "localhost", port 44903. simip: connected. simip: connecting to host "localhost", port 44905. simip: connected. run command: 0 ... 12:59:21: 3103003906: (885576794): Login daemon starting got emulSocket 19 12:59:22: 3103114449: (885687330): Rlogind waiting for first connection on port 44913. 12:59:22: 3103128504: (885701385): K42 ready for login
If you don't see the thinwire3 and/or simip lines, then run_simip and/or thinwire_mambo may have not been executed correctly. This may be due to your shell. Try using either sh or bash on the first line of these scripts:
$MKANCHOR/install/tools/Linux_i686/powerpc/run_simip $MKANCHOR/install/tools/Linux_i686/powerpc/thinwire_mambo
Logging in to K42
rlogin -p 44913 <victim>
Make sure to use the rsh-client package instead of ssh, otherwise you may not be able to log in.