On Wed, 2008-02-06 at 11:32 -0600, Anthony Liguori wrote:
> Guillaume Thouvenin wrote:
> > Hello,
> >
> >   I read on the kvmwiki/TODO that there is a work in progress for
> > extending x86 emulator to support more instructions in real mode and for
> > changing the execution loop to call the emulator for real mode. 
> >   
> 
> Yes, Nitin has done some work in this area.
> 
> >   As I'm interested to work on this part I'd like to know what was
> > already done.
> >
> >   I'd like to have more information about how the execution loop need to
> > be changed. Currently we enter/leave real mode through a call to 
> > enter_rmode()/enter_pmode(). The function sets a variable
> > "arch.rmode.active" and also sets the bit X86_EFLAGS_VM of
> > GUEST_RFLAGS. That means that we are using the VM mode to virtualize
> > the real mode. I know that in virtual mode some instructions can not be
> > used as they are in full real mode (that would have been too easy). So
> > these instructions generate a protection fault and need to be emulated.
> > So we handle this kind of exception in handle_exception() and we call
> > the x86 emulator. From the emulator we read the eflags
> > (kvm_x86_ops->get_rflags(vcpu)) and we can know if we are in real mode
> > or not. It's the current scheme, right?
> >   
> 
> Sort of.  Right now we put the guest into vm86 mode and use that to 
> execute real mode code.  There are a number of problems with using vm86 
> (some due to VT restrictions on vm86).  The biggest problem is Big Real 
> Mode.
> 
> In real mode, the x86 uses segmentation only.  Normally, the segment 
> limits are setup to be 0xffff and since the translation for segment mode 
> is 16-bit segment register * 16, you can address 2^20 work of address space.
> 
> However, if you switch to protected mode, you can setup the GDT to have 
> 4G segments.  If you then switch back to real mode, you can use 32-bit 
> address overrides to access the full 32-bit address space in 16-bit mode.
> 
> vm86 does not support this trick though.  To further complicate matters, 
> there are certain gotcha's when using vm86 with VT that are less easy to 
> detect.
> 
> So what we would like to do, is instead of setting up vm86 mode for the 
> guest to execute real mode, use x86_emulate() to just emulate the code.  
> This means that we wouldn't be using the "vmlaunch" instruction when in 
> real mode and instead would be doing an x86_emulate() loop.


and for the matter of fact there are not too many instructions that
needed to be emulated in oreder to make it work as that the vm86
instructions are very limited anyway
(15.1.3 in the intel manual list them)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to