qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: Li Qiang <liq3ea@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Qemu Developers <qemu-devel@nongnu.org>
Subject: Re: Questions about the real mode in kvm/qemu
Date: Thu, 26 Sep 2019 11:59:15 +0300	[thread overview]
Message-ID: <3d3f3a0e6e796260348c66e69e859e1901501ee8.camel@redhat.com> (raw)
In-Reply-To: <CAKXe6SK+cEytTtgKHw8KXY=jY4xv=27GBu55hTbTmbRyTPsfxg@mail.gmail.com>

On Thu, 2019-09-26 at 16:52 +0800, Li Qiang wrote:
> 
> 
> Maxim Levitsky <mlevitsk@redhat.com> 于2019年9月26日周四 下午4:31写道:
> > On Thu, 2019-09-26 at 15:52 +0800, Li Qiang wrote:
> > > Hi Paolo and all,
> > > 
> > > There are some question about the emulation for real mode in kvm/qemu. For all the 
> > > question I suppose the 'unstrict guest' is not enabled. 
> > > 
> > > 1. how the protected mode CPU emulate the real mode? It seems it uses vm86, however, vm86 is not available in x86_64 CPU? So what's the 'to_vmx(vcpu)->rmode.vm86_active' here vm86 means?
> > > 
> > 
> 
> Hi Maxim,
> 
> Thanks for your kind reply.
> 
>  
> > As far as I know it, modern intel's cpus support so called unrestricted guest mode, which allows guest to be basically in any mode,
> 
> Right, but I also want to know the secret when the 'unstrict guest' is disabled. So I suppose the 'unstrict guest' is  not enabled for these questions.
>  
> > as long as EPT paging is used (that is guest can be in real mode with
> > no paging, but EPT has to be enabled).
> > The 'vm86_active' is probably lefover support for cpus that don't support EPT and/or the unrestricted guest mode,
> > where KVM tried to use the good old vm86 mode to
> > for real mode virtualization.
> > 
> > 
> > > 2. Does the guest's real mode code run directly in native CPU? It seems 'vmx->emulation_required' is also be false, it the vmx_vcpu_run will do a switch to guest.
> > 
> > Same as above
> > 
> > > 
> > > 3. How the EPT work in guest real mode? The EPT is for GVA->GPA->HPA, however there is no GVA, seems the identity mapping does something. But there also some confusion for me. For example the
> > real
> > > mode uses CS*4 + IP to address the code.  Who does this calculation? In the kernel emulator? 
> > 
> > EPT sits underneath the guest's paging mode, which in case of real mode is 1:1 mapping.
> 
> It seems when the 'unstrict guest' is enabled, there is no identity mapping table.

If you mean to ask if there is a way to let guest access use no paging at all, that is access host physical addresses directly,
then indeed there is no way, since regular non 'unrestricted guest' mode required both protected mode and paging, and 'unrestricted guest' requires
EPT.
Academically speaking it is of course possible to create paging tables that are 1:1...


Best regards,
	Maxim Levitsky



  reply	other threads:[~2019-09-26  9:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-26  7:52 Questions about the real mode in kvm/qemu Li Qiang
2019-09-26  8:31 ` Maxim Levitsky
2019-09-26  8:52   ` Li Qiang
2019-09-26  8:59     ` Maxim Levitsky [this message]
2019-09-26  9:18       ` Paolo Bonzini
2019-09-26  9:24         ` Maxim Levitsky
2019-09-26  9:33           ` Paolo Bonzini
2019-09-26  9:41             ` Maxim Levitsky
2019-09-26 10:00               ` Paolo Bonzini
2019-09-26 10:03                 ` Maxim Levitsky
2019-09-28 22:10         ` Avi Kivity
2019-09-29  7:39         ` Li Qiang
2019-09-26  9:15 ` Paolo Bonzini
2019-09-26  9:35   ` Maxim Levitsky
2019-09-26  9:35   ` Li Qiang
2019-09-26  9:53     ` Paolo Bonzini
2019-09-26 11:47       ` Li Qiang

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=3d3f3a0e6e796260348c66e69e859e1901501ee8.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).