Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3494324rdh; Thu, 28 Sep 2023 13:24:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm7AlLzT17dcbS0TewK/wS4cjlYjBF7QJlIcSkffXb8VVcbmMc9tmnee4cf2rAkL39f7aT X-Received: by 2002:a17:902:ec81:b0:1c5:fdfd:e297 with SMTP id x1-20020a170902ec8100b001c5fdfde297mr2645233plg.44.1695932648554; Thu, 28 Sep 2023 13:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695932648; cv=none; d=google.com; s=arc-20160816; b=Ccfbr4sL9FPRTi+TO5+6ML5eFcsfrUtBlsplZxqsEFachrDQESpwcZF9NcNmIC2OEo nbRZy5133hwWL4a1Oix15f1tx8v2C/OhhARoejlBw+KHakQv1vh6bYFwi2d2hR0I2Kf+ MykPl/OXuy/Zc+h9GIPJTNV/K2ZX/rqvFckPckiChAp3DinxthXl30A9dPz72fgIAGBh v2h56v9xo+Zlnk4erzXstkw0OIgAEhhP3U9gIqa8ECvmHxMOLq/rgoQwjtrpXpU8bfNq Jq7HewNEAOoDWEvZsybxZ3Fw/8efrQuDsi6a7hf62cteAolCBq8ai140ArZUnV+tVvUc nklg== 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=jEwA8CyX78/GkMVoiAVbpRnGMlV0gBkCqcXscfLzkHs=; fh=7KlpA4Bjwb9QBszesWchOFreRBW5Vq50Y+lUlai2k4M=; b=mFJDxpmwKgKKf9nx8lYURKLYX/HT1bTLo+dRa5ZoZV1lNBVyeEE6URYpZpOUB9D6P4 N0irdqLda6Sz3lJqc30oXmQU6yE9taD8Xq/eteDVJYU77LUUYvGDsExUhhYhcfIZUyxf xLgAZxOQEDxcIIY1jPQvI+zHF9YRbypRuQwBeYDQ3Iy72yf82Rz/giqpEnLQHicwYdvz lVyTy6Wl4WWvMZk96DWoW7cOHdeD5hjoet2DkLaswMO2/IrGxzeC+5pxqlmbC3RlPfQO Dl4m+r5VIWQxm5UVs/4IsO+SnzuMpMISbdKZEvm5W23s6q04zdtlOGdEYzL7UD7ioa0o xleQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S4rYQnMi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y14-20020a17090322ce00b001c71eed110esi7946515plg.254.2023.09.28.13.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 13:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S4rYQnMi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7BB89807E920; Thu, 28 Sep 2023 10:35:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232004AbjI1RfF (ORCPT + 99 others); Thu, 28 Sep 2023 13:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231954AbjI1RfE (ORCPT ); Thu, 28 Sep 2023 13:35:04 -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 44DEFC0 for ; Thu, 28 Sep 2023 10:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695922454; 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=jEwA8CyX78/GkMVoiAVbpRnGMlV0gBkCqcXscfLzkHs=; b=S4rYQnMiIKh30TVOkRSTq3/TAykdShsSTM6paTA87i/SJFxgzuYpMDc1JSl66zQDU5B837 Na5cM4ASSadGM48+fEgLVJXJzfELXFUBomCexcRW2mLD90TnmDCmk9R4fo8NscbKaC6oYv fDCHPgDIgUdcrq1xE2VF1CfLmKIohUY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-8q4-2IX4M9GzgZ9LF6aO2A-1; Thu, 28 Sep 2023 13:34:12 -0400 X-MC-Unique: 8q4-2IX4M9GzgZ9LF6aO2A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C8F9185A790; Thu, 28 Sep 2023 17:34:11 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B43D14171CB; Thu, 28 Sep 2023 17:34:07 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: iommu@lists.linux.dev, "H. Peter Anvin" , Sean Christopherson , Maxim Levitsky , Paolo Bonzini , Thomas Gleixner , Borislav Petkov , Joerg Roedel , x86@kernel.org, Suravee Suthikulpanit , linux-kernel@vger.kernel.org, Dave Hansen , Will Deacon , Ingo Molnar , Robin Murphy , stable@vger.kernel.org Subject: [PATCH v2 3/4] x86: KVM: SVM: refresh AVIC inhibition in svm_leave_nested() Date: Thu, 28 Sep 2023 20:33:53 +0300 Message-Id: <20230928173354.217464-4-mlevitsk@redhat.com> In-Reply-To: <20230928173354.217464-1-mlevitsk@redhat.com> References: <20230928173354.217464-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 28 Sep 2023 10:35:20 -0700 (PDT) svm_leave_nested() similar to a nested VM exit, get the vCPU out of nested mode and thus should end the local inhibition of AVIC on this vCPU. Failure to do so, can lead to hangs on guest reboot. Raise the KVM_REQ_APICV_UPDATE request to refresh the AVIC state of the current vCPU in this case. Fixes: f44509f849fe ("KVM: x86: SVM: allow AVIC to co-exist with a nested guest running") Cc: stable@vger.kernel.org Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/nested.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index dd496c9e5f91f28..3fea8c47679e689 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1253,6 +1253,9 @@ void svm_leave_nested(struct kvm_vcpu *vcpu) nested_svm_uninit_mmu_context(vcpu); vmcb_mark_all_dirty(svm->vmcb); + + if (kvm_apicv_activated(vcpu->kvm)) + kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu); } kvm_clear_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu); -- 2.26.3