New ‘redir’ / ‘hostfwd’ syntax for Qemu

it’s mandatory now in 2.9 so where we go.

Instead of:

-redir tcp::42323:23

which listens on all ip’s and redirects host port 42323 to port 23 on the default guest IP address of 10.0.2.15 we now have to use

-net user,hostfwd=tcp::42323-:23

as you could tell from this ‘easy’ syntax.

-netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport

Right?

Manually adding ncurses & VDE support to the Linux Qemu build

For some reason I had issues for this to automatically pick up building Qemu 2.8.0 on Ubuntu 16.10 (Which is really Debian)…

Anyways, be sure to have the needed dev components installed.  If you have a FRESH system, natrually you’ll need a lot more.

apt-get install libvdeplug-dev
apt-get install libvde-dev
apt-get install ncurses-dev

editing the file config-host.mak, I found I needed to add the following to turn on ncurses & VDE:

CONFIG_CURSES=y
CONFIG_VDE=y

And lastly add in the following libs to the libs_softmmu, to ensure it’ll link

-lncurses -lvdeplug

And now I’m good!

From my notes on flags needed to run Qemu the old fashioned way:

-net none -device pcnet,mac=00:0a:21:df:df:01,netdev=qemu-lan -netdev vde,id=qemu-lan,sock=/tmp/local/

This will join it to the VDE listening in /tmp/local

Obviously I have something more interesting and more evil going on….

Cross compiled Linux 1.0.9!

Linux 1.0.9 running!

Linux 1.0.9 running!

After getting Linux 0.98 to compile, I thought I’d take a stab at Linux 1.0.  I vaugely recall when it was released, and I just remember a much larger push to 1.1.  So I guess it really comes as no surprise that in the Linux kernel archives, there is simply the 1.0 tar, and 9 patch files.

I went ahead, and patched up the release, and then tried to build with GCC 2.3.3.  This however proved not to be up to the task, as 2.3.3 has issues with some of the assembly macros, so delving into the readme shows that you need to use GCC 2.4.5 or higher.  Since I wanted to keep at least the tools on par, I went ahead and build 2.4.5, and once more again used the gcc driver from 2.6.3.  I further ended up relying on headers, and checking tool versions from Debian 0.91, which also revealed that they were still using GAS 1.38 back then.

One interesting note while building piggback, which takes the compressed system object, and wraps it in an object file, is that it directly uses the magic “0x00640107”, which is for a later “Linux/i386 impure executable (OMAGIC)” filetype.  But because my binutils is so ancient, I needed to change it to “0x00000107” so that the linker would recognize it as a “386 executable not stripped” file.  As always when having no idea what I was doing, it was easier to have it make an empty object file, set the type for 12345678 and look for where it occurs in the data stream, and just match it with a known object file.  As you can see, it worked.

I don’t know if it is of any interest, but the kernel source, along with a binary is available to download linux-1.0.9.7z, and the same goes for GCC gcc-2.4.5.7z.

And of course, you’ll want the latest download, which includes the pre-built tools, qemu, and build environment to get you started.

Torbjörn Granlund’s Excellent resource on running free OS’s on Qemu

Ever get tired of x86 on x86?  yeah me too.

How to solve that problem?

Simple, grab QEMU, and jump off into all those cool RISC processors of the 1990’s that were going to save us all from the WINTEL hegemony!

Lots of instructions, samples, images, and hints here:

https://gmplib.org/~tege/qemu.html

It’s really more comprehensive than I’ve sat down to do, so yeah it’s awesome!

Supported platforms include:

mips32,mips64,sparc32,sparc64,ppc32,ppc64,arm32,arm64,s390x,alpha

NetBSD 1.0 i386

It had just hit me that I’d never actually installed NetBSD 1.0

So here we go!  For whatever reason Qemu and NetBSD 1.0 see the floppy as a 1.2 MB, so I had to make 1.2 MB images.  For anyone feeling like shuffling a whole lot of floppies here you go!

For everyone else, here is a pre-installed VMDK + Qemu all set to run (for Windows).

I’ve setup the networking, so you can telnet into the VM, and of course access outside, but remember with SLiRP, things like FTP & NFS aren’t going to work.

NetBSD 1.0 on Qemu

NetBSD 1.0 on Qemu

Linux at 25 years!

As we quickly approach this amazing milestone, I think it’s always interesting to re-visit the roots of Linux, back to the really ancient versions.  Thanks to the hard work of oldlinux.org, the oldest intact Linux source code available is Linux 0.10 from November of 1991.  A popular writeup on 0.10 was up on kerneltrap.org which appears to have been vaporized, but thanks to archvie.org is preserved.

