lab 92 - vxinferno In this lab I create a new Inferno builtin module that calls the vx32 library and get a minimal system working that runs native x86 code, with system calls redirected to inferno's system calls and therefore making the inferno namespace visible to the sandboxed code.
From the vx32 paper,
"Vx32 is a multipurpose user-level sandbox that enables any application to
load and safely execute one or more guest plug-ins, confining each guest
to a system call API controlled by the host application and to a restricted
memory region within the host’s address space."
Inferno, being a virtual operating system, provides its own system call API to limbo applications. The same system calls are available as a C API for use by linked native libraries that appear as builtin modules or devices within the inferno environment. This API is a natural fit for building a Vx32 sandbox allowing native code of all kinds to run within inferno, which controls the namespace.
Please read the vx32 paper, download the code and play with it. I haven't included the vx32 code in the lab. Instead this lab is more tutorial in creating a new builtin module for inferno. This labs code, linked to in the steps below, is all the code necessary to make vx32 appear as a builtin. I've done enough to show some simple examples working, but I haven't defined the full system call interface.
So here are the steps in creating a new builtin module linkage.
Edit /module/runt.m to include new include the new module interface. This file includes all builtin modules and is used later to generate a runtime C struct.
To get this to build we need to edit the /libinterp/mkfile to include the new module, with dependency on header file, generate header file. Add vxrun.$O to the list of OFILES, add vxrun.m to the list of MODULES, and the following rules to ensure the module header, vxrunmod.h, is generated.
vxrunmod.h:D: $MODULES rm -f $target && limbo -t Vxrun -I../module ../module/runt.m > $target vxrun.$O: vxrunmod.hWe can now compile libinterp.
$ cd ~/vx32/src/vxrun $ vxrungcc cat.c $ emu -s -r ~/inferno-os ; vxinferno /home/caerwyn/vx32/src/vxrun/_a.out /dev/drivers #/ root #c cons #e env #M mnt ...