From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC9EC19F2D for ; Tue, 9 Aug 2022 18:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343824AbiHIST1 (ORCPT ); Tue, 9 Aug 2022 14:19:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346788AbiHISRp (ORCPT ); Tue, 9 Aug 2022 14:17:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8C762ED65; Tue, 9 Aug 2022 11:06:56 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 6E1DCB818E2; Tue, 9 Aug 2022 18:06:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B991EC433B5; Tue, 9 Aug 2022 18:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068387; bh=sZkq70RwvIjDXbL2WLFX6bnGB7uLboQX0UZurcdhliU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TdTJqjQ/x4y1KkujQNpMugEJKuBBXoTkprOzSRmfkeJmr0Bid/xoLeMj8Gia/zKeK VM4xLd/PjKLscdwGGGc4xWZphK3munHC0qGb0feyIh4ezOlfDiMrEBnu0PVZWqCzXT 44IBr+fWmoSDtLlbbpXPtq+lj/CgywUBDx6RYvT8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Levitsky , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.18 13/35] KVM: x86: disable preemption while updating apicv inhibition Date: Tue, 9 Aug 2022 20:00:42 +0200 Message-Id: <20220809175515.542696207@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175515.046484486@linuxfoundation.org> References: <20220809175515.046484486@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Maxim Levitsky [ Upstream commit 66c768d30e64e1280520f34dbef83419f55f3459 ] Currently nothing prevents preemption in kvm_vcpu_update_apicv. On SVM, If the preemption happens after we update the vcpu->arch.apicv_active, the preemption itself will 'update' the inhibition since the AVIC will be first disabled on vCPU unload and then enabled, when the current task is loaded again. Then we will try to update it again, which will lead to a warning in __avic_vcpu_load, that the AVIC is already enabled. Fix this by disabling preemption in this code. Signed-off-by: Maxim Levitsky Message-Id: <20220606180829.102503-6-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 91d887fd10ab..65b0ec28bd52 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -9784,6 +9784,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu) return; down_read(&vcpu->kvm->arch.apicv_update_lock); + preempt_disable(); activate = kvm_apicv_activated(vcpu->kvm); if (vcpu->arch.apicv_active == activate) @@ -9803,6 +9804,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu) kvm_make_request(KVM_REQ_EVENT, vcpu); out: + preempt_enable(); up_read(&vcpu->kvm->arch.apicv_update_lock); } EXPORT_SYMBOL_GPL(kvm_vcpu_update_apicv); -- 2.35.1