Since this version is complete I thought it would be fun to run it through the Linux 0.11 build process & toolchain to see if I could get a working kernel.  Well I had a few stumbling blocks, the bootblocks and the keyboard assembly driver were giving me issues, and for the sake of time, I went ahead and replaced them with the code from 0.11, and along with minor patching to the IDE disk driver.  I added in a simple line to let me know I was actually booting up my franken 0.10 kernel with Qemu.  Also I found later versions of Qemu work much better with 0.10 regarding the IDE disk.

Linux 0.10 on Qemu, cross compiled on Windows

Linux 0.10 on Qemu, cross compiled on Windows

I know it’s not much to look at but it really is building and running.  I’m using the disk for the 0.11 series, as the userland seems to somewhat work.  It’s very touchy, and prone to crashing as it ‘has a bug in the buffer cache’ that I didn’t feel like trying to track down.  Nobody should be using this for anything serious anyways.

Install the 0.11 a.out GCC 1.40 on Win32 cross environment (I guess you can build them on Linux too if you so desire), and if you have a working MSYS environment you can run ‘make’ and it should give you a kernel.  The command file ‘linux.cmd’ will boot it up, and attach the disk image that I used to test.  There are permission errors, and well.. errors.  0.10 was not able to selfhost, but it should be enough to boot, mount the root, and run stuff like the sample ‘hello world’ program.

For those who like to browse the source, I have a browsable tree here.

And for the 2-3 people who care, here is my updated linux-0.10 source tree hosted on sourceforge.

Updated build of Linux 0.11 on Windows 10

Building & Running Linux

Building & Running Linux

I’ve updated my project for compiling Linux 0.11 on Windows 10.  In this version it builds a lot better with TDM MinGW 5.1.0 + MSYS.

The big improvements is that you can compile Linux without the full MinGW/MSYS install by running the ‘blind’ script which will compile the kernel without make and friends.

The build process for the kernel works as well so now with the included Qemu 0.12.5, no need to link under Linux anymore.  I fixed up some of the build processes as I thought I’d re-build and some stuff bombed so it’s all fixed up.

For those interested, I just updated the original download here:

MinGW-aout-linux-011.7z

Mainframe (s390 Linux) Moon Buggy

Linux/s390

Linux/s390

For all you mainframe/Qemu fan’s I came across the ‘QEMU Advent Calendar‘, which includes Moon Buggy on s390!

Moon-buggy is an ascii art game styled after moon-patrol.

Since I do get people always requesting something to run on the Qemu s390 emulation, here you go!  And for Windows users, I packed it up somewhat to make it somewhat easy to run with the image files, emulator and ansicon as moon.7z .

Just unpack and run “run32.cmd” for the 32bit ansicon, or “run64.cmd” for the 64bit ansicon.

20 years of OpenBSD

puffy58Yes, 20 years!

The list announcement:

OpenBSD's source tree just turned 20 years old.

I recall the import taking about 3 hours on an EISA-bus 486 with 
two ESDI drives.  There was an import attempt a few days earlier, 
but it failed due to insufficient space.  It took some time to 
repartition the machine.

It wasn't terribly long before David Miller, Chuck Cranor and 
Niklas Hallqvist were commiting... then more people showed up.

The first developments were improvements to 32-bit sparc.

Chuck and I also worked on setting up the first 'anoncvs' to make 
sure noone was ever cut out from 'the language of diffs' again.
I guess that was the precursor for the github concept these 
days :-).  People forget, but even FSF was a walled garden at 
the time -- throwing tar files with vague logs over the wall 
every couple months.

I was lucky to have one of the few 64Kbit ISDN links in town,
otherwise this would not have happened.  My desktop was a 
Sparcstation 10; the third machine I had was a very slow 386.

The project is now at:

~322,000 commits
~44 commits/day average
~356 hackers through the years

I thought I’d try OpenBSD 2.0 SPARC on Qemu!  Well either with SUN PROMs, or OpenBIOS the result is the same, it crashes when initializing the SCSI bus.

