James Mastros wrote:

> > Looks very promising! I've done some benchmarking as well:
> >
> > You cannot really just turn prescanning off for this kind of
> > code. Generating a page fault for each read/write in VGA memory is too
> > expensive as well. The fastest I know of is to emulate the CPU for a
> > while after a PF, what is what we're doing in dosemu: making it almost as
> > slow as Bochs for graphically intensive code.

Well, if you get real smart about it, you can mark instructions
in the cache with a bit denoting they hit Memory-Mapped IO space.
Then rather than transitioning back to user space to execute them
(which only will fault back to the monitor) just emulate them.
You could keep stats on a page or region basis, and decide to
emulate within that region.

There's some other general techniques that will help.  For example,
if you measure the time between an entry point (starting execution
of guest code) and subsequent exit points (faults to the monitor),
you could mark the original entry point accordingly.  If there
is a tendency to yield a short execution span (because of MemMapIO,
virtualized instructions somewhere in the code sequence, etc), then
the monitor could chose, in future iterations, to emulate until it
hits an instruction path with unknown or better execution span
characteristics.

There's lots of stuff like this I've got buzzing around in
my virtual brain.

Though, the best option, when available, is to use a special video
driver to exchange data with the host efficiently.  But it's
not always an option.  Using a direct VGA lib and mapping in
the frame buffer to the guest is nice too.

It's a long way (time-wise) to go from guest space to the user host component
of plex86.  There are also possibilities of moving parts of device emulation
into the monitor, for example the memory interface and latches from VGA.


> So we're going to need three modes: full-native, SBE, and full-emulated.  We
> can go full-native if the guest is in v86 or we're running in ring3 without
> hope of going out without hope of getting out without a fault.  We should go
> full-emulated when we're taking a lot of faults.  Otherwise, we want SBE mode.
> 
> Does this mean porting all of the emulation code from bochs or the dynamic
> translation stuff?

Well, plex86 already can run in pure emulation mode, though everything
occurs in monitor space as normal.  I just haven't made it a config option
at this point.  So we have the capabilities already, at least when I
finish the SBE-off code.

Though, I'm not going to spend my life worrying about how to
squeeze every drop out of code running with VGA emulation in
640x480x16 color mode.  That mode sucks, period.  Best to
use a special driver, emulate a better card, or memory map
in the real VGA card, and not get _any_ faults.

-Kevin



-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Kevin Lawton                        [EMAIL PROTECTED]
MandrakeSoft, Inc.                  Plex86 developer
http://www.linux-mandrake.com/      http://www.plex86.org/

Reply via email to