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