ok boot disk0:b
Boot device: /iommu/sbus/espdma@5,8400000/esp@5,8800000/sd@0,0:b File and args:
>> OpenBSD BOOT [$Revision: 1.2 $]
Booting /bsd @ 0x4000
1179616+113448+93300+[48552+53058]=0x16f46e
(if this doesn’t work, fix pmap_bootstrap4m in pmap.c)[ preserving 101620 bytes of bsd symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

OpenBSD 2.0 (GENERIC) #2: Thu Oct 10 17:50:37 MDT 1996
deraadt@sun4c:/usr/src/sys/arch/sparc/compile/GENERIC
real mem = 33165312
avail mem = 29028352
using 404 buffers containing 1654784 bytes of memory
bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0:b
mainbus0 (root): SUNW,SPARCstation-5
cpu0 at mainbus0: FMI,MB86904 @ 1169 MHz, MB86910 or WTL1164/5 FPU
cpu0: physical 16K instruction (32 b/l), 8K data (16 b/l) cache NOT enabled for 4/0 cpu/mmu combination
obio0 at mainbus0
clock0 at obio0 addr 0x71200000: mk48t08 (eeprom)
timer0 at obio0 addr 0x71d00000 delay constant 73
auxreg0 at obio0 addr 0x71900000
zs0 at obio0 addr 0x71100000 pri 12, softpri 6
zs0a: console i/o
zs1 at obio0 addr 0x71000000 pri 12, softpri 6
[slavioconfig at obio0] addr 0x71800000 not configured
power0 at obio0 addr 0x71910000
fdc0 at obio0 addr 0x71400000 pri 11, softpri 4: chip 82077
fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
iommu0 at mainbus0 addr 0x10000000: version 5/0, page-size 4096, range 64MB
sbus0 at iommu0: clock = 584.500 MHz
dma0 at sbus0 slot 5 offset 0x8400000: rev 2
esp0 at dma0 slot 0x5 offset 0x8800000 pri 4: ESP200 40Mhz, target 7
scsibus0 at esp0
trap type 0x29: pc=f80e2494 npc=f80e2498 psr=4001bc0<EF,S,PS>
panic: trap
Stopped at _Debugger+0x4: jmpl [%o7 + 0x8], %g0
db>

But you can play kernel hangman, if you are into that kind of thing.

But make no mistake, the new 5.8 release (just released!) boots up just fine on Qemu:

Welcome to OpenBIOS v1.1 built on Jun 17 2015 18:50
Type ‘help’ for detailed information
Trying disk…
Not a bootable ELF image
Loading a.out image…
Loaded 66648 bytes
entry point is 0x4000
bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0

Jumping to entry point 00004000 for type 00000005…
switching to new context:
>> OpenBSD BOOT 2.11
Booting bsd
Loading at physical address 400000
1316320+2139464+409400=0x3b0604
cannot open /etc/random.seed: No such file or directory
console is ttya
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2015 OpenBSD. All rights reserved. http://www.OpenBSD.org

OpenBSD 5.8 (RAMDISK) #23: Sun Aug 9 00:08:29 GMT 2015
miod@tekumel.gentiane.org:/usr/src/sys/arch/sparc/compile/RAMDISK
real mem = 117309440 (111MB)
avail mem = 111083520 (105MB)
mainbus0 at root: SUNW,SPARCstation-5
cpu0 at mainbus0: MB86904 @ 170 MHz, MB86910 or WTL1164/5 FPU
cpu0: 16K instruction (32 b/l), 8K data (16 b/l), 512K external (32 b/l) cache enabled
obio0 at mainbus0
clock0 at obio0 addr 0x71200000: mk48t08 (eeprom)
timer0 at obio0 addr 0x71d00000: delay constant 73, frequency 2000000 Hz
zs0 at obio0 addr 0x71100000 pri 12, softpri 6
zstty0 at zs0 channel 0: console
zstty1 at zs0 channel 1
zs1 at obio0 addr 0x71000000 pri 12, softpri 6
zskbd0 at zs1 channel 0: no keyboard
zstty2 at zs1 channel 1: mouse
fdc0 at obio0 addr 0x71400000 pri 11, softpri 4: chip 82077
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
auxreg0 at obio0 addr 0x71900000
power0 at obio0 addr 0x71910000
slavioconfig at obio0 addr 0x71800000 not configured
chosen “reg” property length = -1 (need multiple of 12)
builtin “reg” property length = -1 (need multiple of 12)
iommu0 at mainbus0 addr 0x10000000: version 0x5/0x0, page-size 4096, range 64MB
sbus0 at iommu0: 21.250 MHz
dma0 at sbus0 slot 5 offset 0x8400000: rev 2
esp0 at dma0 offset 0x8800000 pri 4: ESP200, 40MHz
scsibus0 at esp0: 8 targets, initiator 7
sd0 at scsibus0 targ 0 lun 0: <QEMU, QEMU HARDDISK, 2.4.> SCSI3 0/direct fixed
sd0: 6MB, 512 bytes/sector, 12288 sectors
cd0 at scsibus0 targ 2 lun 0: <QEMU, QEMU CD-ROM, 2.4.> SCSI3 5/cdrom removable
ledma0 at sbus0 slot 5 offset 0x8400010: rev 2
le0 at ledma0 offset 0x8c00000 pri 6: address 52:54:00:12:34:56
le0: 16 receive buffers, 4 transmit buffers
tcx0 at sbus0 slot 3 offset 0x800000 pri 9: 1024x768x8
wsdisplay0 at tcx0
wsdisplay0: screen 0 added (std, sun emulation)
“SUNW,CS4231” at sbus0 class serial slot 4 offset 0xc000000 not configured
“power-management” at sbus0 slot 4 offset 0xa000000 not configured
bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0
root on rd0a swap on rd0b dump on rd0b
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

Welcome to the OpenBSD/sparc 5.8 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell?

Just don’t bother with the ‘install diskette’ try the miniroot instead.