From: Paolo Bonzini <pbonzini@redhat.com>
To: David Matlack <dmatlack@google.com>, kvm@vger.kernel.org
Cc: jmattson@google.com, pfeiner@google.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS
Date: Thu, 14 Jul 2016 10:33:50 +0200 [thread overview]
Message-ID: <7f189511-4432-8208-28f0-701f1d05e91e@redhat.com> (raw)
In-Reply-To: <1468455397-22003-1-git-send-email-dmatlack@google.com>
On 14/07/2016 02:16, David Matlack wrote:
> KVM maintains L1's current VMCS in guest memory, at the guest physical
> page identified by the argument to VMPTRLD. This makes hairy
> time-of-check to time-of-use bugs possible,as VCPUs can be writing
> the the VMCS page in memory while KVM is emulating VMLAUNCH and
> VMRESUME.
>
> The spec documents that writing to the VMCS page while it is loaded is
> "undefined". Therefore it is reasonable to load the entire VMCS into
> an internal cache during VMPTRLD and ignore writes to the VMCS page
> -- the guest should be using VMREAD and VMWRITE to access the current
> VMCS.
>
> To adhere to the spec, KVM should flush the current VMCS during VMPTRLD,
> and the target VMCS during VMCLEAR (as given by the operand to VMCLEAR).
> Since this implementation of VMCS caching only maintains the the current
> VMCS, VMCLEAR will only do a flush if the operand to VMCLEAR is the
> current VMCS pointer.
>
> KVM will also flush during VMXOFF, which is not mandated by the spec,
> but also not in conflict with the spec.
>
> Signed-off-by: David Matlack <dmatlack@google.com>
This is a good change. There is another change that is possible on top:
with this change you don't need current_vmcs12/current_vmcs12_page at
all, I think. You can just use current_vmptr and kvm_read/write_guest
to write back the VMCS12, possibly the cached variants.
Of course this would just be a small simplification, so I'm applying the
patch as is to kvm/next.
Thanks,
Paolo
next prev parent reply other threads:[~2016-07-14 8:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 0:16 [PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS David Matlack
2016-07-14 8:33 ` Paolo Bonzini [this message]
2016-07-15 17:54 ` David Matlack
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=7f189511-4432-8208-28f0-701f1d05e91e@redhat.com \
--to=pbonzini@redhat.com \
--cc=dmatlack@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pfeiner@google.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).