public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>,
	"Nadav Har'El" <nyh@math.technion.ac.il>,
	"Nakajima, Jun" <jun.nakajima@intel.com>
Subject: Re: [PATCH] KVM: nVMX: Fix setting of CR0 and CR4 in guest mode
Date: Mon, 4 Mar 2013 23:00:35 +0200	[thread overview]
Message-ID: <20130304210035.GJ14220@redhat.com> (raw)
In-Reply-To: <513505FD.8000509@web.de>

On Mon, Mar 04, 2013 at 09:37:17PM +0100, Jan Kiszka wrote:
> On 2013-03-04 21:24, Gleb Natapov wrote:
> >>> That doesn't make sense to me. I do not even sure what you are saying
> >>> since you do not specify what shadow is matched. From the code I see
> >>> that on CR0 exit to L0 from L2 we check if L2 tries to change CR0 bits
> >>> that L1 claims to belong to it and do #vmexit to L1 if it is:
> >>>
> >>>    if (vmcs12->cr0_guest_host_mask & (val ^ vmcs12->cr0_read_shadow))
> >>>             return 1;
> >>>
> >>> We never reach handle_set_cr0() in that case.
> >>>
> >>> Can you provide an example with actual values for L2/L1/L0 of what you
> >>> are trying to say?
> >>
> >> I already provided a concrete one: L1 clears PE/PG from its
> >> guest_host_mask (assuming we support unrestricted guest mode for L1), L2
> >> switches from real to protected mode, thus sets PE=1 while the shadow
> >> (set by L0) holds 0 => we end up in handle_set_cr0.
> >>
> > So how is this "inverse of what the comment suggest"? I do not
> > understand your grudge against the comment. Just clarify that TS is the
> > one example of how we can get here if you think that it is not clear enough.
> > The TS part was useful to me.
> 
> Hmm, if the comment was helpful, why did you have to ask me what was
> wrong? :)
> 
Comment helped me understand what's the case that should be handled
here. I didn't asked you what was wrong, Nadav did, but that's because
I haven't wrapped my mind around this code yet. I will ask it later :)

> If you insist on clarification, let's try it again:
> 
> "We get here when L2 changed cr0 in a way that did not change
> any of L1's shadowed bits (see nested_vmx_exit_handled_cr),
> but did change L0 shadowed bits. KVM only hands over TS to L1,
> and that only if the FPU is enabled. So we will be called for
> every change that L1 allows L2 to perform natively."

I find this much more confusing that original comment. Actually
re-reading the original one I do not think it's about KVM as L2 either.
What bout:

     We get here when L2 changed cr0 in a way that did not change
     any of L1's shadowed bits (see nested_vmx_exit_handled_cr),
     but did change L0 shadowed bits. This may happen with
     the TS bit: L0 may want to leave TS on (for lazy fpu loading)
     while pretending to allow the guest to change it.

So in your case it may happen to PE, but TS is only an example anyway.

> 
> For me, ignoring TS made things clearer and simpler.
> 
Because you had other example to work with.

--
			Gleb.

  reply	other threads:[~2013-03-04 21:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-28  9:44 [PATCH] KVM: nVMX: Fix setting of CR0 and CR4 in guest mode Jan Kiszka
2013-03-04 13:22 ` Gleb Natapov
2013-03-04 14:09   ` Jan Kiszka
2013-03-04 14:15     ` Gleb Natapov
2013-03-04 14:25       ` Jan Kiszka
2013-03-04 15:30         ` Nadav Har'El
2013-03-04 16:01           ` Jan Kiszka
2013-03-04 17:56         ` Gleb Natapov
2013-03-04 18:08           ` Jan Kiszka
2013-03-04 18:39             ` Gleb Natapov
2013-03-04 19:23               ` Jan Kiszka
2013-03-04 19:33                 ` Gleb Natapov
2013-03-04 19:37                   ` Jan Kiszka
2013-03-04 20:00                     ` Gleb Natapov
2013-03-04 20:12                       ` Jan Kiszka
2013-03-04 20:24                         ` Gleb Natapov
2013-03-04 20:37                           ` Jan Kiszka
2013-03-04 21:00                             ` Gleb Natapov [this message]
2013-03-04 21:09                               ` Jan Kiszka
2013-03-05  6:25                                 ` Gleb Natapov

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=20130304210035.GJ14220@redhat.com \
    --to=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=jun.nakajima@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=nyh@math.technion.ac.il \
    /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