From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitaly Kuznetsov Subject: Re: [PATCH v5 09/12] x86/kvm/nVMX: allow bare VMXON state migration Date: Fri, 14 Sep 2018 09:49:32 +0200 Message-ID: <87o9d08qnn.fsf@vitty.brq.redhat.com> References: <20180913170522.24876-1-vkuznets@redhat.com> <20180913170522.24876-10-vkuznets@redhat.com> Mime-Version: 1.0 Content-Type: text/plain Cc: kvm list , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley \(EOSG\)" , Liran Alon , LKML To: Jim Mattson Return-path: In-Reply-To: (Jim Mattson's message of "Thu, 13 Sep 2018 12:21:13 -0700") Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Jim Mattson writes: > On Thu, Sep 13, 2018 at 10:05 AM, Vitaly Kuznetsov wrote: >> It is perfectly valid for a guest to do VMXON and not do VMPTRLD. This >> state needs to be preserved on migration. >> >> Signed-off-by: Vitaly Kuznetsov >> --- >> arch/x86/kvm/vmx.c | 15 ++++++++------- >> 1 file changed, 8 insertions(+), 7 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index d3297fadf7ed..25a25fff8dd9 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -14482,13 +14482,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, >> if (!page_address_valid(vcpu, kvm_state->vmx.vmxon_pa)) >> return -EINVAL; >> >> - if (kvm_state->size < sizeof(kvm_state) + sizeof(*vmcs12)) >> - return -EINVAL; >> - >> - if (kvm_state->vmx.vmcs_pa == kvm_state->vmx.vmxon_pa || >> - !page_address_valid(vcpu, kvm_state->vmx.vmcs_pa)) >> - return -EINVAL; >> - >> if ((kvm_state->vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) && >> (kvm_state->flags & KVM_STATE_NESTED_GUEST_MODE)) >> return -EINVAL; >> @@ -14510,6 +14503,14 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, >> if (ret) >> return ret; >> >> + /* Empty 'VMXON' state is permitted */ >> + if (kvm_state->size < sizeof(kvm_state) + sizeof(*vmcs12)) >> + return 0; > > In the original version of this code, the early exit is: > > if (kvm_state.vmcs_pa == -1ull) > return 0; Time to restore the status quo :-) In any case this early exit should be done after enter_vmx_operation() as even without a valid VMCS we need to preserve VMXON state (e.g. Linux with loaded KVM but without any guests running). -- Vitaly