Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1443245

Re: [PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS

From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS
Date 2016-07-14 10:40 +0200
Message-ID <rUKlB-7jX-67@gated-at.bofh.it> (permalink)
References <rUCxH-20Y-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



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

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS David Matlack <dmatlack@google.com> - 2016-07-14 02:20 +0200
  Re: [PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS Paolo Bonzini <pbonzini@redhat.com> - 2016-07-14 10:40 +0200
    Re: [PATCH] kvm: x86: nVMX: maintain internal copy of current VMCS David Matlack <dmatlack@google.com> - 2016-07-15 20:00 +0200

csiph-web