From: David Hildenbrand Subject: Re: [PATCH 7/8] kvm: nVMX: Introduce KVM_CAP_VMX_STATE Date: Mon, 8 Jan 2018 22:46:26 +0100 Message-ID: References: <1480536229-11754-1-git-send-email-jmattson@google.com> <75bde61a-34ff-c0af-436e-c8328fe7e870@redhat.com> <67833a23-5dd4-c502-d724-fea5598c41df@redhat.com> <2301ab3e-c318-4494-4c1e-bd85e24ef78c@redhat.com> <4c348439-81f7-11e9-0e68-3e18df86f4c4@redhat.com> <4703cc37-ba01-d370-9b61-57d63f2a0b32@redhat.com> <113868cd-5a82-495b-8a0b-d17217c76fd5@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Paolo Bonzini , kvm list , David Hildenbrand To: Jim Mattson Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60246 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752942AbeAHVq2 (ORCPT ); Mon, 8 Jan 2018 16:46:28 -0500 In-Reply-To: Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: > The vmcs01 does serve as a cache of L1 state at the time of VM-entry, > so if we simply restored the vmcs01 state, that would take care of > most of the rollback issues, as long as we don't deliver any > interrupts in this context. However, I would like to see the > vmcs01/vmcs02 separation go away at some point. svm.c seems to do fine > with just once VMCB. Interesting point, might make things easier for VMX. > >> If the page >>> tables have changed, or the L1 guest has overwritten the >>> VMLAUNCH/VMRESUME instruction, then you're out of luck. >> >> Page tables getting changed by other CPUs is actually a good point. But >> I would consider both as "theoretical" problems. At least compared to >> the interrupt stuff, which could also happen on guests behaving in a >> more sane way. > > My preference is for solutions that are architecturally correct, > thereby solving the theoretical problems as well as the empirical > ones. However, I grant that the Linux community leans the other way in > general. I usually agree, unless it makes the code horribly complicated without any real benefit. (e.g. for corner cases like this one: a CPU modifying instruction text of another CPU which is currently executing them) >>> 3. I'm assuming that you're planning to store most of the current L2 >>> state in the cached VMCS12, at least where you can. Even so, the next >>> "VM-entry" can't perform any of the normal VM-entry actions that would >>> clobber the current L2 state that isn't in the cached VMCS12 (e.g. >>> processing the VM-entry MSR load list). So, you need to have a flag >>> indicating that this isn't a real VM-entry. That's no better than >>> carrying the nested_run_pending flag. >> >> Not sure if that would really be necessary (would have to look into the >> details first). But sounds like nested_run_pending seems unavoidable on >> x86. So I'd better get used to QEMU dealing with nested CPU state (which >> is somehow scary to me - an emulator getting involved in nested >> execution - what could go wrong :) ) > > For save/restore, QEMU doesn't actually have to know what the flag > means. It just has to pass it on. (Our userspace agent doesn't know > anything about the meaning of the flags in the kvm_vmx_state > structure.) I agree on save/restore. My comment was rather about involving a L0 emulator when running a L2 guest. But as Paolo pointed out, this can't really be avoided. -- Thanks, David / dhildenb