Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp456477imm; Fri, 14 Sep 2018 00:49:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaIWdIrMiSRj/ZKF4T9qMFr8iiX7uj7aZoJKqVtxwwlo0jfAH3k/f14UqRq6ocCZmRKqPGL X-Received: by 2002:aa7:83cd:: with SMTP id j13-v6mr11060250pfn.236.1536911397479; Fri, 14 Sep 2018 00:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536911397; cv=none; d=google.com; s=arc-20160816; b=LILyRW9UNJeO/GSg+GqDR4yUUWzJCJ2b0uWiin5wm1op/4ObKgIrM0SK4x4dl3u+yI l7sMFBRC/TneUEnG4/p4ifkBR8Flp6A0iu5FJ4NKxB2jG1mCmqAhSdIq35YlF/o26ydB XNT+ajtxS9vZMZl6ueoX+OB7yrvTOmQfy4iFbxCeBn2T2H4Lh/EiJRFMb5DKFgujGCMf k4YxvvbO2cRyHX6e81EhH40xQD5VK8Wk/WAvCDbL2M/JJdSSG7hC+e2FVqIEahcwTGJ4 Sf09mtJutSZ5793+Q9sQ+u5/IlPfJNvZn2xybWOXlOJcUOFOmbSgP0oA6XWPnTqsBsjM 48Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=ec5J22QhnRtEOWjm/TH74M45zYZTKJ+R0Qf2NIcfNp4=; b=ed46H/aQhmgmDtLGRH1g9B/ajPRCemrKbVTBrEqF0gwhRuHjVNjWBX2KX7idcZKP2t lq6dtxlTYIUDQnzMD5vmqsDo2WUz9DFcplqOLHs1yAZAJVSnymz24YsREiFIxKLbs4Hc 1QxOGfeCiLWks1Cy8yhg8+Kcx6exjw67SPPjhMnEUD/mAUNAR3glQBf4VLwGwqT4GeAI vu0DvY0wZTYjTYxA7/5rzGXLLpWOPMYFCDt0T1edyqGDXCrIKHUYZ3bvocW7Vpp1ijk6 vnyPu6Bg5HIRw8QHaRctRSN9/0yo3cGxT7uZKAs1sv8+pxFr0t8HapRlCyYSwXbyLEIm f9wQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si6288405pgk.33.2018.09.14.00.49.42; Fri, 14 Sep 2018 00:49:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbeINNCu (ORCPT + 99 others); Fri, 14 Sep 2018 09:02:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727194AbeINNCu (ORCPT ); Fri, 14 Sep 2018 09:02:50 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1EB181DE3; Fri, 14 Sep 2018 07:49:35 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82ACA308BDA5; Fri, 14 Sep 2018 07:49:33 +0000 (UTC) From: Vitaly Kuznetsov To: Jim Mattson 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 Subject: Re: [PATCH v5 09/12] x86/kvm/nVMX: allow bare VMXON state migration References: <20180913170522.24876-1-vkuznets@redhat.com> <20180913170522.24876-10-vkuznets@redhat.com> Date: Fri, 14 Sep 2018 09:49:32 +0200 In-Reply-To: (Jim Mattson's message of "Thu, 13 Sep 2018 12:21:13 -0700") Message-ID: <87o9d08qnn.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 14 Sep 2018 07:49:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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