Hello,
I've added code to emulate a few instructions (lgdt/lidt/lldt/ldt/int/iret).
Note that this is just a first try, them semantics of these instructions
is not yet completely implemented (especially error conditions).
Furthermore, I'm using a somewhat ugly hack to force 'iret' to always trap
to the monitor: I'm running the guest with the NT flag always set, while
the TSS back link is zero. This causes 'iret' to trap with exception 10.
It is necessary to have 'iret' trap, because guest code running in 'ring-0'
will in reality run in ring-3, and hence on return from guest ring-0 to
guest ring-3 code, the processor would perform an *intra*-privilege-level
iret, and not switch stacks, although the guest code expects it to ...
The hack of course works only as long as the guest doesn't reset the NT
flag, as we can't protect against 'popf' currently. A real fix will
probably not be possible without implementing real pre-scanning and
trapping the 'iret' via scanning.
In any case, with the hack in place, the 'cooperative' guest code runs
completely without aborting. Of course, you don't see anything, as the
VGA emulation is not yet available ;-)
As a side note, after emulating 'lgdt', the code now actually re-maps
the monitor at new selectors (the old ones might be in use in the new
table) ...
Bye,
Ulrich
--
Ulrich Weigand,
IMMD 1, Universitaet Erlangen-Nuernberg,
Martensstr. 3, D-91058 Erlangen, Phone: +49 9131 85-7688