From: Gleb Natapov <gleb@redhat.com>
To: Abel Gordon <ABELG@il.ibm.com>
Cc: dongxiao.xu@intel.com, jun.nakajima@intel.com,
kvm@vger.kernel.org, "Nadav Har'El" <nyh@math.technion.ac.il>,
owasserm@redhat.com
Subject: Re: [PATCH 10/11] KVM: nVMX: Synchronize VMCS12 content with the shadow vmcs
Date: Thu, 11 Apr 2013 09:54:11 +0300 [thread overview]
Message-ID: <20130411065411.GO17919@redhat.com> (raw)
In-Reply-To: <OF815EEDA1.6DF4C5C6-ONC2257B49.0031AC1A-C2257B49.0069CCD6@il.ibm.com>
On Wed, Apr 10, 2013 at 10:15:37PM +0300, Abel Gordon wrote:
>
>
> Gleb Natapov <gleb@redhat.com> wrote on 09/04/2013 04:14:35 PM:
>
> > On Mon, Mar 11, 2013 at 09:54:47AM +0200, Abel Gordon wrote:
> > > "Nadav Har'El" <nyh@math.technion.ac.il> wrote on 11/03/2013 12:43:35
> AM:
> > >
> > >
> > > > On Sun, Mar 10, 2013, Abel Gordon wrote about "[PATCH 10/11] KVM:
> > > > nVMX: Synchronize VMCS12 content with the shadow vmcs":
> > > > > nested_vmx_vmexit(vcpu);
> > > > > + if (enable_shadow_vmcs)
> > > > > + copy_vmcs12_to_shadow(to_vmx(vcpu));
> > > >
> > > > I was curious why your patch adds this call to copy_vmcs12_to_shadow
> > > after
> > > > every nested_vmx_vmexit (3 times), instead of making this call inside
> > > > nested_vmx_vmexit(), say right after prepare_vmcs12(). Until I saw:
> > >
>
> > > Because nested code sometimes modifies vmcs fileds "after"
> > > nested_vmx_vmexit (see below). I was afraid nested logic
> > > may be changed in the future and some field may become out-of-sync.
> > >
> > > If we do have to call copy_vmcs12_to_shadow explicitly, then, it will
> be
> > > more difficult to miss some field.
> > >
>
>
> > I think the patch already miss some fields. What if nested_vmx_run()
> > fails and calls nested_vmx_entry_failure(). nested_vmx_entry_failure()
> > sets vmcs12->vm_exit_reason and vmcs12->exit_qualification, but where do
> > we copy them back to shadow before going back to L1?
>
> Good catch! :)
>
> Note that the entry path is easy to handle because we copy the fields
> as part of nested_vmx_entry. This is not like exit path where
> KVM(L0) code can modify fields after nested_vmx_vmexit is called.
>
> So here, we could simple call copy_vmcs12_to_shadow if the entry fails
> (as part of nested_vmx_entry_failure or nested_vmx). We could optimize
> the code by updating these specific fields directly, but I don't think
> we really need to optimize code that is part of the error path.
>
We needn't.
> > May be we need to introduce vmcs12 accessors to track what is changes
> > and if something need to be copied to shadow before going back to L1.
>
> That means we will need to modify all the lines of code that uses
> "vmcs12->" with an inline nested_vmcs_read or nested_vmcs_write function.
> Inside these inline functions we could access the shadow vmcs directly.
> However, to access the shadow vmcs we need to vmptrld first and this will
> force
> unnecessary vmptrlds (between shadow vmcs 12 and current vmcs 01) each time
> the code accesses a vmcs12 field. Alternatively, if we want to avoid
> unnecessary vmptrlds each time we access vmcs12 we could simple set a
> flag that indicates when a shadow field was changed. In this case, we will
> need to find all the places to check the flag and copy the fields,
> considering both success and error paths.
That's not how I see it. nested_vmcs_write() will set a request bit in
vcpu (this is the flag you mention above). The bit will be checked during
a guest entry and vmcs12 will be synced to shadow at this point. Later
we can track what fields were written and sync only them.
> Finally, I am afraid that these directions will introduce new issues,
> will force us to modify too many lines and they may create a merge/rebase
> mess...
Conflicts should be trivial and I do not expect many iterations for the
patch series. I like the approach you take to use vmcs shadowing and most
comment are nitpicks. I promise to review the next version as soon as
it is posted :)
>
> Maybe we should simple fix nested_vmx_entry_failure (as well as the
> other fixes you suggested in other patches) and apply the code.
> Do you agree ?
>
The approach is error prone. Even if we will fix all bugs in the current
code each new nested vmx modification will have to be reviewed with shadowing
in mind and sometimes it is hard to see global picture just from a
patch. It is better to hide shadow details from occasional nested vmx hacker.
Are you expecting EPT patches to make it right for instance?
--
Gleb.
next prev parent reply other threads:[~2013-04-11 6:54 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-10 16:03 [PATCH 0/11] KVM: nVMX: shadow VMCS support, v1 Abel Gordon
2013-03-10 16:03 ` [PATCH 01/11] KVM: nVMX: Stats counters for nVMX Abel Gordon
2013-04-08 10:27 ` Gleb Natapov
2013-04-10 19:08 ` Abel Gordon
2013-04-11 6:10 ` Gleb Natapov
2013-03-10 16:04 ` [PATCH 02/11] KVM: nVMX: Shadow-vmcs control fields/bits Abel Gordon
2013-03-10 16:04 ` [PATCH 03/11] KVM: nVMX: Detect shadow-vmcs capability Abel Gordon
2013-04-08 11:12 ` Gleb Natapov
2013-04-10 19:14 ` Abel Gordon
2013-03-10 16:05 ` [PATCH 04/11] KVM: nVMX: Introduce vmread and vmwrite bitmaps Abel Gordon
2013-04-08 11:50 ` Gleb Natapov
2013-04-10 19:14 ` Abel Gordon
2013-03-10 16:05 ` [PATCH 05/11] KVM: nVMX: Refactor handle_vmwrite Abel Gordon
2013-04-09 11:05 ` Gleb Natapov
2013-04-10 20:35 ` Abel Gordon
2013-03-10 16:06 ` [PATCH 06/11] KVM: nVMX: Allocate shadow vmcs Abel Gordon
2013-03-10 16:06 ` [PATCH 07/11] KVM: nVMX: Release " Abel Gordon
2013-03-10 16:07 ` [PATCH 08/11] KVM: nVMX: Copy processor-specific shadow-vmcs to VMCS12 Abel Gordon
2013-03-10 16:07 ` [PATCH 09/11] KVM: nVMX: Copy VMCS12 to processor-specific shadow vmcs Abel Gordon
2013-04-09 12:47 ` Gleb Natapov
2013-04-10 19:15 ` Abel Gordon
2013-03-10 16:08 ` [PATCH 10/11] KVM: nVMX: Synchronize VMCS12 content with the " Abel Gordon
2013-03-10 22:43 ` Nadav Har'El
2013-03-11 7:54 ` Abel Gordon
2013-04-09 13:14 ` Gleb Natapov
2013-04-10 19:15 ` Abel Gordon
2013-04-11 6:54 ` Gleb Natapov [this message]
2013-04-12 10:26 ` Abel Gordon
2013-04-12 10:31 ` Gleb Natapov
2013-04-12 10:44 ` Abel Gordon
2013-04-12 10:48 ` Gleb Natapov
2013-04-14 9:51 ` Abel Gordon
2013-04-14 10:00 ` Gleb Natapov
2013-04-14 10:07 ` Gleb Natapov
2013-04-14 10:27 ` Jan Kiszka
2013-04-14 10:34 ` Abel Gordon
2013-04-14 10:34 ` Gleb Natapov
2013-04-14 10:49 ` Abel Gordon
2013-04-14 11:16 ` Gleb Natapov
2013-04-14 13:47 ` Abel Gordon
2013-04-14 14:41 ` Gleb Natapov
2013-03-10 16:08 ` [PATCH 11/11] KVM: nVMX: Enable and disable shadow vmcs functionality Abel Gordon
2013-03-21 12:22 ` [PATCH 0/11] KVM: nVMX: shadow VMCS support, v1 Orit Wasserman
2013-03-21 13:56 ` Abel Gordon
-- strict thread matches above, loose matches on Subject: below --
2013-04-18 8:34 [PATCH 0/11] KVM: nVMX: shadow VMCS support, v4 Abel Gordon
2013-04-18 8:39 ` [PATCH 10/11] KVM: nVMX: Synchronize VMCS12 content with the shadow vmcs Abel Gordon
2013-04-18 11:34 [PATCH 0/11] KVM: nVMX: shadow VMCS support, v5 Abel Gordon
2013-04-18 11:39 ` [PATCH 10/11] KVM: nVMX: Synchronize VMCS12 content with the shadow vmcs Abel Gordon
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=20130411065411.GO17919@redhat.com \
--to=gleb@redhat.com \
--cc=ABELG@il.ibm.com \
--cc=dongxiao.xu@intel.com \
--cc=jun.nakajima@intel.com \
--cc=kvm@vger.kernel.org \
--cc=nyh@math.technion.ac.il \
--cc=owasserm@redhat.com \
/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).