Subject: VM86 stuff: how faithful to Linux interface?
To: None <port-i386@NetBSD.ORG>
From: John Kohl <jtk@atria.com>
List: port-i386
Date: 03/13/1995 09:58:27
I'm well along in my work to port the linux dosemu to NetBSD.  Now comes
some of the tricky stuff:  I/O permission bitmaps, and kernel assist for
traps.

For I/O permission bitmaps, linux has a two-tier mechanism.  If a
program only wants to access ports below 0x3ff, then it will diddle an
I/O bitmap in the process's TSS.  For ports above 0x3ff, the program
must set its IOPL to 3 (that's what X11 does currently to get access to
the video ports).

This is nice because many I/O ports are below 0x3ff, and it doesn't
require gobs of bitmap space in the TSS. I'm tempted to implement the
same scheme for NetBSD/i386.

The other sticky problem is kernel assistance for VM86 mode operations.
There are a few common VM86 traps that are easily handled (a few lines
of code each) in the kernel trap handler, so they're done in the linux
kernel.  I can easily pull this code out into the dosemu user space (and
play games with setjmp()/longjmp() to simulate the linux vm86 syscall),
but it's certainly more efficient and probably easier to implement
kernel handling of those few traps.

For both issues, there's the question of derivative works vs. GPL.  For
the bitmap stuff, I'm certain I can write equivalent code without
looking at the linux kernel.  For the kernel assist, the code in
question is fairly straightforward but I would need to look at the linux
code (and tread lightly).

And then there's the linux emulation mode stuff to consider--do we want
to support the linux vm86 syscall interface?  If so, then the
implementation choices of user vs. kernel code is forced.  We _could_
easily share the code and make it available for a NetBSD vm86 interface,
but _should_ we use the interface as it stands?

Comments, suggestions, etc?

==John