public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Guillaume Thouvenin
	<guillaume.thouvenin-Z51IpKcfGtLk1uMJSBkQmQ@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [ToDo] Real Mode Support
Date: Wed, 06 Feb 2008 11:32:17 -0600	[thread overview]
Message-ID: <47A9EF21.3050103@us.ibm.com> (raw)
In-Reply-To: <20080206083326.43005755@frecb000711>

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.

Regards,

Anthony Liguori

>   My question is why the execution loop needs to be changed here. I mean
> isn't it possible to just extend x86 emulator to support more
> instructions in real mode? I think that I'm missing something here so
> any help, hint, advice, link are welcome. 
>
> Best Regards,
>
>   


-------------------------------------------------------------------------
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/

  parent reply	other threads:[~2008-02-06 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06  7:33 [ToDo] Real Mode Support Guillaume Thouvenin
2008-02-06  8:52 ` Izik Eidus
     [not found]   ` <1202287974.23342.8.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-02-06 12:07     ` Guillaume Thouvenin
2008-02-06 12:52       ` Izik Eidus
2008-02-06 23:52       ` Kamble, Nitin A
2008-02-07 18:36         ` Alexey Eremenko
2008-02-06 17:32 ` Anthony Liguori [this message]
     [not found]   ` <47A9EF21.3050103-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-02-06 17:47     ` Izik Eidus
2008-02-10 11:44   ` Avi Kivity
2008-02-11 13:39     ` Guillaume Thouvenin
2008-02-11 14:20       ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47A9EF21.3050103@us.ibm.com \
    --to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=guillaume.thouvenin-Z51IpKcfGtLk1uMJSBkQmQ@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox