lars brinkhoff,
nocrew labs


a386 is a C programming library which provides a virtual machine. The virtual machine is an abstraction of an Intel 386 running in protected mode. Functions in the library corresponds to privileged processor instructions and access to hardware. The intended use for the library is to serve as a minimal hardware abstraction layer for operating system research.

a386 is implemented with ordinary Unix system calls, so operating systems using this library can be run in a virtual machine on top of the hosting operating system. The library could also be implemented in terms of the privileged instructions provided by a processor, and thus the operating system would be running on bare hardware.

There are some illustrations explaining how a386 provides a virtual and abstract machine.

What is so i386 about a386?

  • the MMU works exactly like the one in an i386
  • interrupts are either enabled or disabled, no interrupt priorities
  • the kernel mode address space is equal to the user mode address space
  • vectored interrupts
On the other hand, many things are abstracted away from the i386:
  • the syscall instruction takes a syscall number argument, like on an ARM or PDP-11
  • the TLB can be flushed in three ways: all pages, one page, a range of pages
  • i386-specific features, like virtual 8086 mode and descriptor tables, are not included


a386 source code is available with anonymous CVS access:
cvs -d :pserver:anonymous@cvs.nocrew.org:/usr/local/cvsroot login
(empty password)
cvs -d :pserver:anonymous@cvs.nocrew.org:/usr/local/cvsroot co a386


There is a mailing list for discussion about a386 development. Send a mail to a386-devel-request@nocrew.org with subscribe in the subject line to subscribe to the list. You can do that by clicking here.


So far only Linux/x86 >= 2.3.22 is supported. Ports to ARM Linux and UltraLinux are started, but far from finished. Bare hardware support is started for x86, m68k, ARM, and Sparc.


a386.h defines the a386 programming interface. The programming model includes CPU kernel and user modes, operating system host binary compatible system calls, context switching, MMU with TLB, timer, interrupts, memory, disk, and a serial port.


There is an attempt to port Linux to a386. Porting some flavour of BSD should be possible too, as well as Mach (i.e. the Hurd), and any other open-source operating system.


Question: Doesn't the Brown Simulator already do all this?
Answer: Not quite, it can't trap system calls. Thus, applications for the hosting OS can't be run in the simulator.

Question: What about the user-mode Linux port?
Answer: It doesn't have a separate hardware abstraction layer, but instead implements everything using Linux system calls directly. This makes it difficult to reuse the same code to port other operating systems.

Question: Is a386 similar to VMware/plex86?
Answer: In a way, yes. But instead of trapping and emulating all the privileged instructions the operating system makes, they are inlined. Also, a386 runs entirely in user space.

Question: Is a386 portable to Windows?
Answer: I'm not sure, but maybe Windows NT is powerful enough. I know that Windows 95 isn't.


It all started with a predecessor to Linux/a386 called Linux2, started in April 1999. This project was exactly like the user-mode Linux port (except it never got as far as starting to execute the init kernel thread). I abandoned this approach in May when I learned about the Brown Simulator. Initially, I thought I would port the Brown Simulator to Linux and then port Linux to run in the Brown Simulator. But when I found out that the Brown Simulator wasn't very i386-like and couldn't catch user-mode syscalls, I decided to make my own CPU simlator instead. Around the same time, I came across Jeff Dike's user-mode Linux and his trick for catching system calls. I took a break during the summer, and started implementing a386 in October. In November Linux/a386 displayed its first shell prompt.


  • Linux/a386, Linux ported to a386
  • NetBSD/a386, planned NetBSD port
  • User-mode Linux, a port of the Linux kernel to its own system call interface
  • plex86, a PC virtualization software program
  • the Brown Simulator, a high-level machine simulator intended for operating system prototyping/instruction
  • Bochs, a highly portable x86 PC emulator
  • Solaris MINIX, a version of MINIX that has been ported to run as a SunOS process

traps system callsyesyesyesnoyes
inlined instructionsyesyesnoyesno
emulates privileged instructions onlyyesyesyesyesno
separate hardware layeryesnoyesyesyes
runs native operating systemsnonoyesnoyes
multiprocessor emulationnoyes?yesyes

License: GNU GPL

Copyright © 2000 Lars Brinkhoff

Last modified