From: Paolo Bonzini Subject: Re: [PATCH 7/8] kvm: nVMX: Introduce KVM_CAP_VMX_STATE Date: Wed, 15 Feb 2017 17:14:10 +0100 Message-ID: References: <1480536229-11754-1-git-send-email-jmattson@google.com> <1480536229-11754-8-git-send-email-jmattson@google.com> <555d6a5a-fd6d-e1c2-6a40-3ecfbb09b379@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, David Hildenbrand To: Jim Mattson Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34800 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751555AbdBOQOJ (ORCPT ); Wed, 15 Feb 2017 11:14:09 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 15/02/2017 17:06, Jim Mattson wrote: > The VMCS cache can be safely flushed to guest memory at any time. > However, I think your proposal has some unfortunate consequences: > > 1. If KVM_SET_NESTED_STATE is asynchronous, then any subsequent set > operations (e.g. KVM_SET_SREGS) may be overridden on the next KVM_RUN. > 2. Guest memory (at least the cached VMCS page(s)) has to be saved > after KVM_GET_NESTED_STATE. > 3. KVM_GET_NESTED_STATE is not transparent to the guest. I can't choose which is the worst of the three. :) A better one perhaps is to flush the VMCS cache on L2->userspace exit, since that should be pretty rare (suggested by David). I think that would help at least with (2) and (3). As to (1), after KVM_SET_NESTED_STATE sets the in-guest-mode flag you don't really need to reload all of the vmcs12 into vmcs02. Only the host state needs to be reloaded, while the guest state is set with KVM_SET_SREGS and others. Paolo