Subject: Emulation pointer wanted
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 09/14/1999 17:29:16
I was pondering some of the "build lab" problems, and it occurred to me
that while cross-compiling is nice, it would be nicer to run native
compilers for the slow ports (such as sun3 and vax).  But of course
you'd really like to run them on fast hardware.

I was thinking of doing this as an emulation package in the kernel,
having the kernel load the emulator executable somewhere "out of the
way" (as if by an address-unspecified mmap) and then turn control over
to it after loading the executable itself "normally".  Then you could
use, say, the VAX native toolchain, building VAX native executables,
but running on some killer Alpha or something, far faster than a real
VAX.  Of course, the emulation wouldn't be perfect; any kmem groveler,
for example, is instant toast.  But it should be fairly straightforward
to make it good enough to run the toolchain.

This shouldn't be hard to do.  I believe I could build, say, a VAX
emulator to run on a SPARC (I pick those simply because they are the
two architectures I know best).  As I see it, there are three issues:

(a) Emulating the instructions
(b) Emulating failure modes
(c) Emulating syscalls
(d) Getting it started

What I'm writing here to ask about is some questions with (d) (and
secondarily (b) and (c), but those I believe I can handle on my own).

I believe I can deal with (a), at least for a couple of cases (like
SPARC emulating m68k or VAX).  (b) is harder, but less important; I'd
*like* a segfault to appear to come from the faulting instruction, but
could live with it appearing in the emulator executable.  (c) is a bit
of an issue; the emulator would have to recognize syscall traps (CHMK
for the VAX, for example) and swizzle the argument list into something
native before doing a *real* syscall trap.  This too I believe is
workable, at least for enough syscalls to make it useful.  (d) is the
major problem I'd have: I don't know enough about exec packages and
emulations to have much hope of getting it working.  Is there any
documentation lying around, or someone who's willing to point me in the
correct direction?  For example, do I want to create an new emulation
(in the sense of "struct emul") or do I want to add code to an existing

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B