Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1629760rwi; Thu, 3 Nov 2022 07:26:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4i/0QfeNQnObmu3KSkK9CR2idGWcBcRHhm0hGNMuMf/7OpD2d74v7SOuJCEjYxqOmaD5AZ X-Received: by 2002:a17:907:7da5:b0:78e:2c3b:55a2 with SMTP id oz37-20020a1709077da500b0078e2c3b55a2mr29172730ejc.96.1667485563614; Thu, 03 Nov 2022 07:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667485563; cv=none; d=google.com; s=arc-20160816; b=aJobrt8fNCuEXAeHfo+atRmoEdtowEx6Sumfr7Yo2s2DfUkPs7a56PhIavgFT/KYnW V98zbMnFe3IARO5oJD2+PoQt/1xBwJERDjXKxRPCvR5OaPl5eFVW3yVD3WldizCtgmVW bBjou7CmoVthQpnseC7ygJwflJL4n6qhYIZg1sva6vKPQYjPlwiGRZHtBTgxK0j43Xi2 OJNG8Xp8PioY7FlBFU/gOCQfoYvNMPBOyFZBJ1Z2iGu/IpYR7B76JkWd86Q3+iFarvp8 V+s95574XgcOzTYvzU2GuJzxcF1YruOuIaM4Z55PLqS/D3f5OcIAo9scMPt+qhTi9HhF MZRQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MNLPTKjKZGsyp4iQjia1o+n+MQq5Qzv7rr6Sw6M18Rc=; b=GJlrJrfqhUsh70gVC7KwZrNYSa/5Eelt/Bk8UMgbkp2tejduVIGm5RhQ+vfK2XxYH8 7mxPO7IIHAV2JpAxn0z6XIHNkOk+oZA/N4JaJEkv72ebRusypzGBARvyPixeMsgB4xbs SSWQYeDayCNHjTd1XjJRo6bxYqIfciP3vq37qX4QKM7iJCEXucBHeO19BmcGJt9WuSt5 0ipJICauJQjTvFsvvC9U9tp+fOTvwA3eo8vUKK/xrS06NmunOmVkll48KkUqNiA4h9+s 1mhHVWwQVHwsK0Ge3YSkX5rvNO/eG1oefKUuD91+sPy+4fQlpURX1yx2n6fDqO1BrfpZ epUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DKkTyV7E; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn25-20020a1709070d1900b007ad6a0afbc6si1715678ejc.7.2022.11.03.07.25.40; Thu, 03 Nov 2022 07:26:03 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=DKkTyV7E; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231739AbiKCN7I (ORCPT + 97 others); Thu, 3 Nov 2022 09:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbiKCN6y (ORCPT ); Thu, 3 Nov 2022 09:58:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EC4C15A19 for ; Thu, 3 Nov 2022 06:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667483872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MNLPTKjKZGsyp4iQjia1o+n+MQq5Qzv7rr6Sw6M18Rc=; b=DKkTyV7EMb1nbrXy6AyBeXDJ5jtnVLvgX3HMZlZQ+sShIVKeAGtRqBMKmuQajQxBkxZdoK lHUoDACiNn/IHxYzCn280jWjrDqWNzAPIy6S/bwtsmgPxWYSuQduwOfuhv5wgSjVNOnZ1i T1MdZNPafieYd9HqetCWbUUL00YN7pI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-0tTLQ6N2NNiqYTNDc7oPOQ-1; Thu, 03 Nov 2022 09:57:49 -0400 X-MC-Unique: 0tTLQ6N2NNiqYTNDc7oPOQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A11A1C1434A; Thu, 3 Nov 2022 13:57:44 +0000 (UTC) Received: from amdlaptop.tlv.redhat.com (dhcp-4-238.tlv.redhat.com [10.35.4.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11AE840C83D9; Thu, 3 Nov 2022 13:57:40 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Paolo Bonzini , "H. Peter Anvin" , Shuah Khan , Yang Zhong , Wei Wang , Colton Lewis , Sean Christopherson , Jim Mattson , Chenyi Qiang , Borislav Petkov , linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Dave Hansen , Ingo Molnar , David Matlack , Peter Xu , Maxim Levitsky , linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/9] KVM: x86: nSVM: leave nested mode on vCPU free Date: Thu, 3 Nov 2022 15:57:28 +0200 Message-Id: <20221103135736.42295-2-mlevitsk@redhat.com> In-Reply-To: <20221103135736.42295-1-mlevitsk@redhat.com> References: <20221103135736.42295-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 If the VM was terminated while nested, we free the nested state while the vCPU still is in nested mode. Soon a warning will be added for this condition. Cc: stable@vger.kernel.org Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/svm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index d22a809d923339..e9cec1b692051c 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1440,6 +1440,7 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu) */ svm_clear_current_vmcb(svm->vmcb); + svm_leave_nested(vcpu); svm_free_nested(svm); sev_free_vcpu(vcpu); -- 2.34.3