Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3491374imu; Sun, 11 Nov 2018 16:18:13 -0800 (PST) X-Google-Smtp-Source: AJdET5f8ElCu2QP3va5wyCZdHjhXiJNL/lNhdnKQHdFP7JStgT+bUBKkI1BARYgksN16TIlXIQl9 X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr15801878pgk.427.1541981893057; Sun, 11 Nov 2018 16:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981893; cv=none; d=google.com; s=arc-20160816; b=bPxtaEoLHVfeNcv1lR3ipl4Ab8SP4BKrlPwNqiYmxywx+Lc4PF4aDhl+9c/tu2ENHW ZGCtLDjDlcMTrw5GiISFLY+7FRM7PAtYQGFPHW5oHwHsqgm7SalmEjUEPACLT+O/nRwq 2e7PXERaAzGFxN17u8/cAivzY/TQRHHrM7IdVwqW5Wi8zygrexfqX184UDYeL/CwJuV4 9X/FGuqy3FMNCcBVQ0UbzqQD7Lx5UBP25cJBmcweqtIaWrAZBb7OB7QUHygF/KdWiODg tZPpRkE59g+ljA13GpNMe8w2xBIZXcmwmOA/tLNPR8PzCMBZ3bAjL4wHI4MDKESs3w0R nF/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Hsj1KgKgR7VUXY+7LhdKcwIcoviFUHhBcGAlwk3Vio=; b=nqRyN6ghGtgsYeRWgeD1XawaVqEyfY662Q1YCxF7MSXhU1IJLj7Kqml+ykZqNVg3wL uJMkF8HfJa35hx1Y4auM3mKpoU8WQYrKUTxYS3MMVoBNAqyTxrctUcE84ZwATd/qQB2i VIss/jAE1MhbBccw+warwz67t7oJMdrw96V5mnDd6rDoyAFhzUlWxfkYlIPx2FyvGuFV R9rXw88MN2zqmQCzsEV/Xp/m8bJr6vGNeqABxCLBJC7h9y+vQEadU0eoHp3OqZcW2/c9 G3zpmaCOEHlLQEKNVSes2hA01UW1bDDkkYUVqT+N1JpsfsyuuiaI4a4GN8viUXGluhRv IwKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JS6ZU7bR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cd11-v6si17997816plb.59.2018.11.11.16.17.57; Sun, 11 Nov 2018 16:18:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=JS6ZU7bR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbeKLIRG (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:58420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730069AbeKLIRC (ORCPT ); Mon, 12 Nov 2018 03:17:02 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BAD61216FD; Sun, 11 Nov 2018 22:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975226; bh=9Lv6k26O8hNOwoaA/btY/FNGrcrSoU9S42Ah4/dWm1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JS6ZU7bRVRVHgUOyfDZWa4EDrOfBEqXHFohvMNMpJEigmEDMkmnu1FDjleSRTp3k+ sXyFHffy6vIl/qDyynQ+G+ZYcW6yZ7t8UOXTAQ4l5Du8c66+9Q7Jc74bOfnQP/2MXP 8ujX/FBkuNS3/9b1Xjfl86cY+FiY38opscGwFmt4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Paolo Bonzini Subject: [PATCH 4.19 044/361] x86/kvm/nVMX: allow bare VMXON state migration Date: Sun, 11 Nov 2018 14:16:31 -0800 Message-Id: <20181111221626.079501205@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vitaly Kuznetsov commit a1b0c1c64dfef0cff8555bb708bfc5d7c66c6ca4 upstream. It is perfectly valid for a guest to do VMXON and not do VMPTRLD. This state needs to be preserved on migration. Cc: stable@vger.kernel.org Fixes: 8fcc4b5923af5de58b80b53a069453b135693304 Signed-off-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -14010,13 +14010,6 @@ static int vmx_set_nested_state(struct k 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; @@ -14046,6 +14039,14 @@ static int vmx_set_nested_state(struct k if (ret) return ret; + /* Empty 'VMXON' state is permitted */ + if (kvm_state->size < sizeof(kvm_state) + sizeof(*vmcs12)) + return 0; + + if (kvm_state->vmx.vmcs_pa == kvm_state->vmx.vmxon_pa || + !page_address_valid(vcpu, kvm_state->vmx.vmcs_pa)) + return -EINVAL; + set_current_vmptr(vmx, kvm_state->vmx.vmcs_pa); if (kvm_state->vmx.smm.flags & KVM_STATE_NESTED_SMM_VMXON) {