Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3924329pxb; Mon, 21 Feb 2022 08:24:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtabXgwJObVPllQP2KkNaNPhkaonI4Exlw9CnF+jbXnnNxwOIbSpsf4j6LtuF7SIXtA6b6 X-Received: by 2002:aa7:ca04:0:b0:410:92a6:1a9e with SMTP id y4-20020aa7ca04000000b0041092a61a9emr22003297eds.411.1645460684923; Mon, 21 Feb 2022 08:24:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645460684; cv=none; d=google.com; s=arc-20160816; b=YtpbzQXNPrFlPgxFvE1akif2NUcQjDrYOzUo561hfvx7jeNA0sdRdA1I9xa4F16/ma 2iikLYtVgBjAhZK8ZSFKfQ+2QhbWYBJy/lPyXXM5uFfhL12iFY3Ew5dBWJog4BJo8lLW mVua8OyQlqvzRd50PIG1xEXjlwHX/WoPyPe27cOkMdczboS7BuIEng6+RzYuU32M5C/i YLm23HkZPNHkydT6j02tQlm6SSKXNMrGtjKKSovGQ+Ib7rPsCEkaQhJ0nBlb3FwW3XD+ 71XMh+0aPkqfHnmZSmSly/j/UbuNI5iih53AZYIjhRQyUFzyGAGixGjGggLmgBRi1QWh V1PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KqEDEFGlLy8UoPoOvCw/xxendWQDgfQ9mw625fodktc=; b=swzOfyyuyvoQL6aBIdrpycQdgqjgFxvl9vsTRIUlvCGtWrF7596zx3Dn7qRo2TWDNG K/yaL2i0FjEL3zcIcx2zZI22UiUStp5DhhbkO9MqZqvk4pMjkcxm0TP8tIs3EKUuxC0h VmAUovqP+cmcfUrtjo5Xu200besP5vq/adhlAhj1p/J+MOWsSFupFjC62iPz+hA+bMCi 6CRVbl59GRJfc3TNC7x/81O9s2edDp4ZPjphXfXaxgCkpKXkpmae4BNX1cDP4Qnfb6h/ eDwNhaEkrjjZabexgD95pWcKy1bjZ9MNU6xVNDlsJNakKH7qOYQajUrNIlhaD37g7Ys0 5OfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1NJxE6LU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20si10117436ejj.242.2022.02.21.08.24.21; Mon, 21 Feb 2022 08:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1NJxE6LU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351616AbiBUJwJ (ORCPT + 99 others); Mon, 21 Feb 2022 04:52:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352410AbiBUJr0 (ORCPT ); Mon, 21 Feb 2022 04:47:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF690427D2; Mon, 21 Feb 2022 01:19:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A87C608C4; Mon, 21 Feb 2022 09:19:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 663F3C340EB; Mon, 21 Feb 2022 09:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645435182; bh=462r+ZZ80+PfE84UjUTijACRhL9ctfgmXieMZgUM4ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1NJxE6LUTjM5OLQ+DGpuHeGw8z41CgOzO+uoCFvb5mKloiGF3VqSh/Qo+esA0d+96 RNHAJXYChxQew2MIWoU/iMmPQCtL3f3n9+MfzdTOyL2XCY8Wpoqs/Tc7u0VoKswZyG FatL1YW5VebgZhFyDOVuzrUhYawGLqzMEZ1evBfI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Levitsky , Paolo Bonzini Subject: [PATCH 5.16 072/227] KVM: x86: nSVM/nVMX: set nested_run_pending on VM entry which is a result of RSM Date: Mon, 21 Feb 2022 09:48:11 +0100 Message-Id: <20220221084937.267584356@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084934.836145070@linuxfoundation.org> References: <20220221084934.836145070@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Levitsky commit 759cbd59674a6c0aec616a3f4f0740ebd3f5fbef upstream. While RSM induced VM entries are not full VM entries, they still need to be followed by actual VM entry to complete it, unlike setting the nested state. This patch fixes boot of hyperv and SMM enabled windows VM running nested on KVM, which fail due to this issue combined with lack of dirty bit setting. Signed-off-by: Maxim Levitsky Cc: stable@vger.kernel.org Message-Id: <20220207155447.840194-5-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/svm.c | 5 +++++ arch/x86/kvm/vmx/vmx.c | 1 + 2 files changed, 6 insertions(+) --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4445,6 +4445,11 @@ static int svm_leave_smm(struct kvm_vcpu nested_load_control_from_vmcb12(svm, &vmcb12->control); ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, false); + if (ret) + goto unmap_save; + + svm->nested.nested_run_pending = 1; + unmap_save: kvm_vcpu_unmap(vcpu, &map_save, true); unmap_map: --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7534,6 +7534,7 @@ static int vmx_leave_smm(struct kvm_vcpu if (ret) return ret; + vmx->nested.nested_run_pending = 1; vmx->nested.smm.guest_mode = false; } return 0;